# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1263839337 -7200 # Node ID f63038272f30b8fbbc2f9d606c95bdfd406b9edc Revision: 201001 Kit: 201003 diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/bwins/remconabsolutevolumeu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/bwins/remconabsolutevolumeu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ +EXPORTS + ?SetAbsoluteVolume@CRemConAbsoluteVolumeController@@QAEXAAVTRequestStatus@@KAAI@Z @ 1 NONAME ; void CRemConAbsoluteVolumeController::SetAbsoluteVolume(class TRequestStatus &, unsigned long, unsigned int &) + ?RegisterAbsoluteVolumeNotification@CRemConAbsoluteVolumeController@@QAEXXZ @ 2 NONAME ; void CRemConAbsoluteVolumeController::RegisterAbsoluteVolumeNotification(void) + ?NewL@CRemConAbsoluteVolumeTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConAbsoluteVolumeTargetObserver@@KK@Z @ 3 NONAME ; class CRemConAbsoluteVolumeTarget * CRemConAbsoluteVolumeTarget::NewL(class CRemConInterfaceSelector &, class MRemConAbsoluteVolumeTargetObserver &, unsigned long, unsigned long) + ??1CRemConAbsoluteVolumeTarget@@UAE@XZ @ 4 NONAME ; CRemConAbsoluteVolumeTarget::~CRemConAbsoluteVolumeTarget(void) + ?WriteL@RRemConAbsoluteVolumeResponse@@UAEXAAVTDes8@@@Z @ 5 NONAME ; void RRemConAbsoluteVolumeResponse::WriteL(class TDes8 &) + ?AbsoluteVolumeChanged@CRemConAbsoluteVolumeTarget@@QAEXK@Z @ 6 NONAME ; void CRemConAbsoluteVolumeTarget::AbsoluteVolumeChanged(unsigned long) + ?SetAbsoluteVolumeResponse@CRemConAbsoluteVolumeTarget@@QAEXKH@Z @ 7 NONAME ; void CRemConAbsoluteVolumeTarget::SetAbsoluteVolumeResponse(unsigned long, int) + ?ReadL@RRemConAbsoluteVolumeRequest@@UAEXABVTDesC8@@@Z @ 8 NONAME ; void RRemConAbsoluteVolumeRequest::ReadL(class TDesC8 const &) + ?WriteL@RRemConAbsoluteVolumeRequest@@UAEXAAVTDes8@@@Z @ 9 NONAME ; void RRemConAbsoluteVolumeRequest::WriteL(class TDes8 &) + ?ReadL@RRemConAbsoluteVolumeResponse@@UAEXABVTDesC8@@@Z @ 10 NONAME ; void RRemConAbsoluteVolumeResponse::ReadL(class TDesC8 const &) + ??1CRemConAbsoluteVolumeController@@UAE@XZ @ 11 NONAME ; CRemConAbsoluteVolumeController::~CRemConAbsoluteVolumeController(void) + ?CancelAbsoluteVolumeNotification@CRemConAbsoluteVolumeController@@QAEXXZ @ 12 NONAME ; void CRemConAbsoluteVolumeController::CancelAbsoluteVolumeNotification(void) + ?Close@RRemConAbsoluteVolume@@QAEXXZ @ 13 NONAME ; void RRemConAbsoluteVolume::Close(void) + ?NewL@CRemConAbsoluteVolumeController@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConAbsoluteVolumeControllerObserver@@K@Z @ 14 NONAME ; class CRemConAbsoluteVolumeController * CRemConAbsoluteVolumeController::NewL(class CRemConInterfaceSelector &, class MRemConAbsoluteVolumeControllerObserver &, unsigned long) + ?CancelSetAbsoluteVolume@CRemConAbsoluteVolumeController@@QAEXXZ @ 15 NONAME ; void CRemConAbsoluteVolumeController::CancelSetAbsoluteVolume(void) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/eabi/remconabsolutevolumeu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/eabi/remconabsolutevolumeu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +EXPORTS + _ZN21RRemConAbsoluteVolume5CloseEv @ 1 NONAME + _ZN27CRemConAbsoluteVolumeTarget21AbsoluteVolumeChangedEm @ 2 NONAME + _ZN27CRemConAbsoluteVolumeTarget25SetAbsoluteVolumeResponseEmi @ 3 NONAME + _ZN27CRemConAbsoluteVolumeTarget4NewLER24CRemConInterfaceSelectorR35MRemConAbsoluteVolumeTargetObservermm @ 4 NONAME + _ZN27CRemConAbsoluteVolumeTargetD0Ev @ 5 NONAME + _ZN27CRemConAbsoluteVolumeTargetD1Ev @ 6 NONAME + _ZN27CRemConAbsoluteVolumeTargetD2Ev @ 7 NONAME + _ZN28RRemConAbsoluteVolumeRequest5ReadLERK6TDesC8 @ 8 NONAME + _ZN28RRemConAbsoluteVolumeRequest6WriteLER5TDes8 @ 9 NONAME + _ZN29RRemConAbsoluteVolumeResponse5ReadLERK6TDesC8 @ 10 NONAME + _ZN29RRemConAbsoluteVolumeResponse6WriteLER5TDes8 @ 11 NONAME + _ZN31CRemConAbsoluteVolumeController17SetAbsoluteVolumeER14TRequestStatusmRj @ 12 NONAME + _ZN31CRemConAbsoluteVolumeController32CancelAbsoluteVolumeNotificationEv @ 13 NONAME + _ZN31CRemConAbsoluteVolumeController34RegisterAbsoluteVolumeNotificationEv @ 14 NONAME + _ZN31CRemConAbsoluteVolumeController4NewLER24CRemConInterfaceSelectorR39MRemConAbsoluteVolumeControllerObserverm @ 15 NONAME + _ZN31CRemConAbsoluteVolumeControllerD0Ev @ 16 NONAME + _ZN31CRemConAbsoluteVolumeControllerD1Ev @ 17 NONAME + _ZN31CRemConAbsoluteVolumeControllerD2Ev @ 18 NONAME + _ZTI28RRemConAbsoluteVolumeRequest @ 19 NONAME + _ZTI29RRemConAbsoluteVolumeResponse @ 20 NONAME + _ZTV28RRemConAbsoluteVolumeRequest @ 21 NONAME + _ZTV29RRemConAbsoluteVolumeResponse @ 22 NONAME + _ZN31CRemConAbsoluteVolumeController23CancelSetAbsoluteVolumeEv @ 23 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/group/absolutevolumeapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/group/absolutevolumeapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +// Copyright (c) 2004-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: +// absolutevolumeapicontroller.dll Remote Control Absolute Volume API- an outer-layer client +// side library. +// + + + +/** + @file + @internalComponent +*/ + +TARGET remconabsolutevolume.dll +TARGETPATH /system/libs + +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x101f9067 +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE absolutevolumeapicontroller.cpp +SOURCE absolutevolumeapitarget.cpp +SOURCE absolutevolumesender.cpp +SOURCE absolutevolumeutils.cpp + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib +LIBRARY avrcpipc.lib +LIBRARY estor.lib + +#include + +UNPAGED + +SMPSAFE + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +// Copyright (c) 2007-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: +// + + + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +absolutevolumeapi.mmp + +PRJ_EXPORTS +../public/absolutevolumeapicontroller.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(absolutevolumeapicontroller.h) +../public/absolutevolumeapicontrollerobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(absolutevolumeapicontrollerobserver.h) +../public/absolutevolumeapitarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(absolutevolumeapitarget.h) +../public/absolutevolumeapitargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(absolutevolumeapitargetobserver.h) +../public/absolutevolumeutils.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(absolutevolumeutils.h) +../public/absolutevolumeapi.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(absolutevolumeapi.h) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/inc/absolutevolumesender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/inc/absolutevolumesender.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +// Copyright (c) 2008-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: +// + +#ifndef ABSOLUTEVOLUMESENDER_H +#define ABSOLUTEVOLUMESENDER_H + +#include +#include +#include + +/** +@file +@internalComponent +@released +*/ + +NONSHARABLE_CLASS(CAbsVolSender) : public CActive + { +public: + static CAbsVolSender* NewL(CRemConInterfaceSelector& aIfSel, MAbsVolSenderObserver& aObserver); + ~CAbsVolSender(); + + void SendNotify(const TDesC8& aData); + void SendSetAbsoluteVolume(TUint& aNumRemotes, const TDesC8& aData); + +private: + void RunL(); + void DoCancel(); + + CAbsVolSender(CRemConInterfaceSelector& aIfSel, MAbsVolSenderObserver& aObserver); + +private: + CRemConInterfaceSelector& iIfSel; + MAbsVolSenderObserver& iObserver; + TBool iSendingNotify; + }; + +#endif // ABSOLUTEVOLUMESENDER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapi.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,73 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef ABSOLUTEVOLUMEAPI_H_ +#define ABSOLUTEVOLUMEAPI_H_ + +#include + +const TInt KRemConAbsoluteVolumeControllerApiUid = 0x1020831E; +const TInt KRemConAbsoluteVolumeTargetApiUid = 0x10215bbd; + +const TInt KErrAbsoluteVolumeInternalError = -6537; + +/** +Error code(4 bytes) + The relative volume(4 bytes) + +The maximum volume against which volume is relative(4 bytes) +*/ +const TUint KAbsoluteVolumeResponseDataSize = 12; + +/** Operation Id of set absolute volume */ +const TUint KRemConSetAbsoluteVolume = 0x1050; +/** Operation Id of register volume change notification */ +const TUint KRemConAbsoluteVolumeNotification = 0x0d31; + +/** +The relative volume to be set(4 bytes) + +The maximum volume against which volume is relative(4 bytes) + +Reserved(4 bytes) +*/ +const TInt KAbsoluteVolumeRequestDataSize = 12; + +/** +The absolute volume is represented in one octet. The top bit(bit 7) +is reserved for future use. +*/ +const TUint8 KAbsoluteVolumeMask = 0x7f; + +/** PDU length of set absolute volume response */ +const TUint8 KLengthSetAbsoluteVolumeResponse = 11; +/** PDU length of notify volume change response */ +const TUint8 KLengthNotifyVolumeChangeResponse = 12; + +/** Absolute Volume(1 byte) */ +const TUint8 KLengthSetAbsoluteVolumeRequestParameter = 1; +/** Event ID(1 byte) + Reserved(4 bytes) */ +const TUint8 KLengthNotifyVolumeChangeRequestParameter = 5; + +/** Absolute Volume(1 byte) */ +const TUint8 KLengthSetAbsoluteVolumeResponseParamter = 1; +/** Event ID(1 byte) + Absolute Volume(1 byte) */ +const TUint8 KLengthNotifyVolumeChangeResponseParameter = 2; + +#endif /*ABSOLUTEVOLUMEAPI_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapicontroller.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapicontroller.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,148 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONABSOLUTEVOLUMEAPICONTROLLER_H_ +#define REMCONABSOLUTEVOLUMEAPICONTROLLER_H_ + +#include +#include +#include + +_LIT(KAbsoluteVolumeControllerPanicName, "AbsoluteVolumeController"); +enum TAbsoluteVolumeControllerPanics + { + EControllerInvalidMaxVolume = 0, + EControllerVolumeBeyondMaxVolume = 1, + EAbsoluteVolumeNotificationAlreadyRegistered = 2, + EMultipleSetAbsoluteVolumes = 3, + EMultipleNotifies = 4, + }; + +class MRemConAbsoluteVolumeControllerObserver; +class CAbsVolSender; + +/** +@internalComponent +*/ +class MAbsVolSenderObserver + { +public: + virtual void MavsoSendComplete(TInt aResult) = 0; + }; + +/** +This class is used to set and observer the volume level on a remote device. + +An active scheduler is required in order to use this class. +*/ +NONSHARABLE_CLASS(CRemConAbsoluteVolumeController) +: public CRemConInterfaceBase, public MRemConInterfaceIf2, public MAbsVolSenderObserver + { +public: + IMPORT_C static CRemConAbsoluteVolumeController* NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeControllerObserver& aObserver, + TUint32 aMaxVolume); + + IMPORT_C ~CRemConAbsoluteVolumeController(); + +public: + IMPORT_C void SetAbsoluteVolume(TRequestStatus& aStatus, + TUint32 aVolume, + TUint& aNumRemotes); + IMPORT_C void CancelSetAbsoluteVolume(); + + IMPORT_C void RegisterAbsoluteVolumeNotification(); + IMPORT_C void CancelAbsoluteVolumeNotification(); + +private: + CRemConAbsoluteVolumeController( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeControllerObserver& aObserver, + TUint32 aMaxVolume); + void ConstructL(); + +private: // Utility functions + void HandleNotify(const TDesC8& aData, + TRemConMessageSubType aMessageSubType); + + void HandleSetAbsoluteVolumeResponse( const TDesC8& aData ); + static TInt AsyncErrorCallBack(TAny* aObserver); + void KickOffSendIfNeeded(); + void SetAbsoluteVolumeSendComplete(TInt aResult); + void RegisterNotifySendComplete(); + void SendSetAbsoluteVolume(); + void SendNotify(); + + void VolumeUpdate(TUint32 aVolume, TUint32 aMaxVolume); + +private: // From CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // From MRemConInterfaceIf2 + void MrcibNewMessage(TUint aOperationId, + const TDesC8& aData, + TRemConMessageSubType + aMessageSubType); + +private: // From MAbsVolSenderObserver + void MavsoSendComplete(TInt aResult); + +private: // Unowned + MRemConAbsoluteVolumeControllerObserver& iObserver; + +private: // Owned + // For operation-specific data. + TBuf8 iNotifyData; + TBuf8 iSetData; + + // Records the current absolute volume value. + TUint32 iCurrentVolume; + TUint32 iCurrentMaxVolume; + + // Used when sending SetAbsoluteVolume commands + TUint32 iClientMaxVolume; + + CAbsVolSender* iAbsVolSender; + + TBool iNotificationRequested; + + // Only used for abs vol sends. + TRequestStatus* iClientStatus; + TUint* iClientNumRemotes; + + enum TRequestState + { + // There is no request outstanding + ENotInUse = 0, + // We're currently sending this request. + ESending, + // This request is waiting to be sent (possibly because we were busy sending a previous request when this one arose). + EPending, + }; + // The two requests we support. + TRequestState iAbsVolRequest; + TRequestState iNotifyRequest; + }; + +#endif /*REMCONABSOLUTEVOLUMEAPICONTROLLER_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapicontrollerobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapicontrollerobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,71 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + + +#ifndef REMCONABSOLUTEVOLUMEAPICONTROLLEROBSERVER_H_ +#define REMCONABSOLUTEVOLUMEAPICONTROLLEROBSERVER_H_ + +#include + +/** +Clients must implement this interface in order to instantiate objects of type +CRemConAbsoluteVolumeController. This interface passes incoming responses +from RemCon to the client. +*/ +class MRemConAbsoluteVolumeControllerObserver + { +public: + /** + The current volume has been received. + + @param aVolume The current relative volume on the target device. + @param aMaxVolume The maximum volume against which aVolume is relative. + @param aError The response error. + */ + virtual void MrcavcoCurrentVolume(TUint32 aVolume, + TUint32 aMaxVolume, + TInt aError)=0; + + /** + The response for setting absolute volume. + + @param aVolume The relative volume that has been set on the target device. + @param aMaxVolume The maximum volume against which aVolume is relative. + @param aError The response error. + */ + virtual void MrcavcoSetAbsoluteVolumeResponse(TUint32 aVolume, + TUint32 aMaxVolume, + TInt aError)=0; + + /** + The error occurs for absolute volume notification. + + When this is called, the client must call + RegisterAbsoluteVolumeNotification() to register again if the client + wants to receive the notification. + */ + virtual void MrcavcoAbsoluteVolumeNotificationError() = 0; + + }; + +#endif /*REMCONABSOLUTEVOLUMEAPICONTROLLEROBSERVER_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapitarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapitarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,96 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONABSOLUTEVOLUMEAPITARGET_H +#define REMCONABSOLUTEVOLUMEAPITARGET_H + +#include +#include + +_LIT(KAbsoluteVolumeTargetPanicName, "AbsoluteVolumeTarget"); +enum TAbsoluteVolumeTargetPanics + { + ETargetInvalidMaxVolume = 0, + ETargetVolumeBeyondMaxVolume = 1, + }; + +class MRemConAbsoluteVolumeTargetObserver; + +/** +Client-instantiable type supporting sending absolute volume API responses for +Set Absolute Volume and Register Absolute Volume Change Notification. This API +should be used in preference to the extapi. +*/ +NONSHARABLE_CLASS(CRemConAbsoluteVolumeTarget) : public CRemConInterfaceBase, + public MRemConInterfaceIf2 + { +public: + IMPORT_C static CRemConAbsoluteVolumeTarget* NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeTargetObserver& aObserver, + TUint32 aVolume, + TUint32 aMaxVolume); + + IMPORT_C ~CRemConAbsoluteVolumeTarget(); + +public: + IMPORT_C void SetAbsoluteVolumeResponse(TUint32 aVolume, + TInt aErr); + + IMPORT_C void AbsoluteVolumeChanged(TUint32 aVolume); + +private: + CRemConAbsoluteVolumeTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeTargetObserver& aObserver, + TUint32 aVolume, + TUint32 aMaxVolume); + + void ConstructL(); + +private: // From CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // From MRemConInterfaceIf2 + void MrcibNewMessage(TUint aOperationId, + const TDesC8& aData, + TRemConMessageSubType aMsgSubType); + +private: // Utility Funtions + void SendError(TInt aError, TUint aOperationId); + void SendNotificationResponse(TRemConMessageSubType aMsgSubType); + void ProcessGetStatus(); + void ProcessGetStatusAndBeginObserving(); + void ProcessSetAbsoluteVolume(const TDesC8& aData); + +private: // Unowned + MRemConAbsoluteVolumeTargetObserver& iObserver; + +private: // Owned + // ETrue indicates a request for absolute volume change notification has + // been received. + TBool iAbsoluteVolumeNotificationRequest; + RBuf8 iOutBuf; + TUint32 iClientVolume; + TUint32 iClientMaxVolume; + }; +#endif // ABSOLUTEVOLUMEAPITARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapitargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeapitargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONABSOLUTEVOLUMEAPITARGETOBSERVER_H +#define REMCONABSOLUTEVOLUMEAPITARGETOBSERVER_H + +#include + +/** +Clients must implement this interface in order to instantiate objects of type +CRemConAbsoluteVolumeTarget. This interface passes incoming commands from +RemCon to the client. +*/ +NONSHARABLE_CLASS(MRemConAbsoluteVolumeTargetObserver) + { +public: + /** + This is called when the controller wishes to set absolute volume on the + client. Response must be provided by the client by calling + CRemConAbsoluteVolumeTarget::SetAbsoluteVolumeResponse() + + @see CRemConAbsoluteVolumeTarget::SetAbsoluteVolumeResponse() + @param aVolume The relative volume. + @param aMaxVolume The maximum volume against which aVolume is relative. + */ + virtual void MrcavtoSetAbsoluteVolumeRequest(TUint32 aVolume, + TUint32 aMaxVolume) = 0; + }; + +#endif // REMCONABSOLUTEVOLUMEAPITARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/public/absolutevolumeutils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,62 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedPartner + @released +*/ + +#ifndef ABSOLUTEVOLUMEUTILS_H_ +#define ABSOLUTEVOLUMEUTILS_H_ + +#include +#include + +class RRemConAbsoluteVolume + { +public: + virtual void ReadL(const TDesC8& aData) = 0; + virtual void WriteL(TDes8& aOutData) = 0; + IMPORT_C void Close(); + +public: + TUint32 iVolume; + TUint32 iMaxVolume; + +protected: + RDesWriteStream iStream; + RDesReadStream iReadStream; + }; + +class RRemConAbsoluteVolumeRequest : public RRemConAbsoluteVolume + { +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +class RRemConAbsoluteVolumeResponse : public RRemConAbsoluteVolume + { +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); +public: + TInt32 iError; + }; + +#endif /*ABSOLUTEVOLUMEUTILS_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumeapicontroller.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumeapicontroller.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,478 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include +#include "absolutevolumesender.h" +#include +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_REMCONABSOLUTEVOLUME); +#endif + +#ifdef _DEBUG +_LIT(KAbsoluteVolumeControllerFaultName, "AbsVolFault"); +// The panic codes associated with category KAbsoluteVolumeControllerFaultName are line numbers in this file. +#endif + +/** +Allocates and constructs a new CRemConAbsoluteVolumeController object + +@param aInterfaceSelector The interface selector. The client must have + created one of these first. +@param aObserver The observer. The client must have implemented the observer, + owned by the client. +@param aMaxVolume The client maximum volume. +@return A new CRemConAbsoluteVolumeController, owned by the interface selector +@panic AbsoluteVolumeController 0 if aMaxVolume is zero. +*/ +EXPORT_C +CRemConAbsoluteVolumeController* CRemConAbsoluteVolumeController::NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeControllerObserver& aObserver, + TUint32 aMaxVolume) + { + LOG_STATIC_FUNC + + __ASSERT_ALWAYS(aMaxVolume > 0, + User::Panic(KAbsoluteVolumeControllerPanicName, + EControllerInvalidMaxVolume) + ); + + CRemConAbsoluteVolumeController* self = + new(ELeave) CRemConAbsoluteVolumeController(aInterfaceSelector, + aObserver, aMaxVolume); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +/** +Constructor. + +@param aInterfaceSelector The interface selector. +@param aObserver The observer. +*/ +CRemConAbsoluteVolumeController::CRemConAbsoluteVolumeController( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeControllerObserver& aObserver, + TUint32 aMaxVolume) +: CRemConInterfaceBase(TUid::Uid(KRemConAbsoluteVolumeControllerApiUid), + KAbsoluteVolumeResponseDataSize, + aInterfaceSelector, + ERemConClientTypeController), + iObserver(aObserver), + iClientMaxVolume(aMaxVolume), + iNotificationRequested(EFalse), + iAbsVolRequest(ENotInUse), + iNotifyRequest(ENotInUse) + { + LOG_FUNC + } + +EXPORT_C CRemConAbsoluteVolumeController::~CRemConAbsoluteVolumeController() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + delete iAbsVolSender; + } + +void CRemConAbsoluteVolumeController::ConstructL() + { + LOG_FUNC + + iAbsVolSender = CAbsVolSender::NewL(InterfaceSelector(), *this); + BaseConstructL(); + } + +/** +Sets an absolute volume on the target device, +Any responses will be returned via the observer interface. + +@pre The send of any previous SetAbsoluteVolume command has completed. +@param aStatus Indicates the completion of the send request. The client must + not block execution by using User::WaitForRequest to await + completion of this send. +@param aVolume The relative volume against the client max volume. +@param aNumRemotes The number of remotes to which the command was sent. +@panic AbsoluteVolumeController 1, if aVolume greater than the client + max volume. +*/ +EXPORT_C void CRemConAbsoluteVolumeController::SetAbsoluteVolume( + TRequestStatus& aStatus, + TUint32 aVolume, + TUint& aNumRemotes) + { + LOG_FUNC + LOG1(_L8("\taVolume = %d"), aVolume); + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + __ASSERT_ALWAYS(aVolume <= iClientMaxVolume, + User::Panic(KAbsoluteVolumeControllerPanicName, + EControllerVolumeBeyondMaxVolume) + ); + __ASSERT_DEBUG(iAbsVolRequest == ENotInUse, User::Panic(KAbsoluteVolumeControllerPanicName, + EMultipleSetAbsoluteVolumes)); + + RRemConAbsoluteVolumeRequest setAbsVol; + setAbsVol.iVolume = aVolume; + setAbsVol.iMaxVolume = iClientMaxVolume; + TRAPD(err, setAbsVol.WriteL(iSetData)); + if (err == KErrNone) + { + // Store the client's info so we can complete their request later + aStatus = KRequestPending; + iAbsVolRequest = EPending; + __ASSERT_DEBUG(iClientStatus == NULL, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + iClientStatus = &aStatus; + __ASSERT_DEBUG(iClientNumRemotes == NULL, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + iClientNumRemotes = &aNumRemotes; + KickOffSendIfNeeded(); + } + else + { + iObserver.MrcavcoSetAbsoluteVolumeResponse(0, 0, err); + } + } + +EXPORT_C void CRemConAbsoluteVolumeController::CancelSetAbsoluteVolume() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + switch ( iAbsVolRequest ) + { + case ENotInUse: + // Nothing to do. + break; + case ESending: + iAbsVolSender->Cancel(); + SetAbsoluteVolumeSendComplete(KErrCancel); + break; + case EPending: + SetAbsoluteVolumeSendComplete(KErrCancel); + break; + default: + __ASSERT_DEBUG(EFalse, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + break; + } + } + +/** +Requests notification when the volume on the target device changes, +Any responses will be returned via the observer interface. + +Volume changes will continue to be provided until either the +CancelAbsoluteVolumeNotification function is called, or MrcavcoCurrentVolume +is called on the client with an error. + +@see MRemConAbsoluteVolumeControllerObserver::MrcavcoCurrentVolume +@see CRemConAbsoluteVolumeController::CancelAbsoluteVolumeNotification +@pre The client is not currently registered to receive absolute volume notifications. +*/ +EXPORT_C +void CRemConAbsoluteVolumeController::RegisterAbsoluteVolumeNotification() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + // The request is outstanding, so not allowed to register again. + __ASSERT_DEBUG(!iNotificationRequested, User::Panic(KAbsoluteVolumeControllerPanicName, EAbsoluteVolumeNotificationAlreadyRegistered)); + __ASSERT_DEBUG(iNotifyRequest == ENotInUse, User::Panic(KAbsoluteVolumeControllerPanicName, EMultipleNotifies)); + + RRemConAbsoluteVolumeRequest absVol; + TRAPD(err, absVol.WriteL(iNotifyData)); + if (err == KErrNone) + { + iNotifyRequest = EPending; + iNotificationRequested = ETrue; + KickOffSendIfNeeded(); + } + else + { + iObserver.MrcavcoAbsoluteVolumeNotificationError(); + } + } + +/** +Called by the client to tell the controller that the client doesn't wish to +receicve the volume change notification +until the client re-register again. +*/ +EXPORT_C +void CRemConAbsoluteVolumeController::CancelAbsoluteVolumeNotification() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + if ( iNotifyRequest == ESending ) + { + iAbsVolSender->Cancel(); + } + + iNotificationRequested = EFalse; + RegisterNotifySendComplete(); + } + +TAny* CRemConAbsoluteVolumeController::GetInterfaceIf(TUid aUid) + { + LOG_FUNC + + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf2) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +void CRemConAbsoluteVolumeController::MrcibNewMessage(TUint aOperationId, + const TDesC8& aData, + TRemConMessageSubType aMessageSubType) + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + switch (aOperationId) + { + case KRemConAbsoluteVolumeNotification: + HandleNotify(aData, aMessageSubType); + break; + case KRemConSetAbsoluteVolume: + HandleSetAbsoluteVolumeResponse(aData); + break; + default: + break; + } + } + +/** +Process the 'volume changed notification response' + +@param aData The response data. +@param aMessageSubType The RemCon submessage type. +*/ +void CRemConAbsoluteVolumeController::HandleNotify(const TDesC8& aData, + TRemConMessageSubType aMessageSubType) + { + LOG_FUNC + + TInt err = KErrNone; + + if(iNotificationRequested) + { + RRemConAbsoluteVolumeResponse absVol; + TRAP(err, absVol.ReadL(aData)) + if (err == KErrNone) + { + if (absVol.iError == KErrNone) + { + switch ( aMessageSubType ) + { + case ERemConNotifyResponseInterim: + { + VolumeUpdate(absVol.iVolume, absVol.iMaxVolume); + break; + } + case ERemConNotifyResponseChanged: + { + VolumeUpdate(absVol.iVolume, absVol.iMaxVolume); + + // Register notification again. + iNotificationRequested = EFalse; + RegisterAbsoluteVolumeNotification(); + break; + } + default: + break; + }//switch + } + else //Error response + { + iNotificationRequested = EFalse; + iObserver.MrcavcoAbsoluteVolumeNotificationError(); + } + } + else + { + iNotificationRequested = EFalse; + iObserver.MrcavcoAbsoluteVolumeNotificationError(); + } + } + } + +/** +Process the 'set absolute volume response' +@param aData The response data. +*/ +void CRemConAbsoluteVolumeController::HandleSetAbsoluteVolumeResponse( + const TDesC8& aData ) + { + LOG_FUNC + + TInt err = KErrNone; + RRemConAbsoluteVolumeResponse absVol; + TRAP(err, absVol.ReadL(aData)) + if (err == KErrNone) + { + iCurrentVolume = absVol.iVolume; + iCurrentMaxVolume = absVol.iMaxVolume; + iObserver.MrcavcoSetAbsoluteVolumeResponse(absVol.iVolume, + absVol.iMaxVolume, + absVol.iError); + } + else + { + iObserver.MrcavcoSetAbsoluteVolumeResponse(0, + 0, + err); + } + } + +void CRemConAbsoluteVolumeController::MavsoSendComplete(TInt aResult) + { + LOG_FUNC + LOG1(_L8("\taResult = %d"), aResult); + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + if ( iAbsVolRequest == ESending ) + { + __ASSERT_DEBUG(iNotifyRequest != ESending, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + SetAbsoluteVolumeSendComplete(aResult); + } + else if ( iNotifyRequest == ESending ) + { + // This updates our own state and kicks off any pending send. The + // later client upcall (if there was an error) gives them a chance + // to make further calls on us. + RegisterNotifySendComplete(); + + if(aResult != KErrNone) + { + iNotificationRequested = EFalse; + iObserver.MrcavcoAbsoluteVolumeNotificationError(); + } + } + else + { + // Send complete with no send outstanding. + __ASSERT_DEBUG(EFalse, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + } + } + +void CRemConAbsoluteVolumeController::KickOffSendIfNeeded() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + if ( iAbsVolRequest == ESending || iNotifyRequest == ESending ) + { + // Any pending send will be kicked off when current send completes and this function is called again. + return; + } + + if ( iAbsVolRequest == EPending ) + { + SendSetAbsoluteVolume(); + } + else if ( iNotifyRequest == EPending ) + { + SendNotify(); + } + } + +void CRemConAbsoluteVolumeController::SetAbsoluteVolumeSendComplete(TInt aResult) + { + LOG_FUNC + LOG1(_L8("\taResult = %d"), aResult); + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + __ASSERT_DEBUG(iClientStatus, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + User::RequestComplete(iClientStatus, aResult); + iClientStatus = NULL; + iClientNumRemotes = NULL; + iSetData.SetLength(0); + __ASSERT_DEBUG(iAbsVolRequest != ENotInUse, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + iAbsVolRequest = ENotInUse; + + KickOffSendIfNeeded(); + } + +void CRemConAbsoluteVolumeController::RegisterNotifySendComplete() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + iNotifyData.SetLength(0); + // This method doesn't actually complete a client request so we don't bother asserting state. + iNotifyRequest = ENotInUse; + + KickOffSendIfNeeded(); + } + +void CRemConAbsoluteVolumeController::VolumeUpdate(TUint32 aVolume, TUint32 aMaxVolume) + { + LOG_FUNC + LOG2(_L8("\taVolume = %d, aMaxVolume = %d"), aVolume, aMaxVolume); + + // Only update the client if the volume has changed + if (aVolume != iCurrentVolume || aMaxVolume != iCurrentMaxVolume) + { + iCurrentVolume = aVolume; //store the new value + iCurrentMaxVolume = aMaxVolume; + + iObserver.MrcavcoCurrentVolume(aVolume, + aMaxVolume, + KErrNone); + } + } + +void CRemConAbsoluteVolumeController::SendSetAbsoluteVolume() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + __ASSERT_DEBUG(iClientNumRemotes, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + iAbsVolSender->SendSetAbsoluteVolume(*iClientNumRemotes, iSetData); + __ASSERT_DEBUG(iAbsVolRequest == EPending, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + iAbsVolRequest = ESending; + } + +void CRemConAbsoluteVolumeController::SendNotify() + { + LOG_FUNC + LOG2(_L8("\tiAbsVolRequest = %d, iNotifyRequest = %d"), iAbsVolRequest, iNotifyRequest); + + iAbsVolSender->SendNotify(iNotifyData); + __ASSERT_DEBUG(iNotifyRequest == EPending, User::Panic(KAbsoluteVolumeControllerFaultName, __LINE__)); + iNotifyRequest = ESending; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumeapitarget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumeapitarget.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,324 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include +#include +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_REMCONABSOLUTEVOLUME); +_LIT8(KLogFormat, "Operation Id = 0x%x, Data Lengh = %d"); +_LIT8(KLogNewL, "CRemConAbsoluteVolumeTarget::NewL"); +#endif + +/** +Allocates and constructs a new CRemConAbsoluteVolumeTarget object + +@param aInterfaceSelector The interface selector. The client must have + created one of these first. +@param aObserver The observer through which the client will receive absolute + volume commands from M class MRemConAbsoluteVolumeTargetObserver. +@param aVolume The initial relative volume on the client. +@param aMaxVolume The client maximum volume against which aVolume is relative. +@return A new CRemConAbsoluteVolumeTarget, owned by the interface selector. +@panic AbsoluteVolumeTarget 0 if aMaxVolume is zero + AbsoluteVolumeTarget 1 if aVolume greater than aMaxVolume + +*/ +EXPORT_C CRemConAbsoluteVolumeTarget* CRemConAbsoluteVolumeTarget::NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeTargetObserver& aObserver, + TUint32 aVolume, + TUint32 aMaxVolume) + { + LOG(KLogNewL); + + __ASSERT_ALWAYS(aMaxVolume > 0, + User::Panic(KAbsoluteVolumeTargetPanicName, + ETargetInvalidMaxVolume) + ); + __ASSERT_ALWAYS(aVolume <= aMaxVolume, + User::Panic(KAbsoluteVolumeTargetPanicName, + ETargetVolumeBeyondMaxVolume) + ); + + CRemConAbsoluteVolumeTarget* self = + new(ELeave) CRemConAbsoluteVolumeTarget(aInterfaceSelector, + aObserver, aVolume, aMaxVolume); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +/** +Constructor. +@param aInterfaceSelector The interface selector. +@param aObserver The observer of this interface. +@param aVolume The initial relative volume on the client +@param aMaxVolume The maximum volume on the client against which + aVolume is relative. +*/ +CRemConAbsoluteVolumeTarget::CRemConAbsoluteVolumeTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConAbsoluteVolumeTargetObserver& aObserver, + TUint32 aVolume, + TUint32 aMaxVolume) +: CRemConInterfaceBase(TUid::Uid(KRemConAbsoluteVolumeTargetApiUid), + KAbsoluteVolumeRequestDataSize, + aInterfaceSelector, + ERemConClientTypeTarget), + iObserver(aObserver), + iAbsoluteVolumeNotificationRequest(EFalse), + iClientVolume(aVolume), + iClientMaxVolume(aMaxVolume) + { + } + +void CRemConAbsoluteVolumeTarget::ConstructL() + { + iOutBuf.CreateL(KAbsoluteVolumeResponseDataSize); + + //Mandate the following features supported. + RRemConInterfaceFeatures features; + User::LeaveIfError(features.Open()); + CleanupClosePushL(features); + features.AddOperationL(KRemConSetAbsoluteVolume); + + BaseConstructL(features); + CleanupStack::PopAndDestroy(&features); + } + +EXPORT_C CRemConAbsoluteVolumeTarget::~CRemConAbsoluteVolumeTarget() + { + iOutBuf.Close(); + } + +TAny* CRemConAbsoluteVolumeTarget::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf2) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +/** +Called by the client in response to a MrcavtoSetAbsoluteVolume() call. + +@param aVolume The relative volume against the client maximum volume. +@param aErr The error code. + - KErrNone if the client has changed its absolute volume. + - System wide error code otherwise. +@panic AbsoluteVolumeTarget 1, if volume is greater than max volume. +*/ +EXPORT_C void CRemConAbsoluteVolumeTarget::SetAbsoluteVolumeResponse( + TUint32 aVolume, + TInt aErr) + { + __ASSERT_ALWAYS(aVolume <= iClientMaxVolume, + User::Panic(KAbsoluteVolumeTargetPanicName, + ETargetVolumeBeyondMaxVolume) + ); + + RRemConAbsoluteVolumeResponse response; + response.iError = KErrNone; + response.iVolume = aVolume; + response.iMaxVolume = iClientMaxVolume; + TRAPD(error, response.WriteL(iOutBuf)); + if (error != KErrNone) + { + SendError(KErrAbsoluteVolumeInternalError, KRemConSetAbsoluteVolume); + return; + } + + if (aErr == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendUnreliable( + TUid::Uid(KRemConAbsoluteVolumeTargetApiUid), + KRemConSetAbsoluteVolume, ERemConResponse, iOutBuf ); + } + else + { + SendError(KErrAbsoluteVolumeInternalError, KRemConSetAbsoluteVolume); + } + } + +/** +Must be called each time the volume changes on the client. + +It is used to inform the controller if it has requested updates on the client +volume change. + +@param aVolume The relative volume against the client maximum volume. +@panic AbsoluteVolume 1, if volume greater than the client max volume. +*/ +EXPORT_C void CRemConAbsoluteVolumeTarget::AbsoluteVolumeChanged( + TUint32 aVolume) + { + __ASSERT_ALWAYS(aVolume <= iClientMaxVolume, + User::Panic(KAbsoluteVolumeTargetPanicName, + ETargetVolumeBeyondMaxVolume) + ); + + if (aVolume != iClientVolume) + { + // Records the current volume each time + // when the client absolute volume is changed + iClientVolume = aVolume; + + if (iAbsoluteVolumeNotificationRequest) + { + iAbsoluteVolumeNotificationRequest = EFalse; + SendNotificationResponse(ERemConNotifyResponseChanged); + } + } + } + +// From MRemConInterfaceIf +void CRemConAbsoluteVolumeTarget::SendError(TInt aError, TUint aOperationId) + { + TInt error = KErrNone; + RRemConAbsoluteVolumeResponse errRsp; + errRsp.iError = aError; + TRAP(error, errRsp.WriteL(iOutBuf)); + if (error == KErrNone) + { + InterfaceSelector().SendUnreliable( + TUid::Uid(KRemConAbsoluteVolumeTargetApiUid), + aOperationId, ERemConResponse, iOutBuf); + } + } + +void CRemConAbsoluteVolumeTarget::MrcibNewMessage(TUint aOperationId, + const TDesC8& aData, + TRemConMessageSubType aMsgSubType) + { + LOG_FUNC + LOG2(KLogFormat, aOperationId, aData.Length()); + + switch(aOperationId) + { + case KRemConSetAbsoluteVolume: + { + ProcessSetAbsoluteVolume(aData); + break; + } + case KRemConAbsoluteVolumeNotification: + { + // register for Notifications + if (aMsgSubType == ERemConNotifyCommandAwaitingInterim) + { + ProcessGetStatusAndBeginObserving(); + } + else if (aMsgSubType == ERemConNotifyCommandAwaitingChanged) + { + ProcessGetStatus(); + } + break; + } + default: + break; + }; + } + +/** +Processes the request for setting absolute volume. + +@param aData The absolute volume data to be setted. +*/ +void CRemConAbsoluteVolumeTarget::ProcessSetAbsoluteVolume( + const TDesC8& aData) + { + TInt error; + RRemConAbsoluteVolumeRequest request; + TRAP(error, request.ReadL(aData)); + if ( error == KErrNone) + { + iObserver.MrcavtoSetAbsoluteVolumeRequest(request.iVolume, + request.iMaxVolume); + } + else + { + SendError(KErrAbsoluteVolumeInternalError, KRemConSetAbsoluteVolume); + } + } + +/** +Processes the request for notify command waiting interim. +*/ +void CRemConAbsoluteVolumeTarget::ProcessGetStatusAndBeginObserving() + { + //Flag is ETure to indicate the request for absolute volume change + //notification has been received. + iAbsoluteVolumeNotificationRequest = ETrue; + + //send the interim response with the current absolute volume. + SendNotificationResponse(ERemConNotifyResponseInterim); + } + +/** +Processes the request for notify command waiting changed. +*/ +void CRemConAbsoluteVolumeTarget::ProcessGetStatus() + { + // send the current value + SendNotificationResponse(ERemConNotifyResponseChanged); + } + +/** +Sends absolute volume interim or change response according to the message +type aMsgSubType + +@param aMsgSubType The remcon submessage type. +*/ +void CRemConAbsoluteVolumeTarget::SendNotificationResponse( + TRemConMessageSubType aMsgSubType) + { + LOG_FUNC + + TInt error = 0; + RRemConAbsoluteVolumeResponse response; + response.iError = KErrNone; + response.iVolume = iClientVolume; + response.iMaxVolume = iClientMaxVolume; + TRAP(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + error = InterfaceSelector().SendUnreliable( + TUid::Uid(KRemConAbsoluteVolumeTargetApiUid), + KRemConAbsoluteVolumeNotification, + ERemConResponse, + aMsgSubType, + iOutBuf); + } + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumesender.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumesender.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +// Copyright (c) 2008-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 "absolutevolumesender.h" +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_REMCONABSOLUTEVOLUME); +#endif + +CAbsVolSender* CAbsVolSender::NewL(CRemConInterfaceSelector& aIfSel, MAbsVolSenderObserver& aObserver) + { + LOG_STATIC_FUNC + return new(ELeave)CAbsVolSender(aIfSel, aObserver); + } + +CAbsVolSender::CAbsVolSender(CRemConInterfaceSelector& aIfSel, MAbsVolSenderObserver& aObserver) + : CActive(EPriorityStandard), iIfSel(aIfSel), iObserver(aObserver) + { + LOG_FUNC + CActiveScheduler::Add(this); + } + +CAbsVolSender::~CAbsVolSender() + { + LOG_FUNC + Cancel(); + } + +void CAbsVolSender::RunL() + { + LOG_LINE + LOG_FUNC + iObserver.MavsoSendComplete(iStatus.Int()); + } + +void CAbsVolSender::DoCancel() + { + LOG_FUNC + LOG1(_L8("\tiSendingNotify = %d"), iSendingNotify); + + if(iSendingNotify) + { + iIfSel.SendCancel(ERemConNotifyCommand); + } + else + { + iIfSel.SendCancel(ERemConCommand); + } + } + +void CAbsVolSender::SendNotify(const TDesC8& aData) + { + LOG_FUNC + iIfSel.SendNotify(iStatus, + TUid::Uid(KRemConAbsoluteVolumeControllerApiUid), + KRemConAbsoluteVolumeNotification, + ERemConNotifyCommand, + ERemConNotifyCommandAwaitingInterim, + aData); + iSendingNotify = ETrue; + + SetActive(); + } + +void CAbsVolSender::SendSetAbsoluteVolume(TUint& aNumRemotes, const TDesC8& aData) + { + LOG_FUNC + iIfSel.Send(iStatus, + TUid::Uid(KRemConAbsoluteVolumeControllerApiUid), + KRemConSetAbsoluteVolume, + aNumRemotes, + ERemConCommand, + aData); + iSendingNotify = EFalse; + + SetActive(); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumeutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/absolutevolumeapi/src/absolutevolumeutils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedPartner + @released +*/ + +#include + +EXPORT_C +void RRemConAbsoluteVolume::Close() + { + iStream.Close(); + iReadStream.Close(); + } + +EXPORT_C +void RRemConAbsoluteVolumeRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iVolume = iReadStream.ReadUint32L(); + iMaxVolume = iReadStream.ReadUint32L(); + iReadStream.ReadUint32L(); + iReadStream.Close(); + } + +EXPORT_C +void RRemConAbsoluteVolumeRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + iStream.WriteUint32L(iVolume); + iStream.WriteUint32L(iMaxVolume); + iStream.WriteUint32L(NULL); + iStream.CommitL(); + } + +EXPORT_C +void RRemConAbsoluteVolumeResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iError = iReadStream.ReadInt32L(); + if (iError == KErrNone) + { + iVolume = iReadStream.ReadUint32L(); + iMaxVolume = iReadStream.ReadUint32L(); + } + iReadStream.Close(); + } + +EXPORT_C +void RRemConAbsoluteVolumeResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + iStream.WriteInt32L(iError); + if (KErrNone == iError) + { + iStream.WriteUint32L(iVolume); + iStream.WriteUint32L(iMaxVolume); + } + iStream.CommitL(); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avc/avc.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avc/avc.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +// Copyright (c) 2004-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: +// avc.dll. AV/C +// +// + +/** + @file +*/ + +TARGET avc.dll +CAPABILITY All -Tcb +TARGETTYPE dll + +UID 0x1000008d 0x10207ea6 +VENDORID 0x70000001 + +DEFFILE avc.def + +SOURCEPATH . +SOURCE avcframe.cpp + +USERINCLUDE . + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN +LIBRARY euser.lib + +#include + +UNPAGED + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avc/avcframe.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avc/avcframe.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,523 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @publishedPartner + @released +*/ + +#include +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_FRAME); +#endif + +#ifdef _DEBUG +PANICCATEGORY("avctpframe"); +#endif + +/** Constructor. + +@param aFrameType ECommand if this is a command, EResponse + if it's a response. +@internalComponent +@released +*/ +CAVCFrame::CAVCFrame(AVC::TFrameType aFrameType) + : iFrameType(aFrameType) + { + LOG_FUNC + } + +/** Destructor. + +@publishedPartner +@released +*/ +EXPORT_C CAVCFrame::~CAVCFrame() + { + LOG_FUNC + iBuffer.Close(); + } + +/** Factory function. + +This overload should be called when an AV/C frame is +to be constructed, that is it is probably an outgoing frame. + +@param aFrameType ECommand if this is a command, EResponse + if it's a response. +@param aType The AV/C CType for this frame. +@param aSubunitType The AV/C subunit type for this frame. +@param aSubunitId The AV/C subunit id for this frame. +@return A fully constructed CAVCFrame. +@leave System wide error code. +@publishedPartner +@released +*/ +EXPORT_C CAVCFrame* CAVCFrame::NewL(AVC::TFrameType aFrameType, + AVC::TCType aType, + AVC::TSubunitType aSubunitType, + AVC::TSubunitID aSubunitID) + { + CAVCFrame* frame = new(ELeave)CAVCFrame(aFrameType); + CleanupStack::PushL(frame); + frame->ConstructL(aType, aSubunitType, aSubunitID); + CleanupStack::Pop(frame); + return frame; + } + +/** Factory function. + +This overload should be used when a data buffer should +be parsed as an AV/C frame, that is it is probably an +incoming frame. + +@param aBuffer A buffer to be parsed as an AV/C frame. +@param aFrameType ECommand if this is a command, EResponse + if it's a response. +@return A fully constructed CAVCFrame. +@leave System wide error code. +@publishedPartner +@released +*/ +EXPORT_C CAVCFrame* CAVCFrame::NewL(const TDesC8& aBuffer, AVC::TFrameType aFrameType) + { + CAVCFrame* frame = new(ELeave)CAVCFrame(aFrameType); + CleanupStack::PushL(frame); + frame->ConstructL(aBuffer); + CleanupStack::Pop(frame); + return frame; + } + +/** Second phase construction. + +This overload is used when an AV/C frame is +to be constructed, that is it is probably an outgoing frame. + +@param aType The AV/C CType for this frame. +@param aSubunitType The AV/C subunit type for this frame. +@param aSubunitId The AV/C subunit id for this frame. +@return A fully constructed CAVCFrame. +@leave System wide error code. +@internalComponent +@released +*/ +void CAVCFrame::ConstructL(AVC::TCType aType, AVC::TSubunitType aSubunitType, AVC::TSubunitID aSubunitID) + { + iBuffer.CreateL(KAVCFrameMaxLength); + iBuffer.Zero(); + iBuffer.Append(TChar(aType)); + + TInt subType = aSubunitType; + TInt subID = aSubunitID; + + if (subType > AVC::ETypeExtended2) + { + iSubunitTypeExtensionBytes = 1; + iBuffer.Append(TChar(AVC::ETypeExtended1 << 3)); + subType -= 0x100; + + while (subType > 0x100) + { + iBuffer.Append(TChar(AVC::ETypeExtended2)); + subType -= 0x100; + } + + iBuffer.Append(TChar(subType)); + } + else + { + iBuffer.Append(TChar(subType << 3)); + } + + if (subID > AVC::EIDExtended2) + { + iSubunitIDExtensionBytes = 1; + iBuffer[1] |= AVC::EIDExtended1; + subID -= 0x100; + + while (subID > 0x100) + { + iBuffer.Append(TChar(AVC::EIDExtended2)); + subID -= 0x100; + } + + iBuffer.Append(TChar(subID)); + } + else + { + iBuffer[1] |= subID; + } + } + +/** Second phase construction. + +This overload is used when a data buffer should +be parsed as an AV/C frame, that is it is probably an +incoming frame. + +For details of parsing refer to the AV/C digital +interface command set specification. + +@param aBuffer A buffer to be parsed as an AV/C frame. +@return A fully constructed CAVCFrame. +@leave System wide error code. +@publishedPartner +@released +*/ +void CAVCFrame::ConstructL(const TDesC8& aBuffer) + { + iBuffer.CreateL(aBuffer); + FindExtensionL(iBuffer, iSubunitTypeExtensionBytes, iSubunitIDExtensionBytes); + } + +/** Gets the AV/C frame type. + +@return ECommand if this is a command, EResponse if this + is a response. +@publishedPartner +@released +*/ +EXPORT_C AVC::TFrameType CAVCFrame::FrameType() const + { + return iFrameType; + } + +/** Gets the AV/C frame type. + +@param aFrame The frame to get the frame type for. +@return ECommand if this is a command, EResponse if this + is a response. +@publishedPartner +@released +*/ +EXPORT_C AVC::TFrameType CAVCFrame::FrameType(const TDesC8& aFrame) + { + AVC::TFrameType frameType = AVC::ECommand; + + if( aFrame[0] > KAVCCommandMaxRangeLength ) + { + frameType = AVC::EResponse; + } + return frameType; + } + +/** Set the AV/C frame type for this frame. + +@param The frame type to set. +@publishedPartner +@released +*/ +EXPORT_C void CAVCFrame::SetFrameType(AVC::TFrameType aFrameType) + { + iFrameType = aFrameType; + } + +/** Get the AV/C CType for this frame. + +@return The AV/C CType for this frame. +@publishedPartner +@released +*/ +EXPORT_C AVC::TCType CAVCFrame::Type() const + { + return static_cast(iBuffer[0]); + } + +/** Set the AV/C CType for this frame. + +@param aType The AV/C CType to set. +@publishedPartner +@released +*/ +EXPORT_C void CAVCFrame::SetType(AVC::TCType aType) + { + iBuffer[0] = aType; + } + +/** Get the AV/C subunit type for this frame. + +@return The AV/C subunit type for this frame. +@publishedPartner +@released +*/ +EXPORT_C AVC::TSubunitType CAVCFrame::SubunitType() const + { + if (iSubunitTypeExtensionBytes == 0) + { + return static_cast((iBuffer[1] & KAVCSubunitTypeMask) >> 3); + } + + return static_cast(iBuffer[1 + iSubunitTypeExtensionBytes] + (iSubunitTypeExtensionBytes * 0x100)); + } + +/** Get the AV/C subunit id for this frame. + +@return The AV/C subunit id for this frame. +@publishedPartner +@released +*/ +EXPORT_C AVC::TSubunitID CAVCFrame::SubunitID() const + { + if (iSubunitIDExtensionBytes == 0) + { + return static_cast(iBuffer[1] & KAVCSubunitIDMask); + } + + return static_cast(iBuffer[1 + iSubunitTypeExtensionBytes + iSubunitIDExtensionBytes] + (iSubunitIDExtensionBytes * 0x100)); + } + +/** Find extension bytes for the frame. + +@param aBuffer buffer to be used. +@return True if its a valid frame. +@leave System wide error code. +@internalComponent +@released +*/ +/* static */ void CAVCFrame::FindExtensionL(const TDesC8& aBuffer, TInt& aSubunitTypeExtensionBytes, TInt& aSubunitIDExtensionBytes) + { + TInt minLength = KAVCFrameHeaderLength; + if(aBuffer.Length() < minLength) + { + User::Leave(KErrCorrupt); + } + + if (static_cast((aBuffer[1] & KAVCSubunitTypeMask) >> 3) == AVC::ETypeExtended1) + { + aSubunitTypeExtensionBytes++; + minLength++; + + while (aBuffer[1 + aSubunitTypeExtensionBytes] == AVC::ETypeExtended2) + { + if(aBuffer.Length() < minLength) + { + User::Leave(KErrCorrupt); + } + + aSubunitTypeExtensionBytes++; + minLength++; + } + } + + if (static_cast(aBuffer[1] & KAVCSubunitIDMask) == AVC::EIDExtended1) + { + aSubunitIDExtensionBytes++; + minLength++; + + while (aBuffer[1 + aSubunitIDExtensionBytes] == AVC::EIDExtended1) + { + if(aBuffer.Length() < minLength) + { + User::Leave(KErrCorrupt); + } + + aSubunitIDExtensionBytes++; + minLength++; + } + } + + //Ensure frame is a valid length i.e. the Opcode() method can be safely called. + if(aBuffer.Length() < minLength) + { + User::Leave(KErrCorrupt); + } + } + +/** Get the AV/C opcode for this frame. + +@param aBuffer buffer to search. +@return The AV/C opcode for this frame. +@leave System wide error code. +@internalComponent +@released +*/ +/* static */ EXPORT_C AVC::TOpcode CAVCFrame::OpcodeL(const TDesC8& aBuffer) + { + TInt subunitTypeExtensionBytes=0; + TInt subunitIDExtensionBytes=0; + + FindExtensionL(aBuffer, subunitTypeExtensionBytes, subunitIDExtensionBytes); + return static_cast (aBuffer[KAVCFrameHeaderLength + subunitTypeExtensionBytes + subunitIDExtensionBytes - 1]); + } + +/** Get the AV/C opcode for this frame. + +@return The AV/C opcode for this frame. +@publishedPartner +@released +*/ +EXPORT_C TUint8 CAVCFrame::Opcode() const + { + return iBuffer[KAVCFrameHeaderLength + iSubunitTypeExtensionBytes + iSubunitIDExtensionBytes - 1]; + } + +/** Get the AV/C OperationId for this frame. + +This is only valid for passthrough commands. + +@param aOpId On return, the AV/C opcode for this frame. +@return KErrNotSupported if this is not a passthrough command, + KErrCorrupt if this passthrough command does not contain a OpId, + KErrNone otherwise. +@publishedPartner +@released +*/ +EXPORT_C TInt CAVCFrame::OperationId(TUint8& aOpId) const + { + TInt err = KErrNotSupported; + + if(Opcode() == AVC::EPassThrough) + { + if(DataLength()) + { + aOpId = (iBuffer[iSubunitTypeExtensionBytes + iSubunitIDExtensionBytes + KAVCFrameHeaderLength]) & 0x7f; + err = KErrNone; + } + else + { + err = KErrCorrupt; + } + } + + return err; + } + +/** Get the AV/C button action for this frame. + +This is only valid for passthrough commands. + +@param aOpId On return, the AV/C button action for this frame. +@return KErrNotSupported if this is not a passthrough command, + KErrCorrupt if this passthrough command does not contain a button action, + KErrNone otherwise. +@publishedPartner +@released +*/ +EXPORT_C TInt CAVCFrame::ButtonAct(AVCPanel::TButtonAction& aButtonAction) const + { + TInt err = KErrNotSupported; + + if(Opcode() == AVC::EPassThrough) + { + if(DataLength()) + { + aButtonAction = (((iBuffer[iSubunitTypeExtensionBytes + iSubunitIDExtensionBytes + KAVCFrameHeaderLength]) & 0x80) == AVCPanel::EButtonRelease) ? AVCPanel::EButtonRelease : AVCPanel::EButtonPress; + err = KErrNone; + } + else + { + err = KErrCorrupt; + } + } + return err; + } + +/** Retrieve data from the AV/C frame. + +@param aIndex The offset of the data element within the data segment of the frame +@return The data element at aIndex. +@panic If aIndex is outside the frame. DataLength() should be used to check the length of the data segment before using the [] operator. +@publishedPartner +@released +*/ +EXPORT_C const TUint8& CAVCFrame::operator[](TInt aIndex) const + { + return iBuffer[aIndex + iSubunitTypeExtensionBytes + iSubunitIDExtensionBytes + KAVCFrameHeaderLength]; + } + +/** Retrieve the entire AV/C frame. + +@return The AV/C frame. +@publishedPartner +@released +*/ +EXPORT_C const TDesC8& CAVCFrame::Data() const + { + return iBuffer; + } + +/** Append data to the AV/C frame. + +@param aDes The data to be appended. +@publishedPartner +@released +*/ +EXPORT_C void CAVCFrame::Append(const TDesC8& aDes) + { + iBuffer.Append(aDes); + } + +/** Append data to the AV/C frame. + +@param aChar The data to be appended. +@publishedPartner +@released +*/ +EXPORT_C void CAVCFrame::Append(TChar aChar) + { + iBuffer.Append(aChar); + } + +/** Return the length of the data in the AV/C frame + +@return The length of the data in the AV/C frame +@publishedPartner +@released +*/ +EXPORT_C TInt CAVCFrame::DataLength() const + { + return (iBuffer.Length() - iSubunitTypeExtensionBytes - iSubunitIDExtensionBytes - KAVCFrameHeaderLength); + } + +EXPORT_C CAVCFrame* CAVCVendorDependentResponse::NewL(TUint aVendorID) + { + using namespace AVC; + CAVCFrame* frame = CAVCFrame::NewL(EResponse, + ENotImplemented, //client can override + EPanel, + EID0); + // stupid frames don't know about themselves so we construct in derived classes + // first opcode - base class REALLY ought to have opcode setter + frame->Append(0); //opcode for VD frame + // second vendor + frame->Append(aVendorID>>16); + frame->Append(aVendorID>>8); + frame->Append(aVendorID); + return frame; + } + +EXPORT_C TPtrC8 CAVCVendorDependentCommand::GetPayloadAndVID(const CAVCFrame& aFrame, TUint& aVID) + { + ASSERT_DEBUG(aFrame.Opcode()==AVC::EVendorDependent); //opcode + aVID = (aFrame.operator[](0)<<16) | + (aFrame.operator[](1)<<8) | + (aFrame.operator[](2)); + + return (aFrame.Data().Right(aFrame.DataLength()-KAVCVendorIdLength)); + } + +EXPORT_C TPtrC8 CAVCVendorUniquePassthroughCommand::GetPayloadAndVID(const CAVCFrame& aFrame, TUint& aVID) + { + ASSERT_DEBUG(aFrame.Opcode()==AVC::EPassThrough); //opcode + aVID = (aFrame.operator[](2)<<16) | + (aFrame.operator[](3)<<8) | + (aFrame.operator[](4)); + + return (aFrame.Data().Right(aFrame.DataLength()-KAVCVendorIdLength-2)); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avc/avcframe.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avc/avcframe.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,540 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVCFRAME_H +#define AVCFRAME_H + +/** +@file +@released +@publishedPartner +*/ + +#include +#include + +static const TInt KAVCFrameMaxLength = 0x200; +static const TInt KAVCFrameHeaderLength = 0x3; +static const TInt KAVCPassthroughFrameLength = 0x5; +static const TUint8 KAVCCommandTypeMask = 0x0f; +static const TUint8 KAVCResponseTypeMask = 0x0f; +static const TUint8 KAVCSubunitTypeMask = 0xf8; +static const TUint8 KAVCSubunitIDMask = 0x07; +static const TUint8 KAVCCommandMaxRangeLength = 0x7; + +static const TUint KAVCVendorUniquePassthroughHeader = 7; +static const TUint KAVCVendorIdBaseOffset = 5; +static const TUint KAVCVendorIdLength = 3; + +static const TInt KAVCMaxVendorDependentPayload = KAVCFrameMaxLength-KAVCFrameHeaderLength-KAVCVendorIdLength; + +namespace AVC + { + enum TFrameType + { + ECommand, + EResponse + }; + /** + As per section 7.3.1, AV/C Digital Interface Command Set General Specification v4.0 + As per section 7.3.2, AV/C Digital Interface Command Set General Specification v4.0 + */ + enum TCType + { + EControl = 0x0, + EStatus = 0x1, + ESpecificEnquiry = 0x2, + ENotify = 0x3, + EGeneralEnquiry = 0x4, + EReserved1 = 0x5, + EReserved2 = 0x6, + EReserved3 = 0x7, + ENotImplemented = 0x8, + EAccepted = 0x9, + ERejected = 0xa, + EInTransition = 0xb, + EImplemented = 0xc, + EStable = 0xc, // NB: EImplemented and EStable are the same! + EChanged = 0xd, + EReserved4 = 0xe, + EInterim = 0xf + }; + /** + As per sections 7.3.4.1 and 7.3.4.3, AV/C Digital Interface Command Set General Specification v4.0 + + Extended subunit types should be coded as 0xXYY in this enumeration where + X is the nth extension and YY is the type number. e.g. 0x101 would correspond + to example 3 in table 7.9 and 0x201 would correspond to example 4. + */ + enum TSubunitType + { + EMonitor = 0x00, + EAudio = 0x01, + EPrinter = 0x02, + EDisc = 0x03, + ETape = 0x04, + ETuner = 0x05, + ECA = 0x06, + ECamera = 0x07, + EPanel = 0x09, + EBulletinBoard = 0x0a, + ECameraStorage = 0x0b, + EVendorUnique = 0x1c, + ETypeExtended1 = 0x1e, + EUnit = 0x1f, + ETypeExtended2 = 0xff + }; + /** + As per sections 7.3.4.1 and 7.3.4.3, AV/C Digital Interface Command Set General Specification v4.0 + + Extended subunit IDs should be coded as 0xXYY in this enumeration where + X is the nth extension and YY is the ID number. e.g. 0x102 would correspond + to example 2 in table 7.10 and 0x201 would correspond to example 3. + */ + enum TSubunitID + { + EID0 = 0x00, + EID1 = 0x01, + EID2 = 0x02, + EID3 = 0x04, + EIDExtended1 = 0x05, + EIgnore = 0x07, + EIDExtended2 = 0xff + }; + /** + As per section 10.1.2, AV/C Digital Interface Command Set General Specification v4.0 + + AV/C unit source plug addresses + */ + enum TUnitInputPlug + { + ESerialIsochronousInput0 = 0x00, + ESerialIsochronousInput1 = 0x01, + ESerialIsochronousInput2 = 0x02, + ESerialIsochronousInput3 = 0x03, + ESerialIsochronousInput4 = 0x04, + ESerialIsochronousInput5 = 0x05, + ESerialIsochronousInput6 = 0x06, + ESerialIsochronousInput7 = 0x07, + ESerialIsochronousInput8 = 0x08, + ESerialIsochronousInput9 = 0x09, + ESerialIsochronousInput10 = 0x0a, + ESerialIsochronousInput11 = 0x0b, + ESerialIsochronousInput12 = 0x0c, + ESerialIsochronousInput13 = 0x0d, + ESerialIsochronousInput14 = 0x0e, + ESerialIsochronousInput15 = 0x0f, + ESerialIsochronousInput16 = 0x10, + ESerialIsochronousInput17 = 0x11, + ESerialIsochronousInput18 = 0x12, + ESerialIsochronousInput19 = 0x13, + ESerialIsochronousInput20 = 0x14, + ESerialIsochronousInput21 = 0x15, + ESerialIsochronousInput22 = 0x16, + ESerialIsochronousInput23 = 0x17, + ESerialIsochronousInput24 = 0x18, + ESerialIsochronousInput25 = 0x19, + ESerialIsochronousInput26 = 0x1a, + ESerialIsochronousInput27 = 0x1b, + ESerialIsochronousInput28 = 0x1c, + ESerialIsochronousInput29 = 0x1d, + ESerialIsochronousInput30 = 0x1e, + EAnySerialIsochronousInput = 0x7f, + EExternalInput0 = 0x80, + EExternalInput1 = 0x81, + EExternalInput2 = 0x82, + EExternalInput3 = 0x83, + EExternalInput4 = 0x84, + EExternalInput5 = 0x85, + EExternalInput6 = 0x86, + EExternalInput7 = 0x87, + EExternalInput8 = 0x88, + EExternalInput9 = 0x89, + EExternalInput10 = 0x8a, + EExternalInput11 = 0x8b, + EExternalInput12 = 0x8c, + EExternalInput13 = 0x8d, + EExternalInput14 = 0x8e, + EExternalInput15 = 0x8f, + EExternalInput16 = 0x90, + EExternalInput17 = 0x91, + EExternalInput18 = 0x92, + EExternalInput19 = 0x93, + EExternalInput20 = 0x94, + EExternalInput21 = 0x95, + EExternalInput22 = 0x96, + EExternalInput23 = 0x97, + EExternalInput24 = 0x98, + EExternalInput25 = 0x99, + EExternalInput26 = 0x9a, + EExternalInput27 = 0x9b, + EExternalInput28 = 0x9c, + EExternalInput29 = 0x9d, + EExternalInput30 = 0x9e, + ESerialAsynchronousInput0 = 0xa0, + ESerialAsynchronousInput1 = 0xa1, + ESerialAsynchronousInput2 = 0xa2, + ESerialAsynchronousInput3 = 0xa3, + ESerialAsynchronousInput4 = 0xa4, + ESerialAsynchronousInput5 = 0xa5, + ESerialAsynchronousInput6 = 0xa6, + ESerialAsynchronousInput7 = 0xa7, + ESerialAsynchronousInput8 = 0xa8, + ESerialAsynchronousInput9 = 0xa9, + ESerialAsynchronousInput10 = 0xaa, + ESerialAsynchronousInput11 = 0xab, + ESerialAsynchronousInput12 = 0xac, + ESerialAsynchronousInput13 = 0xad, + ESerialAsynchronousInput14 = 0xae, + ESerialAsynchronousInput15 = 0xaf, + ESerialAsynchronousInput16 = 0xb0, + ESerialAsynchronousInput17 = 0xb1, + ESerialAsynchronousInput18 = 0xb2, + ESerialAsynchronousInput19 = 0xb3, + ESerialAsynchronousInput20 = 0xb4, + ESerialAsynchronousInput21 = 0xb5, + ESerialAsynchronousInput22 = 0xb6, + ESerialAsynchronousInput23 = 0xb7, + ESerialAsynchronousInput24 = 0xb8, + ESerialAsynchronousInput25 = 0xb9, + ESerialAsynchronousInput26 = 0xba, + ESerialAsynchronousInput27 = 0xbb, + ESerialAsynchronousInput28 = 0xbc, + ESerialAsynchronousInput29 = 0xbd, + ESerialAsynchronousInput30 = 0xbe, + EAnySerialAsynchronousInput = 0xbf, + EInvalidInput = 0xfe, + EAnyExternalInput = 0xff + }; + /** + As per section 10.1.2, AV/C Digital Interface Command Set General Specification v4.0 + + AV/C unit destination plug addresses + */ + enum TUnitOutputPlug + { + ESerialIsochronousOutput0 = 0x00, + ESerialIsochronousOutput1 = 0x01, + ESerialIsochronousOutput2 = 0x02, + ESerialIsochronousOutput3 = 0x03, + ESerialIsochronousOutput4 = 0x04, + ESerialIsochronousOutput5 = 0x05, + ESerialIsochronousOutput6 = 0x06, + ESerialIsochronousOutput7 = 0x07, + ESerialIsochronousOutput8 = 0x08, + ESerialIsochronousOutput9 = 0x09, + ESerialIsochronousOutput10 = 0x0a, + ESerialIsochronousOutput11 = 0x0b, + ESerialIsochronousOutput12 = 0x0c, + ESerialIsochronousOutput13 = 0x0d, + ESerialIsochronousOutput14 = 0x0e, + ESerialIsochronousOutput15 = 0x0f, + ESerialIsochronousOutput16 = 0x10, + ESerialIsochronousOutput17 = 0x11, + ESerialIsochronousOutput18 = 0x12, + ESerialIsochronousOutput19 = 0x13, + ESerialIsochronousOutput20 = 0x14, + ESerialIsochronousOutput21 = 0x15, + ESerialIsochronousOutput22 = 0x16, + ESerialIsochronousOutput23 = 0x17, + ESerialIsochronousOutput24 = 0x18, + ESerialIsochronousOutput25 = 0x19, + ESerialIsochronousOutput26 = 0x1a, + ESerialIsochronousOutput27 = 0x1b, + ESerialIsochronousOutput28 = 0x1c, + ESerialIsochronousOutput29 = 0x1d, + ESerialIsochronousOutput30 = 0x1e, + EAnySerialIsochronousOutput = 0x7f, + EExternalOutput0 = 0x80, + EExternalOutput1 = 0x81, + EExternalOutput2 = 0x82, + EExternalOutput3 = 0x83, + EExternalOutput4 = 0x84, + EExternalOutput5 = 0x85, + EExternalOutput6 = 0x86, + EExternalOutput7 = 0x87, + EExternalOutput8 = 0x88, + EExternalOutput9 = 0x89, + EExternalOutput10 = 0x8a, + EExternalOutput11 = 0x8b, + EExternalOutput12 = 0x8c, + EExternalOutput13 = 0x8d, + EExternalOutput14 = 0x8e, + EExternalOutput15 = 0x8f, + EExternalOutput16 = 0x90, + EExternalOutput17 = 0x91, + EExternalOutput18 = 0x92, + EExternalOutput19 = 0x93, + EExternalOutput20 = 0x94, + EExternalOutput21 = 0x95, + EExternalOutput22 = 0x96, + EExternalOutput23 = 0x97, + EExternalOutput24 = 0x98, + EExternalOutput25 = 0x99, + EExternalOutput26 = 0x9a, + EExternalOutput27 = 0x9b, + EExternalOutput28 = 0x9c, + EExternalOutput29 = 0x9d, + EExternalOutput30 = 0x9e, + ESerialAsynchronousOutput0 = 0xa0, + ESerialAsynchronousOutput1 = 0xa1, + ESerialAsynchronousOutput2 = 0xa2, + ESerialAsynchronousOutput3 = 0xa3, + ESerialAsynchronousOutput4 = 0xa4, + ESerialAsynchronousOutput5 = 0xa5, + ESerialAsynchronousOutput6 = 0xa6, + ESerialAsynchronousOutput7 = 0xa7, + ESerialAsynchronousOutput8 = 0xa8, + ESerialAsynchronousOutput9 = 0xa9, + ESerialAsynchronousOutput10 = 0xaa, + ESerialAsynchronousOutput11 = 0xab, + ESerialAsynchronousOutput12 = 0xac, + ESerialAsynchronousOutput13 = 0xad, + ESerialAsynchronousOutput14 = 0xae, + ESerialAsynchronousOutput15 = 0xaf, + ESerialAsynchronousOutput16 = 0xb0, + ESerialAsynchronousOutput17 = 0xb1, + ESerialAsynchronousOutput18 = 0xb2, + ESerialAsynchronousOutput19 = 0xb3, + ESerialAsynchronousOutput20 = 0xb4, + ESerialAsynchronousOutput21 = 0xb5, + ESerialAsynchronousOutput22 = 0xb6, + ESerialAsynchronousOutput23 = 0xb7, + ESerialAsynchronousOutput24 = 0xb8, + ESerialAsynchronousOutput25 = 0xb9, + ESerialAsynchronousOutput26 = 0xba, + ESerialAsynchronousOutput27 = 0xbb, + ESerialAsynchronousOutput28 = 0xbc, + ESerialAsynchronousOutput29 = 0xbd, + ESerialAsynchronousOutput30 = 0xbe, + EAnySerialAsynchronousOutput= 0xbf, + EMultipleOutputs = 0xfd, + EInvalidOutput = 0xfe, + EAnyExternalOutput = 0xff + }; + /** + As per section 10.2.3, AV/C Digital Interface Command Set General Specification v4.0 + + AV/C subunit source plug addresses + subunit does not have to implement any subunit plug if it does not send or receive any signals + */ + enum TSubunitSourcePlug + { + ESource0 = 0x00, + ESource1 = 0x01, + ESource2 = 0x02, + ESource3 = 0x03, + ESource4 = 0x04, + ESource5 = 0x05, + ESource6 = 0x06, + ESource7 = 0x07, + ESource8 = 0x08, + ESource9 = 0x09, + ESource10 = 0x0a, + ESource11 = 0x0b, + ESource12 = 0x0c, + ESource13 = 0x0d, + ESource14 = 0x0e, + ESource15 = 0x0f, + ESource16 = 0x10, + ESource17 = 0x11, + ESource18 = 0x12, + ESource19 = 0x13, + ESource20 = 0x14, + ESource21 = 0x15, + ESource22 = 0x16, + ESource23 = 0x17, + ESource24 = 0x18, + ESource25 = 0x19, + ESource26 = 0x1a, + ESource27 = 0x1b, + ESource28 = 0x1c, + ESource29 = 0x1d, + ESource30 = 0x1e, + EInvalidSource = 0xfe, + EAnySource = 0xff + }; + /** + As per section 10.2.3, AV/C Digital Interface Command Set General Specification v4.0 + + AV/C subunit destination plug + subunit does not have to implement any subunit plug if it does not send or receive any signals + */ + enum TSubunitDestinationPlug + { + EDestination0 = 0x00, + EDestination1 = 0x01, + EDestination2 = 0x02, + EDestination3 = 0x03, + EDestination4 = 0x04, + EDestination5 = 0x05, + EDestination6 = 0x06, + EDestination7 = 0x07, + EDestination8 = 0x08, + EDestination9 = 0x09, + EDestination10 = 0x0a, + EDestination11 = 0x0b, + EDestination12 = 0x0c, + EDestination13 = 0x0d, + EDestination14 = 0x0e, + EDestination15 = 0x0f, + EDestination16 = 0x10, + EDestination17 = 0x11, + EDestination18 = 0x12, + EDestination19 = 0x13, + EDestination20 = 0x14, + EDestination21 = 0x15, + EDestination22 = 0x16, + EDestination23 = 0x17, + EDestination24 = 0x18, + EDestination25 = 0x19, + EDestination26 = 0x1a, + EDestination27 = 0x1b, + EDestination28 = 0x1c, + EDestination29 = 0x1d, + EDestination30 = 0x1e, + EMultipleDestinations = 0xfe, + EInvalidDestination = 0xfe, + EAnyDestination = 0xff + }; + /** + As per sections 11 and 12, AV/C Digital Interface Command Set General Specification v4.0 + Other commands are defined by the various subunit specifications + */ + enum TOpcode + { + EPower = 0xb2, + EUnitInfo = 0x30, + ESubunitInfo = 0x31, + EReserve = 0x01, + EVersion = 0xb0, + EVendorDependent = 0x00, + EPlugInfo = 0x02, + EChannelUsage = 0x12, + EConnect = 0x24, + EConnectAV = 0x20, + EConnections = 0x22, + EDigitalInput = 0x11, + EDigitalOutput = 0x10, + EDisconnect = 0x25, + EDisconnectAV = 0x21, + EInputPlugSignalFormat = 0x19, + EOutputPlugSignalFormat = 0x18, + EPassThrough = 0x7c + }; + + enum TPacketType + { + EASingle = 0x00, + EStart = 0x01, + EContinue = 0x10, + EEnd = 0x11, + }; + + typedef TUint TAVCVendorId; + } + +/** +AVC frame creation and utilities. +@released +@publishedPartner +*/ +NONSHARABLE_CLASS(CAVCFrame) : public CBase + { +public: + + // Construction / destruction + // TBH this acts as a factory now and could (eventually!) return a derived class + // the caller could check by calling Opcode + // at the moment we are going to use the derived classes just for outbound responses + IMPORT_C static CAVCFrame* NewL(AVC::TFrameType aFrameType, + AVC::TCType aType, + AVC::TSubunitType aSubunitType, + AVC::TSubunitID aSubunitID); + + IMPORT_C static CAVCFrame* NewL(const TDesC8& aBuffer, AVC::TFrameType aType); + + IMPORT_C virtual ~CAVCFrame(); + + // Utility + IMPORT_C AVC::TFrameType FrameType() const; + IMPORT_C static AVC::TFrameType FrameType(const TDesC8& aFrame); + IMPORT_C void SetFrameType(AVC::TFrameType aFrameType); + + IMPORT_C AVC::TCType Type() const; + IMPORT_C void SetType(AVC::TCType aType); + + IMPORT_C AVC::TSubunitType SubunitType() const; + IMPORT_C AVC::TSubunitID SubunitID() const; + IMPORT_C TUint8 Opcode() const; + IMPORT_C TInt OperationId(TUint8& aOpId) const; + IMPORT_C TInt ButtonAct(AVCPanel::TButtonAction& aButtonAction) const; + + IMPORT_C const TUint8& operator[](TInt aIndex) const; + IMPORT_C const TDesC8& Data() const; + + IMPORT_C void Append(const TDesC8& aDes); + IMPORT_C void Append(TChar aChar); + IMPORT_C TInt DataLength() const; + + IMPORT_C static AVC::TOpcode OpcodeL(const TDesC8& aBuffer); + +private: + CAVCFrame(AVC::TFrameType aFrameType); + + void ConstructL(AVC::TCType aType, + AVC::TSubunitType aSubunitType, + AVC::TSubunitID aSubunitID); + void ConstructL(const TDesC8& aBuffer); + static void FindExtensionL(const TDesC8& aBuffer, TInt& aSubunitTypeExtensionBytes, TInt& aSubunitIDExtensionBytes); + +private: + RBuf8 iBuffer; + + AVC::TFrameType iFrameType; + TInt iSubunitTypeExtensionBytes; + TInt iSubunitIDExtensionBytes; + }; + + +// Factory pattern stuff - these are useful to do donkey work, +// but have existing clients treat them as the base class + +class CAVCVendorDependentResponse + { +public: + IMPORT_C static CAVCFrame* NewL(TUint aVendorId); + }; + +class CAVCPassthroughCommand + { +public: + }; + +// likely not have newl because dont allocate on parse pattern +class CAVCVendorDependentCommand + { +public: + IMPORT_C static TPtrC8 GetPayloadAndVID(const CAVCFrame& aFrame, TUint& aVID); + }; + +// likely not have newl because dont allocate on parse pattern +class CAVCVendorUniquePassthroughCommand + { +public: + IMPORT_C static TPtrC8 GetPayloadAndVID(const CAVCFrame& aFrame, TUint& aVID); + }; + +#endif // AVCFRAME_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avc/avcpanel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avc/avcpanel.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,96 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVCPANEL_H +#define AVCPANEL_H + +/** +@file +@publishedPartner +@released +*/ + +namespace AVCPanel + { + enum TOperationId + { + ESelect = 0x00, + EUp = 0x01, + EDown = 0x02, + ELeft = 0x03, + ERight = 0x04, + ERightUp = 0x05, + ERightDown = 0x06, + ELeftUp = 0x07, + ELeftDown = 0x08, + ERootMenu = 0x09, + ESetupMenu = 0x0a, + EContentsMenu = 0x0b, + EFavoriteMenu = 0x0c, + EExit = 0x0d, + E0 = 0x20, + E1 = 0x21, + E2 = 0x22, + E3 = 0x23, + E4 = 0x24, + E5 = 0x25, + E6 = 0x26, + E7 = 0x27, + E8 = 0x28, + E9 = 0x29, + EDot = 0x2a, + EEnter = 0x2b, + EClear = 0x2c, + EChannelUp = 0x30, + EChannelDown = 0x31, + EPreviousChannel = 0x32, + ESoundSelect = 0x33, + EInputSelect = 0x34, + EDisplayInformation = 0x35, + EHelp = 0x36, + EPageUp = 0x37, + EPageDown = 0x38, + EPower = 0x40, + EVolumeUp = 0x41, + EVolumeDown = 0x42, + EMute = 0x43, + EPlay = 0x44, + EStop = 0x45, + EPause = 0x46, + ERecord = 0x47, + ERewind = 0x48, + EFastForward = 0x49, + EEject = 0x4a, + EForward = 0x4b, + EBackward = 0x4c, + EAngle = 0x50, + ESubpicture = 0x51, + EF1 = 0x71, + EF2 = 0x72, + EF3 = 0x73, + EF4 = 0x74, + EF5 = 0x75, + EVendorUnique = 0x7e + }; + + enum TButtonAction + { + EButtonPress = 0x0 << 7, + EButtonRelease = 0x1 << 7, + EButtonUnknown = 0x0 << 7 // Default to push + }; + } + +#endif // AVCPANEL_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avc/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avc/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_EXPORTS +avcframe.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(avcframe.h) +avcpanel.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(avcpanel.h) + +PRJ_MMPFILES +avc.mmp diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/bwins/avrcpipcu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/bwins/avrcpipcu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,115 @@ +EXPORTS + ?Close@REAResponse@@QAEXXZ @ 1 NONAME ; void REAResponse::Close(void) + ?Close@RItem@@QAEXXZ @ 2 NONAME ; void RItem::Close(void) + ?Close@RRemConGetCapabilitiesResponse@@QAEXXZ @ 3 NONAME ; void RRemConGetCapabilitiesResponse::Close(void) + ?Close@RRemConGetElementAttributesRequest@@QAEXXZ @ 4 NONAME ; void RRemConGetElementAttributesRequest::Close(void) + ?Close@RRemConGetElementAttributesResponse@@QAEXXZ @ 5 NONAME ; void RRemConGetElementAttributesResponse::Close(void) + ?Close@RRemConGetFolderItemsRequest@@QAEXXZ @ 6 NONAME ; void RRemConGetFolderItemsRequest::Close(void) + ?Close@RRemConGetFolderItemsResponse@@QAEXXZ @ 7 NONAME ; void RRemConGetFolderItemsResponse::Close(void) + ?Close@RRemConGetItemAttributesRequest@@QAEXXZ @ 8 NONAME ; void RRemConGetItemAttributesRequest::Close(void) + ?Close@RRemConGetItemAttributesResponse@@QAEXXZ @ 9 NONAME ; void RRemConGetItemAttributesResponse::Close(void) + ?Close@RRemConGetPlayerApplicationTextResponse@@QAEXXZ @ 10 NONAME ; void RRemConGetPlayerApplicationTextResponse::Close(void) + ?Close@RRemConPlayerAttributeIdsAndValues@@QAEXXZ @ 11 NONAME ; void RRemConPlayerAttributeIdsAndValues::Close(void) + ?Close@RRemConPlayerListOfAttributes@@QAEXXZ @ 12 NONAME ; void RRemConPlayerListOfAttributes::Close(void) + ?Close@RRemConSearchRequest@@QAEXXZ @ 13 NONAME ; void RRemConSearchRequest::Close(void) + ?Close@RAvrcpGetFolderItemsResponse@@QAEXXZ @ 14 NONAME ; void RAvrcpGetFolderItemsResponse::Close(void) + ?WriteL@RRemConPlayerInformation32BitResponse@@UAEXAAVTDes8@@@Z @ 15 NONAME ; void RRemConPlayerInformation32BitResponse::WriteL(class TDes8 &) + ?WriteL@RRemConPlayerInformation8BitResponse@@UAEXAAVTDes8@@@Z @ 16 NONAME ; void RRemConPlayerInformation8BitResponse::WriteL(class TDes8 &) + ?WriteL@RRemConPlayerInformationGetPlayStatusResponse@@UAEXAAVTDes8@@@Z @ 17 NONAME ; void RRemConPlayerInformationGetPlayStatusResponse::WriteL(class TDes8 &) + ?ReadL@RRemConSearchRequest@@UAEXABVTDesC8@@@Z @ 18 NONAME ; void RRemConSearchRequest::ReadL(class TDesC8 const &) + ?ReadL@RRemConGetElementAttributesResponse@@UAEXABVTDesC8@@@Z @ 19 NONAME ; void RRemConGetElementAttributesResponse::ReadL(class TDesC8 const &) + ?Size@RRemConGetElementAttributesResponse@@QAEHXZ @ 20 NONAME ; int RRemConGetElementAttributesResponse::Size(void) + ?Size@RMediaPlayerItem@@QAEHXZ @ 21 NONAME ; int RMediaPlayerItem::Size(void) + ?Size@RRemConGetFolderItemsResponse@@QAEHXZ @ 22 NONAME ; int RRemConGetFolderItemsResponse::Size(void) + ?WriteL@RRemConGetCapabilitiesResponse@@UAEXAAVTDes8@@@Z @ 23 NONAME ; void RRemConGetCapabilitiesResponse::WriteL(class TDes8 &) + ?WriteL@RRemConGetFolderItemsResponse@@UAEXAAVTDes8@@@Z @ 24 NONAME ; void RRemConGetFolderItemsResponse::WriteL(class TDes8 &) + ?WriteL@RRemConGetElementAttributesResponse@@UAEXAAVTDes8@@@Z @ 25 NONAME ; void RRemConGetElementAttributesResponse::WriteL(class TDes8 &) + ?CopyAttributes@RRemConGetFolderItemsRequest@@QAEHAAV?$RArray@W4TMediaAttributeId@@@@@Z @ 26 NONAME ; int RRemConGetFolderItemsRequest::CopyAttributes(class RArray &) + ?WriteL@RRemConPlayerListOfAttributes@@UAEXAAVTDes8@@@Z @ 27 NONAME ; void RRemConPlayerListOfAttributes::WriteL(class TDes8 &) + ?WriteL@RAvrcpIPCError@@UAEXAAVTDes8@@@Z @ 28 NONAME ; void RAvrcpIPCError::WriteL(class TDes8 &) + ?WriteL@RAvrcpGetFolderItemsRequest@@UAEXAAVTDes8@@@Z @ 29 NONAME ; void RAvrcpGetFolderItemsRequest::WriteL(class TDes8 &) + ?ReadL@RRemConPlayerAttributeIdsAndValues@@UAEXABVTDesC8@@@Z @ 30 NONAME ; void RRemConPlayerAttributeIdsAndValues::ReadL(class TDesC8 const &) + ?CopyItems@RRemConGetFolderItemsResponse@@QAEHABV?$TArray@VTRemConItem@@@@@Z @ 31 NONAME ; int RRemConGetFolderItemsResponse::CopyItems(class TArray const &) + ?Remove@TRemConMessageQueue@@QAEXAAVCRemConQueuedMessage@@@Z @ 32 NONAME ; void TRemConMessageQueue::Remove(class CRemConQueuedMessage &) + ?Find@TRemConMessageQueue@@QAEPBVCRemConQueuedMessage@@VTUid@@H@Z @ 33 NONAME ; class CRemConQueuedMessage const * TRemConMessageQueue::Find(class TUid, int) + ?Close@RMediaPlayerItem@@QAEXXZ @ 34 NONAME ; void RMediaPlayerItem::Close(void) + ?NewL@CRemConQueuedMessage@@SAPAV1@VTUid@@ABVTDesC8@@H@Z @ 35 NONAME ; class CRemConQueuedMessage * CRemConQueuedMessage::NewL(class TUid, class TDesC8 const &, int) + ?WriteL@RRemConChangePathResponse@@UAEXAAVTDes8@@@Z @ 36 NONAME ; void RRemConChangePathResponse::WriteL(class TDes8 &) + ?ReadL@RAvrcpSetAddressedPlayerResponse@@UAEXABVTDesC8@@@Z @ 37 NONAME ; void RAvrcpSetAddressedPlayerResponse::ReadL(class TDesC8 const &) + ?WriteL@RRemConUidsChangedResponse@@UAEXAAVTDes8@@@Z @ 38 NONAME ; void RRemConUidsChangedResponse::WriteL(class TDes8 &) + ?WriteL@RRemConGetFolderItemsRequest@@UAEXAAVTDes8@@@Z @ 39 NONAME ; void RRemConGetFolderItemsRequest::WriteL(class TDes8 &) + ?WriteL@RAvrcpGetFolderItemsResponse@@UAEXAAVTDes8@@@Z @ 40 NONAME ; void RAvrcpGetFolderItemsResponse::WriteL(class TDes8 &) + ?ReadL@RAvrcpGetFolderItemsResponse@@UAEXABVTDesC8@@@Z @ 41 NONAME ; void RAvrcpGetFolderItemsResponse::ReadL(class TDesC8 const &) + ?ReadL@RAvrcpGetFolderItemsRequest@@UAEXABVTDesC8@@@Z @ 42 NONAME ; void RAvrcpGetFolderItemsRequest::ReadL(class TDesC8 const &) + ?ReadL@RRemConNowPlayingResponse@@UAEXABVTDesC8@@@Z @ 43 NONAME ; void RRemConNowPlayingResponse::ReadL(class TDesC8 const &) + ?IsEmpty@TRemConMessageQueue@@QAEHXZ @ 44 NONAME ; int TRemConMessageQueue::IsEmpty(void) + ?SymbianErrToStatus@RAvrcpIPC@@SAEH@Z @ 45 NONAME ; unsigned char RAvrcpIPC::SymbianErrToStatus(int) + ?First@TRemConMessageQueue@@QBEPAVCRemConQueuedMessage@@XZ @ 46 NONAME ; class CRemConQueuedMessage * TRemConMessageQueue::First(void) const + ?Reset@TRemConMessageQueue@@QAEXXZ @ 47 NONAME ; void TRemConMessageQueue::Reset(void) + ?WriteL@RAvrcpSetAddressedPlayerResponse@@UAEXAAVTDes8@@@Z @ 48 NONAME ; void RAvrcpSetAddressedPlayerResponse::WriteL(class TDes8 &) + ?ReadL@RRemConMediaErrorResponse@@UAEXABVTDesC8@@@Z @ 49 NONAME ; void RRemConMediaErrorResponse::ReadL(class TDesC8 const &) + ?SymbianErrorCheck@RAvrcpIPC@@SAHH@Z @ 50 NONAME ; int RAvrcpIPC::SymbianErrorCheck(int) + ?GetEventIdFromIPCOperationId@RAvrcpIPC@@SA?AW4TRegisterNotificationEvent@@H@Z @ 51 NONAME ; enum TRegisterNotificationEvent RAvrcpIPC::GetEventIdFromIPCOperationId(int) + ?WriteL@RRemConSetBrowsedPlayerRequest@@UAEXAAVTDes8@@@Z @ 52 NONAME ; void RRemConSetBrowsedPlayerRequest::WriteL(class TDes8 &) + ?WriteL@RRemConGetElementAttributesRequest@@UAEXAAVTDes8@@@Z @ 53 NONAME ; void RRemConGetElementAttributesRequest::WriteL(class TDes8 &) + ?AddLast@TRemConMessageQueue@@QAEXAAVCRemConQueuedMessage@@@Z @ 54 NONAME ; void TRemConMessageQueue::AddLast(class CRemConQueuedMessage &) + ?WriteL@RRemConGetPathResponse@@UAEXAAVTDes8@@@Z @ 55 NONAME ; void RRemConGetPathResponse::WriteL(class TDes8 &) + ?Size@RRemConGetItemAttributesResponse@@QAEHXZ @ 56 NONAME ; int RRemConGetItemAttributesResponse::Size(void) + ?ReadL@RRemConNowPlayingRequest@@UAEXABVTDesC8@@@Z @ 57 NONAME ; void RRemConNowPlayingRequest::ReadL(class TDesC8 const &) + ?ReadL@RAvrcpSetAddressedPlayerRequest@@UAEXABVTDesC8@@@Z @ 58 NONAME ; void RAvrcpSetAddressedPlayerRequest::ReadL(class TDesC8 const &) + ?WriteL@RRemConPlayerInformation64BitResponse@@UAEXAAVTDes8@@@Z @ 59 NONAME ; void RRemConPlayerInformation64BitResponse::WriteL(class TDes8 &) + ?WriteL@RRemConSearchResponse@@UAEXAAVTDes8@@@Z @ 60 NONAME ; void RRemConSearchResponse::WriteL(class TDes8 &) + ?ReadL@RRemConPlayerInformation64BitResponse@@UAEXABVTDesC8@@@Z @ 61 NONAME ; void RRemConPlayerInformation64BitResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConPlayerInformation8BitResponse@@UAEXABVTDesC8@@@Z @ 62 NONAME ; void RRemConPlayerInformation8BitResponse::ReadL(class TDesC8 const &) + ?WriteL@RRemConNowPlayingRequest@@UAEXAAVTDes8@@@Z @ 63 NONAME ; void RRemConNowPlayingRequest::WriteL(class TDes8 &) + ?Size@RRemConGetPlayerApplicationTextResponse@@QAEHXZ @ 64 NONAME ; int RRemConGetPlayerApplicationTextResponse::Size(void) + ?ReadL@RRemConPlayerListOfAttributes@@UAEXABVTDesC8@@@Z @ 65 NONAME ; void RRemConPlayerListOfAttributes::ReadL(class TDesC8 const &) + ?WriteL@RRemConPlayerAttributeIdsAndValues@@UAEXAAVTDes8@@@Z @ 66 NONAME ; void RRemConPlayerAttributeIdsAndValues::WriteL(class TDes8 &) + ?Size@RItem@@QAEHXZ @ 67 NONAME ; int RItem::Size(void) + ?WriteL@RRemConGetItemAttributesRequest@@UAEXAAVTDes8@@@Z @ 68 NONAME ; void RRemConGetItemAttributesRequest::WriteL(class TDes8 &) + ?WriteL@RRemConChangePathRequest@@UAEXAAVTDes8@@@Z @ 69 NONAME ; void RRemConChangePathRequest::WriteL(class TDes8 &) + ?WriteL@RRemConGetItemAttributesResponse@@UAEXAAVTDes8@@@Z @ 70 NONAME ; void RRemConGetItemAttributesResponse::WriteL(class TDes8 &) + ?Size@RRemConSearchRequest@@QAEHXZ @ 71 NONAME ; int RRemConSearchRequest::Size(void) + ?ReadL@RAvrcpAddressedPlayerNotificationResponse@@UAEXABVTDesC8@@@Z @ 72 NONAME ; void RAvrcpAddressedPlayerNotificationResponse::ReadL(class TDesC8 const &) + ?RequestNextItem@RRemConGetFolderItemsResponse@@QAEHAAHAAVRBuf8@@G@Z @ 73 NONAME ; int RRemConGetFolderItemsResponse::RequestNextItem(int &, class RBuf8 &, unsigned short) + ?ReadL@RRemConPlayerInformation32BitResponse@@UAEXABVTDesC8@@@Z @ 74 NONAME ; void RRemConPlayerInformation32BitResponse::ReadL(class TDesC8 const &) + ?Size@RRemConGetPathResponse@@QAEHXZ @ 75 NONAME ; int RRemConGetPathResponse::Size(void) + ??0TRemConMessageQueue@@QAE@XZ @ 76 NONAME ; TRemConMessageQueue::TRemConMessageQueue(void) + ?ReadL@RRemConGetItemAttributesRequest@@UAEXABVTDesC8@@@Z @ 77 NONAME ; void RRemConGetItemAttributesRequest::ReadL(class TDesC8 const &) + ?ReadL@RRemConGetItemAttributesResponse@@UAEXABVTDesC8@@@Z @ 78 NONAME ; void RRemConGetItemAttributesResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConGetPlayerApplicationTextResponse@@UAEXABVTDesC8@@@Z @ 79 NONAME ; void RRemConGetPlayerApplicationTextResponse::ReadL(class TDesC8 const &) + ?SetIPCOperationIdFromEventId@RAvrcpIPC@@SAHW4TRegisterNotificationEvent@@@Z @ 80 NONAME ; int RAvrcpIPC::SetIPCOperationIdFromEventId(enum TRegisterNotificationEvent) + ?Data@CRemConQueuedMessage@@QAEABVTDesC8@@XZ @ 81 NONAME ; class TDesC8 const & CRemConQueuedMessage::Data(void) + ?WriteL@RRemConNowPlayingResponse@@UAEXAAVTDes8@@@Z @ 82 NONAME ; void RRemConNowPlayingResponse::WriteL(class TDes8 &) + ?ReadL@RRemConPlayerInformationGetPlayStatusResponse@@UAEXABVTDesC8@@@Z @ 83 NONAME ; void RRemConPlayerInformationGetPlayStatusResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConGetFolderItemsRequest@@UAEXABVTDesC8@@@Z @ 84 NONAME ; void RRemConGetFolderItemsRequest::ReadL(class TDesC8 const &) + ?Close@RSettingWithCharset@@QAEXXZ @ 85 NONAME ; void RSettingWithCharset::Close(void) + ?ReadL@RAvrcpIPCError@@UAEXABVTDesC8@@@Z @ 86 NONAME ; void RAvrcpIPCError::ReadL(class TDesC8 const &) + ?WriteL@RRemConMediaErrorResponse@@UAEXAAVTDes8@@@Z @ 87 NONAME ; void RRemConMediaErrorResponse::WriteL(class TDes8 &) + ?ReadL@RRemConGetPathResponse@@UAEXABVTDesC8@@@Z @ 88 NONAME ; void RRemConGetPathResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConSearchResponse@@UAEXABVTDesC8@@@Z @ 89 NONAME ; void RRemConSearchResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConSetBrowsedPlayerRequest@@UAEXABVTDesC8@@@Z @ 90 NONAME ; void RRemConSetBrowsedPlayerRequest::ReadL(class TDesC8 const &) + ?ReadL@RRemConChangePathResponse@@UAEXABVTDesC8@@@Z @ 91 NONAME ; void RRemConChangePathResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConGetCapabilitiesResponse@@UAEXABVTDesC8@@@Z @ 92 NONAME ; void RRemConGetCapabilitiesResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConUidsChangedResponse@@UAEXABVTDesC8@@@Z @ 93 NONAME ; void RRemConUidsChangedResponse::ReadL(class TDesC8 const &) + ?GetPDUIdFromIPCOperationId@RAvrcpIPC@@SA?AW4TMetadataTransferPDU@@H@Z @ 94 NONAME ; enum TMetadataTransferPDU RAvrcpIPC::GetPDUIdFromIPCOperationId(int) + ?Size@RAvrcpGetFolderItemsResponse@@QAEHXZ @ 95 NONAME ; int RAvrcpGetFolderItemsResponse::Size(void) + ?ReadL@RRemConChangePathRequest@@UAEXABVTDesC8@@@Z @ 96 NONAME ; void RRemConChangePathRequest::ReadL(class TDesC8 const &) + ?ReadL@RRemConGetFolderItemsResponse@@UAEXABVTDesC8@@@Z @ 97 NONAME ; void RRemConGetFolderItemsResponse::ReadL(class TDesC8 const &) + ?Close@RRemConGetPathResponse@@QAEXXZ @ 98 NONAME ; void RRemConGetPathResponse::Close(void) + ?ReadL@RRemConGetElementAttributesRequest@@UAEXABVTDesC8@@@Z @ 99 NONAME ; void RRemConGetElementAttributesRequest::ReadL(class TDesC8 const &) + ??1CRemConQueuedMessage@@UAE@XZ @ 100 NONAME ; CRemConQueuedMessage::~CRemConQueuedMessage(void) + ?WriteL@RRemConSearchRequest@@UAEXAAVTDes8@@@Z @ 101 NONAME ; void RRemConSearchRequest::WriteL(class TDes8 &) + ?WriteL@RRemConGetPlayerApplicationTextResponse@@UAEXAAVTDes8@@@Z @ 102 NONAME ; void RRemConGetPlayerApplicationTextResponse::WriteL(class TDes8 &) + ?WriteL@RAvrcpAddressedPlayerNotificationResponse@@UAEXAAVTDes8@@@Z @ 103 NONAME ; void RAvrcpAddressedPlayerNotificationResponse::WriteL(class TDes8 &) + ?WriteL@RAvrcpSetAddressedPlayerRequest@@UAEXAAVTDes8@@@Z @ 104 NONAME ; void RAvrcpSetAddressedPlayerRequest::WriteL(class TDes8 &) + ?Close@RAvrcpGetFolderItemsRequest@@QAEXXZ @ 105 NONAME ; void RAvrcpGetFolderItemsRequest::Close(void) + ?ReadL@RRemConUidsChangedRequest@@UAEXABVTDesC8@@@Z @ 106 NONAME ; void RRemConUidsChangedRequest::ReadL(class TDesC8 const &) + ?WriteL@RRemConUidsChangedRequest@@UAEXAAVTDes8@@@Z @ 107 NONAME ; void RRemConUidsChangedRequest::WriteL(class TDes8 &) + ?WriteL@RAvrcpUidCounterNotificationResponse@@UAEXAAVTDes8@@@Z @ 108 NONAME ; void RAvrcpUidCounterNotificationResponse::WriteL(class TDes8 &) + ?ReadL@RAvrcpUidCounterNotificationResponse@@UAEXABVTDesC8@@@Z @ 109 NONAME ; void RAvrcpUidCounterNotificationResponse::ReadL(class TDesC8 const &) + ?WriteL@RRemConPlayerInformationGetPlayStatusUpdateRequest@@UAEXAAVTDes8@@@Z @ 110 NONAME ; void RRemConPlayerInformationGetPlayStatusUpdateRequest::WriteL(class TDes8 &) + ?ReadL@RRemConPlayerInformationGetPlayStatusUpdateResponse@@UAEXABVTDesC8@@@Z @ 111 NONAME ; void RRemConPlayerInformationGetPlayStatusUpdateResponse::ReadL(class TDesC8 const &) + ?ReadL@RRemConPlayerInformationGetPlayStatusUpdateRequest@@UAEXABVTDesC8@@@Z @ 112 NONAME ; void RRemConPlayerInformationGetPlayStatusUpdateRequest::ReadL(class TDesC8 const &) + ?WriteL@RRemConPlayerInformationGetPlayStatusUpdateResponse@@UAEXAAVTDes8@@@Z @ 113 NONAME ; void RRemConPlayerInformationGetPlayStatusUpdateResponse::WriteL(class TDes8 &) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/eabi/avrcpipcu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/eabi/avrcpipcu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,186 @@ +EXPORTS + _ZN11REAResponse5CloseEv @ 1 NONAME + _ZN14RAvrcpIPCError5ReadLERK6TDesC8 @ 2 NONAME + _ZN14RAvrcpIPCError6WriteLER5TDes8 @ 3 NONAME + _ZN16RMediaPlayerItem4SizeEv @ 4 NONAME + _ZN16RMediaPlayerItem5CloseEv @ 5 NONAME + _ZN19RSettingWithCharset5CloseEv @ 6 NONAME + _ZN19TRemConMessageQueue4FindE4TUidi @ 7 NONAME + _ZN19TRemConMessageQueue5ResetEv @ 8 NONAME + _ZN19TRemConMessageQueue6RemoveER20CRemConQueuedMessage @ 9 NONAME + _ZN19TRemConMessageQueue7AddLastER20CRemConQueuedMessage @ 10 NONAME + _ZN19TRemConMessageQueue7IsEmptyEv @ 11 NONAME + _ZN19TRemConMessageQueueC1Ev @ 12 NONAME + _ZN19TRemConMessageQueueC2Ev @ 13 NONAME + _ZN20CRemConQueuedMessage4DataEv @ 14 NONAME + _ZN20CRemConQueuedMessage4NewLE4TUidRK6TDesC8i @ 15 NONAME + _ZN20CRemConQueuedMessageD0Ev @ 16 NONAME + _ZN20CRemConQueuedMessageD1Ev @ 17 NONAME + _ZN20CRemConQueuedMessageD2Ev @ 18 NONAME + _ZN20RRemConSearchRequest4SizeEv @ 19 NONAME + _ZN20RRemConSearchRequest5CloseEv @ 20 NONAME + _ZN20RRemConSearchRequest5ReadLERK6TDesC8 @ 21 NONAME + _ZN20RRemConSearchRequest6WriteLER5TDes8 @ 22 NONAME + _ZN21RRemConSearchResponse5ReadLERK6TDesC8 @ 23 NONAME + _ZN21RRemConSearchResponse6WriteLER5TDes8 @ 24 NONAME + _ZN22RRemConGetPathResponse4SizeEv @ 25 NONAME + _ZN22RRemConGetPathResponse5CloseEv @ 26 NONAME + _ZN22RRemConGetPathResponse5ReadLERK6TDesC8 @ 27 NONAME + _ZN22RRemConGetPathResponse6WriteLER5TDes8 @ 28 NONAME + _ZN24RRemConChangePathRequest5ReadLERK6TDesC8 @ 29 NONAME + _ZN24RRemConChangePathRequest6WriteLER5TDes8 @ 30 NONAME + _ZN24RRemConNowPlayingRequest5ReadLERK6TDesC8 @ 31 NONAME + _ZN24RRemConNowPlayingRequest6WriteLER5TDes8 @ 32 NONAME + _ZN25RRemConChangePathResponse5ReadLERK6TDesC8 @ 33 NONAME + _ZN25RRemConChangePathResponse6WriteLER5TDes8 @ 34 NONAME + _ZN25RRemConMediaErrorResponse5ReadLERK6TDesC8 @ 35 NONAME + _ZN25RRemConMediaErrorResponse6WriteLER5TDes8 @ 36 NONAME + _ZN25RRemConNowPlayingResponse5ReadLERK6TDesC8 @ 37 NONAME + _ZN25RRemConNowPlayingResponse6WriteLER5TDes8 @ 38 NONAME + _ZN25RRemConUidsChangedRequest5ReadLERK6TDesC8 @ 39 NONAME + _ZN25RRemConUidsChangedRequest6WriteLER5TDes8 @ 40 NONAME + _ZN26RRemConUidsChangedResponse5ReadLERK6TDesC8 @ 41 NONAME + _ZN26RRemConUidsChangedResponse6WriteLER5TDes8 @ 42 NONAME + _ZN27RAvrcpGetFolderItemsRequest5CloseEv @ 43 NONAME + _ZN27RAvrcpGetFolderItemsRequest5ReadLERK6TDesC8 @ 44 NONAME + _ZN27RAvrcpGetFolderItemsRequest6WriteLER5TDes8 @ 45 NONAME + _ZN28RAvrcpGetFolderItemsResponse4SizeEv @ 46 NONAME + _ZN28RAvrcpGetFolderItemsResponse5CloseEv @ 47 NONAME + _ZN28RAvrcpGetFolderItemsResponse5ReadLERK6TDesC8 @ 48 NONAME + _ZN28RAvrcpGetFolderItemsResponse6WriteLER5TDes8 @ 49 NONAME + _ZN28RRemConGetFolderItemsRequest14CopyAttributesER6RArrayI17TMediaAttributeIdE @ 50 NONAME + _ZN28RRemConGetFolderItemsRequest5CloseEv @ 51 NONAME + _ZN28RRemConGetFolderItemsRequest5ReadLERK6TDesC8 @ 52 NONAME + _ZN28RRemConGetFolderItemsRequest6WriteLER5TDes8 @ 53 NONAME + _ZN29RRemConGetFolderItemsResponse15RequestNextItemERiR5RBuf8t @ 54 NONAME + _ZN29RRemConGetFolderItemsResponse4SizeEv @ 55 NONAME + _ZN29RRemConGetFolderItemsResponse5CloseEv @ 56 NONAME + _ZN29RRemConGetFolderItemsResponse5ReadLERK6TDesC8 @ 57 NONAME + _ZN29RRemConGetFolderItemsResponse6WriteLER5TDes8 @ 58 NONAME + _ZN29RRemConGetFolderItemsResponse9CopyItemsERK6TArrayI11TRemConItemE @ 59 NONAME + _ZN29RRemConPlayerListOfAttributes5CloseEv @ 60 NONAME + _ZN29RRemConPlayerListOfAttributes5ReadLERK6TDesC8 @ 61 NONAME + _ZN29RRemConPlayerListOfAttributes6WriteLER5TDes8 @ 62 NONAME + _ZN30RRemConGetCapabilitiesResponse5CloseEv @ 63 NONAME + _ZN30RRemConGetCapabilitiesResponse5ReadLERK6TDesC8 @ 64 NONAME + _ZN30RRemConGetCapabilitiesResponse6WriteLER5TDes8 @ 65 NONAME + _ZN30RRemConSetBrowsedPlayerRequest5ReadLERK6TDesC8 @ 66 NONAME + _ZN30RRemConSetBrowsedPlayerRequest6WriteLER5TDes8 @ 67 NONAME + _ZN31RAvrcpSetAddressedPlayerRequest5ReadLERK6TDesC8 @ 68 NONAME + _ZN31RAvrcpSetAddressedPlayerRequest6WriteLER5TDes8 @ 69 NONAME + _ZN31RRemConGetItemAttributesRequest5CloseEv @ 70 NONAME + _ZN31RRemConGetItemAttributesRequest5ReadLERK6TDesC8 @ 71 NONAME + _ZN31RRemConGetItemAttributesRequest6WriteLER5TDes8 @ 72 NONAME + _ZN32RAvrcpSetAddressedPlayerResponse5ReadLERK6TDesC8 @ 73 NONAME + _ZN32RAvrcpSetAddressedPlayerResponse6WriteLER5TDes8 @ 74 NONAME + _ZN32RRemConGetItemAttributesResponse4SizeEv @ 75 NONAME + _ZN32RRemConGetItemAttributesResponse5CloseEv @ 76 NONAME + _ZN32RRemConGetItemAttributesResponse5ReadLERK6TDesC8 @ 77 NONAME + _ZN32RRemConGetItemAttributesResponse6WriteLER5TDes8 @ 78 NONAME + _ZN34RRemConGetElementAttributesRequest5CloseEv @ 79 NONAME + _ZN34RRemConGetElementAttributesRequest5ReadLERK6TDesC8 @ 80 NONAME + _ZN34RRemConGetElementAttributesRequest6WriteLER5TDes8 @ 81 NONAME + _ZN34RRemConPlayerAttributeIdsAndValues5CloseEv @ 82 NONAME + _ZN34RRemConPlayerAttributeIdsAndValues5ReadLERK6TDesC8 @ 83 NONAME + _ZN34RRemConPlayerAttributeIdsAndValues6WriteLER5TDes8 @ 84 NONAME + _ZN35RRemConGetElementAttributesResponse4SizeEv @ 85 NONAME + _ZN35RRemConGetElementAttributesResponse5CloseEv @ 86 NONAME + _ZN35RRemConGetElementAttributesResponse5ReadLERK6TDesC8 @ 87 NONAME + _ZN35RRemConGetElementAttributesResponse6WriteLER5TDes8 @ 88 NONAME + _ZN36RRemConPlayerInformation8BitResponse5ReadLERK6TDesC8 @ 89 NONAME + _ZN36RRemConPlayerInformation8BitResponse6WriteLER5TDes8 @ 90 NONAME + _ZN37RRemConPlayerInformation32BitResponse5ReadLERK6TDesC8 @ 91 NONAME + _ZN37RRemConPlayerInformation32BitResponse6WriteLER5TDes8 @ 92 NONAME + _ZN37RRemConPlayerInformation64BitResponse5ReadLERK6TDesC8 @ 93 NONAME + _ZN37RRemConPlayerInformation64BitResponse6WriteLER5TDes8 @ 94 NONAME + _ZN39RRemConGetPlayerApplicationTextResponse4SizeEv @ 95 NONAME + _ZN39RRemConGetPlayerApplicationTextResponse5CloseEv @ 96 NONAME + _ZN39RRemConGetPlayerApplicationTextResponse5ReadLERK6TDesC8 @ 97 NONAME + _ZN39RRemConGetPlayerApplicationTextResponse6WriteLER5TDes8 @ 98 NONAME + _ZN41RAvrcpAddressedPlayerNotificationResponse5ReadLERK6TDesC8 @ 99 NONAME + _ZN41RAvrcpAddressedPlayerNotificationResponse6WriteLER5TDes8 @ 100 NONAME + _ZN45RRemConPlayerInformationGetPlayStatusResponse5ReadLERK6TDesC8 @ 101 NONAME + _ZN45RRemConPlayerInformationGetPlayStatusResponse6WriteLER5TDes8 @ 102 NONAME + _ZN5RItem4SizeEv @ 103 NONAME + _ZN5RItem5CloseEv @ 104 NONAME + _ZN9RAvrcpIPC17SymbianErrorCheckEi @ 105 NONAME + _ZN9RAvrcpIPC18SymbianErrToStatusEi @ 106 NONAME + _ZN9RAvrcpIPC26GetPDUIdFromIPCOperationIdEi @ 107 NONAME + _ZN9RAvrcpIPC28GetEventIdFromIPCOperationIdEi @ 108 NONAME + _ZN9RAvrcpIPC28SetIPCOperationIdFromEventIdE26TRegisterNotificationEvent @ 109 NONAME + _ZNK19TRemConMessageQueue5FirstEv @ 110 NONAME + _ZTI14RAvrcpIPCError @ 111 NONAME + _ZTI20RRemConSearchRequest @ 112 NONAME + _ZTI21RRemConSearchResponse @ 113 NONAME + _ZTI22RRemConGetPathResponse @ 114 NONAME + _ZTI24RRemConChangePathRequest @ 115 NONAME + _ZTI24RRemConNowPlayingRequest @ 116 NONAME + _ZTI25RRemConChangePathResponse @ 117 NONAME + _ZTI25RRemConMediaErrorResponse @ 118 NONAME + _ZTI25RRemConNowPlayingResponse @ 119 NONAME + _ZTI25RRemConUidsChangedRequest @ 120 NONAME + _ZTI26RRemConUidsChangedResponse @ 121 NONAME + _ZTI27RAvrcpGetFolderItemsRequest @ 122 NONAME + _ZTI28RAvrcpGetFolderItemsResponse @ 123 NONAME + _ZTI28RRemConGetFolderItemsRequest @ 124 NONAME + _ZTI29RRemConGetFolderItemsResponse @ 125 NONAME + _ZTI29RRemConPlayerListOfAttributes @ 126 NONAME + _ZTI30RRemConGetCapabilitiesResponse @ 127 NONAME + _ZTI30RRemConSetBrowsedPlayerRequest @ 128 NONAME + _ZTI31RAvrcpSetAddressedPlayerRequest @ 129 NONAME + _ZTI31RRemConGetItemAttributesRequest @ 130 NONAME + _ZTI32RAvrcpSetAddressedPlayerResponse @ 131 NONAME + _ZTI32RRemConGetItemAttributesResponse @ 132 NONAME + _ZTI34RRemConGetElementAttributesRequest @ 133 NONAME + _ZTI34RRemConPlayerAttributeIdsAndValues @ 134 NONAME + _ZTI35RRemConGetElementAttributesResponse @ 135 NONAME + _ZTI36RRemConPlayerInformation8BitResponse @ 136 NONAME + _ZTI37RRemConPlayerInformation32BitResponse @ 137 NONAME + _ZTI37RRemConPlayerInformation64BitResponse @ 138 NONAME + _ZTI39RRemConGetPlayerApplicationTextResponse @ 139 NONAME + _ZTI41RAvrcpAddressedPlayerNotificationResponse @ 140 NONAME + _ZTI45RRemConPlayerInformationGetPlayStatusResponse @ 141 NONAME + _ZTV14RAvrcpIPCError @ 142 NONAME + _ZTV20RRemConSearchRequest @ 143 NONAME + _ZTV21RRemConSearchResponse @ 144 NONAME + _ZTV22RRemConGetPathResponse @ 145 NONAME + _ZTV24RRemConChangePathRequest @ 146 NONAME + _ZTV24RRemConNowPlayingRequest @ 147 NONAME + _ZTV25RRemConChangePathResponse @ 148 NONAME + _ZTV25RRemConMediaErrorResponse @ 149 NONAME + _ZTV25RRemConNowPlayingResponse @ 150 NONAME + _ZTV25RRemConUidsChangedRequest @ 151 NONAME + _ZTV26RRemConUidsChangedResponse @ 152 NONAME + _ZTV27RAvrcpGetFolderItemsRequest @ 153 NONAME + _ZTV28RAvrcpGetFolderItemsResponse @ 154 NONAME + _ZTV28RRemConGetFolderItemsRequest @ 155 NONAME + _ZTV29RRemConGetFolderItemsResponse @ 156 NONAME + _ZTV29RRemConPlayerListOfAttributes @ 157 NONAME + _ZTV30RRemConGetCapabilitiesResponse @ 158 NONAME + _ZTV30RRemConSetBrowsedPlayerRequest @ 159 NONAME + _ZTV31RAvrcpSetAddressedPlayerRequest @ 160 NONAME + _ZTV31RRemConGetItemAttributesRequest @ 161 NONAME + _ZTV32RAvrcpSetAddressedPlayerResponse @ 162 NONAME + _ZTV32RRemConGetItemAttributesResponse @ 163 NONAME + _ZTV34RRemConGetElementAttributesRequest @ 164 NONAME + _ZTV34RRemConPlayerAttributeIdsAndValues @ 165 NONAME + _ZTV35RRemConGetElementAttributesResponse @ 166 NONAME + _ZTV36RRemConPlayerInformation8BitResponse @ 167 NONAME + _ZTV37RRemConPlayerInformation32BitResponse @ 168 NONAME + _ZTV37RRemConPlayerInformation64BitResponse @ 169 NONAME + _ZTV39RRemConGetPlayerApplicationTextResponse @ 170 NONAME + _ZTV41RAvrcpAddressedPlayerNotificationResponse @ 171 NONAME + _ZTV45RRemConPlayerInformationGetPlayStatusResponse @ 172 NONAME + _ZN36RAvrcpUidCounterNotificationResponse5ReadLERK6TDesC8 @ 173 NONAME + _ZN36RAvrcpUidCounterNotificationResponse6WriteLER5TDes8 @ 174 NONAME + _ZTI36RAvrcpUidCounterNotificationResponse @ 175 NONAME + _ZTV36RAvrcpUidCounterNotificationResponse @ 176 NONAME + _ZN50RRemConPlayerInformationGetPlayStatusUpdateRequest5ReadLERK6TDesC8 @ 177 NONAME + _ZN50RRemConPlayerInformationGetPlayStatusUpdateRequest6WriteLER5TDes8 @ 178 NONAME + _ZN51RRemConPlayerInformationGetPlayStatusUpdateResponse5ReadLERK6TDesC8 @ 179 NONAME + _ZN51RRemConPlayerInformationGetPlayStatusUpdateResponse6WriteLER5TDes8 @ 180 NONAME + _ZTI50RRemConPlayerInformationGetPlayStatusUpdateRequest @ 181 NONAME + _ZTI51RRemConPlayerInformationGetPlayStatusUpdateResponse @ 182 NONAME + _ZTV50RRemConPlayerInformationGetPlayStatusUpdateRequest @ 183 NONAME + _ZTV51RRemConPlayerInformationGetPlayStatusUpdateResponse @ 184 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/group/avrcpipc.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/group/avrcpipc.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +// Copyright (c) 2007-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: +// avrcp.dll Shared code for IPC communication between the client API and remcon +// side library. +// +// + +/** + @file + @internalComponent +*/ + +TARGET avrcpipc.dll +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x101f9067 +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE ipc.cpp +SOURCE avrcpipc.cpp remconqueuemessage.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../common +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY remconinterfacebase.lib +LIBRARY esock.lib + +#include + +UNPAGED + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +avrcpipc.mmp + +PRJ_EXPORTS +../public/avrcpspec.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcon/avrcpspec.h) + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/inc/avrcpipcutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/inc/avrcpipcutils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +// Copyright (c) 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: +// + +#ifndef AVRCPIPCUTILS_H +#define AVRCPIPCUTILS_H + +_LIT(KAvrcpIpcPanicName, "AVRCP IPC"); + +enum TAvrcpIpcPanic + { + EAvrcpIpcCommandDataTooLong = 0, + }; + +class AvrcpIpcUtils + { +public: + static void Panic(TAvrcpIpcPanic aPanic); // The macro is probably more useful so this can be removed + }; + +/** Utility AVRCP panic function. + +@param aPanic The panic number. +*/ +void AvrcpIpcUtils::Panic(TAvrcpIpcPanic aPanic) + { + User::Panic(KAvrcpIpcPanicName, aPanic); + } + +#endif //AVRCPIPCUTILS_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/public/avrcpspec.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/public/avrcpspec.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,155 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef AVRCPSPEC_H +#define AVRCPSPEC_H + +#include + +// The IANA assigned MIB Enum for UTF8, defined at: +// http://www.iana.org/assignments/character-sets +// and specified in the AVRCP 1.3 specification in +// section 13, "References" as reference number 11. + +const TInt KUtf8MibEnum = 106; + +// The maximum absolute volume defined by the AVRCP 1.4 spcification +// in section 6.13.1 +const TUint8 KAvrcpMaxAbsoluteVolume = 0x7F; + +// These PDU ids are defined by the AVRCP 1.3 specification +// in sections 5.1, 5.2, 5.3 and 5.4. + +enum TMetadataTransferPDU + { + EGetCapabilities = 0x10, + EListPlayerApplicationSettingAttributes = 0x11, + EListPlayerApplicationSettingValues = 0x12, + EGetCurrentPlayerApplicationSettingValue = 0x13, + ESetPlayerApplicationSettingValue = 0x14, + EGetPlayerApplicationSettingAttributeText = 0x15, + EGetPlayerApplicationSettingValueText = 0x16, + EInformDisplayableCharacterSet = 0x17, // not implemented; always use UTF8 + EInformBatteryStatusOfCT = 0x18, + EGetElementAttributes = 0x20, + EGetPlayStatus = 0x30, + ERegisterNotification = 0x31, + ERequestContinuingResponse = 0x40, + EAbortContinuingResponse = 0x41, + ESetAbsoluteVolume = 0x50, + ESetAddressedPlayer = 0x60, + EPlayItem = 0x74, + EAddToNowPlaying = 0x90, + + // Internal values + EGetPlayStatusUpdate = 0xff, + }; + +enum TMediaBrowsePDU + { + EMbSetBrowsedPlayer = 0x70, + EMbGetFolderItems = 0x71, + EMbChangePath = 0x72, + EMbGetItemAttributes = 0x73, + EMbSearch = 0x80, + }; + +// These RegisterNotification (PDU 0x31) event ids are defined +// in the AVRCP 1.3 specification in section 5.4. + +enum TRegisterNotificationEvent + { + ERegisterNotificationPlaybackStatusChanged = 0x1, + ERegisterNotificationTrackChanged = 0x2, + ERegisterNotificationTrackReachedEnd = 0x3, + ERegisterNotificationTrackReachedStart = 0x4, + ERegisterNotificationPlaybackPosChanged = 0x5, + ERegisterNotificationBatteryStatusChanged = 0x6, + ERegisterNotificationSystemStatusChanged_NotSupported= 0x7, // not supported + ERegisterNotificationPlayerApplicationSettingChanged = 0x8, + ERegisterNotificationNowPlayingContentChanged = 0x9, + ERegisterNotificationAvailablePlayersChanged = 0xa, + ERegisterNotificationAddressedPlayerChanged = 0xb, + ERegisterNotificationUidsChanged = 0xc, + ERegisterNotificationVolumeChanged = 0xd, + ERegisterNotificationReservedLast = 0xf, + }; + +// These are the allowed values for GetCapabilities (PDU 0x10) +// and are specified in the AVRCP 1.3 specification, section 5.1.1 + +enum TGetCapabilityValues + { + ECapabilityIdCompanyID = 2, + ECapabilityIdEventsSupported = 3, + }; + +// Pass Through command values for Group Navigation, as +// defined in the AVRCP 1.3 specification, in section 4.7.9 + +enum TGroupNavigationPassthroughOperationIds + { + ENextGroup = 0x0, + EPreviousGroup = 0x1, + }; + +// Error numbers allocated to the AVRCP component, for use in +// IPC communication between the client APIs and the AVRCP bearer + +const TInt KErrAvrcpBaseError = -6751; // Base error number +const TInt KErrAvrcpInvalidCType = KErrAvrcpBaseError - 1; // -6752 +const TInt KErrAvrcpInvalidOperationId = KErrAvrcpBaseError - 2; // -6753 +const TInt KErrAvrcpMetadataInvalidCommand = KErrAvrcpBaseError - 3; // -6754 +const TInt KErrAvrcpMetadataInvalidParameter = KErrAvrcpBaseError - 4; // -6755 +const TInt KErrAvrcpMetadataParameterNotFound = KErrAvrcpBaseError - 5; // -6756 +const TInt KErrAvrcpMetadataInternalError = KErrAvrcpBaseError - 6; // -6757 +const TInt KErrAvrcpHandledInternallyRespondNow = KErrAvrcpBaseError - 7; // -6758 +const TInt KErrAvrcpHandledInternallyInformRemCon = KErrAvrcpBaseError - 8; // -6759 +const TInt KErrAvrcpInternalCommand = KErrAvrcpBaseError - 9; // -6760 +const TInt KErrAvrcpFurtherProcessingRequired = KErrAvrcpBaseError - 10; // -6791 + +const TInt KErrAvrcpAirBase = -6780; +const TInt KErrAvrcpAirInvalidCommand = KErrAvrcpAirBase - 0; +const TInt KErrAvrcpAirInvalidParameter = KErrAvrcpAirBase - 1; +const TInt KErrAvrcpAirParameterNotFound = KErrAvrcpAirBase - 2; +const TInt KErrAvrcpAirInternalError = KErrAvrcpAirBase - 3; +const TInt KErrAvrcpAirSuccess = KErrAvrcpAirBase - 4; +const TInt KErrAvrcpAirUidChanged = KErrAvrcpAirBase - 5; +const TInt KErrAvrcpAirReserved = KErrAvrcpAirBase - 6; +const TInt KErrAvrcpAirInvalidDirection = KErrAvrcpAirBase - 7; +const TInt KErrAvrcpAirNotADirectory = KErrAvrcpAirBase - 8; +const TInt KErrAvrcpAirDoesNotExist = KErrAvrcpAirBase - 9; +const TInt KErrAvrcpAirInvalidScope = KErrAvrcpAirBase - 0xa; +const TInt KErrAvrcpAirRangeOutOfBounds = KErrAvrcpAirBase - 0xb; +const TInt KErrAvrcpAirUidIsADirectory = KErrAvrcpAirBase - 0xc; +const TInt KErrAvrcpAirMediaInUse = KErrAvrcpAirBase - 0xd; +const TInt KErrAvrcpAirNowPlayingListFull = KErrAvrcpAirBase - 0xe; +const TInt KErrAvrcpAirSearchNotSupported = KErrAvrcpAirBase - 0xf; +const TInt KErrAvrcpAirSearchInProgress = KErrAvrcpAirBase - 0x10; +const TInt KErrAvrcpAirInvalidPlayerId = KErrAvrcpAirBase - 0x11; +const TInt KErrAvrcpAirPlayerNotBrowesable = KErrAvrcpAirBase - 0x12; +const TInt KErrAvrcpAirPlayerNotAddressed = KErrAvrcpAirBase - 0x13; +const TInt KErrAvrcpAirNoValidSearchResults = KErrAvrcpAirBase - 0x14; +const TInt KErrAvrcpAirNoAvailablePlayers = KErrAvrcpAirBase - 0x15; +const TInt KErrAvrcpAirAddressedPlayerChanged = KErrAvrcpAirBase - 0x16; +const TInt KErrAvrcpInvalidScope = KErrAvrcpAirBase - 0x17; + +#endif // AVRCPSPEC_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/src/avrcpipc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/src/avrcpipc.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,161 @@ +// Copyright (c) 2008-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: +// This file contains structures shared by the AVRCP API with the AVRCP bearer. +// +// + +/** + @file + @internalTechnology + @released +*/ + +#include +#include +#include "avrcpipc.h" + + +EXPORT_C TMetadataTransferPDU RAvrcpIPC::GetPDUIdFromIPCOperationId(TInt aOperationId) + { + // We send the PDU id through IPC to the playerinformationapi, mediainformationapi + // groupnavigationapi or batterystatusapi. However, PDU 0x31 (Register Notification + // also requires sending an event id. We encode this as the top byte, and the PDU + // id as the lower byte, so mask off the top-byte and return just the PDU id. + return static_cast(aOperationId & 0x00FF); + } + +EXPORT_C TRegisterNotificationEvent RAvrcpIPC::GetEventIdFromIPCOperationId(TInt aOperationId) + { + // See the above comment in GetPDUIdFromIPCOperationId. This performs the opposite operation + return static_cast((aOperationId & 0xFF00) >> 8); + } + +EXPORT_C TInt RAvrcpIPC::SetIPCOperationIdFromEventId(TRegisterNotificationEvent aEventId) + { + // See the comment in GetPDUIdFromIPCOperationId. This sets the PDU id + // as the lower byte to RegisterNotification (0x31) and the eventId as + // the top byte. + return (ERegisterNotification + (aEventId << 8)); + } + +// Big-endian methods; Symbian native methods are little-endian +// This means that we can directly send these packets into the +// wire in the bearer, since they're big-endian. We could have +// used the BigEndian class, but that requires a dependency on +// the esock.lib library, so do it ourselves. + +TUint8 RAvrcpIPC::Read8L() + { + return iReadStream.ReadUint8L(); + } + +TUint16 RAvrcpIPC::Read16L() + { + TUint16 val = 0; + val = (static_cast(iReadStream.ReadUint8L()) << 8); + val += iReadStream.ReadUint8L(); + return val; + } + +TUint32 RAvrcpIPC::Read24L() + { + TUint32 val = 0; + val += (static_cast(iReadStream.ReadUint8L()) << 16); + val += (static_cast(iReadStream.ReadUint8L()) << 8); + val += iReadStream.ReadUint8L(); + return val; + } + +TUint32 RAvrcpIPC::Read32L() + { + TUint32 val = 0; + val = (static_cast(iReadStream.ReadUint8L()) << 24); + val += (static_cast(iReadStream.ReadUint8L()) << 16); + val += (static_cast(iReadStream.ReadUint8L()) << 8); + val += iReadStream.ReadUint8L(); + return val; + } + +TUint64 RAvrcpIPC::Read64L() + { + TUint64 val; + val = (static_cast(iReadStream.ReadUint8L()) << 56); + val += (static_cast(iReadStream.ReadUint8L()) << 48); + val += (static_cast(iReadStream.ReadUint8L()) << 40); + val += (static_cast(iReadStream.ReadUint8L()) << 32); + val += (static_cast(iReadStream.ReadUint8L()) << 24); + val += (static_cast(iReadStream.ReadUint8L()) << 16); + val += (static_cast(iReadStream.ReadUint8L()) << 8); + val += iReadStream.ReadUint8L(); + return val; + } + +void RAvrcpIPC::Write8L(TUint8 aVal) + { + iStream.WriteUint8L(aVal); + } + +void RAvrcpIPC::Write16L(TUint16 aVal) + { + iStream.WriteUint8L(static_cast(aVal >> 8)); + iStream.WriteUint8L(static_cast(aVal)); + } + +void RAvrcpIPC::Write24L(TUint32 aVal) + { + iStream.WriteUint8L(static_cast(aVal >> 16)); + iStream.WriteUint8L(static_cast(aVal >> 8)); + iStream.WriteUint8L(static_cast(aVal)); + } + +void RAvrcpIPC::Write32L(TUint32 aVal) + { + iStream.WriteUint8L(static_cast(aVal >> 24)); + iStream.WriteUint8L(static_cast(aVal >> 16)); + iStream.WriteUint8L(static_cast(aVal >> 8)); + iStream.WriteUint8L(static_cast(aVal)); + } + +void RAvrcpIPC::Write64L(TUint64 aVal) + { + iStream.WriteUint8L(static_cast(aVal >> 56)); + iStream.WriteUint8L(static_cast(aVal >> 48)); + iStream.WriteUint8L(static_cast(aVal >> 40)); + iStream.WriteUint8L(static_cast(aVal >> 32)); + iStream.WriteUint8L(static_cast(aVal >> 24)); + iStream.WriteUint8L(static_cast(aVal >> 16)); + iStream.WriteUint8L(static_cast(aVal >> 8)); + iStream.WriteUint8L(static_cast(aVal)); + } +void RAvrcpIPC::Close() + { + iReadStream.Close(); + iStream.Close(); + } + +EXPORT_C void RAvrcpIPCError::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iError = Read32L(); // Read Big-Endian error code + iReadStream.Close(); + } + +EXPORT_C void RAvrcpIPCError::WriteL(TDes8& aOutData) + { + aOutData.Zero(); // Error code is always before any other data + iStream.Open(aOutData); + Write32L(iError); + iStream.CommitL(); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/src/ipc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/src/ipc.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1541 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalTechnology + @released +*/ + +#include +#include +#include "avrcpipcutils.h" +#include "avrcpinternalinterface.h" +#include "mediabrowse.h" +#include "mediainformation.h" +#include "nowplaying.h" +#include "playerinformation.h" + +/* + * These methods are intended to provide structured IPC communication between + * the AVRCP bearer, and the client API DLLs. They are intended to be 'simple' + * classes, in which the basic operation are as follows: + * + * reading: call ReadL(request) and pull information out of member variables + * writing: put information into member variables, then call WriteL(request) + * + * The ReadL() and WriteL() methods effectively just serialize the information + * already stored in the member varables. However, they serialize in Big-Endian + * format, so that after calling WriteL() and then sending the response back to + * the AVRCP bearer via IPC, the bearer can just append the response straight + * into an AVC frame; no bit-twiddling is necessary. + * + * Therefore it is important that these classes _ALWAYS_ write in Big-Endian + * format, and write out responses that conform to the AVRCP specification for + * PDUs listed in sections 5.1 - 5.4 of the AVRCP 1.3 specification. The ReadL() + * operation is the inverse of the WriteL() operation and reads an AVRCP request + * in the format listed in the AVRCP specification. + * + * There's also a Size() method, which will return the size of the response + * before WriteL() is called. This is required particularly for responses with + * text strings so that the correct-sized buffer can be allocated, as these + * could be very large responses (theoretically up to 16 megabytes!) sent via + * IPC (just once) and then kept and fragmented in the AVRCP bearer. The Close() + * method frees up any memory allocated with these classes. + */ + + +// -------------------------------------------------------------------------------- +// Used for constructing PDU 0x30 responses + +EXPORT_C void RRemConPlayerInformationGetPlayStatusResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iTrackLength = Read32L(); + iPlayPos = Read32L(); + iStatus = (MPlayerEventsObserver::TPlaybackStatus) Read8L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerInformationGetPlayStatusResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + Write32L(iTrackLength); + Write32L(iPlayPos); + Write8L(iStatus); + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for constructing PDU 0xff requests + +EXPORT_C void RRemConPlayerInformationGetPlayStatusUpdateRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iStatus = (MPlayerEventsObserver::TPlaybackStatus) Read8L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerInformationGetPlayStatusUpdateRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write8L(iStatus); + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for constructing PDU 0xff responses + +EXPORT_C void RRemConPlayerInformationGetPlayStatusUpdateResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iStatus = (MPlayerEventsObserver::TPlaybackStatus) Read8L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerInformationGetPlayStatusUpdateResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + Write8L(iStatus); + iStream.CommitL(); + } +// -------------------------------------------------------------------------------- +// Used for constructing PDU 0x15 and PDU 0x16 responses + +EXPORT_C void RRemConGetPlayerApplicationTextResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iNumberAttributes = Read8L(); + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + RSettingWithCharset setting; + CleanupClosePushL(setting); + setting.iAttributeId = Read8L(); + setting.iCharset = Read16L(); + setting.iStringLen = Read8L(); + setting.iString = HBufC8::NewL(setting.iStringLen); + TPtr8 ptr = setting.iString->Des(); + iReadStream.ReadL(ptr); + iAttributes.AppendL(setting); + CleanupStack::Pop(&setting); + } + + } + +EXPORT_C void RRemConGetPlayerApplicationTextResponse::WriteL(TDes8& aOutData) + { + // The caller should have called Size() to pre-allocate enough buffer space + __ASSERT_DEBUG(aOutData.MaxLength() >= Size(), AvrcpIpcUtils::Panic(EAvrcpIpcCommandDataTooLong)); + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + Write8L(iNumberAttributes); + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write8L(iAttributes[i].iAttributeId); + Write16L(iAttributes[i].iCharset); + Write8L(iAttributes[i].iStringLen); + iStream.WriteL(iAttributes[i].iString->Des()); + } + iStream.CommitL(); + } + +EXPORT_C TInt RRemConGetPlayerApplicationTextResponse::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + + TInt size = 5; // 5 bytes: status code + number attributes + for (TInt i = 0; i < iNumberAttributes; i++) + { + size += 4; // 4 bytes: attribute id + charset + stringlen + size += iAttributes[i].iString->Length(); + } + return size; + } + +EXPORT_C void RRemConGetPlayerApplicationTextResponse::Close() + { + for (TInt i = 0; i < iAttributes.Count(); i++) + { + iAttributes[i].Close(); + } + iAttributes.Close(); + RAvrcpIPC::Close(); + } + +// -------------------------------------------------------------------------------- +// Used for constructing PDU 0x10 responses + +EXPORT_C void RRemConGetCapabilitiesResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iCapabilityId = Read8L(); + if ( iCapabilityId != ECapabilityIdCompanyID + && iCapabilityId != ECapabilityIdEventsSupported) + { + iReadStream.Close(); + User::Leave(KErrNotSupported); + } + + iCapabilityCount = Read8L(); + for (TInt i = 0; i < iCapabilityCount; i++ ) + { + if (iCapabilityId == ECapabilityIdCompanyID) + { + iCapabilities.AppendL(Read24L()); // Read 3 bytes + } + else + { + iCapabilities.AppendL(Read8L()); // Read 1 byte + } + } + iReadStream.Close(); + } + +EXPORT_C void RRemConGetCapabilitiesResponse::WriteL(TDes8& aOutData) + { + if ( iCapabilityId != ECapabilityIdCompanyID + && iCapabilityId != ECapabilityIdEventsSupported) + { + User::Leave(KErrNotSupported); + } + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + Write8L(iCapabilityId); + Write8L(iCapabilityCount); + for (TInt i = 0; i < iCapabilityCount; i++ ) + { + if (iCapabilityId == ECapabilityIdCompanyID) + { + Write24L(iCapabilities[i]); // Write 3 bytes + } + else + { + Write8L(iCapabilities[i]); // Write 1 byte + } + } + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for constructing and parsing PDU 0x13 (response) and PDU 0x14 (request) + +EXPORT_C void RRemConPlayerAttributeIdsAndValues::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iNumberAttributes = Read8L(); + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + TInt attributeId = Read8L(); + TInt attributeValue = Read8L(); + iAttributeId.AppendL(attributeId); + iAttributeValue.AppendL(attributeValue); + } + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerAttributeIdsAndValues::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + Write8L(iNumberAttributes); + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write8L(iAttributeId[i]); + Write8L(iAttributeValue[i]); + } + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for constructing PDU 0x11 and PDU 0x12 responses + +EXPORT_C void RRemConPlayerListOfAttributes::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iNumberAttributes = Read8L(); + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + TInt attribute = Read8L(); + iAttributes.AppendL(attribute); + } + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerListOfAttributes::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + iAttributes.Sort(); + Write32L(KErrNone); // Successful operation + Write8L(iNumberAttributes); + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write8L(iAttributes[i]); + } + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing PDU 0x20 requests + +EXPORT_C void RRemConGetElementAttributesRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iElement = Read64L(); + iNumberAttributes = Read8L(); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + TInt attribute = Read32L(); + iAttributes.AppendL(attribute); + } + iReadStream.Close(); + } + +EXPORT_C void RRemConGetElementAttributesRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + iAttributes.Sort(); + Write32L(KErrNone); // Successful operation + + // 64 bits of data + Write64L(iElement); + Write8L(iNumberAttributes); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write32L(iAttributes[i]); + } + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for PDU 0x20 responses + +EXPORT_C void RRemConGetElementAttributesResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iNumberAttributes = Read8L(); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + REAResponse eattr; + CleanupClosePushL(eattr); + eattr.iAttributeId = Read32L(); + eattr.iCharset = Read16L(); + eattr.iStringLen = Read16L(); + eattr.iString = HBufC8::NewL(eattr.iStringLen); + TPtr8 ptr = eattr.iString->Des(); + iReadStream.ReadL(ptr); + iAttributes.AppendL(eattr); + CleanupStack::Pop(&eattr); + } + + } + +EXPORT_C void RRemConGetElementAttributesResponse::WriteL(TDes8& aOutData) + { + __ASSERT_DEBUG(aOutData.MaxLength() >= Size(), AvrcpIpcUtils::Panic(EAvrcpIpcCommandDataTooLong)); + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write8L(iNumberAttributes); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write32L(iAttributes[i].iAttributeId); + Write16L(iAttributes[i].iCharset); + Write16L(iAttributes[i].iStringLen); + iStream.WriteL(iAttributes[i].iString->Des()); + } + iStream.CommitL(); + } + +EXPORT_C TInt RRemConGetElementAttributesResponse::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + + TInt size = 5; // 5 bytes: status code + number attributes + for (TInt i = 0; i < iNumberAttributes; i++) + { + size += 4+2+2; // 8 bytes: attrId (4 bytes) + charset (2 bytes) + stringlen (2 bytes) + size += iAttributes[i].iString->Length(); + } + return size; + } + +EXPORT_C void RRemConGetElementAttributesResponse::Close() + { + for (TInt i = 0; i < iAttributes.Count(); i++) + { + iAttributes[i].Close(); + } + iAttributes.Close(); + RAvrcpIPC::Close(); + } + +// -------------------------------------------------------------------------------- + +EXPORT_C void RRemConPlayerInformation8BitResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iValue = Read8L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerInformation8BitResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write8L(iValue); + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- + +EXPORT_C void RRemConPlayerInformation32BitResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iValue = Read32L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerInformation32BitResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write32L(iValue); + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- + +EXPORT_C void RRemConPlayerInformation64BitResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iValue = Read64L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConPlayerInformation64BitResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write64L(iValue); + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- + +EXPORT_C void RSettingWithCharset::Close() + { + delete iString; + iString = NULL; + } + +EXPORT_C void REAResponse::Close() + { + delete iString; + iString = NULL; + } + +EXPORT_C void RRemConGetCapabilitiesResponse::Close() + { + iCapabilities.Close(); + } + +EXPORT_C void RRemConPlayerListOfAttributes::Close() + { + iAttributes.Close(); + } + +EXPORT_C void RRemConGetElementAttributesRequest::Close() + { + iAttributes.Close(); + } + +EXPORT_C void RRemConPlayerAttributeIdsAndValues::Close() + { + iAttributeId.Close(); + iAttributeValue.Close(); + } + +EXPORT_C void RItem::Close() + { + delete iName; + for(TInt i = 0; i(Read8L()); + iElement = Read64L(); + iUidCounter = Read16L(); + } + +/** +Constructs PDU 0x74 and 0x90 requests. +*/ +EXPORT_C void RRemConNowPlayingRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + Write8L(iScope); + Write64L(iElement); + Write16L(iUidCounter); + iStream.CommitL(); + } + +/** +Parses PDU 0x74 and 0x90 responses +*/ +EXPORT_C void RRemConNowPlayingResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iStatus = Read8L(); + } + +/** +Constructs PDU 0x74 and 0x90 responses. +*/ +EXPORT_C void RRemConNowPlayingResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + if ((KErrAvrcpAirBase - KErrAvrcpAirSuccess) == iStatus) + { + Write32L(KErrNone); // Successful operation + Write8L(iStatus); + } + else + { + Write32L(KErrAvrcpAirBase - iStatus); + } + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing PDU 0x71 requests +EXPORT_C void RRemConGetFolderItemsRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iScope = Read8L(); + iStartItem = Read32L(); + iEndItem = Read32L(); + iNumberAttributes = Read8L(); + + if (iNumberAttributes == 0) + { + // spec says this is a request for all attribs + // current spec has 7 specified (0x01 to 0x07) + for (TInt i = 1; i <= KMaxMediaAttributeValue; i++) + { + iAttributes.AppendL(i); + } + } + else if (iNumberAttributes == 0xff) + { + // No attributes requested + } + else + { + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + TInt attribute = Read32L(); + if (attribute > 0 && attribute <= KMaxMediaAttributeValue ) + { + iAttributes.AppendL(attribute); + } + } + } + + iReadStream.Close(); + } + +EXPORT_C void RRemConGetFolderItemsRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + iAttributes.Sort(); + Write32L(KErrNone); // Successful operation + + Write8L(iScope); + Write32L(iStartItem); + Write32L(iEndItem); + Write8L(iNumberAttributes); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write32L(iAttributes[i]); + } + + iStream.CommitL(); + } + +EXPORT_C void RRemConGetFolderItemsRequest::Close() + { + iAttributes.Close(); + } + +EXPORT_C TInt RRemConGetFolderItemsRequest::CopyAttributes(RArray& aOutAttributes) + { + TInt result = KErrNone; + TMediaAttributeId attributeId; + TInt attributeCount = iAttributes.Count(); + for (TInt i = 0; i < attributeCount; i++) + { + attributeId = static_cast(iAttributes[i]); + result = aOutAttributes.Append(attributeId); + if (result != KErrNone) + { + break; + } + } + return result; + } +// -------------------------------------------------------------------------------- +// Used for PDU 0x71 responses + +EXPORT_C void RRemConGetFolderItemsResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iPduId = Read8L(); + iParamLength = Read16L(); + iStatus = Read8L(); + iUidCounter = Read16L(); + iNumberItems = Read16L(); + + for(TInt i = 0; i < iNumberItems; i++) + { + ReadItemL(); + } + + iReadStream.Close(); + } + +void RRemConGetFolderItemsResponse::ReadItemL() + { + RItem item; + CleanupClosePushL(item); + + item.iType = static_cast(Read8L()); + item.iLength = Read16L(); + item.iUid = Read64L(); + + if(item.iType == AvrcpBrowsing::EFolderItem) + { + item.iFolderType = static_cast(Read8L()); + item.iPlayable = Read8L(); + } + else + { + item.iMediaType = Read8L(); + } + + item.iCharset = Read16L(); + item.iNameLength = Read16L(); + item.iName = HBufC8::NewL(item.iNameLength); + TPtr8 ptr = item.iName->Des(); + iReadStream.ReadL(ptr); + + if(item.iType == AvrcpBrowsing::EMediaElement) + { + item.iNumberAttributes = Read32L(); + + for (TInt i = 0; i < item.iNumberAttributes; i++ ) + { + REAResponse eattr; + CleanupClosePushL(eattr); + + eattr.iAttributeId = Read32L(); + eattr.iCharset = Read16L(); + eattr.iStringLen = Read16L(); + eattr.iString = HBufC8::NewL(eattr.iStringLen); + TPtr8 ptr = eattr.iString->Des(); + iReadStream.ReadL(ptr); + + item.iAttributes.AppendL(eattr); + CleanupStack::Pop(&eattr); + } + } + + iItems.AppendL(item); + CleanupStack::Pop(&item); + } + +EXPORT_C void RRemConGetFolderItemsResponse::WriteL(TDes8& aOutData) + { + __ASSERT_DEBUG(aOutData.MaxLength() >= Size(), AvrcpIpcUtils::Panic(EAvrcpIpcCommandDataTooLong)); + aOutData.Zero(); + iStream.Open(aOutData); + + Write8L(iPduId); + Write16L(iParamLength); + Write8L(iStatus); + + if(iStatus == 0x4) + { + Write16L(iUidCounter); + Write16L(iNumberItems); + + for (TInt i = 0; i < iNumberItems; i++ ) + { + WriteItemL(i); + } + } + + iStream.CommitL(); + } + +void RRemConGetFolderItemsResponse::WriteItemL(TInt aIndex) + { + RItem& item = iItems[aIndex]; + + Write8L(item.iType); + Write16L(item.iLength); + Write64L(item.iUid); + + if(item.iType == AvrcpBrowsing::EFolderItem) + { + Write8L(item.iFolderType); + Write8L(item.iPlayable); + } + else + { + Write8L(item.iMediaType); + } + + Write16L(item.iCharset); + Write16L(item.iNameLength); + iStream.WriteL(item.iName->Des()); + + if(item.iType == AvrcpBrowsing::EMediaElement) + { + Write8L(item.iNumberAttributes); + + for(TInt i = 0; i < item.iNumberAttributes; i++) + { + Write32L(item.iAttributes[i].iAttributeId); + Write16L(item.iAttributes[i].iCharset); + Write16L(item.iAttributes[i].iStringLen); + iStream.WriteL(item.iAttributes[i].iString->Des()); + } + } + } + +EXPORT_C TInt RRemConGetFolderItemsResponse::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + + // base size + // pduid + paramlength + status + uidcount + number items + TInt size = KGetFolderItemsResponseBaseSize; + + for (TInt i = 0; i < iNumberItems; i++) + { + size += iItems[i].Size(); + } + return size; + } + +EXPORT_C void RRemConGetFolderItemsResponse::Close() + { + for (TInt i = 0; i < iItems.Count(); i++) + { + iItems[i].Close(); + } + iItems.Reset(); + } + +EXPORT_C TInt RRemConGetFolderItemsResponse::CopyItems( + const TArray& aItems) + { + TInt err = KErrNone; + for(TInt i = 0; i < aItems.Count(); i++) + { + RItem item; + item.iName = NULL; + item.iUid = aItems[i].iUid; + item.iType = static_cast(aItems[i].iType); + + err = iItems.Append(item); + if(err) + { + break; + } + } + return err; + } + +EXPORT_C TBool RRemConGetFolderItemsResponse::RequestNextItem(TInt& aError, + RBuf8& aOutBuf, TUint16 aCookie) + { + aError = KErrNone; + // Work out if we have as many items as fit + TBool getMoreItems = ETrue; + iCurrentListingSize += (iCurrentItem + 1) ? iItems[iCurrentItem].Size() : 0; + if(iCurrentListingSize > iMaxResponse) + { + // We can't fit this item in the listing + iItems[iCurrentItem].Close(); + getMoreItems = EFalse; + iItems.Remove(iCurrentItem); + } + + if(getMoreItems && ++iCurrentItem < iItems.Count()) + { + return ETrue; + } + else + { + // We have all items, send the response + iNumberItems = iCurrentItem; + if(aOutBuf.Create(Size()) != KErrNone) + { + aError = KErrGeneral; + return EFalse; + } + + iPduId = AvrcpBrowsing::EGetFolderItems; + iStatus = KErrAvrcpAirBase - KErrAvrcpAirSuccess;//0x4 + iUidCounter = aCookie; + TRAP(aError, WriteL(aOutBuf)); + } + return EFalse; + } +// -------------------------------------------------------------------------------- +// Used for parsing PDU 0x72 requests + +EXPORT_C void RRemConChangePathRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iUidCounter = Read16L(); + iDirection = Read8L(); + + if(iDirection == AvrcpBrowsing::KDown) + { + iElement = Read64L(); + } + + iReadStream.Close(); + } + +EXPORT_C void RRemConChangePathRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write16L(iUidCounter); + Write8L(iDirection); + Write64L(iElement); + + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for PDU 0x72 responses + +EXPORT_C void RRemConChangePathResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iStatus = Read8L(); + iNumberItems = Read32L(); + + iReadStream.Close(); + } + +EXPORT_C void RRemConChangePathResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write8L(iPduId); + Write16L(iParamLength); + Write8L(iStatus); + + if(iStatus == 0x4) + { + Write32L(iNumberItems); + } + + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing PDU 0x73 requests + +EXPORT_C void RRemConGetItemAttributesRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iScope = Read8L(); + iElement = Read64L(); + iUidCounter = Read16L(); + iNumberAttributes = Read8L(); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + TInt attribute = Read32L(); + iAttributes.AppendL(attribute); + } + + iReadStream.Close(); + } + +EXPORT_C void RRemConGetItemAttributesRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + iAttributes.Sort(); + Write32L(KErrNone); // Successful operation + + Write8L(iScope); + // 64 bits of data + Write64L(iElement); + Write16L(iUidCounter); + Write8L(iNumberAttributes); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write32L(iAttributes[i]); + } + iStream.CommitL(); + } + +EXPORT_C void RRemConGetItemAttributesRequest::Close() + { + iAttributes.Close(); + } + +// -------------------------------------------------------------------------------- +// Used for PDU 0x73 responses + +EXPORT_C void RRemConGetItemAttributesResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iStatus = Read8L(); + iNumberAttributes = Read8L(); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + REAResponse eattr; + eattr.iAttributeId = Read32L(); + eattr.iCharset = Read16L(); + eattr.iStringLen = Read16L(); + eattr.iString = HBufC8::NewL(eattr.iStringLen); + TPtr8 ptr = eattr.iString->Des(); + iReadStream.ReadL(ptr); + iAttributes.AppendL(eattr); + } + iReadStream.Close(); + } + +EXPORT_C void RRemConGetItemAttributesResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write8L(iPduId); + Write16L(iParamLength); + Write8L(iStatus); + + if(iStatus == 0x4) + { + Write8L(iNumberAttributes); + + for (TInt i = 0; i < iNumberAttributes; i++ ) + { + Write32L(iAttributes[i].iAttributeId); + Write16L(iAttributes[i].iCharset); + Write16L(iAttributes[i].iStringLen); + iStream.WriteL(iAttributes[i].iString->Des()); + } + } + iStream.CommitL(); + } + +EXPORT_C TInt RRemConGetItemAttributesResponse::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + + TInt size = 9; // 6 bytes: error + pduid + paramlength + status code + number attributes + for (TInt i = 0; i < iAttributes.Count(); i++) + { + size += 4+2+2; // 8 bytes: attrId (4 bytes) + charset (2 bytes) + stringlen (2 bytes) + size += iAttributes[i].iString->Length(); + } + return size; + } + +EXPORT_C void RRemConGetItemAttributesResponse::Close() + { + for (TInt i = 0; i < iAttributes.Count(); i++) + { + iAttributes[i].Close(); + } + iAttributes.Close(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing PDU 0x80 requests + +EXPORT_C void RRemConSearchRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iCharset = Read16L(); + iStringLen = Read16L(); + + TInt dataLength = aData.Length(); + TPtrC8 pString = aData.Right(dataLength - 2*sizeof(TUint16)); + if (pString.Length() != iStringLen) + { + User::Leave(KErrArgument); + } + + RBuf8 searchBuf; + searchBuf.CreateL(iStringLen); + CleanupClosePushL(searchBuf); + + iReadStream.ReadL(searchBuf); + + CleanupStack::Pop(&searchBuf); + iSearchString.Assign(searchBuf); + + iReadStream.Close(); + } + +EXPORT_C void RRemConSearchRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write16L(iCharset); + Write16L(iStringLen); + WriteL(iSearchString); + + iStream.CommitL(); + } + +EXPORT_C TInt RRemConSearchRequest::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + TInt size = sizeof(iCharset) + sizeof(iStringLen) + iSearchString.Length(); + + return size; + } + +EXPORT_C void RRemConSearchRequest::Close() + { + iSearchString.Close(); + } + +// -------------------------------------------------------------------------------- +// Used for PDU 0x80 responses + +EXPORT_C void RRemConSearchResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iStatus = Read8L(); + iUidCounter = Read16L(); + iNumberItems = Read32L(); + + iReadStream.Close(); + } + +EXPORT_C void RRemConSearchResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write8L(iPduId); + Write16L(iParamLength); + Write8L(iStatus); + + if(iStatus == 0x4) + { + Write16L(iUidCounter); + Write32L(iNumberItems); + } + + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing SetBrowsedPlayer requests + +EXPORT_C void RRemConSetBrowsedPlayerRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + // iMaxResponse is little endian + iMaxResponse = iReadStream.ReadInt32L(); + iPlayerId = Read16L(); + + iReadStream.Close(); + } + +EXPORT_C void RRemConSetBrowsedPlayerRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + // Use little endian on iMaxResponse + iStream.WriteInt32L(iMaxResponse); + Write16L(iPlayerId); + + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for SetBrowsedPlayer responses + +EXPORT_C void RRemConGetPathResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iStatus = Read8L(); + iUidCounter = Read16L(); + iNumberItems = Read32L(); + + iReadStream.Close(); + } + +EXPORT_C void RRemConGetPathResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write8L(iPduId); + Write16L(iParamLength); + Write8L(iStatus); + + if(iStatus != 0x4) + { + iStream.CommitL(); + return; + } + + // The depth is equal to the number of items in the array. + iFolderDepth = iPath.Count(); + Write16L(iUidCounter); + Write32L(iNumberItems); + Write16L(KUtf8MibEnum); + Write8L(iFolderDepth); + + for(TInt i = 0; i < iFolderDepth; i++) + { + Write16L((iPath[i])->Length()); + iStream.WriteL(*(iPath[i])); + } + + iStream.CommitL(); + } + +EXPORT_C TInt RRemConGetPathResponse::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + iFolderDepth = iPath.Count(); + TInt size = 13 + (iFolderDepth*2); + + for(TInt i = 0; i < iFolderDepth; i++) + { + size += (iPath[i])->Length(); + } + + return size; + } + +EXPORT_C void RRemConGetPathResponse::Close() + { + iPath.ResetAndDestroy(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing SetAddressedPlayer requests + +EXPORT_C void RAvrcpSetAddressedPlayerRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iPlayerId = Read16L(); + + iReadStream.Close(); + } + +EXPORT_C void RAvrcpSetAddressedPlayerRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write16L(iPlayerId); + + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for SetAddressedPlayer responses + +EXPORT_C void RAvrcpSetAddressedPlayerResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iStatus = Read8L(); + + iReadStream.Close(); + } + +EXPORT_C void RAvrcpSetAddressedPlayerResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + + Write32L(KErrNone); // Successful operation + Write8L(iStatus); + + iStream.CommitL(); + } + +// -------------------------------------------------------------------------------- +// Used for parsing PDU 0x71 requests with media player list scope + +EXPORT_C void RAvrcpGetFolderItemsRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iScope = Read8L(); + iStartItem = Read32L(); + iEndItem = Read32L(); + } + +EXPORT_C void RAvrcpGetFolderItemsRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write8L(iScope); + Write32L(iStartItem); + Write32L(iEndItem); + + iStream.CommitL(); + } + +EXPORT_C void RAvrcpGetFolderItemsRequest::Close() + { + RAvrcpIPC::Close(); + } + +// -------------------------------------------------------------------------------- +// Used for PDU 0x71 responses with media player list scope + +EXPORT_C void RAvrcpGetFolderItemsResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + + iPduId = Read8L(); + iParamLength = Read16L(); + iStatus = Read8L(); + iUidCounter = Read16L(); + iNumberItems = Read16L(); + + for(TInt i = 0; i < iNumberItems; i++) + { + ReadItemL(); + } + + iReadStream.Close(); + } + +void RAvrcpGetFolderItemsResponse::ReadItemL() + { + RMediaPlayerItem item; + CleanupClosePushL(item); + + item.iType = static_cast(Read8L()); + item.iLength = Read16L(); + item.iPlayerId = Read16L(); + + item.iPlayerType = Read8L(); + item.iPlayerSubType = Read32L(); + item.iPlayStatus = Read8L(); + iReadStream.ReadL(item.iFeatureBitmask); + + item.iCharset = Read16L(); + item.iNameLength = Read16L(); + + item.iName.CreateL(item.iNameLength); + iReadStream.ReadL(item.iName); + + iItems.AppendL(item); + CleanupStack::Pop(&item); + } + +EXPORT_C void RAvrcpGetFolderItemsResponse::WriteL(TDes8& aOutData) + { + __ASSERT_DEBUG(aOutData.MaxLength() >= Size(), AvrcpIpcUtils::Panic(EAvrcpIpcCommandDataTooLong)); + aOutData.Zero(); + iStream.Open(aOutData); + + Write8L(iPduId); + Write16L(iParamLength); + Write8L(iStatus); + + if(iStatus == 0x4) + { + Write16L(iUidCounter); + Write16L(iNumberItems); + + for (TInt i = 0; i < iNumberItems; i++ ) + { + WriteItemL(i); + } + } + + iStream.CommitL(); + } + +void RAvrcpGetFolderItemsResponse::WriteItemL(TInt aIndex) + { + RMediaPlayerItem& item = iItems[aIndex]; + + Write8L(item.iType); + Write16L(item.iLength); + Write16L(item.iPlayerId); + + Write8L(item.iPlayerType); + Write32L(item.iPlayerSubType); + Write8L(item.iPlayStatus); + iStream.WriteL(item.iFeatureBitmask); + + Write16L(item.iCharset); + Write16L(item.iNameLength); + iStream.WriteL(item.iName); + } + +EXPORT_C TInt RAvrcpGetFolderItemsResponse::Size() + { + // Return the size that a buffer needs to be allocated to + // serialise the data encapsulated within this data structure. + + // base size + // pduid + paramlength + status + uidcount + number items + TInt size = KGetFolderItemsResponseBaseSize; + + for (TInt i = 0; i < iNumberItems; i++) + { + size += iItems[i].Size(); + } + return size; + } + +EXPORT_C void RAvrcpGetFolderItemsResponse::Close() + { + for (TInt i = 0; i < iNumberItems; i++) + { + iItems[i].Close(); + } + iItems.Reset(); + } + +// -------------------------------------------------------------------------------- +// Used for PDU 0x30 responses with event addressed player changed + +EXPORT_C void RAvrcpAddressedPlayerNotificationResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iPlayerId = Read16L(); + iUidCounter = Read16L(); + iReadStream.Close(); + } + +EXPORT_C void RAvrcpAddressedPlayerNotificationResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write16L(iPlayerId); + Write16L(iUidCounter); + iStream.CommitL(); + } + +EXPORT_C void RAvrcpUidCounterNotificationResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iUidCounter = Read16L(); + iReadStream.Close(); + } + +EXPORT_C void RAvrcpUidCounterNotificationResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write32L(KErrNone); // Successful operation + + Write16L(iUidCounter); + iStream.CommitL(); + } + +EXPORT_C void RRemConMediaErrorResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iPduId = Read8L(); + iLength = Read16L(); + iStatus = Read8L(); + iReadStream.Close(); + } + +EXPORT_C void RRemConMediaErrorResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write8L(iPduId); + Write16L(KErrResponseParameterLength); + Write8L(iStatus); + iStream.CommitL(); + } + +EXPORT_C TUint8 RAvrcpIPC::SymbianErrToStatus(TInt aErr) + { + return KErrAvrcpAirBase - SymbianErrorCheck(aErr); + } + +/** +Ensure we get a known error. +*/ +EXPORT_C TInt RAvrcpIPC::SymbianErrorCheck(TInt aError) + { + TInt error = aError; + + switch (error) + { + case KErrNone: + error = KErrAvrcpAirSuccess; + break; + case KErrAvrcpAirInvalidCommand: + case KErrAvrcpAirInvalidParameter: + case KErrAvrcpAirParameterNotFound: + case KErrAvrcpAirInternalError: + case KErrAvrcpAirSuccess: + case KErrAvrcpAirUidChanged: + case KErrAvrcpAirReserved: + case KErrAvrcpAirInvalidDirection: + case KErrAvrcpAirNotADirectory: + case KErrAvrcpAirDoesNotExist: + case KErrAvrcpAirInvalidScope: + case KErrAvrcpAirRangeOutOfBounds: + case KErrAvrcpAirUidIsADirectory: + case KErrAvrcpAirMediaInUse: + case KErrAvrcpAirNowPlayingListFull: + case KErrAvrcpAirSearchNotSupported: + case KErrAvrcpAirSearchInProgress: + case KErrAvrcpAirInvalidPlayerId: + case KErrAvrcpAirPlayerNotBrowesable: + case KErrAvrcpAirPlayerNotAddressed: + case KErrAvrcpAirNoValidSearchResults: + case KErrAvrcpAirNoAvailablePlayers: + case KErrAvrcpAirAddressedPlayerChanged: + case KErrAvrcpInvalidScope: + break; + default: + error = KErrAvrcpAirInternalError; + } + + return error; + } + +EXPORT_C void RRemConUidsChangedRequest::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iInitialUidCounter = Read16L(); + } + +EXPORT_C void RRemConUidsChangedRequest::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write16L(iInitialUidCounter); + iStream.CommitL(); + } + +EXPORT_C void RRemConUidsChangedResponse::ReadL(const TDesC8& aData) + { + iReadStream.Open(aData); + iUidCounter = Read16L(); + } + +EXPORT_C void RRemConUidsChangedResponse::WriteL(TDes8& aOutData) + { + aOutData.Zero(); + iStream.Open(aOutData); + Write16L(iUidCounter); + iStream.CommitL(); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/avrcpipc/src/remconqueuemessage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/avrcpipc/src/remconqueuemessage.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalTechnology + @released +*/ + +#include "remconqueuemessage.h" +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_BEARER); +#endif + +EXPORT_C CRemConQueuedMessage* CRemConQueuedMessage::NewL(TUid aInterfaceUid + ,const TDesC8& aData + ,TInt aOperationId + ) + { + LOG_STATIC_FUNC + CRemConQueuedMessage* self = new(ELeave) CRemConQueuedMessage( + aInterfaceUid + ,aOperationId + ); + + CleanupStack::PushL(self); + self->ConstructL(aData); + CleanupStack::Pop(self); + return self; + } + +CRemConQueuedMessage::CRemConQueuedMessage(TUid aInterfaceUid + ,TInt aOperationId + ) +: iInterfaceUid(aInterfaceUid), iOperationId(aOperationId) + { + LOG_FUNC + } + +void CRemConQueuedMessage::ConstructL(const TDesC8& aData) + { + iData.CreateL(aData); + } + +EXPORT_C CRemConQueuedMessage::~CRemConQueuedMessage() + { + LOG_FUNC + iData.Close(); + } + +EXPORT_C const TDesC8& CRemConQueuedMessage::Data() + { + return iData; + } + +EXPORT_C const CRemConQueuedMessage* TRemConMessageQueue::Find( + TUid aInterfaceUid + ,TInt aOperationId + ) + { + CRemConQueuedMessage* request = NULL; + while (iIter) + { + request = iIter++; + if(request->iInterfaceUid == aInterfaceUid + && request->iOperationId == aOperationId + ) + { + return request; + } + } + + return NULL; + } + +EXPORT_C TRemConMessageQueue::TRemConMessageQueue() + :iQueue(_FOFF(CRemConQueuedMessage, iLink)) + , iIter(iQueue) + { + + } + +EXPORT_C void TRemConMessageQueue::Reset() + { + CRemConQueuedMessage* msg; + iIter.SetToFirst(); + while (NULL != (msg = iIter++)) + { + iQueue.Remove(*msg); + delete msg; + } + } + +EXPORT_C void TRemConMessageQueue::AddLast(CRemConQueuedMessage& aMsg) + { + iQueue.AddLast(aMsg); + } + +EXPORT_C TBool TRemConMessageQueue::IsEmpty() + { + return iQueue.IsEmpty(); + } + +EXPORT_C CRemConQueuedMessage* TRemConMessageQueue::First() const + { + return iQueue.First(); + } + +EXPORT_C void TRemConMessageQueue::Remove(CRemConQueuedMessage& aMsg) + { + iQueue.Remove(aMsg); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/bwins/remconbatterystatusapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/bwins/remconbatterystatusapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ??1CRemConBatteryApiTarget@@UAE@XZ @1 + ?NewL@CRemConBatteryApiTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConBatteryTargetObserver@@@Z @2 diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/eabi/remconbatterystatusapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/eabi/remconbatterystatusapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,5 @@ +EXPORTS + _ZN23CRemConBatteryApiTarget4NewLER24CRemConInterfaceSelectorR28MRemConBatteryTargetObserver @1 NONAME + _ZN23CRemConBatteryApiTargetD0Ev @2 NONAME + _ZN23CRemConBatteryApiTargetD1Ev @3 NONAME + _ZN23CRemConBatteryApiTargetD2Ev @4 NONAME diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconbatterystatusapi.mmp + +PRJ_EXPORTS +../public/remconbatterytarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconbatterytarget.h) +../public/remconbatterytargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconbatterytargetobserver.h) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/group/remconbatterystatusapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/group/remconbatterystatusapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +// Copyright (c) 2004-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: +// remconbatterystatusapi.dll Remote Control Battery Status API - an outer-layer client side library. +// +// + +/** + @file + @internalComponent +*/ + +TARGET remconbatterystatusapi.dll +TARGETPATH /system/libs + +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x101f9067 +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE batterystatusapi.cpp + +USERINCLUDE ../../common +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib + +#include + +UNPAGED + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/public/remconbatterytarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/public/remconbatterytarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONBATTERYTARGET_H +#define REMCONBATTERYTARGET_H + +#include +#include +#include + +class MRemConBatteryTargetObserver; +class MRemConCoreApiTargetObserver; +class CRemConInterfaceSelector; + +/** +Client-instantiable type supporting sending Battery Status responses. +*/ +NONSHARABLE_CLASS(CRemConBatteryApiTarget) : public CRemConInterfaceBase, + public MRemConInterfaceIf + { +public: + /** + Factory function. + @see CRemConInterfaceSelector + @see MRemConBatteryTargetObserver + @param aInterfaceSelector The interface selector. The client must have + created one of these first. + @param aObserver The observer of this interface. + @return A new CRemConBatteryApiTarget, owned by the interface selector. + */ + IMPORT_C static CRemConBatteryApiTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConBatteryTargetObserver& aObserver); + + /** Destructor */ + IMPORT_C ~CRemConBatteryApiTarget(); + +private: + /** + Constructor. + @param aInterfaceSelector The interface selector. + @param aObserver The observer of this interface. + */ + CRemConBatteryApiTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConBatteryTargetObserver& aObserver); + + void ConstructL(); + +private: // from CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // from MRemConInterfaceIf + void MrcibNewMessage(TUint aOperationId, const TDesC8& aData); + +private: // unowned + MRemConBatteryTargetObserver& iObserver; + +private: // owned + CBufFlat* iOutData; + + + }; + +#endif // REMCONBATTERYTARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/public/remconbatterytargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/public/remconbatterytargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONBATTERYTARGETOBSERVER_H +#define REMCONBATTERYTARGETOBSERVER_H + +#include + +enum TControllerBatteryStatus + { + ENormal = 0, + EWarning = 1, + ECritical = 2, + EExternal = 3, + EFullCharge = 4, + }; + +/** +Clients must implement this interface in order to instantiate objects of type +CRemConBatteryTarget. This interface passes incoming commands from RemCon to +the client. +*/ +class MRemConBatteryTargetObserver + { +public: + /** + A 'InformBatteryStatusOfCT' has been received. + @param aBatteryStatus The current battery status. + */ + virtual void MrcbstoBatteryStatus(TControllerBatteryStatus& aBatteryStatus) = 0; + + }; + +#endif // REMCONBATTERYSTATUSTARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/batterystatusapi/src/batterystatusapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/batterystatusapi/src/batterystatusapi.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,129 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include +#include + +#include "remconbattery.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_BATTERY_STATUS); +#endif + +EXPORT_C CRemConBatteryApiTarget* CRemConBatteryApiTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConBatteryTargetObserver& aObserver) + { + LOG_STATIC_FUNC + + CRemConBatteryApiTarget* self = new(ELeave) CRemConBatteryApiTarget(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CRemConBatteryApiTarget::CRemConBatteryApiTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConBatteryTargetObserver& aObserver) +: CRemConInterfaceBase(TUid::Uid(KRemConBatteryApiUid), + KLengthBatteryStatusMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iObserver(aObserver) + { + } + +void CRemConBatteryApiTarget::ConstructL() + { + // Create a output buffer (arbitrary value of 32 for granularity of buffer expansion) + iOutData = CBufFlat::NewL(32); + + // allocate a output buffer big enough for a TRemConBatteryApiResponse + iOutData->SetReserveL(sizeof(TPckg)); //do this now for easier writing to buffer + BaseConstructL(); + } + +EXPORT_C CRemConBatteryApiTarget::~CRemConBatteryApiTarget() + { + delete iOutData; + } + +/** Gets a pointer to a specific interface version. +@return A pointer to the interface, NULL if not supported. +@internalComponent +@released +*/ +TAny* CRemConBatteryApiTarget::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +// from MRemConInterfaceIf +void CRemConBatteryApiTarget::MrcibNewMessage(TUint /* aOperationId */, const TDesC8& aData) + { + // don't bother to log the operation ID as this was causing a build warning + LOG1(_L("\taInformBatteryStatusOfCT Data.Length = %d"), aData.Length()); + + TRemConBatteryApiResponse batteryApiResponse; + batteryApiResponse.iError = KErrNone; + iOutData->Reset(); + + // check for malformed messages, there should be 1 byte of data + if ( aData.Length() == 1 ) + { + // check the battery status is validvalue to the client observer + if ( aData[0] <= EFullCharge ) + { + TControllerBatteryStatus value = (TControllerBatteryStatus)aData[0]; + iObserver.MrcbstoBatteryStatus(value); + } + else + { + LOG(_L("\tMalformed message, data out range")); + batteryApiResponse.iError = KErrAvrcpMetadataInvalidParameter; + } + } + else + { + LOG(_L("\tMalformed message, data missing")); + batteryApiResponse.iError = KErrAvrcpMetadataParameterNotFound; + } + + // send a response to remcon (if OOM silently drop message) + TRAPD(error, iOutData->ResizeL(sizeof(TRemConBatteryApiResponse))); + if (error == KErrNone) + { + iOutData->Write(0,TPckg(batteryApiResponse)); + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConBatteryApiUid), + EInformBatteryStatusOfCT, ERemConResponse, iOutData->Ptr(0)); + } + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +#include "avrcpipc/group/bld.inf" +#include "avc/bld.inf" +#include "batterystatusapi/group/bld.inf" +#include "groupnavigationapi/group/bld.inf" +#include "mediainformationapi/group/bld.inf" +#include "playerinformation/group/bld.inf" +#include "mediabrowseapi/group/bld.inf" +#include "nowplayingapi/group/bld.inf" +#include "remconbeareravrcp/group/bld.inf" +#include "statusclient/bld.inf" +#include "statusconverter/bld.inf" +#include "absolutevolumeapi/group/bld.inf" diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/bluetooth_avrcp.history.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/bluetooth_avrcp.history.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,203 @@ + + + + Audio/Video Remote Control Profile + + + + MetadataTransferCommands timer cancelled properly and put some delays in the ctrl scripts. + + + + Added copyright headers + + + + Set button action for all passthrough commands, including EVendorUnique ones. + + + + Fixed non-leavesafe automatic RArray. + + + + Some refactoring of HandleSetAddressedPlayer method. + + + + Initialise CPlayerInfoTarget::iBatteryStatus to the best value that can be retrieved from hardware P & S properties. Modify CPlayerInfoTarget::DoSetBatteryStatus() to filter out invalid values + + + + Ignore passthrough responses. + + + + Add IMPORT_C to ~CRemConNowPlayingTargetBase. + + + + Remove IMPORT_C from CPlayerApplicationSettings::NewL and NewLC. + + + + Fix to prevent memory leak in remconbeareravrcp caused when CAVCFrame* frame is allocated on the heap but Not deallocated when it goes out of scope. + + + + Change all logging over to Bluetooth logger. + + + + Added a static function -OpcodeL- which checks the Descriptor against the given opcode. + + + + Now its triggered if it exceed or equal the interval. + + + + Evaulation order clarified in avrcpoutgoingcommandhandler.cpp. + + + + Placed the leaving function on cleaup stack to handle unsafe leave. + + + + Split avrcp-settings.rss into avrcp-setting.rss and avrcp-settings.rls + + + + The PASS THROUGH commands with a non PANEL subunit_type should have a NOT IMPLEMENTED response. + + + + Modified the error code. + + + + Notify remcon of commands that have expired when a remote device disconnects + + + + calculated the Play Back Interval value between current and when last notification was sent and if it greater then iPlayerIntervalInMilliseconds,then send notification i.e. sent notification even in rewound case. + + + + Handled the unsafe leave by placing the concerned values and valueTexts in function playerApplicationSettingsResourceInit::DefineAttributesL(..) on cleanupstack. + + + + Method renamed to show it can leave. + + + + RArray replaced with a new class to store supported events in a bit mask. + + + + RAvrcpIPC::SetIPCOperationIdFromEventId(aEvent) is called to populate the correct operation Id for senderror(). + + + + Convert the playback interval to milliseconds. + + + + Codes added to handle the processing of Changed Play Status,Changed Current Track and Reached end or beginning of track. + + + + RemCon bearer changes to prevent panic. + + + + CleanupStack::PushL and CleanupStack::Pop are used to avoid memory leak. + + + + Make numRemotes a member variable so it's guaranteed to be there whenever the server writes to it. + + + + Add the boundary check for the number of attribute and the value of an attribute + + + + Now sending the response for EVENT_PLAYER_APPLICATION_SETTING_CHANGED i.e. PDU14 + + + + Add the boundary check for the numbers of player application setting values and value texts + + + + MPlayerCapabilitiesObserver::AddCompanyId() now fails with KErrOverflow if 255 company IDs are already listed. + + + + Non relevant comments are removed. + + + + Leave in a non-leaving function now handled + + + + Force disconnections of controller by transport now handled correctly + + + + Return value has been changed to KErrNone, instead of the position of the event + + + + API added to get inbound MTU for AVDTP media socket + + + + CPlayerInfoTarget::ProcessListPlayerApplicationAttributes does not return error when called without defined attributes. + + + + Interface access tags corrected for AVRCP APIs. + + + + removing the event from the pending notification list, if RemoveEvent is called. + + + + Appropriate level of Doxygen comments added + + + + Unwanted system INC file path is removed from mmp file + + + + Fixes key press problems + + + + + Changed the function call to get the Transaction ID + + + + Corrected filenames to enable building of Symbian OS in Linux + + + + Fixing CAVCFrame::FrameType(const TDesC8& aFrame) API so that it returns the type of the frame. This change has required a BR. + + + + AVRCP now sets message type to Response in CRcpCommand::ProcessOutgoingResponse. + + + + Handling memory leaks in AVRCP + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Symbian Foundation License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component bluetooth_avrcp +source \sf\mw\btservices\bluetoothappprofiles\avrcp + +binary \sf\mw\btservices\bluetoothappprofiles\avrcp all +exports \sf\mw\btservices\bluetoothappprofiles\avrcp +notes_source \component_defs\release.src + + +ipr E + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/bwins/avcU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/bwins/avcU.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +EXPORTS + ??1CAVCFrame@@UAE@XZ @ 1 NONAME ; CAVCFrame::~CAVCFrame(void) + ??ACAVCFrame@@QBEABEH@Z @ 2 NONAME ; unsigned char const & CAVCFrame::operator[](int) const + ?Append@CAVCFrame@@QAEXABVTDesC8@@@Z @ 3 NONAME ; void CAVCFrame::Append(class TDesC8 const &) + ?Append@CAVCFrame@@QAEXVTChar@@@Z @ 4 NONAME ; void CAVCFrame::Append(class TChar) + ?ButtonAct@CAVCFrame@@QBEHAAW4TButtonAction@AVCPanel@@@Z @ 5 NONAME ; int CAVCFrame::ButtonAct(enum AVCPanel::TButtonAction &) const + ?Data@CAVCFrame@@QBEABVTDesC8@@XZ @ 6 NONAME ; class TDesC8 const & CAVCFrame::Data(void) const + ?FrameType@CAVCFrame@@QBE?AW4TFrameType@AVC@@XZ @ 7 NONAME ; enum AVC::TFrameType CAVCFrame::FrameType(void) const + ?FrameType@CAVCFrame@@SA?AW4TFrameType@AVC@@ABVTDesC8@@@Z @ 8 NONAME ; enum AVC::TFrameType CAVCFrame::FrameType(class TDesC8 const &) + ?NewL@CAVCFrame@@SAPAV1@ABVTDesC8@@W4TFrameType@AVC@@@Z @ 9 NONAME ; class CAVCFrame * CAVCFrame::NewL(class TDesC8 const &, enum AVC::TFrameType) + ?NewL@CAVCFrame@@SAPAV1@W4TFrameType@AVC@@W4TCType@3@W4TSubunitType@3@W4TSubunitID@3@@Z @ 10 NONAME ; class CAVCFrame * CAVCFrame::NewL(enum AVC::TFrameType, enum AVC::TCType, enum AVC::TSubunitType, enum AVC::TSubunitID) + ?Opcode@CAVCFrame@@QBEEXZ @ 11 NONAME ; unsigned char CAVCFrame::Opcode(void) const + ?OperationId@CAVCFrame@@QBEHAAE@Z @ 12 NONAME ; int CAVCFrame::OperationId(unsigned char &) const + ?SetFrameType@CAVCFrame@@QAEXW4TFrameType@AVC@@@Z @ 13 NONAME ; void CAVCFrame::SetFrameType(enum AVC::TFrameType) + ?SetType@CAVCFrame@@QAEXW4TCType@AVC@@@Z @ 14 NONAME ; void CAVCFrame::SetType(enum AVC::TCType) + ?SubunitID@CAVCFrame@@QBE?AW4TSubunitID@AVC@@XZ @ 15 NONAME ; enum AVC::TSubunitID CAVCFrame::SubunitID(void) const + ?SubunitType@CAVCFrame@@QBE?AW4TSubunitType@AVC@@XZ @ 16 NONAME ; enum AVC::TSubunitType CAVCFrame::SubunitType(void) const + ?Type@CAVCFrame@@QBE?AW4TCType@AVC@@XZ @ 17 NONAME ; enum AVC::TCType CAVCFrame::Type(void) const + ?DataLength@CAVCFrame@@QBEHXZ @ 18 NONAME ; int CAVCFrame::DataLength(void) const + ?GetPayloadAndVID@CAVCVendorDependentCommand@@SA?AVTPtrC8@@ABVCAVCFrame@@AAI@Z @19 + ?GetPayloadAndVID@CAVCVendorUniquePassthroughCommand@@SA?AVTPtrC8@@ABVCAVCFrame@@AAI@Z @20 + ?NewL@CAVCPassthroughResponse@@SAPAVCAVCFrame@@XZ @21 ABSENT + ?NewL@CAVCVendorDependentResponse@@SAPAVCAVCFrame@@I@Z @22 + ?OpcodeL@CAVCFrame@@SA?AW4TOpcode@AVC@@ABVTDesC8@@@Z @ 23 NONAME ; enum AVC::TOpcode CAVCFrame::OpcodeL(class TDesC8 const &) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/bwins/remconstatusapiU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/bwins/remconstatusapiU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,7 @@ +EXPORTS + ??1CRemConStatusApiController@@UAE@XZ @ 1 NONAME ; CRemConStatusApiController::~CRemConStatusApiController(void) + ?Mrcsaco_ExtensionInterfaceL@MRemConStatusApiControllerObserver@@UAEXVTUid@@AAPAX@Z @ 2 NONAME ; void MRemConStatusApiControllerObserver::Mrcsaco_ExtensionInterfaceL(class TUid, void * &) + ?NewL@CRemConStatusApiController@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConStatusApiControllerObserver@@@Z @ 3 NONAME ; class CRemConStatusApiController * CRemConStatusApiController::NewL(class CRemConInterfaceSelector &, class MRemConStatusApiControllerObserver &) + ?SubunitInfo@CRemConStatusApiController@@QAEXAAVTRequestStatus@@AAI@Z @ 4 NONAME ; void CRemConStatusApiController::SubunitInfo(class TRequestStatus &, unsigned int &) + ?UnitInfo@CRemConStatusApiController@@QAEXAAVTRequestStatus@@AAI@Z @ 5 NONAME ; void CRemConStatusApiController::UnitInfo(class TRequestStatus &, unsigned int &) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/avrcpinternalinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/avrcpinternalinterface.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,155 @@ +// Copyright (c) 2008-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: +// + +#ifndef AVRCPINTERNALINTERFACE_H +#define AVRCPINTERNALINTERFACE_H + +/** +@file +@internalTechnology +@prototype +*/ + +#include +#include "avrcpipc.h" +#include "browsingframe.h" + +const TInt KUidAvrcpInternalInterface = 0x10285eef; + +enum TAvrcpInternalInterfaceOperationId + { + EAvrcpInternalGetFolderItems = 0x0, + EAvrcpInternalAvailablePlayersNotification = 0xa31, + EAvrcpInternalAddressedPlayerNotification = 0xb31, + EAvrcpInternalUidChangedNotification = 0xc31, + EAvrcpInternalSetAddressedPlayer = 0x60, + }; + +const TInt KSetAddressedPlayerResponseSize = 8; +const TInt KRegisterNotificationEmptyResponseSize = 4; +const TInt KRegisterNotificationAddressedPlayerResponseSize = 8; +const TInt KRegisterNotificationUidChangedResponseSize = 6; +const TUint16 KMediaPlayerListUidCounter = 0; + +class RMediaPlayerItem + { +public: + IMPORT_C void Close(); + IMPORT_C TInt Size(); + +public: + AvrcpBrowsing::TItemType iType; + TUint16 iLength; + TUint16 iPlayerId; + + TUint8 iPlayerType; + TUint32 iPlayerSubType; + TUint8 iPlayStatus; + TBuf8<16> iFeatureBitmask; + + TUint16 iCharset; + TUint16 iNameLength; + RBuf8 iName; + }; + +//-------------------------------------------------- +// SetAddressedPlayer 0x60 +//-------------------------------------------------- +class RAvrcpSetAddressedPlayerRequest : public RAvrcpIPC + { +public: + TUint16 iPlayerId; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +class RAvrcpSetAddressedPlayerResponse : public RAvrcpIPC + { +public: + TUint8 iStatus; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +//-------------------------------------------------- +// GetFolderItems Media Player Scope 0x71 +//-------------------------------------------------- +class RAvrcpGetFolderItemsRequest : public RAvrcpIPC + { +public: + AvrcpBrowsing::TScope iScope; + TUint iStartItem; + TUint iEndItem; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); + }; + +class RAvrcpGetFolderItemsResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iParamLength; + TUint8 iStatus; + TUint16 iUidCounter; + TUint16 iNumberItems; + RArray iItems; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C TInt Size(); + IMPORT_C void Close(); + +private: + void ReadItemL(); + void WriteItemL(TInt aIndex); + }; + +//-------------------------------------------------- +// Register Notification Addressed Player +//-------------------------------------------------- +class RAvrcpAddressedPlayerNotificationResponse : public RAvrcpIPC + { +public: + TUint16 iPlayerId; + TUint16 iUidCounter; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + }; + +//-------------------------------------------------- +// Register Notification Uid Counter +//-------------------------------------------------- +class RAvrcpUidCounterNotificationResponse : public RAvrcpIPC + { +public: + TUint16 iUidCounter; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + }; + + +#endif //AVRCPINTERNALINTERFACE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/avrcpipc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/avrcpipc.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,74 @@ +// Copyright (c) 2007-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: +// This file contains structures shared by the AVRCP API with the AVRCP bearer. +// +// + +/** + @file + @internalTechnology + @released +*/ + +#ifndef AVRCPIPC_H +#define AVRCPIPC_H + +#include +#include + +// Structure of commands for AVRCP player information requests via IPC +class RAvrcpIPC +{ +public: + IMPORT_C static TMetadataTransferPDU GetPDUIdFromIPCOperationId(TInt aOperationId); + IMPORT_C static TRegisterNotificationEvent GetEventIdFromIPCOperationId(TInt aOperationId); + IMPORT_C static TInt SetIPCOperationIdFromEventId(TRegisterNotificationEvent aEventId); + IMPORT_C static TUint8 SymbianErrToStatus(TInt aErr); + IMPORT_C static TInt SymbianErrorCheck(TInt aError); + +public: + virtual void ReadL(const TDesC8& aData) = 0; + virtual void WriteL(TDes8& aOutData) = 0; + +protected: + // Big-endian methods; Symbian native methods are little-endian + TUint8 Read8L(); + TUint16 Read16L(); + TUint32 Read32L(); + TUint32 Read24L(); // Required for PDU 0x10 + TUint64 Read64L(); + void Write8L(TUint8 aVal); + void Write16L(TUint16 aVal); + void Write24L(TUint32 aVal); // Required for PDU 0x10 + void Write32L(TUint32 aVal); + void Write64L(TUint64 aVal); + void Close(); + +public: + RDesWriteStream iStream; + RDesReadStream iReadStream; +}; + +const TUint8 KLengthErrorResponse = 4; // 4 bytes for errors returned via IPC +class RAvrcpIPCError : public RAvrcpIPC +{ +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + +public: + TInt iError; +}; + +#endif // AVRCPIPC_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/browsingframe.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/browsingframe.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,95 @@ +// Copyright (c) 2008-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: +// browisngframe.h +// + +#ifndef BROWSINGFRAME_H +#define BROWSINGFRAME_H + +/** +@file +@internalComponent +@released +*/ + +#include + +const TInt KUidCounter = 0; + +namespace AvrcpBrowsing + { +const TInt KHeaderLength = 3; +typedef TUint8 TPduId; +typedef TUint8 TScope; +typedef TUint8 TDirection; +typedef TUint8 TPlayable; +typedef TUint8 TMediaType; + +const TScope KMediaPlayerScope = 0x0; +const TScope KVirtualFilesystemScope = 0x1; +const TScope KSearchScope = 0x2; +const TScope KNowPlayingScope = 0x3; + +const TDirection KUp = 0x00; +const TDirection KDown = 0x01; + +const TPlayable KPlayable = 1; +const TPlayable KNotPlayable = 0; +const TPlayable KPlayableReserved = 2; + +const TMediaType KAudio = 0; +const TMediaType KVideo = 1; +const TMediaType KMediaTypeReserved = 2; + +enum TPdu + { + ESetBrowsedPlayer = 0x70, + EGetFolderItems = 0x71, + EChangePath = 0x72, + EGetItemAttributes = 0x73, + ESearch = 0x80, + EGeneralReject = 0xa0, + }; + +enum TItemType + { + EMediaPlayer = 0x01, + EFolderItem = 0x02, + EMediaElement = 0x03, + }; + +enum TFolderType + { + EMixed = 0, + ETitles = 1, + EAlbums = 2, + EArtists = 3, + EGenres = 4, + EPlaylists = 5, + EYears = 6, + EFolderTypeReserved = 7, + }; + +class BrowsingFrame + { +public: + static void VerifyFrameL(const TDesC8& aFrame); + static TPduId PduId(const TDesC8& aFrame); + static TInt ParamLength(const TDesC8& aFrame); + static void Payload(const TDesC8& aFrame, TPtrC8& aPayload); + }; + + } // end namespace BrowsingFrame + +#endif //BROWSINGFRAME_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/mediabrowse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/mediabrowse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,315 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalTechnology + @released +*/ + +#ifndef MEDIABROWSE_H +#define MEDIABROWSE_H + +#include +#include +#include +#include "avrcpipc.h" +#include "browsingframe.h" +#include "mediainformation.h" + +//-------------------------------------------------------------------------- +// Interface Data +//-------------------------------------------------------------------------- + +enum TRemConMediaBrowseOperationId + { + EGetFolderItemsOperationId, + EChangePathOperationId, + EGetItemAttributesOperationId, + ESearchOperationId, + ESetMaxResponseOperationId, + ESetBrowsedPlayerOperationId, + EUIDPersistency, + EMediaLibraryStateCookieUpdateOperationId, + }; + +/** + * The UID identifying the RemCon NowPlaying interface. + */ +const TInt KRemConMediaBrowseApiUid = 0x10285bbb; + +// identifier (8bytes) NumAttributes (1) AttributeID (max is 4*7) = 37 + UID Counter + scope +const TInt KMaxLengthMediaBrowseMsg = 400; + +//PDU ID(1 byte) + Parameter length(2 bytes) + Status(1 byte), +//the total of which is 4 bytes +const TInt KBrowseResponseBaseLength = 4; + +//KBrowseResponseBaseLength(4 bytes) + UID Counter(2 bytes) + Number of Items(2 bytes) +//the total of which is 8 +const TInt KGetFolderItemsResponseBaseSize = 8; + +//UID 8 + FolderType 1 + Is Playable 1 + Character set ID 2 + Name length 2 +const TInt KFolderItemBaseLength = 14; + +//UID 8 + Type 1 + Character Set 2 + Name Length 2 + Number of attributes 1 +const TInt KMediaElementItemBaseLength = 14; + +//ID 4 + Character Set 2 + Length filed 2 +const TInt KAttributeBaseLength = 8; + +//Status 1 +const TInt KErrResponseParameterLength = 1; + +/** +This is the max length of a response used in media browse API for fix-length responses. +For the response which have a fix-length the Search(PDU 0x80) has the maximum response +which is KBrowseResponseBaseLength(4 bytes)+ UID Counter(2 bytes) + Number of Items(4 bytes) +the total of which is 10 +*/ +const TInt KMediaBrowseOutBufMaxLength = 10; + +class RItem + { +public: + IMPORT_C void Close(); + IMPORT_C TInt Size(); + +public: + AvrcpBrowsing::TItemType iType; + TUint16 iLength; + TUint64 iUid; + + TUint16 iCharset; + TUint16 iNameLength; + HBufC8* iName; + + // Folder attributes + AvrcpBrowsing::TFolderType iFolderType; + AvrcpBrowsing::TPlayable iPlayable; + + // Media element attributes + AvrcpBrowsing::TMediaType iMediaType; + TInt iNumberAttributes; + RArray iAttributes; + }; + +//-------------------------------------------------- +// GetFolderItems 0x71 +//-------------------------------------------------- +class RRemConGetFolderItemsRequest : public RAvrcpIPC + { +public: + AvrcpBrowsing::TScope iScope; + TUint iStartItem; + TUint iEndItem; + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); + IMPORT_C TInt CopyAttributes(RArray& aOutAttributes); + }; + +class RRemConGetFolderItemsResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iParamLength; + TUint8 iStatus; + TUint16 iUidCounter; + TUint16 iNumberItems; + RArray iItems; + + TInt iMaxResponse; + TInt iCurrentItem; + TInt iCurrentListingSize; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C TInt Size(); + IMPORT_C void Close(); + IMPORT_C TInt CopyItems(const TArray& aItems); + IMPORT_C TBool RequestNextItem(TInt& aError, RBuf8& aOutBuf, TUint16 aCookie); + +private: + void ReadItemL(); + void WriteItemL(TInt aIndex); + }; + +//-------------------------------------------------- +// ChangePath 0x72 +//-------------------------------------------------- +class RRemConChangePathRequest : public RAvrcpIPC + { +public: + TUint16 iUidCounter; + AvrcpBrowsing::TDirection iDirection; + TUint64 iElement; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + + +class RRemConChangePathResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iParamLength; + TUint8 iStatus; + TInt iNumberItems; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +//-------------------------------------------------- +// GetItemAttributes 0x73 +//-------------------------------------------------- +class RRemConGetItemAttributesRequest : public RAvrcpIPC + { +public: + AvrcpBrowsing::TScope iScope; + TUint64 iElement; + TUint16 iUidCounter; + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); + }; + + +class RRemConGetItemAttributesResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iParamLength; + TUint8 iStatus; + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C TInt Size(); + IMPORT_C void Close(); + }; + +//-------------------------------------------------- +// Search 0x80 +//-------------------------------------------------- +class RRemConSearchRequest : public RAvrcpIPC + { +public: + TUint16 iCharset; + TUint16 iStringLen; + RBuf8 iSearchString; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C TInt Size(); + IMPORT_C void Close(); + }; + +class RRemConSearchResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iParamLength; + TUint8 iStatus; + TUint16 iUidCounter; + TUint iNumberItems; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +//-------------------------------------------------- +// SetBrowsedPlayer +//-------------------------------------------------- +class RRemConSetBrowsedPlayerRequest : public RAvrcpIPC + { +public: + TInt iMaxResponse; + TUint16 iPlayerId; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +class RRemConGetPathResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iParamLength; + TUint8 iStatus; + TUint16 iUidCounter; + TUint iNumberItems; + TUint16 iCharset; + TUint8 iFolderDepth; + RPointerArray iPath; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C TInt Size(); + IMPORT_C void Close(); + }; + +class RRemConMediaErrorResponse : public RAvrcpIPC + { +public: + TUint8 iPduId; + TUint16 iLength; + TUint8 iStatus; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +class RRemConUidsChangedRequest : public RAvrcpIPC + { +public: + TUint16 iInitialUidCounter; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +class RRemConUidsChangedResponse : public RAvrcpIPC + { +public: + TUint16 iUidCounter; +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; +#endif //MEDIABROWSE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/mediainformation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/mediainformation.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @internalTechnology + @released +*/ + +#ifndef REMCONMEDIAINFORMATION_H +#define REMCONMEDIAINFORMATION_H + +#include "avrcpipc.h" + +//-------------------------------------------------------------------------- +// Interface Data +//-------------------------------------------------------------------------- + +/** + * The UID identifying the RemCon MediaInformation interface. + */ +const TInt KRemConMediaInformationApiUid = 0x10285B20; + +// identifier (8bytes) NumAttributes (1) AttributeID (max is 4*7) = 37 +const TInt KMaxLengthMediaInformationMsg = 37; +const TInt KMaxMediaAttributeValue = 7; + +class RRemConGetElementAttributesRequest : public RAvrcpIPC + { +public: + TUint64 iElement; + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); + }; + + +class REAResponse + { +public: + IMPORT_C void Close(); +public: + TInt iAttributeId; + TUint16 iCharset; + TUint16 iStringLen; + HBufC8* iString; + }; + + +class RRemConGetElementAttributesResponse : public RAvrcpIPC + { +public: + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C TInt Size(); + IMPORT_C void Close(); + }; + +#endif // REMCONMEDIAINFORMATION_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/nowplaying.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/nowplaying.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,63 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalTechnology + @released +*/ + +#ifndef NOWPLAYING_H +#define NOWPLAYING_H + +#include +#include +#include "avrcpipc.h" + +//The UID identifying the RemCon NowPlaying interface. +const TInt KRemConNowPlayingApiUid = 0x10285bbc; + +/** +This is the maximum length of a request that can be received +Play Item(0x74) and AddToNowPlaying(0x90) have the largest possible request +which is Scope (1 byte) + UID (8 bytes) + UID Counter (2 bytes) +the total of which is 11 +*/ +const TInt KMaxLengthNowPlayingMsg = 11; + + +class RRemConNowPlayingRequest : public RAvrcpIPC + { +public: + TRemConFolderScope iScope; + TUint64 iElement; + TUint16 iUidCounter; +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +class RRemConNowPlayingResponse : public RAvrcpIPC + { +public: + TUint8 iStatus; +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + }; + +#endif //NOWPLAYING_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/playerinformation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/playerinformation.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,172 @@ +// Copyright (c) 2008-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: +// playerinformation.h This file contains structures shared by the AVRCP API with the AVRCP bearer. +// +// + +/** + @file + @internalTechnology + @released +*/ + +#ifndef REMCONPLAYERINFORMATION_H +#define REMCONPLAYERINFORMATION_H + +#include "playerinformationtarget.h" +#include "avrcpipc.h" +#include + +/** + * The UID identifying the RemCon PlayerInformation interface. + */ +const TInt KRemConPlayerInformationUid = 0x10285B21; + +// The Bluetooth SIG registered VendorId, see table 4.7 +const AVC::TAVCVendorId KBluetoothSIGVendorId = 0x001958; + +// This is the maximum length of a request that can be received +// GetElementAttributes (PDU 0x20) has the largest possible request +// which is identifier (8 bytes) + numAttr (1 byte) + attributes +// (255 * 4 bytes) the total of which is 1029 bytes. +const TInt KMaxLengthPlayerInformationMsg = 1029; + + +// Used by PDU 0x11 and PDU 0x12 +class RRemConPlayerListOfAttributes : public RAvrcpIPC +{ +public: + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); +}; + +// Used by PDU 0x13 (response) and PDU 0x14 (request) +class RRemConPlayerAttributeIdsAndValues : public RAvrcpIPC +{ +public: + TInt iNumberAttributes; + RArray iAttributeId; + RArray iAttributeValue; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); +}; + +class RSettingWithCharset + { +public: + IMPORT_C void Close(); + +public: + TInt iAttributeId; + TUint16 iCharset; + TInt iStringLen; + HBufC8* iString; +}; + +// Used by PDU 0x15 and PDU 0x16 +class RRemConGetPlayerApplicationTextResponse : public RAvrcpIPC +{ +public: + TInt iNumberAttributes; + RArray iAttributes; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); + IMPORT_C TInt Size(); +}; + +// Used by PDU 0x10 +class RRemConGetCapabilitiesResponse : public RAvrcpIPC +{ +public: + TUint16 iCapabilityId; + TUint16 iCapabilityCount; + RArray iCapabilities; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8& aOutData); + IMPORT_C void Close(); +}; + +// Used by PDU 0x30 +class RRemConPlayerInformationGetPlayStatusResponse : public RAvrcpIPC + { +public: + TUint iPlayPos; + TUint iTrackLength; + MPlayerEventsObserver::TPlaybackStatus iStatus; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + }; + +// Used by PDU 0xff +class RRemConPlayerInformationGetPlayStatusUpdateRequest : public RAvrcpIPC + { +public: + MPlayerEventsObserver::TPlaybackStatus iStatus; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + }; + +// Used by PDU 0xff +class RRemConPlayerInformationGetPlayStatusUpdateResponse : public RAvrcpIPC + { +public: + MPlayerEventsObserver::TPlaybackStatus iStatus; + +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + }; + +class RRemConPlayerInformation8BitResponse : public RAvrcpIPC + { +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + TUint8 iValue; + }; + +class RRemConPlayerInformation32BitResponse : public RAvrcpIPC + { +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + TInt iValue; + }; + +class RRemConPlayerInformation64BitResponse : public RAvrcpIPC + { +public: + IMPORT_C void ReadL(const TDesC8& aData); + IMPORT_C void WriteL(TDes8&); + TUint64 iValue; + }; + +#endif // REMCONPLAYERINFORMATION_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/remconbattery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/remconbattery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalTechnology +*/ + +#ifndef REMCONBATTERY_H +#define REMCONBATTERY_H + +#include + + +//-------------------------------------------------------------------------- +// Interface Data +//-------------------------------------------------------------------------- + +/** +The UID identifying this outer-layer RemCon interface. +*/ +const TInt KRemConBatteryApiUid = 0x10285AE7; + +struct TRemConBatteryApiResponse + { + // Error code + TInt iError; + }; + +const TInt KLengthBatteryStatusMsg = 1; + + +#endif // REMCONBATTERY_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/remcongroupnavigation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/remcongroupnavigation.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @internalTechnology +*/ + +#ifndef REMCONGROUPNAVIGATION_H +#define REMCONGROUPNAVIGATION_H + +#include + +//-------------------------------------------------------------------------- +// Interface Data +//-------------------------------------------------------------------------- + +/** +The UID identifying the RemCon Group Navigation interface. +*/ +const TInt KRemConGroupNavigationApiUid = 0x10285B01; + +const TInt KMaxSizeRemConGroupNavigationMsg =1; + +struct TRemConGroupNavigationResponse + { + // Error code + TInt iError; + }; + +#endif // REMCONGROUPNAVIGATION_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/remconqueuemessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/remconqueuemessage.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalTechnology + @released +*/ + +#ifndef REMCONQUEUEMESSAGE_H_ +#define REMCONQUEUEMESSAGE_H_ + +#include + +class CRemConQueuedMessage; + +/** +A queue for RemCon request command messages. +*/ +NONSHARABLE_CLASS(TRemConMessageQueue) + { +public: + IMPORT_C TRemConMessageQueue(); + IMPORT_C void Reset(); + IMPORT_C void AddLast(CRemConQueuedMessage& aMsg); + IMPORT_C TBool IsEmpty(); + IMPORT_C CRemConQueuedMessage* First() const; + IMPORT_C void Remove(CRemConQueuedMessage& aMsg); + IMPORT_C const CRemConQueuedMessage* Find(TUid aInterfaceUid + ,TInt aOperationId + ); +private: + TSglQue iQueue; + TSglQueIter iIter; + }; + +/** +A data encapsulation class for a request. + +The object contains the data of the request and the type of the request, which +will be put in a queue. +*/ +NONSHARABLE_CLASS(CRemConQueuedMessage) : public CBase + { +public: + IMPORT_C static CRemConQueuedMessage* NewL(TUid aInterfaceUid + ,const TDesC8& aData + ,TInt aOperationId + ); + + IMPORT_C ~CRemConQueuedMessage(); + IMPORT_C const TDesC8& Data(); + +private: + CRemConQueuedMessage(TUid aInterfaceUid, TInt aOperationId); + void ConstructL(const TDesC8& aData); + +public: + TSglQueLink iLink; + TUid iInterfaceUid; + TInt iOperationId; + +private: + RBuf8 iData; + }; + + +#endif /*REMCONQUEUEMESSAGE_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/common/remconstatusapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/common/remconstatusapi.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,106 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent + @released +*/ + +#ifndef REMCONSTATUSAPI_H +#define REMCONSTATUSAPI_H + +#include + +const TUint KRemConStatusApiMaxOperationSpecificDataSize = 10; + +//-------------------------------------------------------------------------- +// Unit info response data format +//-------------------------------------------------------------------------- + +/** Length of the VendorId field in bytes. */ +const TUint KRemConStatusApiVendorIdLength = 3; + +/** Offset for VendorId field */ +const TUint KRemConStatusApiVendorIdOffset = 0; + +/** Length of the Unit field in bytes. */ +const TUint KRemConStatusApiUnitLength = 1; + +/** Offset for Unit field */ +const TUint KRemConStatusApiUnitOffset = KRemConStatusApiVendorIdLength; + +/** Length of the Unit type field in bytes. */ +const TUint KRemConStatusApiUnitTypeLength = 1; + +/** Offset for Unit type field */ +const TUint KRemConStatusApiUnitTypeOffset = KRemConStatusApiVendorIdLength + KRemConStatusApiUnitLength; + +/** Length of the Extended Unit type field in bytes. */ +const TUint KRemConStatusApiExtendedUnitTypeLength = 2; + +/** Offset for Extended Unit type field. + +This data is only valid if Unit type is 0x1e. +The second byte is only valid if the first byte is 0xff. +See AV/C general specification for details. +*/ +const TUint KRemConStatusApiExtendedUnitTypeOffset = + KRemConStatusApiVendorIdLength + KRemConStatusApiUnitLength +KRemConStatusApiUnitTypeLength; + +//-------------------------------------------------------------------------- +// SubUnit info response data format +//-------------------------------------------------------------------------- + +/** Length of the page field in bytes. */ +const TUint KRemConStatusApiPageLength = 1; + +/** Offset for page field */ +const TUint KRemConStatusApiPageOffset = 0; + +/** Length of the extension field in bytes. */ +const TUint KRemConStatusApiExtensionLength = 1; + +/** Offset for extension field */ +const TUint KRemConStatusApiExtensionOffset = KRemConStatusApiPageLength; + +/** Length of the page data field in bytes. + +This is defined as being all data from KRemConStatusApiPageDataOffset +to the end of the response data. +*/ + +/** Offset for page data field */ +const TUint KRemConStatusApiPageDataOffset = KRemConStatusApiPageLength + KRemConStatusApiExtensionLength; + +//-------------------------------------------------------------------------- +// Interface Data +//-------------------------------------------------------------------------- + +/** +The UID identifying this outer-layer RemCon interface. +*/ +const TInt KRemConStatusApiUid = 0x10207ea5; + +/** +Operation ids belonging to the Status API. +*/ +enum TRemConStatusApiOperationId + { + ERemConStatusApiUnitInfo = 0x00, + ERemConStatusApiSubunitInfo = 0x01, + }; + +#endif // REMCONSTATUSAPI_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/eabi/avcU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/eabi/avcU.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +EXPORTS + _ZN9CAVCFrame12SetFrameTypeEN3AVC10TFrameTypeE @ 1 NONAME + _ZN9CAVCFrame4NewLEN3AVC10TFrameTypeENS0_6TCTypeENS0_12TSubunitTypeENS0_10TSubunitIDE @ 2 NONAME + _ZN9CAVCFrame4NewLERK6TDesC8N3AVC10TFrameTypeE @ 3 NONAME + _ZN9CAVCFrame6AppendE5TChar @ 4 NONAME + _ZN9CAVCFrame6AppendERK6TDesC8 @ 5 NONAME + _ZN9CAVCFrame7SetTypeEN3AVC6TCTypeE @ 6 NONAME + _ZN9CAVCFrame9FrameTypeERK6TDesC8 @ 7 NONAME + _ZN9CAVCFrameD0Ev @ 8 NONAME + _ZN9CAVCFrameD1Ev @ 9 NONAME + _ZN9CAVCFrameD2Ev @ 10 NONAME + _ZNK9CAVCFrame11OperationIdERh @ 11 NONAME + _ZNK9CAVCFrame11SubunitTypeEv @ 12 NONAME + _ZNK9CAVCFrame4DataEv @ 13 NONAME + _ZNK9CAVCFrame4TypeEv @ 14 NONAME + _ZNK9CAVCFrame6OpcodeEv @ 15 NONAME + _ZNK9CAVCFrame9ButtonActERN8AVCPanel13TButtonActionE @ 16 NONAME + _ZNK9CAVCFrame9FrameTypeEv @ 17 NONAME + _ZNK9CAVCFrame9SubunitIDEv @ 18 NONAME + _ZNK9CAVCFrameixEi @ 19 NONAME + _ZNK9CAVCFrame10DataLengthEv @ 20 NONAME + _ZN23CAVCPassthroughResponse4NewLEv @21 NONAME ABSENT + _ZN26CAVCVendorDependentCommand16GetPayloadAndVIDERK9CAVCFrameRj @22 NONAME + _ZN27CAVCVendorDependentResponse4NewLEj @23 NONAME + _ZN34CAVCVendorUniquePassthroughCommand16GetPayloadAndVIDERK9CAVCFrameRj @24 NONAME + _ZN9CAVCFrame7OpcodeLERK6TDesC8 @ 25 NONAME diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/eabi/remconstatusapiU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/eabi/remconstatusapiU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,11 @@ +EXPORTS + _ZN26CRemConStatusApiController11SubunitInfoER14TRequestStatusRj @ 1 NONAME + _ZN26CRemConStatusApiController4NewLER24CRemConInterfaceSelectorR34MRemConStatusApiControllerObserver @ 2 NONAME + _ZN26CRemConStatusApiController8UnitInfoER14TRequestStatusRj @ 3 NONAME + _ZN26CRemConStatusApiControllerD0Ev @ 4 NONAME + _ZN26CRemConStatusApiControllerD1Ev @ 5 NONAME + _ZN26CRemConStatusApiControllerD2Ev @ 6 NONAME + _ZN34MRemConStatusApiControllerObserver27Mrcsaco_ExtensionInterfaceLE4TUidRPv @ 7 NONAME + _ZTI34MRemConStatusApiControllerObserver @ 8 NONAME ; ## + _ZTV34MRemConStatusApiControllerObserver @ 9 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/bwins/remcongroupnavigationapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/bwins/remcongroupnavigationapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,6 @@ +EXPORTS + ??1CRemConGroupNavigationApiTarget@@UAE@XZ @ 1 NONAME ; CRemConGroupNavigationApiTarget::~CRemConGroupNavigationApiTarget(void) + ?NewL@CRemConGroupNavigationApiTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConGroupNavigationTargetObserver@@@Z @ 2 NONAME ; class CRemConGroupNavigationApiTarget * CRemConGroupNavigationApiTarget::NewL(class CRemConInterfaceSelector &, class MRemConGroupNavigationTargetObserver &) + ?NextGroupResponse@CRemConGroupNavigationApiTarget@@QAEXAAPAVTRequestStatus@@H@Z @ 3 NONAME ; void CRemConGroupNavigationApiTarget::NextGroupResponse(class TRequestStatus * &, int) + ?PreviousGroupResponse@CRemConGroupNavigationApiTarget@@QAEXAAPAVTRequestStatus@@H@Z @ 4 NONAME ; void CRemConGroupNavigationApiTarget::PreviousGroupResponse(class TRequestStatus * &, int) + ?NewL@CRemConGroupNavigationApiTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConGroupNavigationTargetObserver@@HH@Z @ 5 NONAME ; class CRemConGroupNavigationApiTarget * CRemConGroupNavigationApiTarget::NewL(class CRemConInterfaceSelector &, class MRemConGroupNavigationTargetObserver &, int, int) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/eabi/remcongroupnavigationapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/eabi/remcongroupnavigationapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,9 @@ +EXPORTS + _ZN31CRemConGroupNavigationApiTarget17NextGroupResponseERP14TRequestStatusi @ 1 NONAME + _ZN31CRemConGroupNavigationApiTarget21PreviousGroupResponseERP14TRequestStatusi @ 2 NONAME + _ZN31CRemConGroupNavigationApiTarget4NewLER24CRemConInterfaceSelectorR36MRemConGroupNavigationTargetObserver @ 3 NONAME + _ZN31CRemConGroupNavigationApiTargetD0Ev @ 4 NONAME + _ZN31CRemConGroupNavigationApiTargetD1Ev @ 5 NONAME + _ZN31CRemConGroupNavigationApiTargetD2Ev @ 6 NONAME + _ZN31CRemConGroupNavigationApiTarget4NewLER24CRemConInterfaceSelectorR36MRemConGroupNavigationTargetObserverii @ 7 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remcongroupnavigationapi.mmp + +PRJ_EXPORTS +../public/remcongroupnavigationtarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcongroupnavigationtarget.h) +../public/remcongroupnavigationtargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcongroupnavigationtargetobserver.h) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/group/remcongroupnavigationapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/group/remcongroupnavigationapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +// Copyright (c) 2007-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: +// remcongroupnavigationapi.dll Remote Control Group Navigation API - an outer-layer client side library. +// +// + +/** + @file + @internalComponent +*/ + +TARGET remcongroupnavigationapi.dll +TARGETPATH /system/libs + +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x101f9067 +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE groupnavigationapi.cpp + +USERINCLUDE ../../common +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib +LIBRARY estor.lib + +#include + +UNPAGED + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/public/remcongroupnavigationtarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/public/remcongroupnavigationtarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,116 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONGROUPNAVIGATIONTARGET_H +#define REMCONGROUPNAVIGATIONTARGET_H + +#include +#include +#include +#include + +#include +#include + +class MRemConGroupNavigationTargetObserver; +class CRemConInterfaceSelector; + +/** +Client-instantiable type supporting sending Battery Status responses. +*/ +NONSHARABLE_CLASS(CRemConGroupNavigationApiTarget) : public CRemConInterfaceBase, + public MRemConInterfaceIf + { +public: + /** + Factory function. + @see CRemConInterfaceSelector + @param aInterfaceSelector The interface selector. The client must have + created one of these first. + @param aObserver The observer of this interface. + @return A new CRemConGroupNavigationApiTarget, owned by the interface selector. + */ + IMPORT_C static CRemConGroupNavigationApiTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConGroupNavigationTargetObserver& aObserver); + /** + Factory function. + @see CRemConInterfaceSelector + @param aInterfaceSelector The interface selector. The client must have + created one of these first. + @param aObserver The observer of this interface. + @param aNextGroupSupported Whether the Client support the next Group functionality. + @param aPreviousGroupSupported Whether the Client support the previous Group functionality. + @return A new CRemConGroupNavigationApiTarget, owned by the interface selector. + */ + IMPORT_C static CRemConGroupNavigationApiTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConGroupNavigationTargetObserver& aObserver, TBool aNextGroupSupported, TBool aPreviousGroupSupported); + + /** Destructor */ + IMPORT_C ~CRemConGroupNavigationApiTarget(); + +public: + /** Send a 'next group' response. + Called by the client after receiving a MRemConGroupNavigationTargetObserver::MrcgntoNextGroup(). + @param aStatus Used by RemCon to indicate completion of the send request. + aStatus may be NULL if no completion indication required. + @param aError The response error. + */ + IMPORT_C void NextGroupResponse(TRequestStatus*& aStatus, TInt aError); + + /** Send a 'previous group' response. + Called by the client after receiving a MRemConGroupNavigationTargetObserver::MrcgntoPreviousGroup(). + @param aStatus Used by RemCon to indicate completion of the send request. + aStatus may be NULL if no completion indication required. + @param aError The response error. + */ + IMPORT_C void PreviousGroupResponse(TRequestStatus*& aStatus, TInt aError); + +private: + /** + Constructor. + @param aInterfaceSelector The interface selector. + @param aObserver The observer of this interface. + */ + CRemConGroupNavigationApiTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConGroupNavigationTargetObserver& aObserver); + + void SendGroupResponse(TGroupNavigationPassthroughOperationIds aId, TRequestStatus*& aStatus, TInt aError); + + void ConstructL(); + + void ConstructL(TBool aNextGroupSupported, TBool aPreviousGroupSupported); +private: // from CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // from MRemConInterfaceIf + void MrcibNewMessage(TUint aOperationId, const TDesC8& aData); + +private: // unowned + MRemConGroupNavigationTargetObserver& iObserver; + +private: // owned + CBufFlat* iOutData; + TPtr8 iPtr; + RBufWriteStream iStream; + TUint iNumRemotes; + }; + +#endif // REMCONGROUPNAVIGATIONTARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/public/remcongroupnavigationtargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/public/remcongroupnavigationtargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONGROUPNAVIGATIONTARGETOBSERVER_H +#define REMCONGROUPNAVIGATIONTARGETOBSERVER_H + +#include +#include + +/** +Clients must implement this interface in order to instantiate objects of type +CRemConGroupNavigation. This interface passes incoming commands from RemCon to +the client. +*/ +class MRemConGroupNavigationTargetObserver + { +public: + /** + A 'Next Group' has been received. + @see TRemConCoreApiButtonAction + @param aButtonAct The button action associated with the command. + */ + virtual void MrcgntoNextGroup(TRemConCoreApiButtonAction aButtonAct) = 0; + + /** + A 'Previous Group' has been received. + @see TRemConCoreApiButtonAction + @param aButtonAct The button action associated with the command. + */ + virtual void MrcgntoPreviousGroup(TRemConCoreApiButtonAction aButtonAct) =0; + + }; + +#endif // REMCONGROUPNAVIGATIONTARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/groupnavigationapi/src/groupnavigationapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/groupnavigationapi/src/groupnavigationapi.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,194 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include + +#include + +#include + +#include "remcongroupnavigation.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_GROUP_NAVIGATION); +#endif + +EXPORT_C CRemConGroupNavigationApiTarget* CRemConGroupNavigationApiTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConGroupNavigationTargetObserver& aObserver) + { + LOG_STATIC_FUNC + + CRemConGroupNavigationApiTarget* self = new(ELeave) CRemConGroupNavigationApiTarget(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CRemConGroupNavigationApiTarget* CRemConGroupNavigationApiTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConGroupNavigationTargetObserver& aObserver,TBool aNextGroupSupported, TBool aPreviousGroupSupported) + { + LOG_STATIC_FUNC + + CRemConGroupNavigationApiTarget* self = new(ELeave) CRemConGroupNavigationApiTarget(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->ConstructL(aNextGroupSupported,aPreviousGroupSupported); + CleanupStack::Pop(self); + return self; + } +CRemConGroupNavigationApiTarget::CRemConGroupNavigationApiTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConGroupNavigationTargetObserver& aObserver) +: CRemConInterfaceBase(TUid::Uid(KRemConGroupNavigationApiUid), + KMaxSizeRemConGroupNavigationMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iObserver(aObserver), iPtr(0,0,0) + { + } + +void CRemConGroupNavigationApiTarget::ConstructL() + { + // Create a output buffer (arbitrary value of 32 for granularity of buffer expansion) + iOutData = CBufFlat::NewL(32); + iOutData->SetReserveL(sizeof(TPckg)); + BaseConstructL(); + } +void CRemConGroupNavigationApiTarget::ConstructL(TBool aNextGroupSupported, TBool aPreviousGroupSupported) + { + // Create a output buffer (arbitrary value of 32 for granularity of buffer expansion) + iOutData = CBufFlat::NewL(32); + iOutData->SetReserveL(sizeof(TPckg)); + + RRemConInterfaceFeatures features; + User::LeaveIfError(features.Open()); + CleanupClosePushL(features); + + if(aNextGroupSupported) + { + features.AddOperationL(ENextGroup); + } + + if(aPreviousGroupSupported) + { + features.AddOperationL(EPreviousGroup); + } + + BaseConstructL(features); + CleanupStack::PopAndDestroy(&features); + } + + +/** Destructor. + +@publishedAll +@released +*/ +EXPORT_C CRemConGroupNavigationApiTarget::~CRemConGroupNavigationApiTarget() + { + delete iOutData; + iStream.Close(); + } + +/** Gets a pointer to a specific interface version. + +@return A pointer to the interface, NULL if not supported. +@internalComponent +@released +*/ +TAny* CRemConGroupNavigationApiTarget::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +EXPORT_C void CRemConGroupNavigationApiTarget::NextGroupResponse(TRequestStatus*& aStatus, TInt aError) + { + SendGroupResponse(ENextGroup, aStatus, aError); + } + +EXPORT_C void CRemConGroupNavigationApiTarget::PreviousGroupResponse(TRequestStatus*& aStatus, TInt aError) + { + SendGroupResponse(EPreviousGroup, aStatus, aError); + } + +void CRemConGroupNavigationApiTarget::SendGroupResponse(TGroupNavigationPassthroughOperationIds aId, TRequestStatus*& aStatus, TInt aError) + { + // format data to be sent + TRAPD(error, iOutData->ResizeL(sizeof(TRemConGroupNavigationResponse))); + if (error != KErrNone) + { + // if this fails, then silently drop response + return; + } + + TRemConGroupNavigationResponse response; + response.iError = aError; + iOutData->Write(0,TPckg(response)); + iPtr.Set(iOutData->Ptr(0)); + + // if a TRequestStatus has been supplied + if (aStatus) + { + InterfaceSelector().Send(*aStatus, TUid::Uid(KRemConGroupNavigationApiUid), aId, iNumRemotes, ERemConResponse, iPtr); + } + else + { + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConGroupNavigationApiUid), aId, ERemConResponse, iPtr); + } + } + +// from MRemConInterfaceIf +void CRemConGroupNavigationApiTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& aData) + { + LOG1(_L("\taOperationId = 0x%02x"), aOperationId); + LOG1(_L("\taData.Length = %d"), aData.Length()); + + /* Decode the get GroupNavigation message */ + TGroupNavigationPassthroughOperationIds currentOp = static_cast(aOperationId); + TRemConCoreApiButtonAction button = static_cast(aData.Ptr()[0]); + + switch (currentOp) + { + case ENextGroup: + { + iObserver.MrcgntoNextGroup( button ); + break; + } + case EPreviousGroup: + { + iObserver.MrcgntoPreviousGroup( button ); + break; + } + default: + break; + + } + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/bwins/remconmediabrowseapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/bwins/remconmediabrowseapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +EXPORTS + ?MrcdumlbFolderListing@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXABV?$TArray@VTRemConItem@@@@I@Z @ 1 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderListing(class TArray const &, unsigned int) + ?MrcdamlbMediaLibraryStateChange@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXG@Z @ 2 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbMediaLibraryStateChange(unsigned short) + ?MrcdumlbSearchResult@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXIH@Z @ 3 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbSearchResult(unsigned int, int) + ?MrcdumlbMediaElementItemResult@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXAB_KABVTDesC8@@EABV?$TArray@VTMediaElementAttribute@@@@H@Z @ 4 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbMediaElementItemResult(unsigned long long const &, class TDesC8 const &, unsigned char, class TArray const &, int) + ?MrcdumlbMediaLibraryStateChange@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXXZ @ 5 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbMediaLibraryStateChange(void) + ?MrcdamlbMediaElementItemResult@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXAB_KABVTDesC8@@EABV?$TArray@VTMediaElementAttribute@@@@H@Z @ 6 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbMediaElementItemResult(unsigned long long const &, class TDesC8 const &, unsigned char, class TArray const &, int) + ?MrcdunpbFolderListing@MRemConDatabaseUnawareNowPlayingBrowse@@QAEXABV?$TArray@VTRemConItem@@@@I@Z @ 7 NONAME ; void MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbFolderListing(class TArray const &, unsigned int) + ?MrcdumlbGetPathResult@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXIH@Z @ 8 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbGetPathResult(unsigned int, int) + ?MrcdumlbFolderUpResult@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXIH@Z @ 9 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderUpResult(unsigned int, int) + ?MrcdamlbFolderDownResult@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXIH@Z @ 10 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderDownResult(unsigned int, int) + ?MrcdumlbFolderDownResult@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXIH@Z @ 11 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderDownResult(unsigned int, int) + ?MrcdamlbFolderItemResult@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXAB_KABVTDesC8@@W4TFolderItemType@@EABV?$TArray@VTMediaElementAttribute@@@@H@Z @ 12 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderItemResult(unsigned long long const &, class TDesC8 const &, enum TFolderItemType, unsigned char, class TArray const &, int) + ?MrcdumlbFolderItemResult@MRemConDatabaseUnawareMediaLibraryBrowse@@QAEXAB_KABVTDesC8@@W4TFolderItemType@@EABV?$TArray@VTMediaElementAttribute@@@@H@Z @ 13 NONAME ; void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderItemResult(unsigned long long const &, class TDesC8 const &, enum TFolderItemType, unsigned char, class TArray const &, int) + ?MrcdamlbFolderListing@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXABV?$TArray@VTRemConItem@@@@GI@Z @ 14 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderListing(class TArray const &, unsigned short, unsigned int) + ?MrcdamlbGetPathResult@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXIGH@Z @ 15 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbGetPathResult(unsigned int, unsigned short, int) + ?MrcdamlbSearchResult@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXIGH@Z @ 16 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbSearchResult(unsigned int, unsigned short, int) + ?MrcdanpbFolderListing@MRemConDatabaseAwareNowPlayingBrowse@@QAEXABV?$TArray@VTRemConItem@@@@GI@Z @ 17 NONAME ; void MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbFolderListing(class TArray const &, unsigned short, unsigned int) + ?MrcdamlbFolderUpResult@MRemConDatabaseAwareMediaLibraryBrowse@@QAEXIH@Z @ 18 NONAME ; void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderUpResult(unsigned int, int) + ?MrcdunpbMediaElementItemResult@MRemConDatabaseUnawareNowPlayingBrowse@@QAEXAB_KABVTDesC8@@EABV?$TArray@VTMediaElementAttribute@@@@H@Z @ 19 NONAME ; void MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbMediaElementItemResult(unsigned long long const &, class TDesC8 const &, unsigned char, class TArray const &, int) + ?NewL@CRemConDatabaseUnawareMediaBrowseTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConDatabaseUnawareMediaLibraryBrowseObserver@@AAVMRemConDatabaseUnawareNowPlayingBrowseObserver@@HAAPAVMRemConDatabaseUnawareMediaLibraryBrowse@@AAPAVMRemConDatabaseUnawareNowPlayingBrowse@@@Z @ 20 NONAME ; class CRemConDatabaseUnawareMediaBrowseTarget * CRemConDatabaseUnawareMediaBrowseTarget::NewL(class CRemConInterfaceSelector &, class MRemConDatabaseUnawareMediaLibraryBrowseObserver &, class MRemConDatabaseUnawareNowPlayingBrowseObserver &, int, class MRemConDatabaseUnawareMediaLibraryBrowse * &, class MRemConDatabaseUnawareNowPlayingBrowse * &) + ?NewL@CRemConDatabaseAwareMediaBrowseTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConDatabaseAwareMediaLibraryBrowseObserver@@AAVMRemConDatabaseAwareNowPlayingBrowseObserver@@HAAPAVMRemConDatabaseAwareMediaLibraryBrowse@@AAPAVMRemConDatabaseAwareNowPlayingBrowse@@G@Z @ 21 NONAME ; class CRemConDatabaseAwareMediaBrowseTarget * CRemConDatabaseAwareMediaBrowseTarget::NewL(class CRemConInterfaceSelector &, class MRemConDatabaseAwareMediaLibraryBrowseObserver &, class MRemConDatabaseAwareNowPlayingBrowseObserver &, int, class MRemConDatabaseAwareMediaLibraryBrowse * &, class MRemConDatabaseAwareNowPlayingBrowse * &, unsigned short) + ?MrcdanpbMediaElementItemResult@MRemConDatabaseAwareNowPlayingBrowse@@QAEXAB_KABVTDesC8@@EABV?$TArray@VTMediaElementAttribute@@@@H@Z @ 22 NONAME ; void MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbMediaElementItemResult(unsigned long long const &, class TDesC8 const &, unsigned char, class TArray const &, int) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/eabi/remconmediabrowseapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/eabi/remconmediabrowseapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +EXPORTS + _ZN36MRemConDatabaseAwareNowPlayingBrowse21MrcdanpbFolderListingERK6TArrayI11TRemConItemEtj @ 1 NONAME + _ZN36MRemConDatabaseAwareNowPlayingBrowse30MrcdanpbMediaElementItemResultERKyRK6TDesC8hRK6TArrayI22TMediaElementAttributeEi @ 2 NONAME + _ZN37CRemConDatabaseAwareMediaBrowseTarget4NewLER24CRemConInterfaceSelectorR46MRemConDatabaseAwareMediaLibraryBrowseObserverR44MRemConDatabaseAwareNowPlayingBrowseObserveriRP38MRemConDatabaseAwareMediaLibraryBrowseRP36MRemConDatabaseAwareNowPlayingBrowset @ 3 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse20MrcdamlbSearchResultEjti @ 4 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse21MrcdamlbFolderListingERK6TArrayI11TRemConItemEtj @ 5 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse21MrcdamlbGetPathResultEjti @ 6 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse22MrcdamlbFolderUpResultEji @ 7 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse24MrcdamlbFolderDownResultEji @ 8 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse24MrcdamlbFolderItemResultERKyRK6TDesC815TFolderItemTypehRK6TArrayI22TMediaElementAttributeEi @ 9 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse30MrcdamlbMediaElementItemResultERKyRK6TDesC8hRK6TArrayI22TMediaElementAttributeEi @ 10 NONAME + _ZN38MRemConDatabaseAwareMediaLibraryBrowse31MrcdamlbMediaLibraryStateChangeEt @ 11 NONAME + _ZN38MRemConDatabaseUnawareNowPlayingBrowse21MrcdunpbFolderListingERK6TArrayI11TRemConItemEj @ 12 NONAME + _ZN38MRemConDatabaseUnawareNowPlayingBrowse30MrcdunpbMediaElementItemResultERKyRK6TDesC8hRK6TArrayI22TMediaElementAttributeEi @ 13 NONAME + _ZN39CRemConDatabaseUnawareMediaBrowseTarget4NewLER24CRemConInterfaceSelectorR48MRemConDatabaseUnawareMediaLibraryBrowseObserverR46MRemConDatabaseUnawareNowPlayingBrowseObserveriRP40MRemConDatabaseUnawareMediaLibraryBrowseRP38MRemConDatabaseUnawareNowPlayingBrowse @ 14 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse20MrcdumlbSearchResultEji @ 15 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse21MrcdumlbFolderListingERK6TArrayI11TRemConItemEj @ 16 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse21MrcdumlbGetPathResultEji @ 17 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse22MrcdumlbFolderUpResultEji @ 18 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse24MrcdumlbFolderDownResultEji @ 19 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse24MrcdumlbFolderItemResultERKyRK6TDesC815TFolderItemTypehRK6TArrayI22TMediaElementAttributeEi @ 20 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse30MrcdumlbMediaElementItemResultERKyRK6TDesC8hRK6TArrayI22TMediaElementAttributeEi @ 21 NONAME + _ZN40MRemConDatabaseUnawareMediaLibraryBrowse31MrcdumlbMediaLibraryStateChangeEv @ 22 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconmediabrowseapi.mmp + +PRJ_EXPORTS +../public/remcondatabaseawaremediabrowsetarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawaremediabrowsetarget.h) +../public/remcondatabaseawaremedialibrarybrowse.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawaremedialibrarybrowse.h) +../public/remcondatabaseawaremedialibrarybrowseobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawaremedialibrarybrowseobserver.h) +../public/remcondatabaseawarenowplayingbrowse.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawarenowplayingbrowse.h) +../public/remcondatabaseawarenowplayingbrowseobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawarenowplayingbrowseobserver.h) + +../public/remcondatabaseunawaremediabrowsetarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawaremediabrowsetarget.h) +../public/remcondatabaseunawaremedialibrarybrowse.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawaremedialibrarybrowse.h) +../public/remcondatabaseunawaremedialibrarybrowseobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawaremedialibrarybrowseobserver.h) +../public/remcondatabaseunawarenowplayingbrowse.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawarenowplayingbrowse.h) +../public/remcondatabaseunawarenowplayingbrowseobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawarenowplayingbrowseobserver.h) + +../public/remconmediaerror.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconmediaerror.h) +../public/remconmediabrowsetypes.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconmediabrowsetypes.h) +../public/remconmediabrowsepanic.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconmediabrowsepanic.h) + +../public/remconmediabrowsetargetbase.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(remcon/remconmediabrowsetargetbase.h) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/group/remconmediabrowseapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/group/remconmediabrowseapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,66 @@ +// Copyright (c) 2008-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: +// remconmediainformationapi.dll Remote Control Media Information API - an outer-layer client side library. +// + + + +/** + @file + @internalComponent +*/ + +TARGET remconmediabrowseapi.dll +TARGETPATH /system/libs + +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x10285bbb +VENDORID 0x70000001 + +SOURCEPATH ../src + +SOURCE remcondatabaseawaremediabrowsetarget.cpp +SOURCE remcondatabaseawaremedialibrarybrowse.cpp +SOURCE remcondatabaseawarenowplayingbrowse.cpp + +SOURCE remcondatabaseunawaremediabrowsetarget.cpp +SOURCE remcondatabaseunawaremedialibrarybrowse.cpp +SOURCE remcondatabaseunawarenowplayingbrowse.cpp + +SOURCE remconmediabrowsetargetbase.cpp +SOURCE remconmediabrowseutils.cpp + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc +USERINCLUDE ../../common + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib +LIBRARY avrcpipc.lib +LIBRARY estor.lib +LIBRARY remconmediainformationapi.lib + +#include +#include + +UNPAGED + +SMPSAFE + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/inc/remconmediabrowsefault.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/inc/remconmediabrowsefault.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#ifndef REMCONMEDIABROWSEFAULT_H +#define REMCONMEDIABROWSEFAULT_H + +#include + +_LIT(KMediaBrowseFaultName, "RcMbFault"); + +enum TRemConMediaBrowseFault + { + EInvalidEventId = 0, + EUnexpectedNextMessageCallback = 1, + EResultErrorCodeMismatch = 2, + EUnexpectedOperationId = 3, + ERequestWithoutMaxResponseBeingSet = 4, + // The cookie update request is only generated by the + // bearer and so should always be correctly formatted + EBadlyFormattedMediaLibraryStateCookieUpdate = 5, + ENonZeroMediaLibraryStateCookie = 6, + }; + +class MediaBrowseFault + { +public: + static void Fault(TRemConMediaBrowseFault aFault); + }; + +#endif //REMCONMEDIABROWSEFAULT_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawaremediabrowsetarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawaremediabrowsetarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,102 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEAWAREMEDIABROWSETARGET_H +#define REMCONDATABASEAWAREMEDIABROWSETARGET_H + +#include +#include +#include +#include +#include +#include + +NONSHARABLE_CLASS(CRemConDatabaseAwareMediaBrowseTarget) : public CRemConMediaBrowseTargetBase, + private MRemConDatabaseAwareMediaLibraryBrowse, private MRemConDatabaseAwareNowPlayingBrowse + { +public: + IMPORT_C static CRemConDatabaseAwareMediaBrowseTarget* NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseAwareNowPlayingBrowseObserver& aNpObserver, + TBool aSearchSupported, + MRemConDatabaseAwareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseAwareNowPlayingBrowse*& aNpInterface, + TUint16 aMediaLibraryStateCookie); + virtual ~CRemConDatabaseAwareMediaBrowseTarget(); + +private: + // from MRemConDatabaseAwareMediaLibraryBrowse + virtual void MrcdamlbDoFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult); + + virtual void MrcdamlbDoFolderUpResult(TUint aItemCount, TInt aResult); + virtual void MrcdamlbDoFolderDownResult(TUint aItemCount, TInt aResult); + + virtual void MrcdamlbDoGetPathResult(TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + virtual void MrcdamlbDoSearchResult(TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + virtual void MrcdamlbDoMediaLibraryStateChange(TUint16 aMediaLibraryStateCookie); + + virtual void MrcdamlbDoFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult); + + virtual void MrcdamlbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + + // from MRemConDatabaseAwareNowPlayingBrowse + virtual void MrcdanpbDoFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult); + + virtual void MrcdanpbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: + CRemConDatabaseAwareMediaBrowseTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseAwareNowPlayingBrowseObserver& aNpObserver, + MRemConDatabaseAwareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseAwareNowPlayingBrowse*& aNpInterface, + TUint16 aMediaLibraryStateCookie); + void ConstructL(TBool aSearchSupported); + }; + +#endif //REMCONDATABASEAWAREMEDIABROWSETARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawaremedialibrarybrowse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawaremedialibrarybrowse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,95 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include + +#ifndef REMCONDATABASEAWAREMEDIALIBRARYBROWSE_H +#define REMCONDATABASEAWAREMEDIALIBRARYBROWSE_H + +NONSHARABLE_CLASS(MRemConDatabaseAwareMediaLibraryBrowse) + { +public: + IMPORT_C void MrcdamlbFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult); + + IMPORT_C void MrcdamlbFolderUpResult(TUint aItemCount, TInt aResult); + IMPORT_C void MrcdamlbFolderDownResult(TUint aItemCount, TInt aResult); + + IMPORT_C void MrcdamlbGetPathResult(TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + IMPORT_C void MrcdamlbSearchResult(TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + IMPORT_C void MrcdamlbMediaLibraryStateChange(TUint16 aMediaLibraryStateCookie); + + IMPORT_C void MrcdamlbFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult); + + IMPORT_C void MrcdamlbMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: + virtual void MrcdamlbDoFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult) = 0; + + virtual void MrcdamlbDoFolderUpResult(TUint aItemCount, TInt aResult) = 0; + virtual void MrcdamlbDoFolderDownResult(TUint aItemCount, TInt aResult) = 0; + + virtual void MrcdamlbDoGetPathResult(TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult) = 0; + + virtual void MrcdamlbDoSearchResult(TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult) = 0; + + virtual void MrcdamlbDoMediaLibraryStateChange(TUint16 aMediaLibraryStateCookie) = 0; + + virtual void MrcdamlbDoFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) = 0; + + virtual void MrcdamlbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) = 0; + }; + +#endif // REMCONDATABASEAWAREMEDIALIBRARYBROWSE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawaremedialibrarybrowseobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawaremedialibrarybrowseobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,174 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include + +#ifndef REMCONDATABASEAWAREMEDIALIBRARYBROWSEOBSERVER_H +#define REMCONDATABASEAWAREMEDIALIBRARYBROWSEOBSERVER_H + +NONSHARABLE_CLASS(MRemConDatabaseAwareMediaLibraryBrowseObserver) + { +public: + /** + This requests a list of the items present in a folder. No metadata is + requested, that can be retrieved separately on a per item basis. + + The result should be returned via a call to + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderListing(). And + the ordering should be as shown locally, but should list folders before + media element items. + + @param aScope The scope in which the folder listing is made. + This indicates which listing should be returned. If the scope is + EBrowseFolder then the contents of the current browsed folder + should be returned. If it is the ESearchResultFolder scope then + the contents of the folder populated by the last search should be + returned. + + @param aStartItem The offset into the folder listing of the first item to + retrieve. If there is no media available at this offset the error + KErrMediaBrowseInvalidOffset should be returned via the result call + to MrcdamlbFolderListing(). + + @param aEndItem The offset into the folder listing of the final item to + retrieve. If this is beyond the end of the folder listing then the + items from the aStartItem offset to the end of the listing should + be returned via the result call to MrcdamlbFolderListing(). + */ + virtual void MrcdamlboGetFolderListing(TRemConFolderScope aScope, + TUint aStartItem, + TUint aEndItem) = 0; + + /** + Requests a specific item which may be a folder item or a media element + item. + + If it returns KErrNone the client must return the metadata for the + requested item through the response function either + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderItemResult() + or + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbMediaElementItemResult() + according to the item type which is a folder item or media element item. + If it is unable to process this call then it can return error but not + call the response function. + + @param aScope The scope in which the item is present. If the scope is + EBrowseFolder then the item is present in the media library's + virtual filesystem. If it is the ESearchResultFolder scope then the + item is present in the current set of search results. + + @param aItemId The UID for the requested Item. + + @param aIter An iterator for TMediaAttributeIds containing a list of + TMediaAttributeIds requested by the controller. It is intended for + the media element item, so omit it if the item is a folder item. + + @param aMediaLibraryStateCookie The cookie which the remote device + believes refers to the current state of the media library. If this + does not match the current state according to the client then the + client shall call + MrcdamlbFolderItemResult() or MrcdamlbMediaElementItemResult() to + return the error KErrInvalidMediaLibraryStateCookie according it + is a folder item or a media element item. + @return The call back result. + - KErrNone If success. + - The appropriate error code. + */ + virtual TInt MrcdamlboGetItem(TRemConFolderScope aScope, + const TRemConItemUid& aItemId, + TMediaAttributeIter& aIter, + TUint16 aMediaLibraryStateCookie) = 0; + + /** + This requests that the current position within the folder heirarchy is + moved to the next folder up. + + The result of this operation must be returned via a call to + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderUpResult. + + @param aMediaLibraryStateCookie The cookie which the remote device + believes refers to the current state of the media library. If this + does not match the current state according to the client then the + client should call + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderUpResult with + the error KErrInvalidMediaLibraryStateCookie. + */ + virtual void MrcdamlboFolderUp(TUint16 aMediaLibraryStateCookie) = 0; + + /** + This requests that the current position within the folder hierarchy is + moved to the child folder of the current folder specified by aFolder. + + The result of this operation must be returned via a call to + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderDownResult. + + @param aFolder The child folder to change into. + + @param aMediaLibraryStateCookie The cookie which the remote device + believes refers to the current state of the media library. If this + does not match the current state according to the client then the + client should call + MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderDownResult() + with the error KErrInvalidMediaLibraryStateCookie. + */ + virtual void MrcdamlboFolderDown(const TRemConItemUid& aFolder, + TUint16 aMediaLibraryStateCookie) = 0; + + /** + This requests the current path. + + The client is responsible for appending items to the array then call + MrcdamlbGetPathResult() when completed. Once the item is appended in the + array the ownership of the item is taken so the client should keep the + item valid and never destroy the item. If the client can append the items + successfully then it should return a result via MrcdamlbGetPathResult(). + If the client appends some items to the array but then fails to append all + the items then it should return an error via MrcdamlbGetPathResult(). + + @see MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbGetPathResult() + + @param aPath The current path. + Each entry in the array in one level of the path. For example the + path /A/B/C would be provided as: + aPath[0] 'A' + aPath[1] 'B' + aPath[2] 'C' + All string are in UTF-8. + */ + virtual void MrcdamlboGetPath(RPointerArray& aPath) = 0; + + /** + Perform a search in the current location for items + matching the search string. + + @param aSearch The string to search on in UTF-8. The client can use it until + the client has called MrcdamlbSearchResult(). + + @see MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbSearchResult() + */ + virtual void MrcdamlboSearch(const TDesC8& aSearch) = 0; + }; + + +#endif // REMCONDATABASEAWAREMEDIALIBRARYBROWSEOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawarenowplayingbrowse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawarenowplayingbrowse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,56 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include + +#ifndef REMCONDATABASEAWARENOWPLAYINGBROWSE_H +#define REMCONDATABASEAWARENOWPLAYINGBROWSE_H + +NONSHARABLE_CLASS(MRemConDatabaseAwareNowPlayingBrowse) + { +public: + IMPORT_C void MrcdanpbFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult); + + IMPORT_C void MrcdanpbMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: + virtual void MrcdanpbDoFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult) = 0; + + virtual void MrcdanpbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) = 0; + }; + +#endif //REMCONDATABASEAWARENOWPLAYINGBROWSE_H + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawarenowplayingbrowseobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseawarenowplayingbrowseobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,87 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEAWARENOWPLAYINGBROWSEOBSERVER_H +#define REMCONDATABASEAWARENOWPLAYINGBROWSEOBSERVER_H + +NONSHARABLE_CLASS(MRemConDatabaseAwareNowPlayingBrowseObserver) + { +public: + /** + Requests a listing of the items present in the Now Playing folder. If the + media player does not natively support a Now Plyaing folder the client + shall return a listing of one item which is the currently playing media + element. + + No metadata is requested, that can be retrieved separately on a per item + basis. Trying this out for now as it fits in with the existing metadata + attribute collection, and means that we would also separate out the + listing from the metadata. This means that we can retrieve a NowPlaying + list and then request the metadata from the observer. + + The result shall be returned via a call to + MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbFolderListing() + + @param aStartItem The offset into the folder listing of the first item to + retrieve. If there is no media available at this offset the error + KErrMediaBrowseInvalidOffset shall be returned via the result call + to MrcdanpbFolderListing(). + + @param aEndItem The offset into the folder listing of the final item to + retrieve. If this is beyond the end of the folder listing then the + items from the aStartItem offset to the end of the listing shall + be returned via the result call to MrcdanpbFolderListing(). + */ + virtual void MrcdanpboGetFolderListing(TUint aStartItem, + TUint aEndItem) = 0; + + /** + Requests a set of metadata corresponding to a specific media element item. + + The client must return the metadata for the requested item via using + MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbMediaElementItemResult() if + it returns KErrNone, if it is unable to to process this call then it can + return error but not call the response function + MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbMediaElementItemResult(). + + @param aItemId The UID for the requested media element item. + + @param aIter An iterator for TMediaAttributeIds containing a list of + TMediaAttributeIds requested by the controller. + + @param aMediaLibraryStateCookie The cookie which the remote device + believes refers to the current state of the media library. If this + does not match the current state according to the client then the + client should call MrcdanpbMediaElementItemResult() with the error + KErrInvalidMediaLibraryStateCookie. + + @return The call back result. + - KErrNone If success. + - The appropriate error code. + */ + virtual TInt MrcdanpboGetItem(const TRemConItemUid& aItemId, + TMediaAttributeIter& aIter, + TUint16 aMediaLibraryStateCookie) = 0; + }; + +#endif //REMCONDATABASEAWARENOWPLAYINGBROWSEOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawaremediabrowsetarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawaremediabrowsetarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,98 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEUNAWAREMEDIABROWSETARGET_H +#define REMCONDATABASEUNAWAREMEDIABROWSETARGET_H + +#include +#include +#include +#include +#include +#include + +NONSHARABLE_CLASS(CRemConDatabaseUnawareMediaBrowseTarget) : public CRemConMediaBrowseTargetBase, +private MRemConDatabaseUnawareMediaLibraryBrowse, private MRemConDatabaseUnawareNowPlayingBrowse + { +public: + IMPORT_C static CRemConDatabaseUnawareMediaBrowseTarget* NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseUnawareNowPlayingBrowseObserver& aNpObserver, + TBool aSearchSupported, + MRemConDatabaseUnawareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseUnawareNowPlayingBrowse*& aNpInterface); + + virtual ~CRemConDatabaseUnawareMediaBrowseTarget(); + +private: + // from MRemConDatabaseUnawareMediaLibraryBrowse + virtual void MrcdumlbDoFolderListing(const TArray& aFolderListing, + TUint aResult); + + virtual void MrcdumlbDoFolderUpResult(TUint aItemCount, TInt aResult); + virtual void MrcdumlbDoFolderDownResult(TUint aItemCount, TInt aResult); + + virtual void MrcdumlbDoGetPathResult(TUint aItemCount, + TInt aResult); + + virtual void MrcdumlbDoSearchResult(TUint aNumberItemsFound, + TInt aResult); + + virtual void MrcdumlbDoMediaLibraryStateChange(); + + virtual void MrcdumlbDoFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult); + + virtual void MrcdumlbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + + // from MRemConDatabaseUnawareNowPlayingBrowse + virtual void MrcdunpbDoFolderListing(const TArray& aFolderListing, + TUint aResult); + + virtual void MrcdunpbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: + CRemConDatabaseUnawareMediaBrowseTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseUnawareNowPlayingBrowseObserver& aNpObserver, + MRemConDatabaseUnawareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseUnawareNowPlayingBrowse*& aNpInterface); + + void ConstructL(TBool aSearchSupported); + }; + +#endif //REMCONDATABASEUNAWAREMEDIABROWSETARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawaremedialibrarybrowse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawaremedialibrarybrowse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include + +#ifndef REMCONDATABASEUNAWAREMEDIALIBRARYBROWSE_H +#define REMCONDATABASEUNAWAREMEDIALIBRARYBROWSE_H + +NONSHARABLE_CLASS(MRemConDatabaseUnawareMediaLibraryBrowse) + { +public: + IMPORT_C void MrcdumlbFolderListing(const TArray& aFolderListing, + TUint aResult); + + IMPORT_C void MrcdumlbFolderUpResult(TUint aItemCount, TInt aResult); + IMPORT_C void MrcdumlbFolderDownResult(TUint aItemCount, TInt aResult); + + IMPORT_C void MrcdumlbGetPathResult(TUint aItemCount, + TInt aResult); + + IMPORT_C void MrcdumlbSearchResult(TUint aNumberItemsFound, + TInt aResult); + + IMPORT_C void MrcdumlbMediaLibraryStateChange(); + + IMPORT_C void MrcdumlbFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult); + + IMPORT_C void MrcdumlbMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: + virtual void MrcdumlbDoFolderListing(const TArray& aFolderListing, + TUint aResult) = 0; + + virtual void MrcdumlbDoFolderUpResult(TUint aItemCount, TInt aResult) = 0; + virtual void MrcdumlbDoFolderDownResult(TUint aItemCount, TInt aResult) = 0; + + virtual void MrcdumlbDoGetPathResult(TUint aItemCount, + TInt aResult) = 0; + + virtual void MrcdumlbDoSearchResult(TUint aNumberItemsFound, + TInt aResult) = 0; + + virtual void MrcdumlbDoMediaLibraryStateChange() = 0; + + virtual void MrcdumlbDoFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) = 0; + + virtual void MrcdumlbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) = 0; + }; + +#endif //REMCONDATABASEUNAWAREMEDIALIBRARYBROWSE_H + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawaremedialibrarybrowseobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawaremedialibrarybrowseobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,147 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEUNAWAREMEDIALIBRARYBROWSEOBSERVER_H +#define REMCONDATABASEUNAWAREMEDIALIBRARYBROWSEOBSERVER_H + +NONSHARABLE_CLASS(MRemConDatabaseUnawareMediaLibraryBrowseObserver) + { +public: + /** + This requests a list of the items present in a folder. No metadata is + requested, that can be retrieved separately on a per item basis. + + The result should be returned via a call to + MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderListing(). And + the ordering should be as shown locally, but should list folders before + media element items. + + @param aScope The scope in which the folder listing is made. + This indicates which listing should be returned. If the scope is + EBrowseFolder then the contents of the current browsed + folder should be returned. If it is the ESearchResultFolder scope + then the contents of the folder populated by the last search + should be returned. + + @param aStartItem The offset into the folder listing of the first item to + retrieve. If there is no media available at this offset the error + KErrMediaBrowseInvalidOffset should be returned via the result call + to MrcdumlbFolderListing(). + + @param aEndItem The offset into the folder listing of the final item to + retrieve. If this is beyond the end of the folder listing then the + items from the aStartItem offset to the end of the listing should + be returned via the result call to MrcdumlbFolderListing(). + */ + virtual void MrcdumlboGetFolderListing(TRemConFolderScope aScope, + TUint aStartItem, + TUint aEndItem) = 0; + + /** + Requests a specific item which may be a folder item or a media element + item. + + If it returns KErrNone the client must return the metadata for the + requested item through the response function either + MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderItemResult() + or + MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbMediaElementItemResult() + according to the item type which is a folder item or media element item. + If it is unable to process this call then it can return error but not + call the response function. + + @param aScope The scope in which the item is present. If the scope is + EBrowseFolder then the item is present in the media library's + virtual filesystem. If it is the ESearchResultFolder scope then the + item is present in the current set of search results. + + @param aItemId The UID for the requested Item. + + @param aIter An iterator for TMediaAttributeIds containing a list of + TMediaAttributeIds requested by the controller. It is intended for + the media element item, so omit it if the item is a folder item. + + @return The call back result. + - KErrNone If success. + - The appropriate error code. + */ + virtual TInt MrcdumlboGetItem(TRemConFolderScope aScope, + const TRemConItemUid& aItemId, + TMediaAttributeIter& aIter) = 0; + + /** + This requests that the current position within the folder heirarchy is + moved to the next folder up. + + The result of this operation must be returned via a call to + MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderUpResult(). + */ + virtual void MrcdumlboFolderUp() = 0; + + /** + This requests that the current position within the folder hierarchy is + moved to the child folder of the current folder specified by aFolder. + + The result of this operation must be returned via a call to + MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderDownResult(). + + @param aFolder The child folder to change into. + */ + virtual void MrcdumlboFolderDown(const TRemConItemUid& aFolder) = 0; + + /** + This requests the current path. + + The client is responsible for appending items to the array then call + MrcdumlbGetPathResult() when completed. Once the item is appended in the + array the ownership of the item is taken so the client should keep the + item valid and never destroy the item. If the client can append the items + successfully then it must return a result via MrcdumlbGetPathResult(). + If the client appends some items to the array but then fails to append all + the items then it must return an error via MrcdumlbGetPathResult(). + + @see MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbGetPathResult() + + @param aPath The current path. + Each entry in the array in one level of the path. For example the + path /A/B/C would be provided as: + aPath[0] 'A' + aPath[1] 'B' + aPath[2] 'C' + All string are in UTF-8. + */ + virtual void MrcdumlboGetPath(RPointerArray& aPath) = 0; + + /** + Perform a search in the current location for items + matching the search string. + + @param aSearch The string to search on in UTF-8. The client can use it until + the client has called MrcdumlbSearchResult(). + + @see MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbSearchResult() + */ + virtual void MrcdumlboSearch(const TDesC8& aSearch) = 0; + }; + +#endif //REMCONDATABASEUNAWAREMEDIALIBRARYBROWSEOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawarenowplayingbrowse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawarenowplayingbrowse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include + +#ifndef REMCONDATABASEUNAWARENOWPLAYINGBROWSE_H +#define REMCONDATABASEUNAWARENOWPLAYINGBROWSE_H + +NONSHARABLE_CLASS(MRemConDatabaseUnawareNowPlayingBrowse) + { +public: + IMPORT_C void MrcdunpbFolderListing(const TArray& aFolderListing, + TUint aResult); + + IMPORT_C void MrcdunpbMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: + virtual void MrcdunpbDoFolderListing(const TArray& aFolderListing, + TUint aResult) = 0; + + virtual void MrcdunpbDoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) = 0; + }; + +#endif //REMCONDATABASEUNAWARENOWPLAYINGBROWSE_H + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawarenowplayingbrowseobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remcondatabaseunawarenowplayingbrowseobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,80 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEUNAWARENOWPLAYINGBROWSEOBSERVER_H +#define REMCONDATABASEUNAWARENOWPLAYINGBROWSEOBSERVER_H + +NONSHARABLE_CLASS(MRemConDatabaseUnawareNowPlayingBrowseObserver) + { +public: + /** + Requests a listing of the items present in the Now Playing folder. If the + media player does not natively support a Now Plyaing folder the client + shall return a listing of one item which is the currently playing media + element. + + No metadata is requested, that can be retrieved separately on a per item + basis. Trying this out for now as it fits in with the existing metadata + attribute collection, and means that we would also separate out the + listing from the metadata. This means that we can retrieve a NowPlaying + list and then request the metadata from the observer. + + The result should be returned via a call to + MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbFolderListing(). + + @param aStartItem The offset into the folder listing of the first item to + retrieve. If there is no media available at this offset the error + KErrMediaBrowseInvalidOffset should be returned via the result call + to MrcdunpbFolderListing(). + + @param aEndItem The offset into the folder listing of the final item to + retrieve. If this is beyond the end of the folder listing then the + items from the aStartItem offset to the end of the listing should + be returned via the result call to MrcdunpbFolderListing(). + */ + virtual void MrcdunpboGetFolderListing(TUint aStartItem, + TUint aEndItem) = 0; + + /** + Requests a set of metadata corresponding to a specific media element item. + + The client must return the metadata for the requested item via using + MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbMediaElementItemResult() + if it returns KErrNone, if it is unable to process this call then it can + return error but not call the response function + MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbMediaElementItemResult(). + + @param aItemId The UID for the requested media element item. + + @param aIter An iterator for TMediaAttributeIds containing a list of + TMediaAttributeIds requested by the controller. + + @return The call back result. + - KErrNone If success. + - The appropriate error code. + */ + virtual TInt MrcdunpboGetItem(const TRemConItemUid& aItemId, + TMediaAttributeIter& aIter) = 0; + }; + +#endif //REMCONDATABASEUNAWARENOWPLAYINGBROWSEOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediabrowsepanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediabrowsepanic.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIABROWSEPANIC_H +#define REMCONMEDIABROWSEPANIC_H + +#include + +_LIT(KMediaBrowsePanicName, "RcMediaBrowse"); + +enum TRemConMediaBrowsePanic + { + EFolderListingProvidedTwice = 0, + EFolderItemResultWithoutRequest = 1, + EInvalidFolderType = 2, + EInvalidPlayableValue = 3, + EInvalidMediaType = 4, + EMediaElementItemResultWithoutRequest = 5, + ESearchResultWithoutRequest = 6, + /** The value of the media library state cookie must not be zero. */ + EZeroMediaLibraryStateCookie = 7, + }; + +class MediaBrowsePanic + { +public: + static void Panic(TRemConMediaBrowsePanic aPanic); + }; + +#endif //REMCONMEDIABROWSEPANIC_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediabrowsetargetbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediabrowsetargetbase.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,217 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIABROWSETARGETBASE_H +#define REMCONMEDIABROWSETARGETBASE_H + +#include +#include +#include +#include +#include +#include +#include + +class RRemConGetFolderItemsResponse; +class RRemConGetItemAttributesResponse; +class RRemConGetPathResponse; +class TRemConMessageQueue; +/** +This interface enables the client to present a heirarchical view +of the local media library for browsing by a remote entity. + +The view is a virtual filesystem and does not need to correspond +directly to any structure on local storage. It could for example +map onto a database of media content. + +Each item in the media library is identified by a UID. At a +minimum this must uniquely identify an element within a folder. +For clients that support it the UID can be persistant accross +the entire virtual filesystem. In this case a media library +state cookie is used to ensure that that state is consistent +between the client and the remote device. + +This interface does not have NewL()/NewLC, so the client should +use the object CRemConDatabaseAwareMediaBrowseTarget or +CRemConDatabaseUnawareMediaBrowseTarget to use its exported functions. + +This class is only to be used by classes currently derived from it. + +@see CRemConDatabaseAwareMediaBrowseTarget +@see CRemConDatabaseUnawareMediaBrowseTarget +*/ +NONSHARABLE_CLASS(CRemConMediaBrowseTargetBase) : public CRemConInterfaceBase, public MRemConInterfaceIf + { +protected: + CRemConMediaBrowseTargetBase(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseAwareNowPlayingBrowseObserver& aNpObserver, + TUint16 aMediaLibraryStateCookie); + + CRemConMediaBrowseTargetBase(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseUnawareNowPlayingBrowseObserver& aNpObserver); + + virtual ~CRemConMediaBrowseTargetBase(); + + virtual void BaseConstructL(TBool aSearchSupported); + + void DoFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + void DoFolderUpResult(TUint aItemCount, TInt aResult); + void DoFolderDownResult(TUint aItemCount, TInt aResult); + + void DoGetPathResult(TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + void DoSearchResult(TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult); + + void DoMediaLibraryStateChange(TUint16 aMediaLibraryStateCookie); + + void DoFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult); + + void DoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + +private: // From CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // From MRemConInterfaceIf + void MrcibNewMessage(TUint aOperationId, + const TDesC8& aData); + +private: // Utility + void ProcessGetFolderItems(const TDesC8& aData); + void ProcessChangePath(const TDesC8& aData); + void ProcessGetItemAttributes(const TDesC8& aData); + void ProcessSearch(const TDesC8& aData); + void ProcessGetPath(const TDesC8& aData); + void ProcessMediaLibraryStateCookieUpdate(const TDesC8& aData); + + void SendGetItemAttributesResponse(TInt aResult, const TDesC8& aData); + void SendGetFolderItemsResponse(TInt aResult, const TDesC8& aData); + void SendChangePathResponse(TUint aItemCount, TInt aResult); + void SendInternalNotificationResponse(TRemConMessageSubType aMsgSubType); + void SendNotificationResponse(TRemConMessageSubType aMsgSubType); + void SendSearchResponse(TInt aResult, TUint aNumberItemsFound, TUint16 aMediaLibraryStateCookie); + void SendMediaLibraryStateCookieUpdateResponse(TUint16 aMediaLibraryStateCookie); + + static TInt NextMessageCb(TAny* aThis); + void DoNextMessage(); + + static TInt NextItemCallBack(TAny* aThis); + void RequestNextItem(); + void DoItemComplete(TInt aResult); + + void SendError(TUint8 aPduId, + TUint aOperationId, + TInt aError); + + // Used for Gia + TInt ItemAttributesResult(const TArray& aAttributes); + TInt DoAttributeValue(TMediaAttributeId aAttributeId, const TDesC8& aAttributeData); + void DoAllAttributesCompleted(TInt aResult); + + void AddToOperationQueue(TUint8 aPduId, + TInt aOperationId, + const TDesC8& aData); + TInt ParseGetItemAttributesRequest(const TDesC8& aData, + TRemConFolderScope& aScope, + TRemConItemUid& aItemUid, + TUint16& aMediaLibraryStateCookie); + void ProcessMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult); + void ProcessFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + TInt aResult); + void ProcessGetItemAttributesResult( + const TArray& aAttributes, + TInt aResult); + + inline TBool DatabaseAware() const; + +private: + // Unowned + CRemConInterfaceSelector& iInterfaceSelector; + + MRemConDatabaseAwareMediaLibraryBrowseObserver* iRcdamlbo; + MRemConDatabaseUnawareMediaLibraryBrowseObserver* iRcdumlbo; + + MRemConDatabaseAwareNowPlayingBrowseObserver* iRcdanpbo; + MRemConDatabaseUnawareNowPlayingBrowseObserver* iRcdunpbo; + + // Owned + CAsyncCallBack* iNextMessageCallBack; + CAsyncCallBack* iNextItemCallBack; + + RBuf8 iOutBuf; + + TUint16 iMediaLibraryStateCookie; + + TBool iInProgress; // used internally to see if any operation is in progress + TRemConMessageQueue* iMsgQueue; // used to queue messages if another operation is in progress + + RArray iMediaAttributeIds; // used for Gfl and Gia to store requested attributes + TMediaAttributeIter iAttributeIterator; // provided to the client on requesting item attributes for Gfl and Gia + + RArray iNullArray; + TMediaAttributeIter iNullIterator; // Used for getting a folder item to perform a folder listing + + TBool iGetFolderListing; // used to check Gfl is in progress + RRemConGetFolderItemsResponse* iGflResponse; // used to build up Gfl response from client + TRemConFolderScope iScope; // stored for use in async callbacks to get folder items + + TBool iGetItemAttributes; // used to check Gia is in progress + TBool iSetAttributeValue; // used to check that client has set response if it returns KErrNone + RRemConGetItemAttributesResponse* iGiaResponse; // used to build up Gia response from client + + TBool iSearchSupported; + TBool iSearchInProgress; // used to check Search is in progress + RBuf8 iSearchString; // used to store search string until request is complete + + RRemConGetPathResponse* iGetPathResponse; // used to build up get path response + + TBool iMlscUpdatePending; + TUint16 iLastMlscUpdate; + }; + +#endif // REMCONMEDIABROWSETARGETBASE_H + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediabrowsetypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediabrowsetypes.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,118 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIABROWSETYPES_H +#define REMCONMEDIABROWSETYPES_H + +#include +#include + +/** +Defines a type representing a UID which is 8 octet and uniquely identifys +a folder or media element in the media library. +*/ +typedef TUint64 TRemConItemUid; + +/** +Defines item types to indicate the item is a folder item or media item. +*/ +enum TRemConItemType + { + ERemConFolderItem = 2, + ERemConMediaItem = 3, + }; + +class TRemConItem + { +public: + TRemConItemUid iUid; + TRemConItemType iType; + }; + +/** +Defines a type which indicates whether a folder item is playable. +*/ +typedef TUint8 TFolderItemPlayable; + +/** +Defines a type to indicate a media item type. +*/ +typedef TUint8 TMediaItemType; + +const TFolderItemPlayable KFolderNotPlayable = 0; +const TFolderItemPlayable KFolderPlayable = 1; + +const TMediaItemType KMediaAudio = 0; +const TMediaItemType KMediaVideo = 1; + +enum TFolderItemType + { + EFolderMixed = 0, + EFolderTitles = 1, + EFolderAlbums = 2, + EFolderArtists = 3, + EFolderGenres = 4, + EFolderPlaylists = 5, + EFolderYears = 6, + }; + +/** +Defines folder scopes in which media content navigaition may take place. +*/ +enum TRemConFolderScope + { + /** + Applicable in browsed player. + Valid browseable items are foler item and media element item. + */ + EBrowseFolder = 0x1, + + /** + Applicable in browsed player. + Valid browseable items are media element items. + */ + ESearchResultFolder = 0x2, + + /** + Applicable in addressed player. + Valid browseable items are media element items. + */ + ENowPlayingFolder = 0x3 + }; + +/** +A data container of a media element attribute. + +*/ +class TMediaElementAttribute + { +public: + TMediaAttributeId iAttributeId; + + /** + The value of the attribute in UTF-8. + */ + HBufC8* iString; + }; + +#endif //REMCONMEDIABROWSETYPES_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediaerror.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/public/remconmediaerror.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,97 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIAERROR_H_ +#define REMCONMEDIAERROR_H_ + +#include + +const TInt KErrRemConMediaBase = -6780; + +/** +Invalid media library state cookie. + +This error only occurs in the database aware clients. +*/ +const TInt KErrInvalidMediaLibraryStateCookie = KErrRemConMediaBase - 0x5; + +/** +The direction parameter is invalid + +@see MrcdamlbFolderDownResult() +@see MrcdumlbFolderDownResult() +*/ +const TInt KErrMediaBrowseInvalidDirection = KErrRemConMediaBase - 0x7; + +/** +The UID provided does not refer to a folder item + +@see MrcdamlbFolderDownResult() +@see MrcdumlbFolderDownResult() +*/ +const TInt KErrMediaBrowseNotADirectory = KErrRemConMediaBase - 0x8; + +/** +The UID provided does not refer to any currently valid item + +@see MrcdamlbFolderDownResult() +@see MrcdumlbFolderDownResult() +@see MrcdamlbFolderItemResult() +@see MrcdumlbFolderItemResult() +@see MrcdamlbMediaElementItemResult() +@see MrcdumlbMediaElementItemResult() +@see MrcdanpbMediaElementItemResult() +@see MrcdunpbMediaElementItemResult() +*/ +const TInt KErrInvalidUid = KErrRemConMediaBase - 0x9; + +/** +The start of range provided is not valid + +@see MrcdamlbFolderListing() +@see MrcdumlbFolderListing() +@see MrcdanpbFolderListing() +@see MrcdunpbFolderListing() +*/ +const TInt KErrMediaBrowseInvalidOffset = KErrRemConMediaBase - 0xb; + +/** +The UID provided refers to a directory +which cannot be handled by this media player. + +*/ +const TInt KErrNowPlayingUidIsADirectory = KErrRemConMediaBase - 0xc; + +/** +The media is not able to be used for this operation at this time + +*/ +const TInt KErrNowPlayingMediaInUse = KErrRemConMediaBase - 0xd; + +/** +No more items can be added to the now playing list because it is full + +*/ +const TInt KErrNowPlayingListFull = KErrRemConMediaBase - 0xe; + +#endif /*REMCONMEDIAERROR_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseawaremediabrowsetarget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseawaremediabrowsetarget.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,145 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +EXPORT_C CRemConDatabaseAwareMediaBrowseTarget* CRemConDatabaseAwareMediaBrowseTarget::NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseAwareNowPlayingBrowseObserver& aNpObserver, + TBool aSearchSupported, + MRemConDatabaseAwareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseAwareNowPlayingBrowse*& aNpInterface, + TUint16 aMediaLibraryStateCookie) + { + CRemConDatabaseAwareMediaBrowseTarget* self = new(ELeave)CRemConDatabaseAwareMediaBrowseTarget( + aInterfaceSelector, aMlObserver, aNpObserver, aMlInterface, aNpInterface, aMediaLibraryStateCookie); + CleanupStack::PushL(self); + self->ConstructL(aSearchSupported); + CleanupStack::Pop(self); + return self; + } + +CRemConDatabaseAwareMediaBrowseTarget::CRemConDatabaseAwareMediaBrowseTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseAwareNowPlayingBrowseObserver& aNpObserver, + MRemConDatabaseAwareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseAwareNowPlayingBrowse*& aNpInterface, + TUint16 aMediaLibraryStateCookie) + : CRemConMediaBrowseTargetBase(aInterfaceSelector, aMlObserver, aNpObserver, aMediaLibraryStateCookie) + { + aMlInterface = static_cast(this); + aNpInterface = static_cast(this); + } + +void CRemConDatabaseAwareMediaBrowseTarget::ConstructL( + TBool aSearchSupported) + { + BaseConstructL(aSearchSupported); + } + +CRemConDatabaseAwareMediaBrowseTarget::~CRemConDatabaseAwareMediaBrowseTarget() + { + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoFolderListing( + const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult) + { + DoFolderListing(aFolderListing, aMediaLibraryStateCookie, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoFolderUpResult( + TUint aItemCount, TInt aResult) + { + DoFolderUpResult(aItemCount, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoFolderDownResult( + TUint aItemCount, TInt aResult) + { + DoFolderDownResult(aItemCount, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoGetPathResult( + TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + DoGetPathResult(aItemCount, aMediaLibraryStateCookie, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoSearchResult( + TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + DoSearchResult(aNumberItemsFound, aMediaLibraryStateCookie, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoMediaLibraryStateChange( + TUint16 aMediaLibraryStateCookie) + { + DoMediaLibraryStateChange(aMediaLibraryStateCookie); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoFolderItemResult( + const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) + { + DoFolderItemResult(aFolderID,aFolderName, aFolderType, aPlayable, aAttributes, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdamlbDoMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + DoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdanpbDoFolderListing( + const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult) + { + DoFolderListing(aFolderListing, aMediaLibraryStateCookie, aResult); + } + +void CRemConDatabaseAwareMediaBrowseTarget::MrcdanpbDoMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + DoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseawaremedialibrarybrowse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseawaremedialibrarybrowse.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,205 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +/** +Called by the client in response to a MrcdamlboGetFolderListing() call. + +@param aFolderListing A listing of the items that are + in the range requested by the MrcdamlboGetFolderListing() call. + +@param aMediaLibraryStateCookie The current value of the state cookie. + +@param aResult The result of the MrcdamlboGetFolderListing() operation. + - KErrNone if the operation was successful. + - KErrMediaBrowseInvalidOffset if there is no media available at the + offset of the start item, i.e. the start of range provided via + MrcdamlboGetFolderListing() is not valid. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderListing( + const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult) + { + MrcdamlbDoFolderListing(aFolderListing, aMediaLibraryStateCookie, aResult); + } + +/** +Called by the client in response to a MrcdamlboFolderUp call. + +@param aItemCount The number of items present in this folder. +@param aResult The result of the MrcdamlboFolderUp operation. + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the media library state cookie + provided does not match the client's state cookie + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderUpResult( + TUint aItemCount, TInt aResult) + { + MrcdamlbDoFolderUpResult(aItemCount, aResult); + } + +/** +Called by the client in response to a MrcdamlboFolderDown() call. + +@param aItemCount The number of items present in this folder. + +@param aResult The result of the MrcdamlboFolderDown() operation + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the media library state cookie + provided does not match the client's state cookie + - KErrMediaBrowseInvalidDirection if the folder provided is not a valid + folder e.g. path A/B/C, the current dirctory is B, and the param + provided with MrcdamlboFolderDown()is A, obviously you can not change + folder down to A, so A is invalid. + - KErrMediaBrowseNotADirectory if the UID provided does not refer to a + folder item, e.g. it is a media element. + - KErrInvalidUid if the UID provided is invalid. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderDownResult( + TUint aItemCount, TInt aResult) + { + MrcdamlbDoFolderDownResult(aItemCount, aResult); + } + +/** +Called by the client in response to a MrcdamlboGetPath() call. + +@param aItemCount The number of items present in this folder. + +@param aMediaLibraryStateCookie The current value of the state cookie. + +@param aResult The result of the MrcdamlboGetPath() operation + - KErrNone if the operation is successful. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbGetPathResult( + TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + MrcdamlbDoGetPathResult(aItemCount, aMediaLibraryStateCookie, aResult); + } + +/** +Called by the client in response to a MrcdamlboSearch() call to indicate +that a search has completed. + +@param aNumberItemsFound The number of items found by the search. +@param aMediaLibraryStateCookie The current of the state cookie. +@param aResult The result of the search. + - KErrNone if the search completed successfully + - System wide error otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbSearchResult( + TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + MrcdamlbDoSearchResult(aNumberItemsFound, aMediaLibraryStateCookie, aResult); + } + +/** +Called by the client in the case that the state of the media library has +changed. This means that the media library state cookie provided prior to +this call by the client may no longer be valid. Typical causes for this +would be items added or removed from the media library. + +This function shall be called by any client any time it believes that media +library state cookie has ceased to be valid, for example if the current +directory is on removable media, and that media has been removed. +That includes clients that are only able to offer state cookie that are +limited to one directory. + +@param aMediaLibraryStateCookie The current value of the state cookie which + enables state mismatches between the client and the remote controller + device to be detected. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbMediaLibraryStateChange( + TUint16 aMediaLibraryStateCookie) + { + MrcdamlbDoMediaLibraryStateChange(aMediaLibraryStateCookie); + } + +/** +Called by the client in response to MrcdamlboGetItem() call in the case the +requested item is a folder item. + +@param aFolderID The folder UID. +@param aFolderName The folder name. Takes a copy of it. +@param aFolderType The folder type. +@param aPlayable Indicaties whether the folder is playable + - KFolderNotPlayable the folder can not be played + - KFolderPlayable the folder can be played +@param aAttributes The attributes of the folder item requested by + MrcdamlboGetItem() +@param aResult The result of the MrcdamlboGetItem() operation. + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the media library state cookie + provided does not match the client's state cookie. + - KErrInvalidUid if the uid of the item requested is invalid, + e.g. the client removed the item before the request + MrcdamlboGetItem() coming. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbFolderItemResult( + const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) + { + MrcdamlbDoFolderItemResult(aFolderID, aFolderName, aFolderType, aPlayable, aAttributes, aResult); + } + +/** +Called by the client in response to MrcdamlboGetItem() call in the case the +requested item is a media element item. + +@param aMediaID The media element UID. +@param aMediaName The media name. Takes a copy of it. +@param aMediaType The media type. +@param aAttributes The attributes list. Takes a copy of it. +@param aResult The result of the MrcdamlboGetItem() operation. + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the media library state cookie + provided does not match the client's state cookie. + - KErrInvalidUid if the uid of the item requested is invalid, + e.g. the client removed the item before the request + MrcdamlboGetItem() coming. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareMediaLibraryBrowse::MrcdamlbMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + MrcdamlbDoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes,aResult); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseawarenowplayingbrowse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseawarenowplayingbrowse.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,74 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +/** +Called by the client in response to a MrcdanpboGetFolderListing() call. + +@param aFolderListing A listing of the items that are + in the range requested by the MrcdanpboGetFolderListing() call. If the + media player does not natively support a Now Playing folder the listing + will only contain one item which is the currently playing media element + +@param aMediaLibraryStateCookie The current value of the state cookie. +@param aResult The result of the MrcdanpboGetFolderListing() operation. + - KErrNone if the operation was successful. + - KErrMediaBrowseInvalidOffset if there is no media available at the + offset of the start item, i.e. the start of range provided via + MrcdanpboGetFolderListing() is not valid. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbFolderListing( + const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TUint aResult) + { + MrcdanpbDoFolderListing(aFolderListing, aMediaLibraryStateCookie, aResult); + } + +/** +Called by the client in response to MrcdanpboGetItem() call + +@param aMediaID The media element UID. +@param aMediaName The media name. Takes a copy of it. +@param aMediaType The media type. +@param aAttributes The attributes list. Takes a copy of it. +@param aResult The result of the MrcdanpboGetItem() operation. + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the media library state cookie + does not match the client's state cookie. + - KErrInvalidUid if the uid of the item requested is invalid, + e.g. the client removed the item before the request + MrcdanpboGetItem() coming. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseAwareNowPlayingBrowse::MrcdanpbMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + MrcdanpbDoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseunawaremediabrowsetarget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseunawaremediabrowsetarget.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,139 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +EXPORT_C CRemConDatabaseUnawareMediaBrowseTarget* CRemConDatabaseUnawareMediaBrowseTarget::NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseUnawareNowPlayingBrowseObserver& aNpObserver, + TBool aSearchSupported, + MRemConDatabaseUnawareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseUnawareNowPlayingBrowse*& aNpInterface) + { + CRemConDatabaseUnawareMediaBrowseTarget* self = new(ELeave)CRemConDatabaseUnawareMediaBrowseTarget( + aInterfaceSelector, aMlObserver, aNpObserver, aMlInterface, aNpInterface); + CleanupStack::PushL(self); + self->ConstructL(aSearchSupported); + CleanupStack::Pop(self); + return self; + } + +CRemConDatabaseUnawareMediaBrowseTarget::CRemConDatabaseUnawareMediaBrowseTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseUnawareNowPlayingBrowseObserver& aNpObserver, + MRemConDatabaseUnawareMediaLibraryBrowse*& aMlInterface, + MRemConDatabaseUnawareNowPlayingBrowse*& aNpInterface) + : CRemConMediaBrowseTargetBase(aInterfaceSelector, aMlObserver, aNpObserver) + { + aMlInterface = this; + aNpInterface = this; + } + +void CRemConDatabaseUnawareMediaBrowseTarget::ConstructL( + TBool aSearchSupported) + { + BaseConstructL(aSearchSupported); + } + +CRemConDatabaseUnawareMediaBrowseTarget::~CRemConDatabaseUnawareMediaBrowseTarget() + { + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoFolderListing( + const TArray& aFolderListing, + TUint aResult) + { + DoFolderListing(aFolderListing, 0, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoFolderUpResult( + TUint aItemCount, TInt aResult) + { + DoFolderUpResult(aItemCount, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoFolderDownResult( + TUint aItemCount, TInt aResult) + { + DoFolderDownResult(aItemCount, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoGetPathResult( + TUint aItemCount, + TInt aResult) + { + DoGetPathResult(aItemCount, 0, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoSearchResult( + TUint aNumberItemsFound, + TInt aResult) + { + DoSearchResult(aNumberItemsFound, 0, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoMediaLibraryStateChange() + { + DoMediaLibraryStateChange(0); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoFolderItemResult( + const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) + { + DoFolderItemResult(aFolderID,aFolderName, aFolderType, aPlayable, aAttributes, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdumlbDoMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + DoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdunpbDoFolderListing( + const TArray& aFolderListing, + TUint aResult) + { + DoFolderListing(aFolderListing, 0, aResult); + } + +void CRemConDatabaseUnawareMediaBrowseTarget::MrcdunpbDoMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + DoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseunawaremedialibrarybrowse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseunawaremedialibrarybrowse.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,176 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +/** +Called by the client in response to a MrcdumlboGetFolderListing() call. + +@param aFolderListing A listing of the items that are + in the range requested by the MrcdumlboGetFolderListing() call. + +@param aResult The result of the MrcdumlboGetFolderListing() operation. + - KErrNone if the operation was successful. + - KErrMediaBrowseInvalidOffset if there is no media available at the + offset of the start item, i.e. the start of range provided via + MrcdumlboGetFolderListing() is not valid. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderListing( + const TArray& aFolderListing, + TUint aResult) + { + MrcdumlbDoFolderListing(aFolderListing, aResult); + } + +/** +Called by the client in response to a MrcdumlboFolderUp call. + +@param aItemCount The number of items present in this folder. +@param aResult The result of the MrcdumlboFolderUp operation. + - KErrNone if the operation was successful. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderUpResult( + TUint aItemCount, TInt aResult) + { + MrcdumlbDoFolderUpResult(aItemCount, aResult); + } + +/** +Called by the client in response to a MrcdumlboFolderDown() call. + +@param aItemCount The number of items present in this folder. + +@param aResult The result of the MrcdumlboFolderDown() operation + - KErrNone if the operation was successful. + - KErrMediaBrowseInvalidDirection if the folder provided is not a valid + folder e.g. path A/B/C, the current dirctory is B, and the param + provided with MrcdumlboFolderDown()is A, obviously you can not change + folder down to A, so A is invalid. + - KErrMediaBrowseNotADirectory if the UID provided does not refer to a + folder item, e.g. it is a media element. + - KErrInvalidUid if the UID provided is invalid. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderDownResult( + TUint aItemCount, TInt aResult) + { + MrcdumlbDoFolderDownResult(aItemCount, aResult); + } + +/** +Called by the client in response to a MrcdumlboGetPath() call. + +@param aItemCount The number of items present in this folder. + +@param aResult The result of the MrcdumlboGetPath() operation + - KErrNone if the operation is successful. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbGetPathResult( + TUint aItemCount, + TInt aResult) + { + MrcdumlbDoGetPathResult(aItemCount, aResult); + } + +/** +Called by the client in response to a MrcdumlboSearch() call to indicate +that a search has completed. + +@param aNumberItemsFound The number of items found by the search. +@param aResult The result of the search. + - KErrNone if the search completed successfully + - System wide error otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbSearchResult( + TUint aNumberItemsFound, + TInt aResult) + { + MrcdumlbDoSearchResult(aNumberItemsFound, aResult); + } + +/** +Called by the client to indicate changes to the media database in the client. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbMediaLibraryStateChange() + { + MrcdumlbDoMediaLibraryStateChange(); + } + +/** +Called by the client in response to MrcdumlboGetItem() call in the case the +requested item is a folder item. + +@param aFolderID The folder UID. +@param aFolderName The folder name. Takes a copy of it. +@param aFolderType The folder type. +@param aPlayable Indicaties whether the folder is playable + - KFolderNotPlayable the folder can not be played + - KFolderPlayable the folder can be played +@param aAttributes The attributes of the folder item requested by + MrcdumlboGetItem() +@param aResult The result of the MrcdumlboGetItem() operation. + - KErrNone if the operation was successful. + - KErrInvalidUid if the uid of the item requested is invalid, + e.g. the client removed the item before the request + MrcdumlboGetItem() coming. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbFolderItemResult( + const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) + { + MrcdumlbDoFolderItemResult(aFolderID, aFolderName, aFolderType, aPlayable, aAttributes, aResult); + } + +/** +Called by the client in response to MrcdumlboGetItem() call in the case the +requested item is a media element item. + +@param aMediaID The media element UID. +@param aMediaName The media name. Takes a copy of it. +@param aMediaType The media type. +@param aAttributes The attributes list. Takes a copy of it. +@param aResult The result of the MrcdumlboGetItem() operation. + - KErrNone if the operation was successful. + - KErrInvalidUid if the uid of the item requested is invalid, + e.g. the client removed the item before the request + MrcdumlboGetItem() coming. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareMediaLibraryBrowse::MrcdumlbMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + MrcdumlbDoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseunawarenowplayingbrowse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remcondatabaseunawarenowplayingbrowse.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,70 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +/** +Called by the client in response to a MrcdunpboGetFolderListing() call. + +@param aFolderListing A listing of the items that are + in the range requested by the MrcdunpboGetFolderListing() call. If the + media player does not natively support a Now Playing folder the listing + will only contain one item which is the currently playing media element + +@param aResult The result of the MrcdunpboGetFolderListing() operation. + - KErrNone if the operation was successful. + - KErrMediaBrowseInvalidOffset if there is no media available at the + offset of the start item, that is the start of range provided via + MrcnptoGetFolderListing() is not valid. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbFolderListing( + const TArray& aFolderListing, + TUint aResult) + { + MrcdunpbDoFolderListing(aFolderListing, aResult); + } + +/** +Called by the client in response to MrcdunpboGetItem() call + +@param aMediaID The media element UID. +@param aMediaName The media name. Takes a copy of it. +@param aMediaType The media type. +@param aAttributes The attributes list. Takes a copy of it. +@param aResult The result of the MrcdunpboGetItem() operation. + - KErrNone if the operation was successful. + - KErrInvalidUid if the uid of the item requested is invalid, + e.g. the client removed the item before the request + MrcdunpboGetItem() coming. + - System wide error code otherwise. +*/ +EXPORT_C void MRemConDatabaseUnawareNowPlayingBrowse::MrcdunpbMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + MrcdunpbDoMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowsetargetbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowsetargetbase.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1291 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include +#include +#include +#include +#include "mediabrowse.h" +#include "remconmediabrowsefault.h" +#include "remconqueuemessage.h" + +const TInt KDatabaseUnawareUidCounter = 0; +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_REMCONMEDIABROWSEAPI); +_LIT8(KLogFormat, "Operation Id = 0x%x, Data Lengh = %d"); +#endif +//========================================================================================= +// Construction/Destruction +//========================================================================================= +CRemConMediaBrowseTargetBase::CRemConMediaBrowseTargetBase(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseAwareNowPlayingBrowseObserver& aNpObserver, + TUint16 aMediaLibraryStateCookie) + : CRemConInterfaceBase(TUid::Uid(KRemConMediaBrowseApiUid), + KMaxLengthMediaBrowseMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iInterfaceSelector(aInterfaceSelector), + iRcdamlbo(&aMlObserver), + iRcdanpbo(&aNpObserver), + iMediaLibraryStateCookie(aMediaLibraryStateCookie), + iAttributeIterator(iMediaAttributeIds), + iNullIterator(iNullArray), + iSearchInProgress(EFalse), + iLastMlscUpdate(aMediaLibraryStateCookie) + { + } + +CRemConMediaBrowseTargetBase::CRemConMediaBrowseTargetBase(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareMediaLibraryBrowseObserver& aMlObserver, + MRemConDatabaseUnawareNowPlayingBrowseObserver& aNpObserver) + : CRemConInterfaceBase(TUid::Uid(KRemConMediaBrowseApiUid), + KMaxLengthMediaBrowseMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iInterfaceSelector(aInterfaceSelector), + iRcdumlbo(&aMlObserver), + iRcdunpbo(&aNpObserver), + iAttributeIterator(iMediaAttributeIds), + iNullIterator(iNullArray), + iSearchInProgress(EFalse) + { + } + +CRemConMediaBrowseTargetBase::~CRemConMediaBrowseTargetBase() + { + iMediaAttributeIds.Close(); + iNullArray.Close(); + iOutBuf.Close(); + iSearchString.Close(); + iGetPathResponse->Close(); + iGiaResponse->Close(); + iGflResponse->Close(); + delete iGetPathResponse; + delete iGiaResponse; + delete iGflResponse; + + if (iNextMessageCallBack) + { + iNextMessageCallBack->Cancel(); + delete iNextMessageCallBack; + } + if (iNextItemCallBack) + { + iNextItemCallBack->Cancel(); + delete iNextItemCallBack; + } + + iMsgQueue->Reset(); + delete iMsgQueue; + } + +void CRemConMediaBrowseTargetBase::BaseConstructL(TBool aSearchSupported) + { + iMsgQueue = new(ELeave)TRemConMessageQueue(); + + iGetPathResponse = new(ELeave)RRemConGetPathResponse(); + iGiaResponse = new(ELeave)RRemConGetItemAttributesResponse(); + iGflResponse = new(ELeave)RRemConGetFolderItemsResponse(); + + TCallBack cb(&NextMessageCb, this); + iNextMessageCallBack = new(ELeave)CAsyncCallBack(cb, CActive::EPriorityStandard); + + TCallBack itemCallBack(&NextItemCallBack, this); + iNextItemCallBack = new(ELeave)CAsyncCallBack(itemCallBack, CActive::EPriorityStandard); + + RRemConInterfaceFeatures features; + User::LeaveIfError(features.Open()); + CleanupClosePushL(features); + + if(aSearchSupported) + { + features.AddOperationL(ESearchOperationId); + iSearchSupported = ETrue; + } + + if(DatabaseAware()) + { + features.AddOperationL(EUIDPersistency); + } + + //Mandate the following operationIds to be supported in the client + features.AddOperationL(EGetFolderItemsOperationId); + features.AddOperationL(EChangePathOperationId); + features.AddOperationL(EGetItemAttributesOperationId); + features.AddOperationL(ESetBrowsedPlayerOperationId); + + iOutBuf.CreateL(KMediaBrowseOutBufMaxLength); + + CRemConInterfaceBase::BaseConstructL(features, ETrue); // it's true, this interface is a bulk interface + CleanupStack::PopAndDestroy(&features); + } + +//========================================================================================= +// RemCon interface stuff, called from interface selector +//========================================================================================= + +/** +@internalComponent +@released + +Gets a pointer to a specific interface version. + +@return A pointer to the interface, NULL if not supported. +*/ +TAny* CRemConMediaBrowseTargetBase::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +void CRemConMediaBrowseTargetBase::MrcibNewMessage(TUint aOperationId, + const TDesC8& aData) + { + LOG_FUNC + LOG2(KLogFormat, aOperationId, aData.Length()); + + TMetadataTransferPDU currentOp = RAvrcpIPC::GetPDUIdFromIPCOperationId(aOperationId); + switch(currentOp) + { + case EGetFolderItemsOperationId: + AddToOperationQueue(EMbGetFolderItems, + EGetFolderItemsOperationId, aData); + if (!iMsgQueue->IsEmpty() && !iInProgress && !iMsgQueue->Find( + TUid::Uid(KRemConMediaBrowseApiUid) + ,EGetFolderItemsOperationId)) + { + iNextMessageCallBack->CallBack(); + } + break; + case EChangePathOperationId: + ProcessChangePath(aData); + break; + case EGetItemAttributesOperationId: + { + AddToOperationQueue(EMbGetItemAttributes, + EGetItemAttributesOperationId, aData); + if (!iMsgQueue->IsEmpty() && !iInProgress && !iMsgQueue->Find( + TUid::Uid(KRemConMediaBrowseApiUid) + ,EGetItemAttributesOperationId)) + { + iNextMessageCallBack->CallBack(); + } + break; + } + case ESearchOperationId: + ProcessSearch(aData); + break; + case ESetBrowsedPlayerOperationId: + ProcessGetPath(aData); + break; + case EMediaLibraryStateCookieUpdateOperationId: + ProcessMediaLibraryStateCookieUpdate(aData); + break; + default: + __ASSERT_DEBUG(EFalse, MediaBrowseFault::Fault(EUnexpectedOperationId)); + break; + }; + } + +//========================================================================================= +// Browse Interface functions, called from derived classes +//========================================================================================= +void CRemConMediaBrowseTargetBase::DoFolderListing(const TArray& aFolderListing, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + if (aResult != KErrNone) + { + SendGetFolderItemsResponse(aResult, KNullDesC8); + return; + } + + // If asserted here, means the client calls the interface FolderListing() + // more than once corresponding to the only once call + // MrcmbtoGetFolderListing() + __ASSERT_DEBUG(iGflResponse->iItems.Count() == 0, MediaBrowsePanic::Panic(EFolderListingProvidedTwice)); + + // Store clients state cookie to pass it back when requesting each item. + // This will ensure that we don't miss state change during the course of + // the non-atomic GetFolderListing operation + iGflResponse->iUidCounter = aMediaLibraryStateCookie; + + // Store these UIDs, then ask for info about them + if (iGflResponse->CopyItems(aFolderListing) != KErrNone) + { + SendGetFolderItemsResponse(KErrAvrcpAirInternalError, KNullDesC8); + return; + } + + iGflResponse->iCurrentListingSize = KGetFolderItemsResponseBaseSize; + iGflResponse->iCurrentItem = -1; + RequestNextItem(); + } + +void CRemConMediaBrowseTargetBase::DoFolderUpResult(TUint aItemCount, TInt aResult) + { + SendChangePathResponse(aItemCount, aResult); + } + +void CRemConMediaBrowseTargetBase::DoFolderDownResult(TUint aItemCount, TInt aResult) + { + SendChangePathResponse(aItemCount, aResult); + } + +void CRemConMediaBrowseTargetBase::DoGetPathResult(TUint aItemCount, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + if (aResult != KErrNone) + { + iGetPathResponse->Close(); + return SendError(EMbSetBrowsedPlayer, + ESetBrowsedPlayerOperationId, aResult); + } + + // Store the current UIDs counter. + iMediaLibraryStateCookie = aMediaLibraryStateCookie; + + TInt status = KErrAvrcpAirBase - KErrAvrcpAirSuccess; + iGetPathResponse->iStatus = status; + iGetPathResponse->iUidCounter = aMediaLibraryStateCookie; + iGetPathResponse->iNumberItems = aItemCount; + + RBuf8 responseBuf; + TInt error = responseBuf.Create(iGetPathResponse->Size()); + if (error != KErrNone) + { + iGetPathResponse->Close(); + return SendError(EMbSetBrowsedPlayer, + ESetBrowsedPlayerOperationId, KErrAvrcpAirInternalError); + } + + iGetPathResponse->iPduId = AvrcpBrowsing::ESetBrowsedPlayer; + TRAP(error, iGetPathResponse->WriteL(responseBuf)); + if (error == KErrNone) + { + // Send the response back to the CT + error = InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + ESetBrowsedPlayerOperationId, responseBuf ); + } + + iGetPathResponse->Close(); + responseBuf.Close(); + } + +void CRemConMediaBrowseTargetBase::DoSearchResult(TUint aNumberItemsFound, + TUint16 aMediaLibraryStateCookie, + TInt aResult) + { + // GetFoldItems should in progress When this interface is called. + __ASSERT_DEBUG(iSearchInProgress, MediaBrowsePanic::Panic(ESearchResultWithoutRequest)); + + SendSearchResponse(aResult, aNumberItemsFound, aMediaLibraryStateCookie); + } + +void CRemConMediaBrowseTargetBase::DoMediaLibraryStateChange(TUint16 aMediaLibraryStateCookie) + { + if(DatabaseAware()) + { + __ASSERT_DEBUG(aMediaLibraryStateCookie != KDatabaseUnawareUidCounter, MediaBrowsePanic::Panic(EZeroMediaLibraryStateCookie)); + + // For database aware players we need to update if we have a pending update and + // the new value is different to what we last + if(iMlscUpdatePending && (aMediaLibraryStateCookie != iLastMlscUpdate)) + { + // Send update with new value + SendMediaLibraryStateCookieUpdateResponse(aMediaLibraryStateCookie); + } + + // Always store the last value here. When we are asked for an update + // we will be provided with the value the update should be relative + // to, so we will compare to this. + iLastMlscUpdate = aMediaLibraryStateCookie; + } + else + { + __ASSERT_DEBUG(aMediaLibraryStateCookie == KDatabaseUnawareUidCounter, MediaBrowseFault::Fault(ENonZeroMediaLibraryStateCookie)); + + if(iMlscUpdatePending) + { + SendMediaLibraryStateCookieUpdateResponse(aMediaLibraryStateCookie); + } + else + { + // For database aware clients the value can never change. Indicate that + // the client has informed us of the state change by incrementing our + // update value so that we know there's been a change. The value doesn't + // matter, we just have to make it something other than zero. + iLastMlscUpdate = 1; + } + } + } + +void CRemConMediaBrowseTargetBase::DoFolderItemResult(const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + const TArray& aAttributes, + TInt aResult) + { + // GetFolderItems should in progress When this interface is called. + __ASSERT_DEBUG(iGetFolderListing || iGetItemAttributes, MediaBrowsePanic::Panic(EFolderItemResultWithoutRequest)); + + if(iGetFolderListing) + { + ProcessFolderItemResult(aFolderID, aFolderName, aFolderType, aPlayable, aResult); + } + + if (iGetItemAttributes) + { + ProcessGetItemAttributesResult(aAttributes, aResult); + } + } + +void CRemConMediaBrowseTargetBase::DoMediaElementItemResult(const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + __ASSERT_DEBUG((iGetFolderListing || iGetItemAttributes), MediaBrowsePanic::Panic(EMediaElementItemResultWithoutRequest)); + + if (iGetFolderListing) + { + ProcessMediaElementItemResult(aMediaID, aMediaName, aMediaType, aAttributes, aResult); + } + + if (iGetItemAttributes) + { + ProcessGetItemAttributesResult(aAttributes, aResult); + } + } + +//========================================================================================= +// Utility functions, called internally +//========================================================================================= + +void CRemConMediaBrowseTargetBase::ProcessMediaLibraryStateCookieUpdate(const TDesC8& aData) + { + // Try to read the incoming request + RRemConUidsChangedRequest request; + TRAPD(error, request.ReadL(aData)); + __ASSERT_DEBUG(error == KErrNone, MediaBrowseFault::Fault(EBadlyFormattedMediaLibraryStateCookieUpdate)); + static_cast(error == error); // stops compiler warnings (assert above indicates design contract). + + if(request.iInitialUidCounter != iLastMlscUpdate) + { + // The client has updated the uid counter since the bearer + // last asked. Tell it the new value. The Send..Response + // function deals with all the state management necessary, + // including whether we are database aware or unaware + SendMediaLibraryStateCookieUpdateResponse(iLastMlscUpdate); + } + else + { + // Bearer still up to date. Remember that it's waiting for + // an update. + iMlscUpdatePending = ETrue; + } + } + +void CRemConMediaBrowseTargetBase::ProcessGetItemAttributes(const TDesC8& aData) + { + TRemConFolderScope scope; + TRemConItemUid item; + TUint16 uidCounter; + TInt err = ParseGetItemAttributesRequest(aData, scope, item, uidCounter); + if (err != KErrNone) + { + SendGetItemAttributesResponse(err, KNullDesC8); + return; + } + + iAttributeIterator.Start(); + iInProgress = ETrue; + iGetItemAttributes = ETrue; + TInt result = KErrNone; + if(scope == ENowPlayingFolder) + { + if (!DatabaseAware() && (0 == uidCounter))//Database UnAware + { + result = iRcdunpbo->MrcdunpboGetItem(item, iAttributeIterator); + } + else if (DatabaseAware() && (uidCounter > 0)) + { + result = iRcdanpbo->MrcdanpboGetItem(item, iAttributeIterator, uidCounter); + } + else + { + result = KErrAvrcpAirInvalidParameter; + } + } + else + { + if (!DatabaseAware() && (0 == uidCounter))//Database UnAware + { + result = iRcdumlbo->MrcdumlboGetItem(scope, item, iAttributeIterator); + } + else if (DatabaseAware() && (uidCounter > 0)) + { + result = iRcdamlbo->MrcdamlboGetItem(scope, item, iAttributeIterator, + uidCounter); + } + else + { + result = KErrAvrcpAirInvalidParameter; + } + } + + // The call back function returns error. + if (result != KErrNone) + { + SendGetItemAttributesResponse(result, KNullDesC8); + } + } + +void CRemConMediaBrowseTargetBase::SendGetItemAttributesResponse(TInt aResult, const TDesC8& aData) + { + if(aResult != KErrNone) + { + SendError(EMbGetItemAttributes, EGetItemAttributesOperationId, aResult); + } + else + { + InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + EGetItemAttributesOperationId, aData); + } + + iInProgress = EFalse; + iGetItemAttributes = EFalse; + iMediaAttributeIds.Reset(); + iGiaResponse->Close(); + + if (!iMsgQueue->IsEmpty()) + { + iNextMessageCallBack->CallBack(); + } + } + +void CRemConMediaBrowseTargetBase::ProcessChangePath(const TDesC8& aData) + { + // Try to read the incoming request + TInt error = KErrNone; + RRemConChangePathRequest request; + TRAP(error, request.ReadL(aData)); + + // Couldn't parse the request; tell them it was invalid + if (error != KErrNone) + { + SendError(EMbChangePath, EChangePathOperationId, KErrAvrcpAirInvalidParameter); + return; + } + + if(request.iDirection == AvrcpBrowsing::KUp) + { + if (DatabaseAware() && (request.iUidCounter > 0)) + { + iRcdamlbo->MrcdamlboFolderUp(request.iUidCounter); + } + else if (!DatabaseAware() && (0 == request.iUidCounter)) + { + iRcdumlbo->MrcdumlboFolderUp(); + } + else + { + SendError(EMbChangePath, EChangePathOperationId, KErrAvrcpAirInvalidParameter); + } + } + else if(request.iDirection == AvrcpBrowsing::KDown) + { + if (DatabaseAware() && (request.iUidCounter > 0)) + { + iRcdamlbo->MrcdamlboFolderDown(request.iElement, request.iUidCounter); + } + else if (!DatabaseAware() && (0 == request.iUidCounter)) + { + iRcdumlbo->MrcdumlboFolderDown(request.iElement); + } + else + { + SendError(EMbChangePath, EChangePathOperationId, KErrAvrcpAirInvalidParameter); + } + } + else + { + SendError(EMbChangePath, EChangePathOperationId, KErrAvrcpAirInvalidDirection); + } + } + +void CRemConMediaBrowseTargetBase::SendSearchResponse(TInt aResult, TUint aNumberItemsFound, TUint16 aMediaLibraryStateCookie) + { + iSearchString.Close(); + + // format the response in a RRemConSearchResponse + RRemConMediaErrorResponse errResponse; + RRemConSearchResponse response; + TInt symbianError = errResponse.SymbianErrorCheck(aResult); + + response.iStatus = errResponse.SymbianErrToStatus(symbianError); + response.iPduId = AvrcpBrowsing::ESearch;//0x80 + response.iUidCounter = aMediaLibraryStateCookie; + response.iNumberItems = aNumberItemsFound; + TRAPD(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + ESearchOperationId, iOutBuf ); + } + + //Search operatin complete. + iSearchInProgress = EFalse; + } + +void CRemConMediaBrowseTargetBase::ProcessSearch(const TDesC8& aData) + { + // Don't trouble the client with this if they've informed us they don't + // support it + if (!iSearchSupported) + { + return SendSearchResponse(KErrAvrcpAirSearchNotSupported, 0, 0); + } + + // We know a search operation is in progress + if (iSearchInProgress) + { + return SendSearchResponse(KErrAvrcpAirSearchInProgress, 0, 0); + } + + // Try to read the incoming request + TInt error = KErrNone; + RRemConSearchRequest request; + TRAP(error, request.ReadL(aData)); + + // Couldn't parse the request; tell them it was invalid + if (error != KErrNone) + { + error = (error == KErrNoMemory) ? + KErrAvrcpAirInternalError : KErrAvrcpAirInvalidParameter; + + return SendSearchResponse(error, 0, 0); + } + + // Check the character set + if (request.iCharset != KUtf8MibEnum) + { + iSearchInProgress = EFalse; + return SendSearchResponse(KErrAvrcpAirInvalidParameter, 0, 0); + } + + iSearchString.Close(); + iSearchString.Assign(request.iSearchString); + //iSearchString has taken ownership of request's search string. + request.iSearchString.Assign(NULL); + + iSearchInProgress = ETrue; + + if(DatabaseAware()) + { + iRcdamlbo->MrcdamlboSearch(iSearchString); + } + else + { + iRcdumlbo->MrcdumlboSearch(iSearchString); + } + + request.Close(); + } + +void CRemConMediaBrowseTargetBase::ProcessGetPath(const TDesC8& aData) + { + iGflResponse->iMaxResponse = *(reinterpret_cast(aData.Ptr())); + + if(DatabaseAware()) + { + iRcdamlbo->MrcdamlboGetPath(iGetPathResponse->iPath); + } + else + { + iRcdumlbo->MrcdumlboGetPath(iGetPathResponse->iPath); + } + } + +void CRemConMediaBrowseTargetBase::ProcessGetFolderItems(const TDesC8& aData) + { + // The bearer is responsible for ensuring we have been supplied with response + // max size before sending us any requests + __ASSERT_DEBUG(iGflResponse->iMaxResponse != 0, MediaBrowseFault::Fault(ERequestWithoutMaxResponseBeingSet)); + + iInProgress = ETrue; + iGetFolderListing = ETrue; + + RRemConGetFolderItemsRequest request; + TRAPD(err, request.ReadL(aData)); + if(err != KErrNone) + { + request.Close(); + SendGetFolderItemsResponse(KErrAvrcpAirInvalidParameter, KNullDesC8); + return; + } + + if(request.iScope == AvrcpBrowsing::KSearchScope && !iSearchSupported) + { + request.Close(); + SendGetFolderItemsResponse(KErrAvrcpAirSearchNotSupported, KNullDesC8); + return; + } + + if (request.CopyAttributes(iMediaAttributeIds) != KErrNone) + { + request.Close(); + SendGetFolderItemsResponse(KErrAvrcpAirInternalError, KNullDesC8); + return; + } + iAttributeIterator.Start(); + + if(request.iScope == AvrcpBrowsing::KVirtualFilesystemScope) + { + iScope = EBrowseFolder; + } + else if(request.iScope == AvrcpBrowsing::KNowPlayingScope) + { + iScope = ENowPlayingFolder; + } + else if(request.iScope == AvrcpBrowsing::KSearchScope) + { + iScope = ESearchResultFolder; + } + else + { + request.Close(); + SendGetFolderItemsResponse(KErrAvrcpAirInvalidScope, KNullDesC8); + return; + } + + if (request.iStartItem > request.iEndItem) + { + request.Close(); + SendGetFolderItemsResponse(KErrAvrcpAirRangeOutOfBounds, KNullDesC8); + return; + } + + if(iScope == ENowPlayingFolder) + { + if(DatabaseAware()) + { + iRcdanpbo->MrcdanpboGetFolderListing(request.iStartItem, request.iEndItem); + } + else + { + iRcdunpbo->MrcdunpboGetFolderListing(request.iStartItem, request.iEndItem); + } + } + else + { + if(DatabaseAware()) + { + iRcdamlbo->MrcdamlboGetFolderListing(iScope,request.iStartItem, request.iEndItem); + } + else + { + iRcdumlbo->MrcdumlboGetFolderListing(iScope,request.iStartItem, request.iEndItem); + } + } + + request.Close(); + } + +void CRemConMediaBrowseTargetBase::SendGetFolderItemsResponse(TInt aResult, const TDesC8& aData) + { + if(aResult != KErrNone) + { + SendError(EMbGetFolderItems, EGetFolderItemsOperationId, aResult); + } + else + { + InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + EGetFolderItemsOperationId, aData); + } + + iInProgress = EFalse; + iGetFolderListing = EFalse; + iMediaAttributeIds.Reset(); + iGflResponse->Close(); + + iNextItemCallBack->Cancel(); + + if (!iMsgQueue->IsEmpty()) + { + iNextMessageCallBack->CallBack(); + } + } + +TInt CRemConMediaBrowseTargetBase::NextMessageCb(TAny* aThis) + { + static_cast(aThis)->DoNextMessage(); + return KErrNone; + } + +void CRemConMediaBrowseTargetBase::DoNextMessage() + { + __ASSERT_DEBUG(!iMsgQueue->IsEmpty(), MediaBrowseFault::Fault(EUnexpectedNextMessageCallback)); + CRemConQueuedMessage* msg = iMsgQueue->First(); + iMsgQueue->Remove(*msg); + + switch (msg->iOperationId) + { + case EGetFolderItemsOperationId: + ProcessGetFolderItems(msg->Data()); + break; + case EGetItemAttributesOperationId: + ProcessGetItemAttributes(msg->Data()); + break; + default: + __ASSERT_DEBUG(EFalse, MediaBrowseFault::Fault(EUnexpectedNextMessageCallback)); + break; + } + delete msg; + } + +void CRemConMediaBrowseTargetBase::SendMediaLibraryStateCookieUpdateResponse(TUint16 aMediaLibraryStateCookie) + { + LOG_FUNC + + TUint16 newValue = DatabaseAware() ? aMediaLibraryStateCookie : KDatabaseUnawareUidCounter; + + TInt error = KErrNone; + RRemConUidsChangedResponse response; + response.iUidCounter = newValue; + TRAP(error, response.WriteL(iOutBuf)); + + if (error == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + EMediaLibraryStateCookieUpdateOperationId, iOutBuf); + + iLastMlscUpdate = newValue; + iMlscUpdatePending = EFalse; + } + // otherwise we couldn't update the client. Leave our state with the update + // pending then we'll try again next time the client tells us state has + // changed. + } + +void CRemConMediaBrowseTargetBase::SendChangePathResponse(TUint aItemCount, + TInt aResult) + { + if (aResult != KErrNone) + { + return SendError(EMbChangePath, EChangePathOperationId, aResult); + } + + TInt error = KErrNone; + + // Format the response in a RRemConChangePathResponse + RRemConChangePathResponse response; + response.iStatus = KErrAvrcpAirBase - KErrAvrcpAirSuccess;//0x4 + response.iNumberItems = aItemCount; + + RBuf8 responseBuf; + error = responseBuf.Create(KMediaBrowseOutBufMaxLength); + if (error != KErrNone) + { + responseBuf.Close(); + SendError(EMbChangePath, EChangePathOperationId, KErrAvrcpAirInternalError); + return; + } + + response.iPduId = AvrcpBrowsing::EChangePath; + TRAP(error, response.WriteL(responseBuf)); + if (error == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + EChangePathOperationId, responseBuf ); + } + + responseBuf.Close(); + } + +TInt CRemConMediaBrowseTargetBase::NextItemCallBack(TAny* aThis) + { + static_cast(aThis)->RequestNextItem(); + return KErrNone; + } + +void CRemConMediaBrowseTargetBase::RequestNextItem() + { + TInt err = KErrNone; + TInt result = KErrNone; + RBuf8 responseBuf; + + // If true, indicate that we have not got all the items requested, + // so going on. + // There are some array elements accessed by [] as follows without + // checking range for it is done in RequestNextItem function. + if ( iGflResponse->RequestNextItem(err, responseBuf, + iGflResponse->iUidCounter) ) + { + TBool folderItem = EFalse; + if (AvrcpBrowsing::EFolderItem == iGflResponse->iItems[iGflResponse->iCurrentItem].iType) + { + folderItem = ETrue; + } + iAttributeIterator.Start(); + if(iScope == ENowPlayingFolder) + { + if(DatabaseAware()) + { + result = iRcdanpbo->MrcdanpboGetItem( + iGflResponse->iItems[iGflResponse->iCurrentItem].iUid, + folderItem ? iNullIterator : iAttributeIterator, + iGflResponse->iUidCounter); + } + else + { + result = iRcdunpbo->MrcdunpboGetItem( + iGflResponse->iItems[iGflResponse->iCurrentItem].iUid, + folderItem ? iNullIterator : iAttributeIterator); + } + } + else + { + if(DatabaseAware()) + { + result = iRcdamlbo->MrcdamlboGetItem(iScope, + iGflResponse->iItems[iGflResponse->iCurrentItem].iUid, + folderItem ? iNullIterator : iAttributeIterator, + iGflResponse->iUidCounter); + } + else + { + result = iRcdumlbo->MrcdumlboGetItem(iScope, + iGflResponse->iItems[iGflResponse->iCurrentItem].iUid, + folderItem ? iNullIterator : iAttributeIterator); + } + } + + // The call back function reutrns error. + if (result != KErrNone) + { + SendGetFolderItemsResponse(result, KNullDesC8); + } + } + // If comes here, indicate that we stop requesting the next item + // which means two possibilities: + // 1. Success: Have got all the items we want. + // 2. Error: Error occured internally. + else if ( err == KErrNone ) //Possibility 1. + { + SendGetFolderItemsResponse(KErrNone, responseBuf); + } + else // Possibility 2. + { + SendGetFolderItemsResponse(KErrAvrcpAirInternalError, KNullDesC8); + } + responseBuf.Close(); + } + +void CRemConMediaBrowseTargetBase::DoItemComplete(TInt aResult) + { + if (aResult != KErrNone) + { + SendGetFolderItemsResponse(aResult, KNullDesC8); + } + else + { + // We have to put an async break in here - otherwise if large + // numbers of items are requested we could overflow the stack + iNextItemCallBack->CallBack(); + } + } + +void CRemConMediaBrowseTargetBase::SendError(TUint8 aPduId, + TUint aOperationId, + TInt aError) + { + TInt error = KErrNone; + RRemConMediaErrorResponse response; + response.iPduId = aPduId; + response.iStatus = RAvrcpIPC::SymbianErrToStatus(aError); + TRAP(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + InterfaceSelector().SendBulkUnreliable( + TUid::Uid(KRemConMediaBrowseApiUid), + aOperationId, iOutBuf); + } + } + +/** +Sets an attribute value for the requested item. +*/ +TInt CRemConMediaBrowseTargetBase::DoAttributeValue( + TMediaAttributeId aAttributeId, + const TDesC8& aAttributeData ) + { + iSetAttributeValue = ETrue; + + REAResponse resp; + resp.iAttributeId = aAttributeId; + resp.iCharset = KUtf8MibEnum; + resp.iStringLen = aAttributeData.Length(); + resp.iString = aAttributeData.Alloc(); + if (!resp.iString) + { + iSetAttributeValue = EFalse; + return KErrNoMemory; + } + TInt status = KErrNone; + if(iGiaResponse->Size() + resp.iStringLen < iGflResponse->iMaxResponse) + { + status = iGiaResponse->iAttributes.Append(resp); + if (status != KErrNone) + { + iSetAttributeValue = EFalse; + resp.Close(); // make sure heap string is de-allocated + } + } + + return status; + } + +/** +Signals that all attributes requested has been supplied. +*/ + void CRemConMediaBrowseTargetBase::DoAllAttributesCompleted(TInt aResult) + { + TInt error = KErrNone; + __ASSERT_DEBUG(((aResult != KErrNone) || ((aResult == KErrNone) && iSetAttributeValue)), + MediaBrowseFault::Fault(EResultErrorCodeMismatch)); + + if (aResult == KErrNone) + { + // Finalise response; update number of attributes returned + iGiaResponse->iNumberAttributes = iGiaResponse->iAttributes.Count(); + } + + // Allocate a buffer for the formatted message + RBuf8 messageBuffer; + TInt bufferSize = + (aResult == KErrNone) ? iGiaResponse->Size() : KBrowseResponseBaseLength; + + if ( messageBuffer.Create(bufferSize) != KErrNone ) + { + SendGetItemAttributesResponse(KErrAvrcpAirInternalError, KNullDesC8); + } + else + { + // Send the result back to the CT + iGiaResponse->iPduId = AvrcpBrowsing::EGetItemAttributes; // 0x73 + iGiaResponse->iStatus = RAvrcpIPC::SymbianErrToStatus(aResult); + + TRAP(error, iGiaResponse->WriteL(messageBuffer)); + if (error == KErrNone) + { + SendGetItemAttributesResponse(KErrNone, messageBuffer); + } + else + { + SendGetItemAttributesResponse(KErrAvrcpAirInternalError, KNullDesC8); + } + } + messageBuffer.Close(); + } + +TInt CRemConMediaBrowseTargetBase::ItemAttributesResult( + const TArray& aAttributes) + { + TInt error = KErrNone; + TMediaAttributeId attributeId; + for (TInt i = 0; i < aAttributes.Count(); i++) + { + // check that the values supplied were requested + attributeId = aAttributes[i].iAttributeId; + if ( KErrNotFound == iMediaAttributeIds.Find(attributeId) ) + { + //Omit the invalid ones + continue; + } + + error = DoAttributeValue(attributeId, *aAttributes[i].iString); + if (error != KErrNone) + { + break; + } + } + + return error; + } + +void CRemConMediaBrowseTargetBase::AddToOperationQueue(TUint8 aPduId, + TInt aOperationId, + const TDesC8& aData) + { + CRemConQueuedMessage* msg = NULL; + TRAPD(err, msg = CRemConQueuedMessage::NewL( + TUid::Uid(KRemConMediaBrowseApiUid), aData, aOperationId)); + if (err == KErrNone) + { + iMsgQueue->AddLast(*msg); + } + else + { + SendError(aPduId, aOperationId, KErrAvrcpAirInternalError); + } + } + +TInt CRemConMediaBrowseTargetBase::ParseGetItemAttributesRequest( + const TDesC8& aData, + TRemConFolderScope& aScope, + TRemConItemUid& aItemUid, + TUint16& aMediaLibraryStateCookie) + { + // Try to read the incoming request + TInt error = KErrNone; + RRemConGetItemAttributesRequest request; + TRAP(error, request.ReadL(aData)); + + // Couldn't parse the request;tell them it was invalid + // Specification says unique id must not be 0x0 + if (error != KErrNone || request.iElement == 0) + { + request.Close(); + return KErrAvrcpAirInvalidParameter; + } + + if (request.iNumberAttributes == 0) + { + // spec says this is a request for all attribs + // current spec has 7 specified (0x01 to 0x07) + for (TInt i = 1; i <= KMediaAttributeNum; i++) + { + if (iMediaAttributeIds.Append(static_cast(i)) + != KErrNone) + { + request.Close(); + return KErrAvrcpAirInternalError; + } + } + } + else + { + // No need to check + // request.iNumberAttributes == request.iAttributes.Count() + // as this must be correct or request.ReadL(aData) leaves + TUint8 value; + TMediaAttributeId attributeid; + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + value = request.iAttributes[i]; + if (value > 0 && value <= KMaxMediaAttributeValue ) + { + attributeid = static_cast(value); + if (iMediaAttributeIds.Append(attributeid) != KErrNone) + { + request.Close(); + return KErrAvrcpAirInternalError; + } + } + } + } + // Check that some valid attribute ids have been found + if (iMediaAttributeIds.Count() == 0) + { + request.Close(); + return KErrAvrcpAirInvalidParameter; + } + + if(request.iScope == AvrcpBrowsing::KSearchScope) + { + aScope = ESearchResultFolder; + } + else if(request.iScope == AvrcpBrowsing::KVirtualFilesystemScope) + { + aScope = EBrowseFolder; + } + else if (request.iScope == AvrcpBrowsing::KNowPlayingScope) + { + aScope = ENowPlayingFolder; + } + else + { + request.Close(); + return KErrAvrcpAirInvalidScope; + } + + aItemUid = request.iElement; + aMediaLibraryStateCookie = request.iUidCounter; + + request.Close(); + return KErrNone; + } + +void CRemConMediaBrowseTargetBase::ProcessMediaElementItemResult( + const TRemConItemUid& aMediaID, + const TDesC8& aMediaName, + TMediaItemType aMediaType, + const TArray& aAttributes, + TInt aResult) + { + TInt internalError = KErrNone; + if (aResult == KErrNone) + { + __ASSERT_DEBUG(aMediaType < AvrcpBrowsing::KMediaTypeReserved, MediaBrowsePanic::Panic(EInvalidMediaType)); + + RItem& item = iGflResponse->iItems[iGflResponse->iCurrentItem]; + if (item.iUid == aMediaID) + { + item.iType = AvrcpBrowsing::EMediaElement; + item.iCharset = KUtf8MibEnum; + + item.iName = aMediaName.Alloc(); + internalError = (!item.iName) ? KErrNoMemory : internalError; + + if (internalError == KErrNone) + { + item.iNameLength = aMediaName.Length(); + item.iMediaType = static_cast(aMediaType); + item.iNumberAttributes = aAttributes.Count(); + item.iLength = KMediaElementItemBaseLength + item.iNameLength; + TInt attributeCount = aAttributes.Count(); + REAResponse attribute; + for (TInt i = 0; i < attributeCount; i++) + { + // Check that the values supplied were requested + if (KErrNotFound == iMediaAttributeIds.Find(aAttributes[i].iAttributeId)) + { + //Omit the invalid ones + continue; + } + + attribute.iAttributeId = aAttributes[i].iAttributeId; + attribute.iString = aAttributes[i].iString->Alloc(); + internalError = (!attribute.iString) ? KErrNoMemory : internalError; + if (internalError == KErrNone) + { + attribute.iCharset = KUtf8MibEnum; + attribute.iStringLen = attribute.iString->Length(); + item.iAttributes.Append(attribute); + + item.iLength += + KAttributeBaseLength + attribute.iString->Length(); + } + else + { + //it's useless to continue as there is an allocation issue + break; + } + } + } + } + else + { + internalError = KErrArgument; + } + } + + aResult = + (KErrNone == internalError)? aResult : KErrAvrcpAirInternalError; + + DoItemComplete(aResult); + } + +void CRemConMediaBrowseTargetBase::ProcessFolderItemResult( + const TRemConItemUid& aFolderID, + const TDesC8& aFolderName, + TFolderItemType aFolderType, + TFolderItemPlayable aPlayable, + TInt aResult) + { + TInt internalError = KErrNone; + if (aResult == KErrNone) + { + __ASSERT_DEBUG(aFolderType < AvrcpBrowsing::EFolderTypeReserved, MediaBrowsePanic::Panic(EInvalidFolderType)); + __ASSERT_DEBUG(aPlayable < AvrcpBrowsing::KPlayableReserved, MediaBrowsePanic::Panic(EInvalidPlayableValue)); + + RItem& item = iGflResponse->iItems[iGflResponse->iCurrentItem]; + if (item.iUid == aFolderID) + { + item.iType = AvrcpBrowsing::EFolderItem; + item.iCharset = KUtf8MibEnum; + + item.iName = aFolderName.Alloc(); + internalError = (!item.iName) ? KErrNoMemory : internalError; + + item.iNameLength = aFolderName.Length(); + + item.iFolderType = + static_cast(aFolderType); + + item.iPlayable = aPlayable; + item.iLength = KFolderItemBaseLength + item.iNameLength; + } + else + { + internalError = KErrArgument; + } + } + + aResult = (internalError == KErrNone) ? aResult : KErrAvrcpAirInternalError; + + DoItemComplete(aResult); + } + +void CRemConMediaBrowseTargetBase::ProcessGetItemAttributesResult( + const TArray& aAttributes, + TInt aResult) + { + TInt internalError = KErrNone; + if (aResult == KErrNone) + { + internalError = ItemAttributesResult(aAttributes); + } + + aResult = + (KErrNone == internalError)? aResult : KErrAvrcpAirInternalError; + + DoAllAttributesCompleted(aResult); + } + +inline TBool CRemConMediaBrowseTargetBase::DatabaseAware() const + { + return iRcdanpbo ? ETrue : EFalse; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowseutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediabrowseapi/src/remconmediabrowseutils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include +#include "remconmediabrowsefault.h" + +void MediaBrowsePanic::Panic(TRemConMediaBrowsePanic aPanic) + { + User::Panic(KMediaBrowsePanicName, aPanic); + } + +void MediaBrowseFault::Fault(TRemConMediaBrowseFault aFault) + { + User::Panic(KMediaBrowseFaultName, aFault); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/bwins/remconmediainformationapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/bwins/remconmediainformationapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,9 @@ +EXPORTS + ??1CRemConMediaInformationTarget@@UAE@XZ @ 1 NONAME ; CRemConMediaInformationTarget::~CRemConMediaInformationTarget(void) + ?AttributeValue@CRemConMediaInformationTarget@@QAEHW4TMediaAttributeId@@AAVTDesC8@@@Z @ 2 NONAME ; void CRemConMediaInformationTarget::AttributeValue(enum TMediaAttributeID, class TDesC8 &) + ?Completed@CRemConMediaInformationTarget@@QAEXXZ @ 3 NONAME ; void CRemConMediaInformationTarget::Completed(void) + ?NewL@CRemConMediaInformationTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConMediaInformationTargetObserver@@@Z @ 4 NONAME ; class CRemConMediaInformationTarget * CRemConMediaInformationTarget::NewL(class CRemConInterfaceSelector &, class MRemConMediaInformationTargetObserver &) + ?Next@TMediaAttributeIter@@QAEHAAW4TMediaAttributeId@@@Z @ 5 NONAME + ?Start@TMediaAttributeIter@@QAEXXZ @ 6 NONAME + ??0TMediaAttributeIter@@QAE@AAV?$RArray@W4TMediaAttributeId@@@@@Z @ 7 NONAME ; TMediaAttributeIter::TMediaAttributeIter(class RArray &) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/eabi/remconmediainformationapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/eabi/remconmediainformationapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,12 @@ +EXPORTS + _ZN19TMediaAttributeIter4NextER17TMediaAttributeId @ 1 NONAME + _ZN19TMediaAttributeIter5StartEv @ 2 NONAME + _ZN29CRemConMediaInformationTarget4NewLER24CRemConInterfaceSelectorR37MRemConMediaInformationTargetObserver @ 3 NONAME + _ZN29CRemConMediaInformationTargetD0Ev @ 4 NONAME + _ZN29CRemConMediaInformationTargetD1Ev @ 5 NONAME + _ZN29CRemConMediaInformationTargetD2Ev @ 6 NONAME + _ZN29CRemConMediaInformationTarget14AttributeValueE17TMediaAttributeIdR6TDesC8 @ 7 NONAME + _ZN29CRemConMediaInformationTarget9CompletedEv @ 8 NONAME + _ZN19TMediaAttributeIterC1ER6RArrayI17TMediaAttributeIdE @ 9 NONAME + _ZN19TMediaAttributeIterC2ER6RArrayI17TMediaAttributeIdE @ 10 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconmediainformationapi.mmp + +PRJ_EXPORTS +../public/remconmediainformationtarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconmediainformationtarget.h) +../public/remconmediainformationtargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconmediainformationtargetobserver.h) +../public/remconmediaattributeid.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconmediaattributeid.h) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/group/remconmediainformationapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/group/remconmediainformationapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,51 @@ +// Copyright (c) 2004-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: +// remconmediainformationapi.dll Remote Control Media Information API - an outer-layer client side library. +// +// + +/** + @file + @internalComponent +*/ + +TARGET remconmediainformationapi.dll +TARGETPATH /system/libs + +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x101f9067 +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE mediainformationapi.cpp + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../../common + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib +LIBRARY avrcpipc.lib +LIBRARY estor.lib + +#include + +UNPAGED + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/public/remconmediaattributeid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/public/remconmediaattributeid.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,59 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIAATTRIBUTEID_H_ +#define REMCONMEDIAATTRIBUTEID_H_ + +#include + +const TInt KMediaAttributeNum = 7; +enum TMediaAttributeId + { + ETitleOfMedia =0x1, + ENameOfArtist =0x2, + ENameOfAlbum =0x3, + ETrackNumber =0x4, /* for example the CD track number */ + ENumberOfTracks =0x5, /* for example the total track number of the CD */ + EGenre =0x6, + EPlayingTime =0x7 + }; + +/** + * Provide an iterator wrapper class + */ +class TMediaAttributeIter + { +public: + /** + @internalTechnology + */ + IMPORT_C TMediaAttributeIter(RArray& aMediaAttributeIDs); + IMPORT_C void Start(); + IMPORT_C TBool Next(TMediaAttributeId& aId); + +private: + RArray& iMediaAttributeIDs; + TInt iterator; + }; + +#endif /*REMCONMEDIAATTRIBUTEID_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/public/remconmediainformationtarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/public/remconmediainformationtarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,126 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIAINFORMATIONTARGET_H +#define REMCONMEDIAINFORMATIONTARGET_H + +#include +#include +#include +#include + +class CRemConInterfaceSelector; +class RRemConGetElementAttributesResponse; + +NONSHARABLE_CLASS(CRemConMediaInformationQueuedMessage): public CBase + { +public: + static CRemConMediaInformationQueuedMessage* NewL(const TDesC8& aData); + ~CRemConMediaInformationQueuedMessage(); + + const TDesC8& Data(); +private: + CRemConMediaInformationQueuedMessage(); + void ConstructL(const TDesC8& aData); +public: + TSglQueLink iLink; +private: + RBuf8 iData; + }; + +/** +Client-instantiable type supporting sending media information. +*/ +NONSHARABLE_CLASS(CRemConMediaInformationTarget) : public CRemConInterfaceBase, + public MRemConInterfaceIf + { +public: + + /** + Factory function. + @param aInterfaceSelector The interface selector. The client must have + created one of these first. + @param aObserver The observer of this interface. + @return A new CRemConMediaInformationTarget, owned by the interface selector. + */ + IMPORT_C static CRemConMediaInformationTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConMediaInformationTargetObserver& aObserver); + + /** Destructor */ + IMPORT_C ~CRemConMediaInformationTarget(); + +public: + /** Called by the client in response to a MrcmitoGetCurrentlyPlayingMetadata() call. + Each call provides one of the attribute values requested. + This is repeatedly called until all attributes requested have been supplied and then followed by Completed(). + @param aAttribute The ID of the attribute supplied. + @param aValue A reference to a descriptor containing the attribute data. + This must be valid until Completed() has been called. + @see MRemConMediaInformationTargetObserver::MrcmitoGetCurrentlyPlayingMetadata() + @see CRemConMediaInformationTarget::Completed() + */ + IMPORT_C TInt AttributeValue( TMediaAttributeId aAttributeId, TDesC8& aAttributeData); + + /** Signal that all attributes requested by MrcmitoGetCurrentlyPlayingMetadata() have been supplied + using the AttributeValue() method. + @see MRemConMediaInformationTargetObserver::MrcmitoGetCurrentlyPlayingMetadata() + @see CRemConMediaInformationTarget::AttributeValue() + */ + IMPORT_C void Completed(); + +private: + /** + Constructor. + @param aInterfaceSelector The interface selector. + @param aObserver The observer of this interface. + */ + CRemConMediaInformationTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConMediaInformationTargetObserver& aObserver); + + void ConstructL(); + +private: // from CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // from MRemConInterfaceIf + void MrcibNewMessage(TUint aOperationId, const TDesC8& aData); + +private: // utility + void SendError(TInt aError); + void ProcessMessage(const TDesC8& aData); + + static int NextMessageCb(TAny* aThis); + void DoNextMessage(); +private: // unowned + MRemConMediaInformationTargetObserver& iObserver; + +private: // owned + RRemConGetElementAttributesResponse* iResponse; + + RArray iMediaAttributeIDs; + TMediaAttributeIter iAttributeIterator; + TBool iInProgress; + TSglQue iMsgQueue; + + CAsyncCallBack* iNextMessageCallBack; + }; + +#endif // REMCONMEDIAINFORMATIONTARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/public/remconmediainformationtargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/public/remconmediainformationtargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONMEDIAINFORMATIONTARGETOBSERVER_H +#define REMCONMEDIAINFORMATIONTARGETOBSERVER_H + +#include +#include + +/** +Clients must implement this interface in order to instantiate objects of type +CRemConMediaInformationTarget. This interface passes incoming commands from RemCon to +the client. +*/ +NONSHARABLE_CLASS(MRemConMediaInformationTargetObserver) + { +public: + + /** + For each element in aAttributeList for which the requested Metadata is available, + the client shall respond by calling CRemConMediaInformationTarget::AttributeValue(). + After all attributes have been supplied the client shall call CRemConMediaInformationTarget::Completed(). + @param aAttributeIter A CMediaAttributeIDs containing a list of TMediaAttributeIds requested by the controller + @see CRemConMediaInformationTarget::AttributeValue() + @see CRemConMediaInformationTarget::Completed() + */ + virtual void MrcmitoGetCurrentlyPlayingMetadata( TMediaAttributeIter& aAttributeIter ) = 0; + + }; + +#endif // REMCONMEDIAINFORMATIONTARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/mediainformationapi/src/mediainformationapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/mediainformationapi/src/mediainformationapi.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,371 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include +#include +#include + +#include "mediainformation.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_MEDIA_INFO); +#endif + +EXPORT_C CRemConMediaInformationTarget* CRemConMediaInformationTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConMediaInformationTargetObserver& aObserver) + { + LOG_STATIC_FUNC + + CRemConMediaInformationTarget* self = new(ELeave) CRemConMediaInformationTarget(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CRemConMediaInformationTarget::CRemConMediaInformationTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConMediaInformationTargetObserver& aObserver) +: CRemConInterfaceBase(TUid::Uid(KRemConMediaInformationApiUid), + KMaxLengthMediaInformationMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iObserver(aObserver), + iAttributeIterator(iMediaAttributeIDs), + iMsgQueue(_FOFF(CRemConMediaInformationQueuedMessage, iLink)) + { + } + +void CRemConMediaInformationTarget::ConstructL() + { + iResponse = new(ELeave)RRemConGetElementAttributesResponse(); + TCallBack cb(&NextMessageCb, this); + iNextMessageCallBack = new (ELeave) CAsyncCallBack(cb, CActive::EPriorityStandard); + BaseConstructL(); + } + + +/** Destructor. + +@publishedAll +@released +*/ +EXPORT_C CRemConMediaInformationTarget::~CRemConMediaInformationTarget() + { + iMediaAttributeIDs.Close(); + iResponse->Close(); + delete iResponse; + iNextMessageCallBack->Cancel(); + delete iNextMessageCallBack; + TSglQueIter iter(iMsgQueue); + CRemConMediaInformationQueuedMessage* msg; + iter.SetToFirst(); + while ((msg = iter++) != NULL) + { + iMsgQueue.Remove(*msg); + delete msg; + } + } + +/** Gets a pointer to a specific interface version. + +@return A pointer to the interface, NULL if not supported. +@internalComponent +@released +*/ +TAny* CRemConMediaInformationTarget::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +EXPORT_C TInt CRemConMediaInformationTarget::AttributeValue( TMediaAttributeId aAttributeId, TDesC8& aAttributeData ) + { + // check that the values supplied were requested + if ( KErrNotFound == iMediaAttributeIDs.Find( aAttributeId ) ) + { + return KErrNotFound; + } + + REAResponse resp; + resp.iAttributeId = aAttributeId; + resp.iCharset = KUtf8MibEnum; + resp.iStringLen = aAttributeData.Length(); + resp.iString = aAttributeData.Alloc(); + if (resp.iString == NULL) + { + return KErrNoMemory; + } + TInt status = iResponse->iAttributes.Append(resp); + if (status != KErrNone) + { + resp.Close(); // make sure heap string is de-allocated + } + return status; + } + +// from MRemConInterfaceIf +void CRemConMediaInformationTarget::SendError(TInt aError) + { + RBuf8 outBuf; + if (outBuf.Create(KAVCFrameMaxLength) != KErrNone) + { + // On OOM drop the message + return; + } + + TInt error = 0; + RAvrcpIPCError response; + response.iError = aError; + TRAP(error, response.WriteL(outBuf)); // Don't send error if OOM + if (error == KErrNone) + { + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConMediaInformationApiUid), + EGetElementAttributes, ERemConResponse, outBuf); + } + outBuf.Close(); + } + +// from MRemConInterfaceIf +void CRemConMediaInformationTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& aData ) + { + LOG1(_L("\taOperationId = 0x%02x"), aOperationId); + LOG1(_L("\taData.Length = %d"), aData.Length()); + + (void) aOperationId; // ignore warning about this variable being unused + + if (!iInProgress && iMsgQueue.IsEmpty()) + { + ProcessMessage(aData); + } + else + { + CRemConMediaInformationQueuedMessage* msg = NULL; + TRAPD(err, msg = CRemConMediaInformationQueuedMessage::NewL(aData)); + if (err == KErrNone) + { + iMsgQueue.AddLast(*msg); + } + } + } + +void CRemConMediaInformationTarget::ProcessMessage(const TDesC8& aData) + { + iInProgress = ETrue; + // Try to read the incoming request + TInt error = KErrNone; + RRemConGetElementAttributesRequest request; + TRAP(error, request.ReadL(aData)); + + // Couldn't parse the request; tell them it was invalid + if (error != KErrNone) + { + request.Close(); + return SendError(KErrAvrcpMetadataParameterNotFound); + } + + // Specification section 5.3.1 (page 49) says unique id + // must be 0x0. All other values are currently reserved + if (request.iElement != 0) + { + request.Close(); + return SendError(KErrAvrcpMetadataInvalidParameter); + } + + // this may have been used by a previous GetElementAttributes, so + iMediaAttributeIDs.Reset(); + + if (request.iNumberAttributes == 0) + { + // spec says this is a request for all attribs + // current spec has 7 specified (0x01 to 0x07) + for (TInt i = 1; i <= 7; i++) + { + if (iMediaAttributeIDs.Append((TMediaAttributeId)i) != KErrNone) + { + request.Close(); + return SendError(KErrAvrcpMetadataInternalError); + } + } + } + else + { + // No need to check request.iNumberAttributes == request.iAttributes.Count() + // as this must be correct or request.ReadL(aData) leaves + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + TUint8 value = request.iAttributes[i]; + if (value > 0 && value <= KMaxMediaAttributeValue ) + { + if (iMediaAttributeIDs.Append((TMediaAttributeId)value) != KErrNone) + { + request.Close(); + return SendError(KErrAvrcpMetadataInternalError); + } + } + } + } + request.Close(); + + // check that some valid attribute ids have been found + if (iMediaAttributeIDs.Count()) + { + // if the client has not yet called Completed() on the last request + // clear the the attributes from the previous response + iResponse->Close(); + + // reset the interator to the start, as it may have been used before + iAttributeIterator.Start(); + + // call the client API to get the client value. + iObserver.MrcmitoGetCurrentlyPlayingMetadata(iAttributeIterator); + } + else + { + // no valid attribute ids found so return an error to bearer + SendError(KErrAvrcpMetadataParameterNotFound); + } + } + +// The client application has signaled that all attributes have been returned so +// response can now be sent +EXPORT_C void CRemConMediaInformationTarget::Completed() + { + if (!iInProgress) + { + return; + } + // Finalise response; update number of attributes returned + iResponse->iNumberAttributes = iResponse->iAttributes.Count(); + + //Check the bound of the number of attributes, zero is not permitted + if (iResponse->iNumberAttributes == 0) + { + return SendError(KErrAvrcpMetadataInternalError); + } + + // Allocate a buffer for the formatted message + RBuf8 messageBuffer; + if ( messageBuffer.Create(iResponse->Size()) != KErrNone ) + { + // On OOM drop the message + iResponse->Close(); + return; + } + + // send the result back to the CT + TInt error = KErrNone; + TRAP(error, iResponse->WriteL(messageBuffer)); + if (error == KErrNone) + { + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConMediaInformationApiUid), + EGetElementAttributes, ERemConResponse, messageBuffer); + } + + // Make sure attribute list is reset for next time + iResponse->Close(); + messageBuffer.Close(); + + iInProgress = EFalse; + if (!iMsgQueue.IsEmpty()) + { + iNextMessageCallBack->CallBack(); + } + + } + +int CRemConMediaInformationTarget::NextMessageCb(TAny* aThis) + { + static_cast(aThis)->DoNextMessage(); + return KErrNone; + } + +void CRemConMediaInformationTarget::DoNextMessage() + { + CRemConMediaInformationQueuedMessage* msg = iMsgQueue.First(); + iMsgQueue.Remove(*msg); + ProcessMessage(msg->Data()); + delete msg; + } + +EXPORT_C TMediaAttributeIter::TMediaAttributeIter(RArray& aMediaAttributeIDs) : + iMediaAttributeIDs(aMediaAttributeIDs), + iterator(0) + { + } + +EXPORT_C void TMediaAttributeIter::Start() + { + iterator = 0; + } + +EXPORT_C TBool TMediaAttributeIter::Next(TMediaAttributeId& aId) + { + TInt count = iMediaAttributeIDs.Count(); + if (iterator > count - 1) + { + return EFalse; + } + aId = iMediaAttributeIDs[iterator]; + iterator++; + return ETrue; + } + +CRemConMediaInformationQueuedMessage* CRemConMediaInformationQueuedMessage::NewL(const TDesC8& aData) + { + CRemConMediaInformationQueuedMessage* self = new (ELeave) CRemConMediaInformationQueuedMessage(); + CleanupStack::PushL(self); + self->ConstructL(aData); + CleanupStack::Pop(self); + return self; + } + +CRemConMediaInformationQueuedMessage::CRemConMediaInformationQueuedMessage() + { + + } + +void CRemConMediaInformationQueuedMessage::ConstructL(const TDesC8& aData) + { + iData.CreateL(aData); + } + +CRemConMediaInformationQueuedMessage::~CRemConMediaInformationQueuedMessage() + { + iData.Close(); + } + +const TDesC8& CRemConMediaInformationQueuedMessage::Data() + { + return iData; + } + + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/bwins/remconnowplayingapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/bwins/remconnowplayingapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,8 @@ +EXPORTS + ??1CRemConNowPlayingTargetBase@@MAE@XZ @ 1 NONAME ; CRemConNowPlayingTargetBase::~CRemConNowPlayingTargetBase(void) + ?NowPlayingContentChanged@CRemConNowPlayingTargetBase@@QAEXXZ @ 2 NONAME ; void CRemConNowPlayingTargetBase::NowPlayingContentChanged(void) + ?NewL@CRemConDatabaseAwareNowPlayingTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConDatabaseAwareNowPlayingTargetObserver@@@Z @ 3 NONAME ; class CRemConDatabaseAwareNowPlayingTarget * CRemConDatabaseAwareNowPlayingTarget::NewL(class CRemConInterfaceSelector &, class MRemConDatabaseAwareNowPlayingTargetObserver &) + ?AddToNowPlayingResponse@CRemConNowPlayingTargetBase@@QAEXH@Z @ 4 NONAME ; void CRemConNowPlayingTargetBase::AddToNowPlayingResponse(int) + ?NewL@CRemConDatabaseUnawareNowPlayingTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAVMRemConDatabaseUnawareNowPlayingTargetObserver@@@Z @ 5 NONAME ; class CRemConDatabaseUnawareNowPlayingTarget * CRemConDatabaseUnawareNowPlayingTarget::NewL(class CRemConInterfaceSelector &, class MRemConDatabaseUnawareNowPlayingTargetObserver &) + ?PlayItemResponse@CRemConNowPlayingTargetBase@@QAEXH@Z @ 6 NONAME ; void CRemConNowPlayingTargetBase::PlayItemResponse(int) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/eabi/remconnowplayingapiu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/eabi/remconnowplayingapiu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,10 @@ +EXPORTS + _ZN27CRemConNowPlayingTargetBase16PlayItemResponseEi @ 1 NONAME + _ZN27CRemConNowPlayingTargetBase23AddToNowPlayingResponseEi @ 2 NONAME + _ZN27CRemConNowPlayingTargetBase24NowPlayingContentChangedEv @ 3 NONAME + _ZN27CRemConNowPlayingTargetBaseD0Ev @ 4 NONAME + _ZN27CRemConNowPlayingTargetBaseD1Ev @ 5 NONAME + _ZN27CRemConNowPlayingTargetBaseD2Ev @ 6 NONAME + _ZN36CRemConDatabaseAwareNowPlayingTarget4NewLER24CRemConInterfaceSelectorR44MRemConDatabaseAwareNowPlayingTargetObserver @ 7 NONAME + _ZN38CRemConDatabaseUnawareNowPlayingTarget4NewLER24CRemConInterfaceSelectorR46MRemConDatabaseUnawareNowPlayingTargetObserver @ 8 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconnowplayingapi.mmp + +PRJ_EXPORTS +../public/remcondatabaseawarenowplayingtarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawarenowplayingtarget.h) +../public/remcondatabaseawarenowplayingtargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseawarenowplayingtargetobserver.h) + +../public/remcondatabaseunawarenowplayingtarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawarenowplayingtarget.h) +../public/remcondatabaseunawarenowplayingtargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remcondatabaseunawarenowplayingtargetobserver.h) + +../public/remconnowplayingtargetbase.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(remcon/remconnowplayingtargetbase.h) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/group/remconnowplayingapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/group/remconnowplayingapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,61 @@ +// Copyright (c) 2008-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: +// remconmediainformationapi.dll Remote Control Media Information API - an outer-layer client side library. +// + + + +/** + @file + @internalComponent +*/ + +TARGET remconnowplayingapi.dll +TARGETPATH /system/libs + +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll + +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x10285bbc +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE remconnowplayingtargetbase.cpp +SOURCE remcondatabaseawarenowplayingtarget.cpp +SOURCE remcondatabaseunawarenowplayingtarget.cpp +SOURCE remconnowplayingutils.cpp + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +USERINCLUDE ../inc +USERINCLUDE ../../common + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib +LIBRARY avrcpipc.lib +LIBRARY remconmediainformationapi.lib +LIBRARY remconmediabrowseapi.lib +LIBRARY estor.lib + +#include +#include + +UNPAGED + +SMPSAFE + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/inc/remconnowplayingfault.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/inc/remconnowplayingfault.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,42 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#ifndef REMCONNOWPLAYINGFAULT_H_ +#define REMCONNOWPLAYINGFAULT_H_ + +#include + +_LIT(KNowPlayingFaultName, "RcNpFault"); + +enum TRemConNowPlayingFault + { + EInvalidEventId = 0, + }; + +class NowPlayingFault + { +public: + static void Fault(TRemConNowPlayingFault aFault); + }; + +#endif /*REMCONNOWPLAYINGFAULT_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseawarenowplayingtarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseawarenowplayingtarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEAWARENOWPLAYINGTARGET_H +#define REMCONDATABASEAWARENOWPLAYINGTARGET_H + + +#include +#include + +class CRemConInterfaceSelector; + +NONSHARABLE_CLASS(CRemConDatabaseAwareNowPlayingTarget) : public CRemConNowPlayingTargetBase + { +public: + IMPORT_C static CRemConDatabaseAwareNowPlayingTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareNowPlayingTargetObserver& aObserver); + virtual ~CRemConDatabaseAwareNowPlayingTarget(); + + +private: + CRemConDatabaseAwareNowPlayingTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareNowPlayingTargetObserver& aObserver); + void ConstructL(); + }; + +#endif //REMCONDATABASEAWARENOWPLAYINGTARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseawarenowplayingtargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseawarenowplayingtargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,103 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEAWARENOWPLAYINGTARGETOBSERVER_H +#define REMCONDATABASEAWARENOWPLAYINGTARGETOBSERVER_H + +#include + +/** +It is intended for the client which is database aware. +Clients must implement this interface in order to instantiate objects of type +CRemConDatabaseAwareNowPlayingTarget. This interface passes incoming commands +from RemCon to the client. + +@see CRemConDatabaseAwareNowPlayingTarget +*/ +NONSHARABLE_CLASS(MRemConDatabaseAwareNowPlayingTargetObserver) + { +public: + /** + Requests to play an item. + + @param aItem The item requested to play. + - If it does not refer to any valid item, the client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrInvalidUid; + - If it refers to a directory which can not be handled by this media + player, the client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrNowPlayingUidIsADirectory; + - If it is in use and can not be played, the client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrNowPlayingMediaInUse; + + @param aScope The scope in which the item was requested to play. + + @param aMediaLibraryStateCookie The cookie which the remote device + believes refers to the current state of the media library. If this + does not match the current state according to the client then the + client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrInvalidMediaLibraryStateCookie. + + @see CRemConNowPlayingTargetBase::PlayItemResponse(). + */ + virtual void MrcdanptoPlayItem(const TRemConItemUid& aItem, + TRemConFolderScope aScope, + TUint16 aMediaLibraryStateCookie) = 0; + + /** + Requests to add an item to now playing list. + + @param aItem The item requested to play. + - If it does not refer to any valid item, the client must call + CRemConNowPlayingTargetBase::AddToNowPlayingResponse() + with the error KErrInvalidUid; + - If it refers to a directory which can not be handled by this media + player, the client must call + CRemConNowPlayingTargetBase::AddToNowPlayingResponse() + with the error KErrNowPlayingUidIsADirectory; + - If it is in use and can not be added to now playing list, the + client must call + CRemConNowPlayingTargetBase::AddToNowPlayingResponse() + with the error KErrNowPlayingMediaInUse; + + @param aScope The scope in which the item was requested to play. + + @param aMediaLibraryStateCookie The cookie which the remote device + believes refers to the current state of the media library. If this + does not match the current state according to the client then the + client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrInvalidMediaLibraryStateCookie. + + @see CRemConNowPlayingTargetBase::AddToNowPlayingResponse(). + */ + virtual void MrcdanptoAddToNowPlaying(const TRemConItemUid& aItem, + TRemConFolderScope aScope, + TUint16 aMediaLibraryStateCookie) = 0; + }; + + +#endif //REMCONDATABASEAWARENOWPLAYINGTARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseunawarenowplayingtarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseunawarenowplayingtarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEUNAWARENOWPLAYINGTARGET_H +#define REMCONDATABASEUNAWARENOWPLAYINGTARGET_H + +#include +#include + +class CRemConInterfaceSelector; + +NONSHARABLE_CLASS(CRemConDatabaseUnawareNowPlayingTarget) : public CRemConNowPlayingTargetBase + { +public: + IMPORT_C static CRemConDatabaseUnawareNowPlayingTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareNowPlayingTargetObserver& aObserver); + virtual ~CRemConDatabaseUnawareNowPlayingTarget(); + + +private: + CRemConDatabaseUnawareNowPlayingTarget(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareNowPlayingTargetObserver& aObserver); + void ConstructL(); + }; + +#endif //REMCONDATABASEUNAWARENOWPLAYINGTARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseunawarenowplayingtargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/public/remcondatabaseunawarenowplayingtargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONDATABASEUNAWARENOWPLAYINGTARGETOBSERVER_H +#define REMCONDATABASEUNAWARENOWPLAYINGTARGETOBSERVER_H + +#include + +/** +It is intended for the client which is database aware. +Clients must implement this interface in order to instantiate objects of type +CRemConDatabaseUnawareNowPlayingTarget. This interface passes incoming +commands from RemCon to the client. + +@see CRemConDatabaseUnawareNowPlayingTarget +*/ +NONSHARABLE_CLASS(MRemConDatabaseUnawareNowPlayingTargetObserver) + { +public: + /** + Requests to play an item. + + @param aItem The item requested to play. + - If it does not refer to any valid item, the client must call + CRemConNowPlayingTargetBase::PlayItemResponse() with the error + KErrInvalidUid; + - If it refers to a directory which can not be handled by this media + player, the client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrNowPlayingUidIsADirectory; + - If it is in use and can not be played, the client must call + CRemConNowPlayingTargetBase::PlayItemResponse() + with the error KErrNowPlayingMediaInUse; + + @param aScope The scope in which the item was requested to play. + + @see CRemConNowPlayingTargetBase::PlayItemResponse(). + */ + virtual void MrcdunptoPlayItem(const TRemConItemUid& aItem, + TRemConFolderScope aScope) = 0; + + /** + Requests to add an item to now playing list. + + @param aItem The item requested to play. + - If it does not refer to any valid item, the client must call + CRemConNowPlayingTargetBase::AddToNowPlayingResponse() + with the error KErrInvalidUid; + - If it refers to a directory which can not be handled by this media + player, the client must call + CRemConNowPlayingTargetBase::AddToNowPlayingResponse() + with the error KErrNowPlayingUidIsADirectory; + - If it is in use and can not be added to now playing list, the + client must call + CRemConNowPlayingTargetBase::AddToNowPlayingResponse() + with the error KErrNowPlayingMediaInUse; + + @param aScope The scope in which the item was requested to play. + + @see CRemConNowPlayingTargetBase::AddToNowPlayingResponse(). + */ + virtual void MrcdunptoAddToNowPlaying(const TRemConItemUid& aItem, + TRemConFolderScope aScope) = 0; + }; + +#endif //REMCONDATABASEUNAWARENOWPLAYINGTARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/public/remconnowplayingtargetbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/public/remconnowplayingtargetbase.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,111 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONNOWPLAYINGTARGETBASE_H +#define REMCONNOWPLAYINGTARGETBASE_H + +#include +#include +#include +#include + +class CRemConInterfaceSelector; +class MRemConDatabaseAwareNowPlayingTargetObserver; +class MRemConDatabaseUnawareNowPlayingTargetObserver; +class TRemConMessageQueue; + +/** +A parent class for CRemConDatabaseAwareNowPlayingTarget and +CRemConDatabaseUnawareNowPlayingTarget. + +This class is not intended for instantiation. Clients should instead use the +appropriate derived class - either CRemConDatabaseAwareNowPlayingTarget or +CRemConDatabaseUnawareNowPlayingTarget. + +This class is only to be used by classes currently derived from it. + +@see CRemConDatabaseAwareNowPlayingTarget +@see CRemConDatabaseUnawareNowPlayingTarget +*/ +NONSHARABLE_CLASS(CRemConNowPlayingTargetBase) : public CRemConInterfaceBase, + public MRemConInterfaceIf2 + { +public: + IMPORT_C void PlayItemResponse(TInt aErr); + IMPORT_C void AddToNowPlayingResponse(TInt aErr); + IMPORT_C void NowPlayingContentChanged(); + +protected: + IMPORT_C virtual ~CRemConNowPlayingTargetBase(); + + CRemConNowPlayingTargetBase(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareNowPlayingTargetObserver& aObserver); + + CRemConNowPlayingTargetBase(CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareNowPlayingTargetObserver& aObserver); + + virtual void BaseConstructL(); + +private: //From CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: //From MRemConInterfaceIf2 + void MrcibNewMessage(TUint aOperationId, + const TDesC8& aData, + TRemConMessageSubType aMsgSubType); + +private: //Utility functions + void SendResponse(TUint8 aStatus, TUint aOperationId); + void SendError(TInt aError, TUint aOperationId); + void SendNotificationResponse(TRemConMessageSubType aMsgSubType); + + void ProcessGetStatus(); + void ProcessGetStatusAndBeginObserving(); + void ProcessPlayItem(const TDesC8& aData); + void ProcessAddToNowPlaying(const TDesC8& aData); + + TBool ProcessNowPlaying(const TDesC8& aData, + TUint aOperationId, + TUint64& aItem, + TRemConFolderScope& aScope, + TUint16& aMediaLibraryStateCookie); + + static TInt NextMessageCb(TAny* aThis); + void DoNextMessage(); + void AddToOperationQueue(TInt aOperationId, const TDesC8& aData); + +private: //Unowned + MRemConDatabaseAwareNowPlayingTargetObserver* iDaObserver; + MRemConDatabaseUnawareNowPlayingTargetObserver* iDuObserver; + CRemConInterfaceSelector& iInterfaceSelector; + +private: //Owned + TBool iNotificationPending; + RBuf8 iOutBuf; + + TBool iInProgress; + TRemConMessageQueue* iMsgQueue; + CAsyncCallBack* iNextMessageCallBack; + }; + +#endif //REMCONNOWPLAYINGTARGETBASE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/src/remcondatabaseawarenowplayingtarget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/src/remcondatabaseawarenowplayingtarget.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +EXPORT_C CRemConDatabaseAwareNowPlayingTarget* CRemConDatabaseAwareNowPlayingTarget::NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareNowPlayingTargetObserver& aObserver) + { + CRemConDatabaseAwareNowPlayingTarget* self = new(ELeave)CRemConDatabaseAwareNowPlayingTarget(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CRemConDatabaseAwareNowPlayingTarget::~CRemConDatabaseAwareNowPlayingTarget() + { + } + +CRemConDatabaseAwareNowPlayingTarget::CRemConDatabaseAwareNowPlayingTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareNowPlayingTargetObserver& aObserver) + : CRemConNowPlayingTargetBase(aInterfaceSelector, aObserver) + { + } + +void CRemConDatabaseAwareNowPlayingTarget::ConstructL() + { + BaseConstructL(); + } + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/src/remcondatabaseunawarenowplayingtarget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/src/remcondatabaseunawarenowplayingtarget.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,51 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @publishedAll + @released +*/ + +#include + +EXPORT_C CRemConDatabaseUnawareNowPlayingTarget* CRemConDatabaseUnawareNowPlayingTarget::NewL( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareNowPlayingTargetObserver& aObserver) + { + CRemConDatabaseUnawareNowPlayingTarget* self = new(ELeave)CRemConDatabaseUnawareNowPlayingTarget(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CRemConDatabaseUnawareNowPlayingTarget::~CRemConDatabaseUnawareNowPlayingTarget() + { + } + +CRemConDatabaseUnawareNowPlayingTarget::CRemConDatabaseUnawareNowPlayingTarget( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareNowPlayingTargetObserver& aObserver) + : CRemConNowPlayingTargetBase(aInterfaceSelector, aObserver) + { + } + +void CRemConDatabaseUnawareNowPlayingTarget::ConstructL() + { + BaseConstructL(); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/src/remconnowplayingtargetbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/src/remconnowplayingtargetbase.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,472 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "mediabrowse.h" +#include "nowplaying.h" +#include "remconnowplayingfault.h" +#include "remconqueuemessage.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_REMCONNOWPLAYINGAPI); +_LIT8(KLogFormat, "Operation Id = 0x%x, Data Lengh = %d"); +#endif + +CRemConNowPlayingTargetBase::CRemConNowPlayingTargetBase( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseAwareNowPlayingTargetObserver& aObserver) + : CRemConInterfaceBase( + TUid::Uid(KRemConNowPlayingApiUid), + KMaxLengthNowPlayingMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iDaObserver(&aObserver), + iInterfaceSelector(aInterfaceSelector), + iInProgress(EFalse) + { + } + +CRemConNowPlayingTargetBase::CRemConNowPlayingTargetBase( + CRemConInterfaceSelector& aInterfaceSelector, + MRemConDatabaseUnawareNowPlayingTargetObserver& aObserver) + : CRemConInterfaceBase( + TUid::Uid(KRemConNowPlayingApiUid), + KMaxLengthNowPlayingMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iDuObserver(&aObserver), + iInterfaceSelector(aInterfaceSelector), + iInProgress(EFalse) + { + } + +void CRemConNowPlayingTargetBase::BaseConstructL() + { + iMsgQueue = new(ELeave)TRemConMessageQueue; + TCallBack cb(&NextMessageCb, this); + iNextMessageCallBack = new (ELeave) CAsyncCallBack(cb, + CActive::EPriorityStandard); + + iOutBuf.CreateL(KMaxLengthNowPlayingMsg); + + // Mandate the following features supported. + RRemConInterfaceFeatures features; + User::LeaveIfError(features.Open()); + CleanupClosePushL(features); + + features.AddOperationL(EPlayItem); + features.AddOperationL(EAddToNowPlaying); + features.AddOperationL(ERegisterNotification); + + CRemConInterfaceBase::BaseConstructL(features); + CleanupStack::PopAndDestroy(&features); + } + + +EXPORT_C CRemConNowPlayingTargetBase::~CRemConNowPlayingTargetBase() + { + iOutBuf.Close(); + + iNextMessageCallBack->Cancel(); + delete iNextMessageCallBack; + + iMsgQueue->Reset(); + delete iMsgQueue; + } + +/** +@internalComponent +@released + +Gets a pointer to a specific interface version. + +@return A pointer to the interface, NULL if not supported. +*/ +TAny* CRemConNowPlayingTargetBase::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf2) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +/** +Provide a response to the play item command. For database aware clients this +would have been called via MrcdanptoPlayItem(). For database unaware client +this would have been called via MrcdunptoPlayItem() + +The client must call NowPlayingContentChanged() if the content of the now +playing list has been changed after the client successfully plays the item +and provides the response with KErrNone through this function. + +@param aErr The result of play item operation. + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the client is able to maintain + unique UIDs accross the entire virtual filesystem, but the media + library state cookie provided does not match the client's state cookie. + - KErrInvalidUid if the uid of the item provided does not refer to any + valid item. + - KErrNowPlayingUidIsADirectory if the uid of the item provided refers to + a directory which can not be handled by this media player. + - KErrNowPlayingMediaInUse if the item is in use and can not be played. + - System wide error code otherwise. + +@see NowPlayingContentChanged() +*/ +EXPORT_C void CRemConNowPlayingTargetBase::PlayItemResponse(TInt aErr) + { + TUint8 status = RAvrcpIPC::SymbianErrToStatus(aErr); + SendResponse(status, EPlayItem); + + iInProgress = EFalse; + if (!iMsgQueue->IsEmpty()) + { + iNextMessageCallBack->CallBack(); + } + } + +/** +Sends the response for the request MrcnptoAddToNowPlaying() + +The client must call NowPlayingContentChanged() if the content of the now +playing list has been changed after the client successfully adds the item +to the now playing list and provides the response with KErrNone through +this function. + +param aErr The result of add to now playing operation. + - KErrNone if the operation was successful. + - KErrInvalidMediaLibraryStateCookie if the client is able to maintain + unique UIDs accross the entire virtual filesystem, but the media + library state cookie provided does not match the client's state cookie. + - KErrInvalidUid if the uid of the item provided does not + refer to any valid item. + - KErrNowPlayingUidIsADirectory if the uid of the item provided refers to + a directory which can not be handled by this media player. + - KErrNowPlayingMediaInUse if the item is in use and can not be added to + now playing list. + - KErrNowPlayingListFull if the now playing list if full and no more items + can be added. + - System wide error code otherwise. + +@see NowPlayingContentChanged() +*/ +EXPORT_C void CRemConNowPlayingTargetBase::AddToNowPlayingResponse(TInt aErr) + { + TUint8 status = RAvrcpIPC::SymbianErrToStatus(aErr); + SendResponse(status, EAddToNowPlaying); + + iInProgress = EFalse; + if (!iMsgQueue->IsEmpty()) + { + iNextMessageCallBack->CallBack(); + } + } + +/** +Called by the client in the case that the now playing content changed. + +@see PlayItemResponse() +@see AddToNowPlayingResponse() +*/ +EXPORT_C void CRemConNowPlayingTargetBase::NowPlayingContentChanged() + { + if(iNotificationPending) + { + iNotificationPending = EFalse; + SendNotificationResponse(ERemConNotifyResponseChanged); + } + } + +void CRemConNowPlayingTargetBase::SendResponse(TUint8 aStatus, TUint aOperationId) + { + TInt error = KErrNone; + + // Formats the response in a RRemConNowPlayingResponse + RRemConNowPlayingResponse response; + response.iStatus = aStatus; + + TRAP(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + // Send the response back to the CT + error = InterfaceSelector().SendUnreliable( + TUid::Uid(KRemConNowPlayingApiUid), + aOperationId, ERemConResponse, iOutBuf ); + } + + } + +void CRemConNowPlayingTargetBase::SendError(TInt aError, TUint aOperationId) + { + TInt error = KErrNone; + RAvrcpIPCError response; + response.iError = RAvrcpIPC::SymbianErrorCheck(aError); + TRAP(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConNowPlayingApiUid), + aOperationId, ERemConResponse, iOutBuf); + } + } + +// From MRemConInterfaceIf2 +void CRemConNowPlayingTargetBase::MrcibNewMessage( + TUint aOperationId, + const TDesC8& aData, + TRemConMessageSubType aMsgSubType) + { + LOG_FUNC + LOG2(KLogFormat, aOperationId, aData.Length()); + + TMetadataTransferPDU currentOp = + RAvrcpIPC::GetPDUIdFromIPCOperationId(aOperationId); + switch(currentOp) + { + case EPlayItem: + if ( !iInProgress && + !iMsgQueue->Find(TUid::Uid(KRemConNowPlayingApiUid), EPlayItem)) + { + ProcessPlayItem(aData); + } + else + { + AddToOperationQueue(EPlayItem, aData); + } + break; + case EAddToNowPlaying: + if ( !iInProgress && + !iMsgQueue->Find(TUid::Uid(KRemConNowPlayingApiUid), EAddToNowPlaying)) + { + ProcessAddToNowPlaying(aData); + } + else + { + AddToOperationQueue(EAddToNowPlaying, aData); + } + break; + case ERegisterNotification: + { + // obtain eventId from aOperationId + TRegisterNotificationEvent eventId = + RAvrcpIPC::GetEventIdFromIPCOperationId(aOperationId); + + // If asserted here, must something wrong occured in the + // remconbearer handling + __ASSERT_DEBUG(eventId == ERegisterNotificationNowPlayingContentChanged + , NowPlayingFault::Fault(EInvalidEventId)); + + // register for Notifications + if (aMsgSubType == ERemConNotifyCommandAwaitingInterim) + { + ProcessGetStatusAndBeginObserving(); + } + else if (aMsgSubType == ERemConNotifyCommandAwaitingChanged) + { + ProcessGetStatus(); + } + break; + } + default: + break; + }; + } + +void CRemConNowPlayingTargetBase::ProcessPlayItem(const TDesC8& aData) + { + TUint64 item; + TRemConFolderScope scope; + TUint16 uidCounter; + + if (!ProcessNowPlaying(aData, EPlayItem, item, scope, uidCounter)) + { + return; + } + + iInProgress = ETrue; + if (iDaObserver && (uidCounter > 0)) + { + iDaObserver->MrcdanptoPlayItem(item, scope, uidCounter); + } + else if (!iDaObserver && (0 == uidCounter)) + { + iDuObserver->MrcdunptoPlayItem(item, scope); + } + else + { + PlayItemResponse(KErrAvrcpAirInvalidParameter); + } + } + +void CRemConNowPlayingTargetBase::ProcessAddToNowPlaying(const TDesC8& aData) + { + TUint64 item; + TRemConFolderScope scope; + TUint16 uidCounter; + + if (!ProcessNowPlaying(aData, EAddToNowPlaying, item, scope, uidCounter)) + { + return; + } + + iInProgress = ETrue; + if (iDaObserver && (uidCounter > 0)) + { + iDaObserver->MrcdanptoAddToNowPlaying(item, scope, uidCounter); + } + else if (!iDaObserver && (0 == uidCounter)) + { + iDuObserver->MrcdunptoAddToNowPlaying(item, scope); + } + else + { + AddToNowPlayingResponse(KErrAvrcpAirInvalidParameter); + } + } + +TBool CRemConNowPlayingTargetBase::ProcessNowPlaying( + const TDesC8& aData, + TUint aOperationId, + TUint64& aItem, + TRemConFolderScope& aScope, + TUint16& aMediaLibraryStateCookie) + { + RRemConNowPlayingRequest request; + TRAPD(error, request.ReadL(aData)) + if (error != KErrNone) + { + // Nothing in packet + SendError(KErrAvrcpMetadataParameterNotFound, aOperationId); + return EFalse; + } + + aItem = request.iElement; + aScope = request.iScope; + aMediaLibraryStateCookie = request.iUidCounter; + + //Does not allow invalid scope + if ( aScope != EBrowseFolder + && aScope != ESearchResultFolder + && aScope != ENowPlayingFolder ) + { + SendError(KErrAvrcpAirInvalidScope, aOperationId); + return EFalse; + } + return ETrue; + } + +void CRemConNowPlayingTargetBase::ProcessGetStatusAndBeginObserving() + { + // and request another notification (if there is not one already pending) + // on the next state change + iNotificationPending = ETrue; + + // send the current status + SendNotificationResponse(ERemConNotifyResponseInterim); + } + +void CRemConNowPlayingTargetBase::ProcessGetStatus() + { + // send the current value + SendNotificationResponse(ERemConNotifyResponseChanged); + } + +void CRemConNowPlayingTargetBase::SendNotificationResponse( + TRemConMessageSubType aMsgSubType) + { + LOG_FUNC + + TInt error = KErrNone; + + // No extra data needed + RAvrcpIPCError response; + response.iError = KErrNone; + TRAP(error, response.WriteL(iOutBuf)); + + if (error == KErrNone) + { + // send the response back to the CT + TUint operationId = + RAvrcpIPC::SetIPCOperationIdFromEventId( + ERegisterNotificationNowPlayingContentChanged); + + error = InterfaceSelector().SendUnreliable( + TUid::Uid(KRemConNowPlayingApiUid), + operationId, ERemConResponse, aMsgSubType, iOutBuf); + } + } + +TInt CRemConNowPlayingTargetBase::NextMessageCb(TAny* aThis) + { + static_cast(aThis)->DoNextMessage(); + return KErrNone; + } + +void CRemConNowPlayingTargetBase::DoNextMessage() + { + CRemConQueuedMessage* msg = iMsgQueue->First(); + iMsgQueue->Remove(*msg); + + switch (msg->iOperationId) + { + case EPlayItem: + ProcessPlayItem(msg->Data()); + break; + case EAddToNowPlaying: + ProcessAddToNowPlaying(msg->Data()); + break; + default: + // Never come here. + ASSERT(NULL); + break; + } + delete msg; + } + +void CRemConNowPlayingTargetBase::AddToOperationQueue(TInt aOperationId, + const TDesC8& aData) + { + CRemConQueuedMessage* msg = NULL; + TRAPD(err, msg = CRemConQueuedMessage::NewL( + TUid::Uid(KRemConNowPlayingApiUid), aData, aOperationId)); + if (err == KErrNone) + { + iMsgQueue->AddLast(*msg); + } + else + { + SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/nowplayingapi/src/remconnowplayingutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/nowplayingapi/src/remconnowplayingutils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include "remconnowplayingfault.h" + +void NowPlayingFault::Fault(TRemConNowPlayingFault aFault) + { + User::Panic(KNowPlayingFaultName, aFault); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/bwins/remconplayerinformationu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/bwins/remconplayerinformationu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,21 @@ +EXPORTS + ??1CPlayerApplicationSettings@@UAE@XZ @ 1 NONAME ABSENT ; CPlayerApplicationSettings::~CPlayerApplicationSettings(void) + ??1CPlayerInfoTarget@@UAE@XZ @ 2 NONAME ; CPlayerInfoTarget::~CPlayerInfoTarget(void) + ?AddCompanyId@MPlayerCapabilitiesObserver@@QAEHH@Z @ 3 NONAME ; int MPlayerCapabilitiesObserver::AddCompanyId(int) + ?AddEvent@MPlayerCapabilitiesObserver@@QAEHW4TRegisterNotificationEvent@@@Z @ 4 NONAME ; int MPlayerCapabilitiesObserver::AddEvent(enum TRegisterNotificationEvent) + ?ClearCompanyIds@MPlayerCapabilitiesObserver@@QAEXXZ @ 5 NONAME ; void MPlayerCapabilitiesObserver::ClearCompanyIds(void) + ?ClearEvents@MPlayerCapabilitiesObserver@@QAEXXZ @ 6 NONAME ; void MPlayerCapabilitiesObserver::ClearEvents(void) + ?DefineAttributeL@MPlayerApplicationSettingsObserver@@QAEXIAAVTDesC8@@AAV?$RArray@I@@AAV?$RArray@VTPtrC8@@@@I@Z @ 7 NONAME ; void MPlayerApplicationSettingsObserver::DefineAttributeL(unsigned int, class TDesC8 &, class RArray &, class RArray &, unsigned int) + ?DefineAttributesL@PlayerApplicationSettingsResourceInit@@SAXAAVMPlayerApplicationSettingsObserver@@AAVCResourceFile@@@Z @ 8 NONAME ; void PlayerApplicationSettingsResourceInit::DefineAttributesL(class MPlayerApplicationSettingsObserver &, class CResourceFile &) + ?NewL@CPlayerApplicationSettings@@SAPAV1@IAAVTDesC8@@V?$RArray@I@@AAV?$RArray@VTPtrC8@@@@I@Z @ 9 NONAME ABSENT ; class CPlayerApplicationSettings * CPlayerApplicationSettings::NewL(unsigned int, class TDesC8 &, class RArray, class RArray &, unsigned int) + ?NewL@CPlayerInfoTarget@@SAPAV1@AAVCRemConInterfaceSelector@@AAPAVMPlayerCapabilitiesObserver@@AAPAVMPlayerApplicationSettingsObserver@@AAPAVMPlayerEventsObserver@@AAVMPlayerApplicationSettingsNotify@@@Z @ 10 NONAME ; class CPlayerInfoTarget * CPlayerInfoTarget::NewL(class CRemConInterfaceSelector &, class MPlayerCapabilitiesObserver * &, class MPlayerApplicationSettingsObserver * &, class MPlayerEventsObserver * &, class MPlayerApplicationSettingsNotify &) + ?PlaybackStatusChanged@MPlayerEventsObserver@@QAEXW4TPlaybackStatus@1@@Z @ 11 NONAME ; void MPlayerEventsObserver::PlaybackStatusChanged(enum MPlayerEventsObserver::TPlaybackStatus) + ?RemoveCompanyID@MPlayerCapabilitiesObserver@@QAEHH@Z @ 12 NONAME ; int MPlayerCapabilitiesObserver::RemoveCompanyID(int) + ?RemoveEvent@MPlayerCapabilitiesObserver@@QAEHW4TRegisterNotificationEvent@@@Z @ 13 NONAME ; int MPlayerCapabilitiesObserver::RemoveEvent(enum TRegisterNotificationEvent) + ?SetAttributeL@MPlayerApplicationSettingsObserver@@QAEXII@Z @ 14 NONAME ; void MPlayerApplicationSettingsObserver::SetAttributeL(unsigned int, unsigned int) + ?SetBatteryStatus@MPlayerEventsObserver@@QAEXW4TTargetBatteryStatus@1@@Z @ 15 NONAME ; void MPlayerEventsObserver::SetBatteryStatus(enum MPlayerEventsObserver::TTargetBatteryStatus) + ?SetPlaybackPosition@MPlayerEventsObserver@@QAEXK@Z @ 16 NONAME ; void MPlayerEventsObserver::SetPlaybackPosition(unsigned long) + ?TrackChanged@MPlayerEventsObserver@@QAEX_KK@Z @ 17 NONAME ; void MPlayerEventsObserver::TrackChanged(unsigned long long, unsigned long) + ?TrackReachedEnd@MPlayerEventsObserver@@QAEXXZ @ 18 NONAME ; void MPlayerEventsObserver::TrackReachedEnd(void) + ?TrackReachedStart@MPlayerEventsObserver@@QAEXXZ @ 19 NONAME ; void MPlayerEventsObserver::TrackReachedStart(void) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/eabi/remconplayerinformationu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/eabi/remconplayerinformationu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,21 @@ +EXPORTS + _ZN17CPlayerInfoTarget4NewLER24CRemConInterfaceSelectorRP27MPlayerCapabilitiesObserverRP34MPlayerApplicationSettingsObserverRP21MPlayerEventsObserverR32MPlayerApplicationSettingsNotify @ 1 NONAME + _ZN17CPlayerInfoTargetD0Ev @ 2 NONAME + _ZN17CPlayerInfoTargetD1Ev @ 3 NONAME + _ZN17CPlayerInfoTargetD2Ev @ 4 NONAME + _ZN21MPlayerEventsObserver12TrackChangedEym @ 5 NONAME + _ZN21MPlayerEventsObserver15TrackReachedEndEv @ 6 NONAME + _ZN21MPlayerEventsObserver16SetBatteryStatusENS_20TTargetBatteryStatusE @ 7 NONAME + _ZN21MPlayerEventsObserver17TrackReachedStartEv @ 8 NONAME + _ZN21MPlayerEventsObserver19SetPlaybackPositionEm @ 9 NONAME + _ZN21MPlayerEventsObserver21PlaybackStatusChangedENS_15TPlaybackStatusE @ 10 NONAME + _ZN27MPlayerCapabilitiesObserver11ClearEventsEv @ 11 NONAME + _ZN27MPlayerCapabilitiesObserver11RemoveEventE26TRegisterNotificationEvent @12 NONAME + _ZN27MPlayerCapabilitiesObserver12AddCompanyIdEi @ 13 NONAME + _ZN27MPlayerCapabilitiesObserver15ClearCompanyIdsEv @ 14 NONAME + _ZN27MPlayerCapabilitiesObserver15RemoveCompanyIDEi @ 15 NONAME + _ZN27MPlayerCapabilitiesObserver8AddEventE26TRegisterNotificationEvent @16 NONAME + _ZN34MPlayerApplicationSettingsObserver13SetAttributeLEjj @ 17 NONAME + _ZN34MPlayerApplicationSettingsObserver16DefineAttributeLEjR6TDesC8R6RArrayIjERS2_I6TPtrC8Ej @ 18 NONAME + _ZN37PlayerApplicationSettingsResourceInit17DefineAttributesLER34MPlayerApplicationSettingsObserverR13CResourceFile @ 19 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconplayerinformation.mmp + +PRJ_EXPORTS +../public/playerinformationtarget.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(playerinformationtarget.h) +../public/playerinformationtargetobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(playerinformationtargetobserver.h) diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/group/remconplayerinformation.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/group/remconplayerinformation.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,66 @@ +// Copyright (c) 2007-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: +// remconcoreapi.dll Remote Control Core API- an outer-layer client +// side library. +// +// + +/** + @file + @internalComponent +*/ + +TARGET remconplayerinformation.dll +TARGETPATH /system/libs +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x101f9067 +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE playerinformation.cpp +SOURCE settingsresource.cpp +SOURCE playersettings.cpp +SOURCE playercapabilities.cpp +SOURCE playerevents.cpp +SOURCE playerapplicationsetting.cpp +SOURCE eventsmask.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../common +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY bafl.lib +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY remconinterfacebase.lib +LIBRARY avrcpipc.lib +LIBRARY esock.lib + +SOURCEPATH ../resource +USERINCLUDE ../resource + +start resource avrcp-settings.rss +targetpath /bluetooth/avrcp/ +end + +#include + +UNPAGED + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/inc/eventsmask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/inc/eventsmask.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,51 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent + @released +*/ + +#ifndef EVENTSMASK_H +#define EVENTSMASK_H + +// INCLUDES +#include +#include + +/** +This class stores the supported events list in a bitmask. +The event ids are numbers from 0x01 to 0x09 (from specs). +A 1 in the 0xXX position means that the XX eventid event is supported, a 0 in +the same position means that it's not supported. + */ +NONSHARABLE_CLASS(TEventsMask) + { +public: + TEventsMask(); + void Reset(); + TBool Find(TRegisterNotificationEvent aEvent) const; + void Append(TRegisterNotificationEvent aEvent); + void Remove(TRegisterNotificationEvent aEvent); + void Begin(); + TBool Next(); + TRegisterNotificationEvent Get() const; +private: + TUint16 iMask; + TUint8 iNextSupportedEvent; + }; + +#endif // EVENTSMASK_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/inc/playereventsutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/inc/playereventsutils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,42 @@ +// Copyright (c) 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: +// + +#ifndef PLAYEREVENTSUTILS_H +#define PLAYEREVENTSUTILS_H + +_LIT(KPlayerEventsPanicName, "PlayerEvents"); + +enum TPlayerEventsPanic + { + ETwoGetPlayStatusUpdatesQueued = 0, + EBadlyFormattedInternalData = 1, + }; + +class PlayerEventsUtils + { +public: + static void Panic(TPlayerEventsPanic aPanic); + }; + +/** Utility PlayerEvents panic function. + +@param aPanic The panic number. +*/ +void PlayerEventsUtils::Panic(TPlayerEventsPanic aPanic) + { + User::Panic(KPlayerEventsPanicName, aPanic); + } + +#endif // PLAYEREVENTSUTILS_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/inc/playersettingsutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/inc/playersettingsutils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +// Copyright (c) 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: +// + +#ifndef PLAYERSETTTINGSUTILS_H +#define PLAYERSETTTINGSUTILS_H + +_LIT(KPlayerSettingsPanicName, "PlayerSettings"); + +enum TPlayerSettingsPanic + { + EPlayerSettingsFunnyLengthData = 0, + }; + +class PlayerSettingsUtils + { +public: + static void Panic(TPlayerSettingsPanic aPanic); // The macro is probably more useful so this can be removed + }; + +/** Utility PlayerSettings panic function. + +@param aPanic The panic number. +*/ +void PlayerSettingsUtils::Panic(TPlayerSettingsPanic aPanic) + { + User::Panic(KPlayerSettingsPanicName, aPanic); + } + +#endif //PLAYERSETTTINGSUTILS_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/public/playerinformationtarget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/public/playerinformationtarget.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,175 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONPLAYERINFORMATIONTARGET_H +#define REMCONPLAYERINFORMATIONTARGET_H + +#include +#include +#include + +#include +#include +#include +#include + +class CRemConInterfaceSelector; +class CPlayerApplicationSettings; +class TEventsMask; + +// This is the maximum length of the player application setting attribute and value strings +const TInt KMaxPlayerApplicationSettingsValue = 255 ; +// This is the minimum length of the player application setting attribute and value strings +const TInt KMinPlayerApplicationSettingsValue = 1 ; + +/** +Client-instantiable class supporting player information responses. +This is the container class for the three interface parts +*/ +NONSHARABLE_CLASS(CPlayerInfoTarget) : public CRemConInterfaceBase, + public MRemConInterfaceIf2, + private MPlayerCapabilitiesObserver, + private MPlayerApplicationSettingsObserver, + private MPlayerEventsObserver + + { +public: + /** + Factory function. + @param aInterfaceSelector The interface selector. The client must have + created one of these first. + @param aPlayerCapabilitiesObserver Returns a pointer to a MPlayerCapabilitiesObserver for this interface, owned by the CPlayerInfoTarget. + @param aPlayerApplicationSettingsObserver Returns a pointer to a MPlayerApplicationSettingsObserver for this interface, owned by the CPlayerInfoTarget + @param aPlayerEventsObserver Returns a pointer to a MPlayerEventsObserver for this interface, owned by the CPlayerInfoTarget + @return A new CPlayerInfoTarget, owned by the interface selector. + */ + IMPORT_C static CPlayerInfoTarget* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver, + MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver, + MPlayerEventsObserver*& aPlayerEventsObserver, + MPlayerApplicationSettingsNotify& aApplicationSettingNotifier ); + + /** Destructor */ + IMPORT_C ~CPlayerInfoTarget(); + + + +private: + /** + Constructor. + @param aInterfaceSelector The interface selector. + */ + CPlayerInfoTarget(CRemConInterfaceSelector& aInterfaceSelector, MPlayerApplicationSettingsNotify& aApplicationSettingNotifier ); + + void ConstructL(MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver, + MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver, + MPlayerEventsObserver*& aPlayerEventsObserver ); + +private: // from CRemConInterfaceBase + TAny* GetInterfaceIf(TUid aUid); + +private: // from MRemConInterfaceIf + void MrcibNewMessage(TUint aOperationId, const TDesC8& aData, TRemConMessageSubType aMsgSubType); + +private: + // Bearer attributes (settings) processing + void ProcessListPlayerApplicationAttributes( TInt aOperationId ); + void ProcessGetPlayerApplicationAttributeText( const TDesC8& aData, TInt aOperationId ); + void ProcessListPlayerApplicationValues( const TDesC8& aData, TInt aOperationId ); + void ProcessGetPlayerApplicationValueText( const TDesC8& aData, TInt aOperationId ); + void ProcessGetCurrentPlayerApplicationValue( const TDesC8& aData, TInt aOperationId ); + void ProcessSetPlayerApplicationValue( const TDesC8& aData, TInt aOperationId ); + + // Bearer attributes (settings) API implementation from MPlayerApplicationSettingsObserver + void DoDefineAttributeL(TUint aAttributeID, TDesC8& aAttributeText, RArray &aValues, RArray &aValueTexts, TUint aInitialValue); + void DoSetAttributeL(TUint aAttributeID, TUint aValue); + + // Notifier Events API implementation from MPlayerEventsObserver + void DoPlaybackStatusChanged(TPlaybackStatus aStatus); + void DoTrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds); + void DoTrackReachedEnd(); + void DoTrackReachedStart(); + void DoSetPlaybackPosition(TUint32 aMilliseconds); + void DoSetBatteryStatus(TTargetBatteryStatus aBatteryStatus); + + // Notifier Events bearer processing + void ProcessGetPlayStatus(); + void ProcessGetStatusAndBeginObserving(TUint aOperationId, TRegisterNotificationEvent aEventId, const TDesC8& aData); + void ProcessGetStatus(TUint aOperationId, TRegisterNotificationEvent aEventId); + void SendNotificationResponse(TRegisterNotificationEvent aEventId, TRemConMessageSubType aMsgSubType); + void ProcessGetPlayStatusUpdate(const TDesC8& aData); + + // Capabilities API implementation from MPlayerCapabilitiesObserver + void DoClearEvents(); + TInt DoAddEvent(TRegisterNotificationEvent aEvent); + TInt DoRemoveEvent(TRegisterNotificationEvent aEvent); + void DoClearCompanyIds(); + TInt DoAddCompanyId(TInt aID); + TInt DoRemoveCompanyID(TInt aID); + + // Capabilities bearer processing + void ProcessGetCapabilities( const TDesC8& aData ); + + // Miscellaneous + TBool AttributeSettingExists(TUint anAttribute); + TBool IsValidAttributeValue(TUint anAttributeId, TUint aAttributeValue); + TBool AttributeValueCanBeSet(TUint anAttributeId, TUint aAttributeValue); + void SendError(TInt, TInt); + void SendError(TInt, TInt, TRemConMessageSubType aSubType); + CPlayerApplicationSettings* GetSetting(TUint anAttribute); + MPlayerEventsObserver::TTargetBatteryStatus DetectBatteryStatus(); + +private: // owned + RBuf8 iOutBuf; + + MPlayerApplicationSettingsNotify& iApplicationSettingNotifier; + + // data for MPlayerEventsObserver + TPlaybackStatus iPlayBackStatus; + TUint64 iTrackId; + TUint32 iLengthInMilliseconds; + TPlayPosition iTrackPosition; + + // The time interval (received as part if the RegisterNotification) + // in which the change in playback position will be notified + TUint32 iPlayBackIntervalInMilliseconds; + + TTargetBatteryStatus iBatteryStatus; + TUint32 iPlaybackPositionInMilliseconds; + TUint32 iLastNotifiedPlaybackPositionInMilliseconds; + + // data for MPlayerCapabilitiesObserver + TEventsMask* iSupportedNotificationEventList; + RArray iCompanyIdList; + + // list of events for which notifications have been request + RArray iPendingNotificationEventList; + + // Whether we've been asked for an update when the play status changes + TBool iPlaybackStatusUpdatePending; + + // Attribute (settings) data MPlayerApplicationSettingsObserver + RHashMap iPlayerApplicationSettings; + + }; + + +#endif // REMCONPLAYERINFORMATIONTARGET_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/public/playerinformationtargetobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/public/playerinformationtargetobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,298 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONPLAYERINFORMATIONTARGETOBSERVER_H +#define REMCONPLAYERINFORMATIONTARGETOBSERVER_H + +#include +#include +#include + + +/** +This class is used to define the capabilities of the current application, +and the implementation will generate AVRCP responses to the controller. +For the event part of the API, it is recommended to add all events which make +sense for the media player. In general, this will be everything except +ESystemStatusChanged. The company ID part of the API is only needed if +the media player needs to support vendor extensions other than bluetooth SIG. +The bluetooth SIG company ID is always included in responses to a COMPANY_ID request. +*/ +class MPlayerCapabilitiesObserver + { + public: + /** + Remove all notification events from the supported list + */ + IMPORT_C void ClearEvents(); + /** + Add a notification event to the supported list of events + The AVRCP 1.3 specification mandates that PlaybackStatusChanged + and TrackChanged events must be supported; KErrAlreadyExists will + be returned if AddEvent() is called with either of these events. + @param aEvent the event to add + @return KErrAlreadyExists if the event is already present. + KErrNotSupported if the event isn't supported by the implementation, e.g.. ESystemStatusChanged + */ + IMPORT_C TInt AddEvent(TRegisterNotificationEvent aEvent); + /** + Remove a notification event from the supported list of events + The AVRCP 1.3 specification mandates that PlaybackStatusChanged + and TrackChanged events must be supported; KErrNotSupported will + be returned if RemoveEvent() is called with either of these events. + @param aEvent the event to remove + @return KErrNone if this completes successfully, KErrNotFound if aID + was not in the list, or any other system wide error code. + */ + IMPORT_C TInt RemoveEvent(TRegisterNotificationEvent aEvent); + + const static TInt KMaxCompanyID = 0xFFFFFF; + const static TInt KMaxNrOfCompanyIDs = 255; + + /** + Remove all additional company IDs from the supported list + */ + IMPORT_C void ClearCompanyIds(); + /** + Add a company id to the supported list of company ids. + The AVRCP 1.3 specification mandates that the Bluetooth SIG vendor id + must be supported; KErrAlreadyExists will be returned if AddCompanyId() + is called with this company id. + @param aID the id to add + @return KErrNone if this completes successfully, + KErrAlreadyExists if aID is already present, + KErrOverflow if the maximum number of company ids are already listed, + or any other system wide error code. + */ + IMPORT_C TInt AddCompanyId(TInt aID); + /** + Remove a company id from the list of supported vendor extensions. + The Bluetooth SIG id can't be removed, as this must always be supported + @param aID the id to remove + @return KErrNone if this completes successfully, KErrNotFound if aID + was not in the list, or any other system wide error code. + */ + IMPORT_C TInt RemoveCompanyID(TInt aID); + + private: + virtual void DoClearEvents() = 0; + virtual TInt DoAddEvent(TRegisterNotificationEvent aEvent) = 0; + virtual TInt DoRemoveEvent(TRegisterNotificationEvent aEvent) = 0; + virtual void DoClearCompanyIds() = 0; + virtual TInt DoAddCompanyId(TInt aID) = 0; + virtual TInt DoRemoveCompanyID(TInt aID) = 0; + }; + +/** +This class is for supporting the player application settings PDUs in AVRCP1.3 +specification section 5.2. The RegisterNotification PDU for +EVENT_PLAYER_APPLICATION_SETTING_CHANGED is also supported through this API. + +The media player should first define all the attributes it supports, using +DefineAttributeL. When an attribute's value is changed by the media player, +it should call SetAttributeL to inform the controller. When the controller +changes a setting, the media player application receives a callback via the +MPlayerApplicationSettingsNotify interface +*/ +class MPlayerApplicationSettingsObserver + { + public: + /** + Define an attribute supported by this player. + It will be included in future responses to the following PDUs: + ListPlayerApplicationSettingAttributes, + ListPlayerApplicationSettingValues, + GetCurrentPlayerApplicationSettingValue, + GetPlayerApplicationSettingAttributeText, + GetPlayerApplicationSettingValueText, + @param aAttributeID The specification or player defined attribute + @param aAttributeText The UTF8 text name of the attribute(allowed text length is 1-255) - the API will take a copy + @param aValues The list of defined values + @param aValueTexts The UTF8 text for each defined value(allowed text length is 1-255) - The API will make copies. + @param aInitialValue The initial value for this attribute + @leave KErrNoMemory if memory could not be allocated to store the copies of aAttributeID and relative settings + @leave KErrNotSupported if attribute or value is out of specification defined range, + or aValueTexts is not equal length to aValues + */ + IMPORT_C void DefineAttributeL(TUint aAttributeID, + TDesC8& aAttributeText, + RArray &aValues, + RArray &aValueTexts, + TUint aInitialValue); + + /** + Set the current value of a previously defined attribute + This updates the cache and will cause completion of a + pending EVENT_PLAYER_APPLICATION_SETTING_CHANGED notification PDU + @param aAttributeID The specification or player defined attribute + @param aValue The current value + @leave KErrNotFound if the attribute is not defined, + KErrArgument if the value is not valid according to the definition + */ + IMPORT_C void SetAttributeL(TUint aAttributeID, TUint aValue); + + private: + virtual void DoDefineAttributeL(TUint aAttributeID, + TDesC8& aAttributeText, + RArray &aValues, + RArray &aValueTexts, + TUint aInitialValue) = 0; + virtual void DoSetAttributeL(TUint aAttributeID, TUint aValue) = 0; + + }; + +/** +This is a helper API allowing CPlayerApplicationSettings to be initialised +via a resource file. Using a resource file may help to provide localised text +for the attributes and values, according to current language setting of the phone. +*/ +class PlayerApplicationSettingsResourceInit + { + public: + /** + Defines multiple attributes supported by this player, which are listed in a resource file. + @param aSettings The CPlayerApplicationSettings object on which the attributes should be defined + @param aResource A fully constructed CResourceFile + @leave KErrNoMemory, or leave from CResourceFile functions + */ + IMPORT_C static void DefineAttributesL(MPlayerApplicationSettingsObserver& aSettings, CResourceFile &aResource); + }; + +/** +This class supports the notification PDUs in AVRCP1.3 specification section 5.4, +with the following exceptions: + EVENT_SYSTEM_STATUS_CHANGED is not supported, it is only for adaptors that plug into a media player + EVENT_PLAYER_APPLICATION_SETTING_CHANGED is supported through the CPlayerApplicationSettings API + +Events are pushed by the media player calling functions in this API, where they are +cached until the controller pulls them via a GetPlayStatus or RegisterNotification PDU +@see CPlayerApplicationSettings +*/ +class MPlayerEventsObserver + { + public: + enum TTargetBatteryStatus + { + ENormal = 0, + EWarning = 1, + ECritical = 2, + EExternal = 3, + EFullCharge = 4, + EUnknown = 5 + }; + + enum TPlaybackStatus + { + EStopped = 0, + EPlaying = 1, + EPaused = 2, + EFwdSeek = 3, + ERevSeek = 4, + EError = 0xFF + }; + + enum TPlayPosition + { + EStart = 0, + EMiddle = 1, + EEnd= 2, + }; + + static const TUint64 KNoTrackSelected = KMaxTUint64; + + static const TUint32 KPlaybackPositionUnknown = 0xFFFFFFFF; + + /** + Call this function whenever the playback status changes. + It will be used to complete pending EVENT_PLAYBACK_STATUS_CHANGED + and EVENT_PLAYBACK_POS_CHANGED notifications. + The value is used to generate the response to a GetPlayStatus PDU. + @param aStatus The specification defined playback status + */ + IMPORT_C void PlaybackStatusChanged(TPlaybackStatus aStatus); + /** + Call this function whenever the current media track is changed. + use KNoTrackSelected to indicate that there is no media selected. + This is the default value on construction. It will be used to + complete pending EVENT_TRACK_CHANGED and EVENT_PLAYBACK_POS_CHANGED notifications. + The values are used to generate the response to a GetPlayStatus PDU. + @param aTrackId A handle to the current track. + @param aLengthInMilliseconds The length of the current track. + */ + IMPORT_C void TrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds); + /** + Call this function whenever the current track reaches the end position, + e.g. due to playback or forward seek. It will be used to complete + pending EVENT_TRACK_REACHED_END and EVENT_PLAYBACK_POS_CHANGED notifications. + */ + IMPORT_C void TrackReachedEnd(); + /** + Call this function whenever the current track reaches the start position, + e.g. due to reverse seek (rewind). It will be used to complete pending + EVENT_TRACK_REACHED_START and EVENT_PLAYBACK_POS_CHANGED notifications. + */ + IMPORT_C void TrackReachedStart(); + /** + Call this function during playback or seek operations, to indicate the + current position within the track. It will be used to complete a pending + EVENT_PLAYBACK_POS_CHANGED notification. The value is used to generate the + response to a GetPlayStatus PDU. + @param aMilliseconds The current playback position. It is recommended to call + with a resolution <=1000ms to satisfy the 1s resolution of the notification + playback interval. + */ + IMPORT_C void SetPlaybackPosition(TUint32 aMilliseconds); + + /** + Call this function to report the current battery status + @param aBatteryStatus The current battery status. + */ + IMPORT_C void SetBatteryStatus(TTargetBatteryStatus aBatteryStatus); + + private: + virtual void DoPlaybackStatusChanged(TPlaybackStatus aStatus) = 0; + virtual void DoTrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds) = 0; + virtual void DoTrackReachedEnd() = 0; + virtual void DoTrackReachedStart() = 0; + virtual void DoSetPlaybackPosition(TUint32 aMilliseconds) = 0; + virtual void DoSetBatteryStatus(TTargetBatteryStatus aBatteryStatus) = 0; + + + }; + +/** +Clients must implement this interface if they require callbacks +when the controller has changed the settings via a SetPASValue message +*/ +class MPlayerApplicationSettingsNotify + { + public: + /** + This is called when the controller has changed a setting + @param aAttributeID A list of attribute IDs whose value has changed. + @param aAttributeValue A list of new values for the attributes listed in aAttributeID. + */ + virtual void MpasnSetPlayerApplicationValueL(const RArray& aAttributeID, + const RArray& aAttributeValue)=0; + }; + + +#endif // REMCONPLAYERINFORMATIONTARGETOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/resource/avrcp-settings.rls --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/resource/avrcp-settings.rls Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,144 @@ +// Copyright (c) 2008-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: +// @localize yes +// @description Text that will be displayed on the UI of a remote controller to duplicate +// the UI of the local media player. This text represents Equalizer Mode +// @uicontext notvisible +// +// + +rls_string8<255> STRING_EqualizerMode "Equalizer Mode" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Equalizer Mode Off +@uicontext notvisible +*/ +rls_string8<255> STRING_EqualizerOff "Off" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Equalizer Mode On +@uicontext notvisible +*/ +rls_string8<255> STRING_EqualizerOn "On" + + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Repeat Mode +@uicontext notvisible +*/ +rls_string8<255> STRING_RepeatMode "Repeat Mode" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Repeat Mode Off +@uicontext notvisible +*/ +rls_string8<255> STRING_RepeatOff "Off" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Single Track Repeat +@uicontext notvisible +*/ +rls_string8<255> STRING_RepeatSingle "Single Track Repeat" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents All Tracks Repeat +@uicontext notvisible +*/ +rls_string8<255> STRING_RepeatAll "All Tracks Repeat" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Group Repeat +@uicontext notvisible +*/ +rls_string8<255> STRING_RepeatGroup "Group Repeat" + + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Shuffle Mode +@uicontext notvisible +*/ +rls_string8<255> STRING_ShuffleMode "Shuffle Mode" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Shuffle Mode Off +@uicontext notvisible +*/ +rls_string8<255> STRING_ShuffleOff "Off" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents All Tracks Shuffle +@uicontext notvisible +*/ +rls_string8<255> STRING_ShuffleAll "All Tracks Shuffle" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Group Shuffle +@uicontext notvisible +*/ +rls_string8<255> STRING_ShuffleGroup "Group Shuffle" + + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Scan Mode +@uicontext notvisible +*/ +rls_string8<255> STRING_ScanMode "Scan Mode" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Scan Mode Off +@uicontext notvisible +*/ +rls_string8<255> STRING_ScanOff "Off" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents All Tracks Scan +@uicontext notvisible +*/ +rls_string8<255> STRING_ScanAll "All Tracks Scan" + +/*& +@localize yes +@description Text that will be displayed on the UI of a remote controller to duplicate +the UI of the local media player. This text represents Group Scan +@uicontext notvisible +*/ +rls_string8<255> STRING_ScanGroup "Group Scan" diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/resource/avrcp-settings.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/resource/avrcp-settings.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,124 @@ +// Copyright (c) 2007-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 "settings.rh" +#include "avrcp-settings.rls" + +UID2 KUidAVRCPResourceFile + +// Test setting matching rules +RESOURCE SETTINGS avrcpsettings + { + settings = + { + SETTING + { // Equalizer mode + attribute = KEqualizerMode; + initialValue = KOff; + description = STRING_EqualizerMode; + definedValues = + { + VALUE + { + valueId = KOff; + description = STRING_EqualizerOff; + }, + VALUE + { + valueId = KOn; + description = STRING_EqualizerOn; + } + }; + }, + SETTING + { // Repeat mode + attribute = KRepeatMode; + initialValue = KAllTracksRepeat; + description = STRING_RepeatMode; + definedValues = + { + VALUE + { + valueId = KOff; + description = STRING_RepeatOff; + }, + VALUE + { + valueId = KSingleTrackRepeat; + description = STRING_RepeatSingle; + }, + VALUE + { + valueId = KAllTracksRepeat; + description = STRING_RepeatAll; + }, + VALUE + { + valueId = KGroupRepeat; + description = STRING_RepeatGroup; + } + }; + }, + SETTING + { // Shuffle mode + attribute = KShuffleMode; + initialValue = KAllTracksShuffle; + description = STRING_ShuffleMode; + definedValues = + { + VALUE + { + valueId = KOff; + description = STRING_ShuffleOff; + }, + VALUE + { + valueId = KAllTracksShuffle; + description = STRING_ShuffleAll; + }, + VALUE + { + valueId = KGroupShuffle; + description = STRING_ShuffleGroup; + } + }; + }, + SETTING + { // Scan mode + attribute = KScanMode; + initialValue = KAllTracksScan; + description = STRING_ScanMode; + definedValues = + { + VALUE + { + valueId = KOff; + description = STRING_ScanOff; + }, + VALUE + { + valueId = KAllTracksScan; + description = STRING_ScanAll; + }, + VALUE + { + valueId = KGroupScan; + description = STRING_ScanGroup; + } + }; + } + }; + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/resource/settings.rh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/resource/settings.rh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,131 @@ +// Copyright (c) 2007-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: +// Resource header for AVRCP resource files. +// +// + +/** + @file settings.rh + @publishedPartner + @released +*/ + +#ifndef SETTINGS_RH +#define SETTINGS_RH + +/** +This resource header file defines the structures and constants required +for the AVRCP Player Application Settings and Values, as defined in +Appendix F of the Bluetooth Specification (AVRCP), page 80. + +A setting file consists of an arbitrary number of settings. This file +will be parsed and used to set values for a media application at +startup time, to be queried through the AVRCP profile. + +A setting file has the following structure + +UID2 KUidAVRCPResourceFile // Identifies this as an AVRCP settings file + +RESOURCE SETTINGS mysettings + { + settings = + { + SETTING + { + // definition of setting 1 + }, + SETTING + { + // definition of setting 2 + }, + // etc + }; + } +*/ + +#define KUidAVRCPResourceFile 0x10285ACD + +#define KIllegal 0x00 +#define KEqualizerMode 0x01 +#define KRepeatMode 0x02 +#define KShuffleMode 0x03 +#define KScanMode 0x04 + +#define KOff 0x01 +#define KOn 0x02 + +// Off 0x01 +#define KSingleTrackRepeat 0x02 +#define KAllTracksRepeat 0x03 +#define KGroupRepeat 0x04 + +// Off 0x01 +#define KAllTracksShuffle 0x02 +#define KGroupShuffle 0x03 + +// Off 0x01 +#define KAllTracksScan 0x02 +#define KGroupScan 0x03 + +#define KUserDefined 0x80 + +// Defines a single setting +STRUCT SETTING + { + // The player application setting attribute + // e.g. 0x00 illegal, not to be used + // 0x01 equalizer status + // 0x02 repeat mode status + // 0x03 shuffle mode status + // 0x04 scan mode status + // 0x05 - 0x7f reserved for future use + // 0x80 - 0xff provided for TG driver static media player menu extension by CT + BYTE attribute = 0; + + // The defined settings for this attribute + BYTE initialValue = 0; + + // An string which describes this setting + // This can be localised into the target language + LTEXT8 description = ""; + + // The values and descriptions that this attribute can take + STRUCT definedValues[]; + } + +// Defines a single setting +STRUCT VALUE + { + // The setting value id in hex + BYTE valueId = 0; + + // An string which describes this value + // This can be localised into the target language + LTEXT8 description = ""; + } + +// Defines a set of settings and the implementations UIDs of the default +// setting evaluator and dialog creator plug-ins. +STRUCT SETTINGS + { + // Version of the AVRCP resource file. + // Settings files MUST NOT change this value. + // This must match with the number defined in settingsresource.cpp + WORD version = 1; + + // An array of SETTING structures + STRUCT settings[]; + } + +#endif diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/eventsmask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/eventsmask.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,104 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent + @released +*/ + +#include "eventsmask.h" + +#ifdef _DEBUG +_LIT(KEventsMask, "TEventsMask"); +#endif + +TEventsMask::TEventsMask () + { + Reset(); + } + +void TEventsMask::Reset() + { + iMask = 0x0000; + iNextSupportedEvent = 0x00; + } + +TBool TEventsMask::Find(TRegisterNotificationEvent aEvent) const + { + return ( (0x0001 << (aEvent -1)) & iMask ) ? ETrue : EFalse; + } + +void TEventsMask::Append(TRegisterNotificationEvent aEvent) + { + // the assertion assures that aEvent is a valid argument (in the range) + __ASSERT_DEBUG((aEvent >= ERegisterNotificationPlaybackStatusChanged) && + (aEvent < ERegisterNotificationReservedLast), + User::Panic(KEventsMask, KErrArgument)); + + iMask |= (0x0001 << (aEvent -1)); + } + +void TEventsMask::Remove(TRegisterNotificationEvent aEvent) + { + // the assertion assures that aEvent is a valid argument (in the range) + __ASSERT_DEBUG((aEvent >= ERegisterNotificationPlaybackStatusChanged) && + (aEvent < ERegisterNotificationReservedLast), + User::Panic(KEventsMask, KErrArgument)); + + iMask &= ~(0x0001 << (aEvent -1)); + } + +void TEventsMask::Begin() + { + iNextSupportedEvent = 0x00; + } + +TBool TEventsMask::Next() + { + TUint index = iNextSupportedEvent+1; + + if (index == ERegisterNotificationReservedLast) + { + return EFalse; + } + + while( (!Find((TRegisterNotificationEvent)index)) && (index < ERegisterNotificationReservedLast) ) + { + index++; + } + + if (index < ERegisterNotificationReservedLast) + { + iNextSupportedEvent = index; + return ETrue; + } + else + { + return EFalse; + } + } + +TRegisterNotificationEvent TEventsMask::Get() const + { + // if Get() is called before calling Begin() and at least one call to Next() + // it Panics because iNextSupportedEvent is invalid (equals to 0x00). + __ASSERT_DEBUG(iNextSupportedEvent >= ERegisterNotificationPlaybackStatusChanged, User::Panic(KEventsMask, KErrUnderflow)); + // this should never happen, it would mean that iNextSupport overtakes the + // last valid value + __ASSERT_DEBUG(iNextSupportedEvent < ERegisterNotificationReservedLast, User::Panic(KEventsMask, KErrOverflow)); + + return static_cast(iNextSupportedEvent); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/playerapplicationsetting.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/playerapplicationsetting.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,133 @@ +// Copyright (c) 2008-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: +// This file contains the CPlayerApplicationSettings class. +// This is used to contain the Player application Setting Attributes +// defined by the Bluetooth AVRCP 1.3 specification +// +// + +/** + @file + @internalComponent + @released +*/ + +#include + +#include "playerapplicationsetting.h" +#include "playerinformation.h" + +CPlayerApplicationSettings* CPlayerApplicationSettings::NewL( TUint aAttributeID, + TDesC8& aAttributeText, + RArray aValues, + RArray& aValueTexts, + TUint aInitialValue ) + { + CPlayerApplicationSettings* self = new(ELeave) CPlayerApplicationSettings(); + CleanupStack::PushL(self); + self->ConstructL( aAttributeID, aAttributeText, aValues, aValueTexts, aInitialValue); + CleanupStack::Pop(self); + return self; + } + + +CPlayerApplicationSettings::~CPlayerApplicationSettings() + { + delete iAttributeText; + iValues.Close(); + iValueText.ResetAndDestroy(); + } + +CPlayerApplicationSettings::CPlayerApplicationSettings( ) + { + } + +void CPlayerApplicationSettings::ConstructL(TUint aAttributeID, + TDesC8& aAttributeText, + RArray aValues, + RArray& aValueText, + TUint aInitialValue ) + { + iAttributeID = aAttributeID; + + // copy the attribute description + iAttributeText = aAttributeText.AllocL(); + + // copy the allowed values + for (TInt i=0; i < aValues.Count(); i++ ) + { + + // avoid duplicated defined values + if (iValues.Find(aValues[i]) != KErrNotFound) + { + User::Leave(KErrArgument); + } + + iValues.AppendL( aValues[i] ); + + // copy the value description into a HBuf and add pointer to iValueTexts + HBufC8 * valueText = aValueText[i].AllocL(); + CleanupStack::PushL(valueText); + iValueText.AppendL(valueText); + CleanupStack::Pop(valueText); + } + + TInt error = SetCurrentValue( aInitialValue ); + if ( error != KErrNone ) + { + User::Leave( error ); + } + } + +TUint CPlayerApplicationSettings::GetAttributeID() + { + return( iAttributeID ); + } + +TUint CPlayerApplicationSettings::GetCurrentValue() + { + return( iCurrentValue ); + } + +TPtrC8 CPlayerApplicationSettings::GetAttributeText() + { + return( *iAttributeText ); + } + +RArray* CPlayerApplicationSettings::GetValues() + { + return( &iValues ); + } + +RPointerArray* CPlayerApplicationSettings::GetValuesTexts() + { + return( &iValueText ); + } + +TInt CPlayerApplicationSettings::SetCurrentValue(TUint aValue) + { + // Only allow setting already defined values + for (TInt i=0; i < iValues.Count(); i++ ) + { + if ( aValue == iValues[i] ) + { + iCurrentValue = aValue; + return KErrNone; + } + } + + // value was not already defined, so return KErrArgument + return KErrArgument; + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/playerapplicationsetting.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/playerapplicationsetting.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,89 @@ +// Copyright (c) 2007-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: +// + +/** + @file + @internalComponent + @released +*/ + +#ifndef PLAYERAPPLICATIONSETTING_H +#define PLAYERAPPLICATIONSETTING_H + + +/** +Class containing all the information for one attribute. +All the attributes for a player are contained in a RHashMap +of CPlayerApplicationSettings in CPlayerInfoTarget +*/ +NONSHARABLE_CLASS(CPlayerApplicationSettings) : public CBase + { +public: + /** + Factory function. + @param aAttributeID The ID value + @param aAttributeText A text description of the attribute + @param aValues A list of valid values + @param aValueTexts A list of descriptions of the possible values + @param aInitialValue The starting value + @return A new CPlayerApplicationSettings + */ + static CPlayerApplicationSettings* NewL( TUint aAttributeID, + TDesC8& aAttributeText, + RArray aValues, + RArray& aValueTexts, + TUint aInitialValue ); + + /** Destructor */ + ~CPlayerApplicationSettings(); + + TUint GetAttributeID(); + TUint GetCurrentValue(); + TPtrC8 GetAttributeText(); + RArray* GetValues(); + RPointerArray* GetValuesTexts(); + TInt SetCurrentValue(TUint aValue); + +private: + /** + Constructor. + @param aInterfaceSelector The interface selector. + */ + CPlayerApplicationSettings( ); + + void ConstructL(TUint aAttributeID, + TDesC8& aAttributeText, + RArray aValues, + RArray& aValueText, + TUint aInitialValue ); + +private: + /* attribute ID */ + TUint iAttributeID; + + /* text description of the attribute */ + HBufC8* iAttributeText; + + /* array of allowed values */ + RArray iValues; + + /* array of text descriptions of allowed values */ + RPointerArray iValueText; + + /* the current value */ + TUint iCurrentValue; + }; + +#endif // PLAYERAPPLICATIONSETTING_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/playercapabilities.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/playercapabilities.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,274 @@ +// Copyright (c) 2008-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: +// This file contains the capabilites part of playerinformation. +// +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include + +#include "eventsmask.h" +#include "playerinformation.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_PLAYER_INFO); +#endif + +class TRemConMetadataTransferGetCapabilities + { +public: + TUint8 iCapabilityID; + }; + +EXPORT_C void MPlayerCapabilitiesObserver::ClearEvents() + { + DoClearEvents(); + } + +EXPORT_C TInt MPlayerCapabilitiesObserver::AddEvent(TRegisterNotificationEvent aEvent) + { + return DoAddEvent(aEvent); + } + +EXPORT_C TInt MPlayerCapabilitiesObserver::RemoveEvent(TRegisterNotificationEvent aEvent) + { + return DoRemoveEvent(aEvent); + } + +EXPORT_C void MPlayerCapabilitiesObserver::ClearCompanyIds() + { + DoClearCompanyIds(); + } + +EXPORT_C TInt MPlayerCapabilitiesObserver::AddCompanyId(TInt aID) + { + return DoAddCompanyId( aID ); + } + +EXPORT_C TInt MPlayerCapabilitiesObserver::RemoveCompanyID(TInt aID) + { + return DoRemoveCompanyID( aID ); + } + + +// from MPlayerCapabilitiesObserver +void CPlayerInfoTarget::DoClearEvents() + { + // AVRCP 1.3 specification, Appendix H says that PlaybackStatusChanged + // and TrackChanged event notification support is mandatory, so add these + + iSupportedNotificationEventList->Reset(); + iSupportedNotificationEventList->Append(ERegisterNotificationPlaybackStatusChanged); + iSupportedNotificationEventList->Append(ERegisterNotificationTrackChanged); + } + + +TInt CPlayerInfoTarget::DoAddEvent( TRegisterNotificationEvent aEvent ) + { + // check the event is supported (note system status is NOT supported) + if ( aEvent >= ERegisterNotificationReservedLast + || aEvent == ERegisterNotificationSystemStatusChanged_NotSupported) + { + return KErrNotSupported; + } + + // check if aEvent is already in the list of supported events + if (!iSupportedNotificationEventList->Find(aEvent)) + { + // not found so add it to the list + iSupportedNotificationEventList->Append(aEvent); + return KErrNone; + } + + // else return already in the list + return KErrAlreadyExists; + } + + +TInt CPlayerInfoTarget::DoRemoveEvent( TRegisterNotificationEvent aEvent ) + { + // AVRCP 1.3 specification, Appendix H says that PlaybackStatusChanged + // and TrackChanged event notification support is mandatory, so add these + TInt err = KErrNone; + if ( aEvent == ERegisterNotificationPlaybackStatusChanged + || aEvent == ERegisterNotificationTrackChanged) + { + return KErrNotSupported; + } + + // Find aEvent in the list of supported events + if (iSupportedNotificationEventList->Find(aEvent)) + { + // and then remove it + iSupportedNotificationEventList->Remove(aEvent); + TInt pendingPos = iPendingNotificationEventList.Find(aEvent); + if (pendingPos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pendingPos ); + + // Tell anyone waiting for a notification that an event has been + // removed. Alas, we can't specify _WHICH_ event has been removed + // since there's no way to indicate this in an INTERNAL_ERROR response + SendError(KErrAvrcpMetadataInternalError, + RAvrcpIPC::SetIPCOperationIdFromEventId(aEvent), + ERemConNotifyResponseChanged); + } + } + else + { + err = KErrNotFound; + } + return err; + } + + +void CPlayerInfoTarget::DoClearCompanyIds() + { + // The Bluetooth SIG vendor id must always be present + // See AVRCP 1.3 Specification, section 5.5.1, table 5.4 + iCompanyIdList.Reset(); + iCompanyIdList.Append(KBluetoothSIGVendorId); + } + + +TInt CPlayerInfoTarget::DoAddCompanyId( TInt aID ) + { + if ( aID > KMaxCompanyID ) + { + return KErrNotSupported; + } + + // check if the ID is already in the list + TInt pos = iCompanyIdList.Find( aID ); + + // add only if not present in list to avoid duplicates + if (pos != KErrNotFound) + { + return KErrAlreadyExists; + } + + // make sure the list cannot contain more than 255 items + if (iCompanyIdList.Count() >= KMaxNrOfCompanyIDs) + { + return KErrOverflow; + } + + return iCompanyIdList.Append( aID ); + } + + +TInt CPlayerInfoTarget::DoRemoveCompanyID( TInt aID ) + { + // The Bluetooth SIG vendor id must always be present + // See AVRCP 1.3 Specification, section 5.5.1, table 5.4 + if ( aID == KBluetoothSIGVendorId ) + { + return KErrNotSupported; + } + + // check if the ID is in the list + TInt pos = iCompanyIdList.Find( aID ); + + // if found remove else do nothing + if (pos != KErrNotFound) + { + iCompanyIdList.Remove( pos ); + return KErrNone; + } + return pos; + } + + +void CPlayerInfoTarget::ProcessGetCapabilities(const TDesC8& aData) + { + LOG_STATIC_FUNC + + /* Decode the get capability message */ + TRemConMetadataTransferGetCapabilities getCapability; + + // check there is at least 1 byte of data + if (!aData.Length()) + { + // Invalid packet + return SendError(KErrAvrcpMetadataInvalidParameter, EGetCapabilities); + } + + TPckgC data(*reinterpret_cast(aData.Ptr())); + getCapability = data(); + TGetCapabilityValues id = (TGetCapabilityValues) getCapability.iCapabilityID; + + // format the response in a TRemConGetCapabilitiesResponse + RRemConGetCapabilitiesResponse response; + + switch ( id ) + { + case ECapabilityIdCompanyID: + // respond with ECapabilityIdCompanyID + response.iCapabilityId = ECapabilityIdCompanyID; + + // followed by number of IDs + response.iCapabilityCount = iCompanyIdList.Count(); + + // and then list of company ids, + for (TInt i=0; i< iCompanyIdList.Count(); i++ ) + { + TInt x = iCompanyIdList[i]; + if (response.iCapabilities.Append(x) != KErrNone) + { + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, EGetCapabilities); // Try to send internal error if OOM + } + } + break; + + case ECapabilityIdEventsSupported: + // respond with ECapabilityIdEventsSupported + response.iCapabilityId = ECapabilityIdEventsSupported; + + // followed by number of supported events, and then list of events + response.iCapabilityCount = 0; + iSupportedNotificationEventList->Begin(); + while(iSupportedNotificationEventList->Next()) + { + if (KErrNone != response.iCapabilities.Append(iSupportedNotificationEventList->Get())) + { + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, EGetCapabilities); // Try to send internal error if OOM + } + response.iCapabilityCount++; + } + break; + + default: + /* other IDs are reserved */ + return SendError(KErrAvrcpMetadataInvalidParameter, EGetCapabilities); // Invalid packet + } + + TInt error = 0; + TRAP(error, response.WriteL(iOutBuf)); // Don't send error if OOM + response.Close(); + if (error == KErrNone) + // send the result back to the CT + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + EGetCapabilities, ERemConResponse, iOutBuf ); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/playerevents.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/playerevents.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,477 @@ +// Copyright (c) 2008-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: +// This file contains the events part of the PlayerInformation API. +// +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include +#include + +#include "playerapplicationsetting.h" +#include "eventsmask.h" +#include "playereventsutils.h" +#include "playerinformation.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_PLAYER_INFO); +#endif + +EXPORT_C void MPlayerEventsObserver::PlaybackStatusChanged(TPlaybackStatus aStatus) + { + DoPlaybackStatusChanged(aStatus); + } + +EXPORT_C void MPlayerEventsObserver::TrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds) + { + DoTrackChanged(aTrackId, aLengthInMilliseconds); + } + +EXPORT_C void MPlayerEventsObserver::TrackReachedEnd() + { + DoTrackReachedEnd(); + } + +EXPORT_C void MPlayerEventsObserver::TrackReachedStart() + { + DoTrackReachedStart(); + } + +EXPORT_C void MPlayerEventsObserver::SetPlaybackPosition(TUint32 aMilliseconds) + { + DoSetPlaybackPosition(aMilliseconds); + } + +EXPORT_C void MPlayerEventsObserver::SetBatteryStatus(TTargetBatteryStatus aBatteryStatus) + { + DoSetBatteryStatus(aBatteryStatus); + } + +void CPlayerInfoTarget::ProcessGetStatusAndBeginObserving( const TUint aOperationId, TRegisterNotificationEvent aEventId, const TDesC8& aData) + { + // check the event is in the supported list + if (!iSupportedNotificationEventList->Find(aEventId)) + { + // Not supported so return error + SendError(KErrAvrcpMetadataInvalidParameter, aOperationId, ERemConNotifyResponseInterim); + return; + } + + // if the event is EPlaybackPosChanged then the timeinterval is included in the RegisterNofication + if (aEventId == ERegisterNotificationPlaybackPosChanged) + { + // decode the playback interval from aData + TInt error = 0; + RRemConPlayerInformation32BitResponse request; + TRAP(error, request.ReadL(aData)); + + if (error != KErrNone) + { + // Not supported so return error + SendError(KErrAvrcpMetadataParameterNotFound, aOperationId, ERemConNotifyResponseInterim); + return; + } + + // save the playback interval + iPlayBackIntervalInMilliseconds = request.iValue * 1000; + + // and the current position + iLastNotifiedPlaybackPositionInMilliseconds = iPlaybackPositionInMilliseconds; + } + + // and request another notification (if there is not one already pending) + // on the next state change + if (KErrNotFound ==iPendingNotificationEventList.Find(aEventId)) + { + if (iPendingNotificationEventList.Append(aEventId) != KErrNone) + { + return SendError(KErrAvrcpMetadataInternalError, aOperationId); // Try to send internal error if OOM + } + } + + // send the current status + SendNotificationResponse(aEventId, ERemConNotifyResponseInterim ); + } + +void CPlayerInfoTarget::ProcessGetStatus( const TUint aOperationId, TRegisterNotificationEvent aEventId) + { + // send the current value + if (iSupportedNotificationEventList->Find(aEventId)) + { + SendNotificationResponse(aEventId, ERemConNotifyResponseChanged ); + } + else + { + // Not found so return error + SendError(KErrAvrcpMetadataInvalidParameter, aOperationId, ERemConNotifyResponseChanged); + } + } + +/* ProcessGetPlayStatus This returns the current values of SongLength, + SongPosition and PlayStatus. + Note if SongLength and SongPosition are not supported KPlaybackPositionUnknown is returned + */ +void CPlayerInfoTarget::ProcessGetPlayStatus() + { + LOG_FUNC + + TInt error =0; + + // format the response in a RRemConPlayerInformationGetPlayStatusResponse + RRemConPlayerInformationGetPlayStatusResponse response; + response.iTrackLength = iLengthInMilliseconds; + response.iPlayPos = iPlaybackPositionInMilliseconds; + response.iStatus = iPlayBackStatus; + + TRAP(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + EGetPlayStatus, ERemConResponse, iOutBuf ); + } + } + +/* ProcessGetPlayStatusUpdate returns the current play status if it has changed + * relative to the provided play status, otherwise the request is queued until + * the play status changes. + */ +void CPlayerInfoTarget::ProcessGetPlayStatusUpdate(const TDesC8& aData) + { + LOG_FUNC + + // Bearer should never send us more than one of these in parallel + __ASSERT_DEBUG(!iPlaybackStatusUpdatePending, PlayerEventsUtils::Panic(ETwoGetPlayStatusUpdatesQueued)); + + TInt error =0; + RRemConPlayerInformationGetPlayStatusUpdateRequest request; + TRAP(error, request.ReadL(aData)); + __ASSERT_DEBUG(error == KErrNone, PlayerEventsUtils::Panic(EBadlyFormattedInternalData)); + + if(request.iStatus != iPlayBackStatus) + { + // format the response in a RRemConPlayerInformationGetPlayStatusResponse + RRemConPlayerInformationGetPlayStatusUpdateResponse response; + response.iStatus = iPlayBackStatus; + + TRAP(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + EGetPlayStatusUpdate, ERemConResponse, iOutBuf ); + if(error != KErrNone) + { + // We will try and send the response again next time we get an update + iPlaybackStatusUpdatePending = ETrue; + } + } + } + else + { + iPlaybackStatusUpdatePending = ETrue; + } + } + +// Send a Notification message for aEventID +void CPlayerInfoTarget::SendNotificationResponse( TRegisterNotificationEvent aEventId, TRemConMessageSubType aMsgSubType ) + { + LOG_FUNC + + TInt error = 0; + iOutBuf.Zero(); + + if (!iSupportedNotificationEventList->Find(aEventId)) + { + return SendError(KErrAvrcpMetadataInvalidParameter, + RAvrcpIPC::SetIPCOperationIdFromEventId(aEventId), aMsgSubType); + } + + switch (aEventId) + { + case ERegisterNotificationTrackReachedEnd: + case ERegisterNotificationTrackReachedStart: + { + // no extra data for reached start or end + RAvrcpIPCError response; + response.iError = KErrNone; + TRAP(error, response.WriteL(iOutBuf)); + break; + } + + case ERegisterNotificationPlaybackStatusChanged: + { + // 8bit response -- current playback status + RRemConPlayerInformation8BitResponse response; + response.iValue = iPlayBackStatus; + TRAP(error, response.WriteL(iOutBuf)); + break; + } + + case ERegisterNotificationBatteryStatusChanged: + { + // 8bit response -- current battery status + RRemConPlayerInformation8BitResponse response; + response.iValue = iBatteryStatus; + TRAP(error, response.WriteL(iOutBuf)); + break; + } + + case ERegisterNotificationPlaybackPosChanged: + { + // 32bit response -- current playback position in millisecond + RRemConPlayerInformation32BitResponse response; + response.iValue = iPlaybackPositionInMilliseconds; + TRAP(error, response.WriteL(iOutBuf)); + break; + } + + case ERegisterNotificationTrackChanged: + { + // 64bit response -- index of the current track + RRemConPlayerInformation64BitResponse response; + response.iValue = iTrackId; + TRAP(error, response.WriteL(iOutBuf)); + break; + } + + case ERegisterNotificationPlayerApplicationSettingChanged: + { + // Send a list of the settings that have changed followed by their value + // starting with the number of attributes to be sent + RRemConPlayerAttributeIdsAndValues response; + response.iNumberAttributes = 0; + + // for every entry in the list + THashMapIter iter(iPlayerApplicationSettings); + CPlayerApplicationSettings* const* setting = iter.NextValue(); + while ( setting != NULL ) + { + TUint8 value = (*setting)->GetCurrentValue(); + TInt ret1 = response.iAttributeValue.Append(value); + TInt ret2 = response.iAttributeId.Append((*setting)->GetAttributeID()); + if (ret1 != KErrNone || ret2 != KErrNone) + { + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, + RAvrcpIPC::SetIPCOperationIdFromEventId(aEventId), + aMsgSubType); // Try to send internal error if OOM + } + response.iNumberAttributes++; + setting = iter.NextValue(); + } + + TRAP(error, response.WriteL(iOutBuf)); + response.Close(); + break; + } + default: + return; + } + + if (error == KErrNone) + { + // send the response back to the CT + TUint operationId = RAvrcpIPC::SetIPCOperationIdFromEventId(aEventId); + error = InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + operationId, ERemConResponse, aMsgSubType, iOutBuf); + } + } + +// from MPlayerEventsObserver + void CPlayerInfoTarget::DoPlaybackStatusChanged(TPlaybackStatus aStatus) + { + LOG_FUNC + + iPlayBackStatus = aStatus; + + // if the playback status is in the current event list + TInt pos = iPendingNotificationEventList.Find( ERegisterNotificationPlaybackStatusChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + SendNotificationResponse( ERegisterNotificationPlaybackStatusChanged, ERemConNotifyResponseChanged); + } + + pos = iPendingNotificationEventList.Find( ERegisterNotificationPlaybackPosChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + SendNotificationResponse(ERegisterNotificationPlaybackPosChanged, ERemConNotifyResponseChanged); + } + + if(iPlaybackStatusUpdatePending) + { + // format the response in a RRemConPlayerInformationGetPlayStatusResponse + RRemConPlayerInformationGetPlayStatusUpdateResponse response; + response.iStatus = iPlayBackStatus; + + TRAPD(error, response.WriteL(iOutBuf)); + if (error == KErrNone) + { + // send the response back to the CT + error = InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + EGetPlayStatusUpdate, ERemConResponse, iOutBuf ); + if(error == KErrNone) + { + iPlaybackStatusUpdatePending = EFalse; + } + // if we did error we will try and respond again next time the client's play status + // changes + } + } + } + +void CPlayerInfoTarget::DoTrackChanged(TUint64 aTrackId, TUint32 aLengthInMilliseconds) + { + LOG_FUNC + + iTrackId = aTrackId; + iLengthInMilliseconds = aLengthInMilliseconds; + + // if the playback status is in the current event list + TInt pos = iPendingNotificationEventList.Find( ERegisterNotificationTrackChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + SendNotificationResponse(ERegisterNotificationTrackChanged, ERemConNotifyResponseChanged); + } + + pos = iPendingNotificationEventList.Find( ERegisterNotificationPlaybackPosChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + iPlaybackPositionInMilliseconds = 0; //set 0 to current position for new track + SendNotificationResponse(ERegisterNotificationPlaybackPosChanged, ERemConNotifyResponseChanged); + } + } + +void CPlayerInfoTarget::DoTrackReachedEnd() + { + LOG_FUNC + + iTrackPosition = EEnd; + + // if the ETrackReachedEnd status is in the current event list + TInt pos = iPendingNotificationEventList.Find( ERegisterNotificationTrackReachedEnd ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + SendNotificationResponse(ERegisterNotificationTrackReachedEnd, ERemConNotifyResponseChanged); + } + + pos = iPendingNotificationEventList.Find( ERegisterNotificationPlaybackPosChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + iPlaybackPositionInMilliseconds = iLengthInMilliseconds; + SendNotificationResponse(ERegisterNotificationPlaybackPosChanged, ERemConNotifyResponseChanged); + } + } + +void CPlayerInfoTarget::DoTrackReachedStart() + { + LOG_FUNC + + iTrackPosition = EStart; + + // if the ETrackReachedStart status is in the current event list + TInt pos = iPendingNotificationEventList.Find( ERegisterNotificationTrackReachedStart ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + SendNotificationResponse(ERegisterNotificationTrackReachedStart, ERemConNotifyResponseChanged); + } + + pos = iPendingNotificationEventList.Find( ERegisterNotificationPlaybackPosChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + iPlaybackPositionInMilliseconds = 0; + SendNotificationResponse(ERegisterNotificationPlaybackPosChanged, ERemConNotifyResponseChanged); + } + } + +void CPlayerInfoTarget::DoSetPlaybackPosition(TUint32 aMilliseconds) + { + LOG_FUNC + + iPlaybackPositionInMilliseconds = aMilliseconds; + + // if the playback position is in the current Notification event list + TInt pos = iPendingNotificationEventList.Find( ERegisterNotificationPlaybackPosChanged ); + if (pos != KErrNotFound) + { + // a notification has been requested, now check if it is due + + TUint32 difference = (iPlaybackPositionInMilliseconds > iLastNotifiedPlaybackPositionInMilliseconds) ? + iPlaybackPositionInMilliseconds - iLastNotifiedPlaybackPositionInMilliseconds: + iLastNotifiedPlaybackPositionInMilliseconds - iPlaybackPositionInMilliseconds; + + if (difference >= iPlayBackIntervalInMilliseconds) + { + // Due now so send + iPendingNotificationEventList.Remove( pos ); + SendNotificationResponse(ERegisterNotificationPlaybackPosChanged, ERemConNotifyResponseChanged); + } + } + } + +void CPlayerInfoTarget::DoSetBatteryStatus(TTargetBatteryStatus aBatteryStatus) + { + LOG_FUNC + + TBool validStatus = ETrue; + if (aBatteryStatus < MPlayerEventsObserver::ENormal || + aBatteryStatus > MPlayerEventsObserver::EFullCharge) + { + LOG1(_L("Invalid battery status: %d"),aBatteryStatus); + validStatus = EFalse; + } + else + { + iBatteryStatus = aBatteryStatus; + } + + // if the battery status is in the current event list + TInt pos = iPendingNotificationEventList.Find( ERegisterNotificationBatteryStatusChanged ); + if (pos != KErrNotFound) + { + iPendingNotificationEventList.Remove( pos ); + if (validStatus) + { + SendNotificationResponse(ERegisterNotificationBatteryStatusChanged, ERemConNotifyResponseChanged); + } + } + } + +void CPlayerInfoTarget::SendError(TInt aError, TInt aOperationId, TRemConMessageSubType aSubType) + { + TInt error = 0; + RAvrcpIPCError response; + response.iError = aError; + TRAP(error, response.WriteL(iOutBuf)); // Don't send error if OOM + if (error == KErrNone) + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + aOperationId, ERemConResponse, aSubType, iOutBuf); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/playerinformation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/playerinformation.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,293 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include + +#include "playerapplicationsetting.h" +#include "eventsmask.h" +#include "playerinformation.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_PLAYER_INFO); +#endif + +EXPORT_C CPlayerInfoTarget* CPlayerInfoTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, + MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver, + MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver, + MPlayerEventsObserver*& aPlayerEventsObserver, + MPlayerApplicationSettingsNotify& aApplicationSettingNotifier ) + { + LOG_STATIC_FUNC + + CPlayerInfoTarget* self = new(ELeave) CPlayerInfoTarget(aInterfaceSelector, aApplicationSettingNotifier); + CleanupStack::PushL(self); + self->ConstructL( aPlayerCapabilitiesObserver, aPlayerApplicationSettingsObserver, aPlayerEventsObserver ); + CleanupStack::Pop(self); + return self; + } + +/** +Constructs this interface. +@param aInterfaceSelector An interface selector for use with this interface. +@internalComponent +@released +*/ +CPlayerInfoTarget::CPlayerInfoTarget(CRemConInterfaceSelector& aInterfaceSelector, MPlayerApplicationSettingsNotify& aApplicationSettingNotifier) +: CRemConInterfaceBase(TUid::Uid(KRemConPlayerInformationUid), + KMaxLengthPlayerInformationMsg, + aInterfaceSelector, + ERemConClientTypeTarget), + iApplicationSettingNotifier(aApplicationSettingNotifier), + iPlaybackStatusUpdatePending(EFalse) + { + } + + +void CPlayerInfoTarget::ConstructL(MPlayerCapabilitiesObserver*& aPlayerCapabilitiesObserver, + MPlayerApplicationSettingsObserver*& aPlayerApplicationSettingsObserver, + MPlayerEventsObserver*& aPlayerEventsObserver ) + { + // reserve two AV/C frames, for this reasoning: + // GetCapabilities (PDU 0x10) can generate a response + // which is (255 * 3 bytes) + 2 bytes = 767 total and + // will fit into two AVC frames. Other PDUs generate + // less than this, except for PDUs 0x15 and 0x16 which + // use their own buffer pre-allocated by calling Size() + iOutBuf.CreateL(KAVCFrameMaxLength * 2); + + BaseConstructL(); + + aPlayerCapabilitiesObserver = this; + aPlayerApplicationSettingsObserver = this; + aPlayerEventsObserver = this; + + // default values for event notifiers + iPlayBackStatus = EStopped; + + // If no track currently selected + iTrackId = KNoTrackSelected; + + iLengthInMilliseconds = 0; + iTrackPosition = EStart; + + // If no track currently selected, then return KPlaybackPositionUnknown + iPlaybackPositionInMilliseconds = KPlaybackPositionUnknown; + iLastNotifiedPlaybackPositionInMilliseconds = KPlaybackPositionUnknown; + + // The time interval used for playback position notification + iPlayBackIntervalInMilliseconds = 0; + + // Try to detect battery status from hardware P&S properties + iBatteryStatus = DetectBatteryStatus(); + + // The Bluetooth SIG vendor id must always be present + // See AVRCP 1.3 Specification, section 5.5.1, table 5.4 + iCompanyIdList.AppendL(KBluetoothSIGVendorId); + + // AVRCP 1.3 specification, Appendix H says that PlaybackStatusChanged + // and TrackChanged event notification support is mandatory, so add these + iSupportedNotificationEventList = new (ELeave) TEventsMask(); + iSupportedNotificationEventList->Append(ERegisterNotificationPlaybackStatusChanged); + iSupportedNotificationEventList->Append(ERegisterNotificationTrackChanged); + } + +EXPORT_C CPlayerInfoTarget::~CPlayerInfoTarget() + { + iPendingNotificationEventList.Close(); + iCompanyIdList.Close(); + iOutBuf.Close(); + + // Free up all the settings memory + THashMapIter iter(iPlayerApplicationSettings); + CPlayerApplicationSettings* const* setting = iter.NextValue(); + while ( setting != NULL ) + { + delete *setting; + setting = iter.NextValue(); + } + + // Now close the hash table itself + iPlayerApplicationSettings.Close(); + delete iSupportedNotificationEventList; + } + + +TAny* CPlayerInfoTarget::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf2) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +// from MRemConInterfaceIf +void CPlayerInfoTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& aData, TRemConMessageSubType aMsgSubType) + { + LOG(_L("CPlayerInfoTarget::MrcibNewMessage")); + LOG1(_L("\taOperationId = 0x%02x"), aOperationId); + LOG1(_L("\taData.Length = %d"), aData.Length()); + LOG1(_L("\taMsgSubType = 0x%02x"), aMsgSubType); + + TMetadataTransferPDU currentOp = RAvrcpIPC::GetPDUIdFromIPCOperationId(aOperationId); + + switch (currentOp) + { + case EGetCapabilities: + { + /* process this in playercapabilities */ + ProcessGetCapabilities( aData ); + break; + } + case EListPlayerApplicationSettingAttributes: + { + /* respond with Player Application Attributes*/ + ProcessListPlayerApplicationAttributes( aOperationId ); + break; + } + case EGetPlayerApplicationSettingAttributeText: + { + /* respond with Player Application Attribute Text*/ + ProcessGetPlayerApplicationAttributeText( aData, aOperationId ); + break; + } + case EListPlayerApplicationSettingValues: + { + /* respond with Player Application Values*/ + ProcessListPlayerApplicationValues( aData, aOperationId ); + break; + } + case EGetPlayerApplicationSettingValueText: + { + /* respond with Application Value Text*/ + ProcessGetPlayerApplicationValueText( aData, aOperationId ); + break; + } + case EGetCurrentPlayerApplicationSettingValue: + { + /* respond with Current Player Application Value*/ + ProcessGetCurrentPlayerApplicationValue( aData, aOperationId ); + break; + } + case ESetPlayerApplicationSettingValue: + { + /* Set Player Application Value*/ + ProcessSetPlayerApplicationValue( aData, aOperationId ); + break; + } + case EGetPlayStatus: + { + // process in playerevents + ProcessGetPlayStatus(); + break; + } + case ERegisterNotification: + { + // obtain eventId from aOperationId + TRegisterNotificationEvent eventId = RAvrcpIPC::GetEventIdFromIPCOperationId(aOperationId); + + // register for Notifications + if (aMsgSubType == ERemConNotifyCommandAwaitingInterim) + { + ProcessGetStatusAndBeginObserving(aOperationId, eventId, aData); + } + else if (aMsgSubType == ERemConNotifyCommandAwaitingChanged) + { + ProcessGetStatus(aOperationId, eventId); + } + break; + } + case EGetPlayStatusUpdate: + { + // process in playerevents + ProcessGetPlayStatusUpdate(aData); + break; + } + default: + break; + } + + } + +MPlayerEventsObserver::TTargetBatteryStatus CPlayerInfoTarget::DetectBatteryStatus() + { + MPlayerEventsObserver::TTargetBatteryStatus status = ECritical; + TInt err = KErrNone; + TInt batteryStatus = EBatteryStatusUnknown; + TInt chargingStatus = EChargingStatusNotConnected; + err = RProperty::Get(KPSUidHWRMPowerState,KHWRMBatteryStatus,batteryStatus); + if (!err) + { + err = RProperty::Get(KPSUidHWRMPowerState,KHWRMChargingStatus,chargingStatus); + } + + switch (batteryStatus) + { + // Normal or Charging + case EBatteryStatusOk: + { + if (chargingStatus == EChargingStatusCharging || + chargingStatus == EChargingStatusAlmostComplete || + chargingStatus == EChargingStatusChargingContinued) + { + iBatteryStatus = EExternal; + } + else + { + if (chargingStatus == EChargingStatusChargingComplete) + { + iBatteryStatus = EFullCharge; + } + else + { + iBatteryStatus = ENormal; + } + } + } + break; + // Warning + case EBatteryStatusLow: + { + iBatteryStatus = EWarning; + } + break; + // Critical + case EBatteryStatusEmpty: + { + iBatteryStatus = ECritical; + } + break; + // Unknown state, set as ECritical + case EBatteryStatusUnknown: + { + iBatteryStatus = ECritical; + } + break; + } + return status; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/playersettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/playersettings.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,685 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include + +#include "playerapplicationsetting.h" +#include "playerinformation.h" +#include "playersettingsutils.h" + + +void CPlayerInfoTarget::SendError(TInt aError, TInt aOperationId) + { + TInt error = 0; + RAvrcpIPCError response; + response.iError = aError; + TRAP(error, response.WriteL(iOutBuf)); // Try to send internal error if OOM + if (error == KErrNone) + { + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + aOperationId, ERemConResponse, iOutBuf); + } + } + + +// PDU 0x11 +void CPlayerInfoTarget::ProcessListPlayerApplicationAttributes(TInt aOperationId) + { + RRemConPlayerListOfAttributes response; + response.iNumberAttributes = iPlayerApplicationSettings.Count(); + + THashMapIter iter(iPlayerApplicationSettings); + const TInt* attribute = iter.NextKey(); + while ( attribute != NULL ) + { + if (response.iAttributes.Append(*attribute) != KErrNone) + { + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); // Try to send internal error if OOM + } + attribute = iter.NextKey(); + } + + // send the response back to the CT + TInt error = 0; + TRAP(error, response.WriteL(iOutBuf)); // Try to send internal error if OOM + response.Close(); + if (error != KErrNone) + { + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + EListPlayerApplicationSettingAttributes, ERemConResponse, iOutBuf ); + } + +// PDU 0x12 +void CPlayerInfoTarget::ProcessListPlayerApplicationValues(const TDesC8& aData, TInt aOperationId) + { + TInt error =0; + RDesReadStream readStream; + readStream.Open(aData); + TInt attributeID = 0; + TRAP(error, attributeID = readStream.ReadUint8L()); + readStream.Close(); + if (error != KErrNone) + { + return SendError(KErrAvrcpMetadataParameterNotFound, aOperationId); // Nothing in packet + } + + // Send the number of values for this attribute (1 byte), + // followed by the defined values themselves (n x 1byte) + CPlayerApplicationSettings* thisSetting = GetSetting(attributeID); + if (thisSetting == NULL) + { + // Attribute Id not found + return SendError(KErrAvrcpMetadataInvalidParameter, aOperationId); + } + + RRemConPlayerListOfAttributes response; + RArray* values = thisSetting->GetValues(); + TInt numValues = values->Count(); + response.iNumberAttributes = numValues; + + // Make sure that we always have at least one result to return + // Table 5.18 says that the number of results provided has an + // allowed value of 1-255, so we cannot return zero results. + if (response.iNumberAttributes == 0) + { + return SendError(KErrAvrcpMetadataParameterNotFound, aOperationId); // No attributes matched + } + + for ( TInt i = 0; i < numValues; i++ ) + { + TInt value = (*values)[i]; + if (response.iAttributes.Append(value) != KErrNone) + { + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); // Try to send internal error if OOM + } + } + + // send the response back to the CT + TRAP(error, response.WriteL(iOutBuf)); // Try to send internal error if OOM + response.Close(); + if (error != KErrNone) + { + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + aOperationId, ERemConResponse, iOutBuf ); + } + +// PDU 0x15 +void CPlayerInfoTarget::ProcessGetPlayerApplicationAttributeText(const TDesC8& aData, TInt aOperationId) + { + TInt error =0; + + // If we can't parse the request, then return an error + RRemConPlayerListOfAttributes request; + TRAP(error, request.ReadL(aData)); + if (error != KErrNone) + { + request.Close(); + return SendError(KErrAvrcpMetadataInvalidCommand, aOperationId); + } + + // Iterate through requested attributes and remove + // those which we don't have any settings for. + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + if (! AttributeSettingExists(request.iAttributes[i])) + { + request.iAttributes.Remove(i); + request.iNumberAttributes--; + i--; + } + } + + // Make sure that we always have at least one result to return + // Table 5.18 says that the number of results provided has an + // allowed value of 1-255, so we cannot return zero results. + RRemConGetPlayerApplicationTextResponse response; + response.iNumberAttributes = request.iNumberAttributes; + if (response.iNumberAttributes == 0) + { + request.Close(); + return SendError(KErrAvrcpMetadataInvalidParameter, aOperationId); // No attributes matched + } + + // for every attribute text requested + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + // start with the attribute id requested and the character set + RSettingWithCharset setting; + TInt attId = request.iAttributes[i]; + CPlayerApplicationSettings* thisSetting = GetSetting(attId); + setting.iAttributeId = attId; + setting.iCharset = KUtf8MibEnum; + const TPtrC8 text = thisSetting->GetAttributeText(); + setting.iStringLen = text.Length(); + setting.iString = text.Alloc(); + + // If OOM, try to return an internal error. + if (setting.iString == NULL) + { + request.Close(); + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + // If OOM, try to return an internal error. + if (response.iAttributes.Append(setting) != KErrNone) + { + setting.Close(); + request.Close(); + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + } + request.Close(); + + // Allocate a buffer for the formatted message + RBuf8 messageBuffer; + if ( messageBuffer.Create(response.Size()) != KErrNone ) + { + // On OOM drop the message + response.Close(); + return; + } + + // send the response back to the CT + TRAP(error, response.WriteL(messageBuffer)); // Try to send internal error if OOM + response.Close(); + if (error != KErrNone) + { + messageBuffer.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + aOperationId, ERemConResponse, messageBuffer ); + + messageBuffer.Close(); + } + +// PDU 0x14 +void CPlayerInfoTarget::ProcessSetPlayerApplicationValue(const TDesC8& aData, TInt aOperationId) + { + RRemConPlayerAttributeIdsAndValues request; + TInt error = 0; + + // If we can't parse the request, then return an error + TRAP(error, request.ReadL(aData)); + if (error != KErrNone) + { + request.Close(); + return SendError(KErrAvrcpMetadataInvalidCommand, aOperationId); + } + + // Iterate through all the settings we're sent to update and set them + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + if (! AttributeValueCanBeSet(request.iAttributeId[i], request.iAttributeValue[i])) + { + // remove this setting + request.iAttributeId.Remove(i); + request.iAttributeValue.Remove(i); + request.iNumberAttributes--; + i--; + } + } + __ASSERT_DEBUG(request.iAttributeId.Count() == request.iAttributeValue.Count(), PlayerSettingsUtils::Panic(EPlayerSettingsFunnyLengthData)); + + // Section 5.7 of the AVRCP specification (page 56) says: + // If CT sent a PDU with nonexistent PDU ID or a PDU containing + // only one parameter with nonexistent parameter ID, TG shall return + // REJECTED response with Error Status Code. If CT sent a PDU with + // multiple parameters where at least one ID is existent and the + // others are nonexistent, TG shall proceed with the existent ID and + // ignore the non-existent IDs. + // + // This means we return REJECTED if we have nothing to set + if (request.iNumberAttributes == 0) + { + request.Close(); + return SendError(KErrAvrcpMetadataInvalidParameter, aOperationId); + } + + // If an application setting notifier has been requested then notify it + // If the notification succeeds, then set all the values + + TRAP(error, iApplicationSettingNotifier.MpasnSetPlayerApplicationValueL(request.iAttributeId, request.iAttributeValue)); + if ( error == KErrNone ) + { + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + CPlayerApplicationSettings* thisSetting = GetSetting(request.iAttributeId[i]); + thisSetting->SetCurrentValue(request.iAttributeValue[i]); + } + } + else + { + // Return an AVRCP internal error via RemCon. See section 5.7.1 of specification. + request.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + request.Close(); + // Send a notification if one has been registered + if ( KErrNotFound != iPendingNotificationEventList.Find( ERegisterNotificationPlayerApplicationSettingChanged )) + { + SendNotificationResponse( ERegisterNotificationPlayerApplicationSettingChanged, ERemConNotifyResponseChanged ); + } + + + // SendError KErrNone is used to send a valid response + SendError(KErrNone, aOperationId); + } + +// PDU 0x13 +void CPlayerInfoTarget::ProcessGetCurrentPlayerApplicationValue(const TDesC8& aData, TInt aOperationId) + { + TInt error = 0; + + // If we can't parse the request, then return an error + RRemConPlayerListOfAttributes request; + TRAP(error, request.ReadL(aData)); + if (error != KErrNone) + { + request.Close(); + return SendError(KErrAvrcpMetadataInvalidCommand, aOperationId); + } + + // Look through requested attributes, and assemble a response + // for those which we posess. If none are found, return an error + RRemConPlayerAttributeIdsAndValues response; + response.iNumberAttributes = 0; + request.iAttributes.Sort(); + + for (TInt i = 0; i < request.iNumberAttributes; i++) + { + TInt attToSend = request.iAttributes[i]; + if (AttributeSettingExists(attToSend)) + { + TInt ret1 = response.iAttributeId.Append(attToSend); + TInt ret2 = response.iAttributeValue.Append(GetSetting(attToSend)->GetCurrentValue()); + if (ret1 != KErrNone || ret2 != KErrNone) + { + request.Close(); + response.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); // Try to send internal error if OOM + } + response.iNumberAttributes++; + } + } + request.Close(); + + // Make sure that we always have at least one result to return + // Table 5.18 says that the number of results provided has an + // allowed value of 1-255, so we cannot return zero results. + if (response.iNumberAttributes == 0) + { + response.Close(); + return SendError(KErrAvrcpMetadataInvalidParameter, aOperationId); // No attributes matched + } + + // send the response back to the CT + TRAP(error, response.WriteL(iOutBuf)); // Try to send internal error if OOM + response.Close(); + if (error != KErrNone) + { + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + aOperationId, ERemConResponse, iOutBuf ); + } + +// PDU 0x16 +void CPlayerInfoTarget::ProcessGetPlayerApplicationValueText(const TDesC8& aData, TInt aOperationId) + { + RDesReadStream readStream; + readStream.Open(aData); + + TInt error = 0; + TInt reqAttribute = 0; + + // Read the attribute id + TRAP(error, reqAttribute = readStream.ReadUint8L()); + if (error != KErrNone) + { + readStream.Close(); + return SendError(KErrAvrcpMetadataParameterNotFound, aOperationId); // Nothing in packet + } + + // If we don't have settings for this attribute, return an error + CPlayerApplicationSettings* thisSetting = GetSetting(reqAttribute); + if (thisSetting == NULL) + { + readStream.Close(); + return SendError(KErrAvrcpMetadataInvalidParameter, aOperationId); // Attribute not found + } + + // Read the number of PAS values + TInt numSettings = 0; + TRAP(error, numSettings = readStream.ReadUint8L()); + if (error != KErrNone) + { + readStream.Close(); + return SendError(KErrAvrcpMetadataParameterNotFound, aOperationId); // Nothing in packet + } + + RArray valueTextsRequested; + for (TInt i = 0; i < numSettings; i++) + { + TInt requestedValueText = 0; + TRAP(error, requestedValueText = readStream.ReadUint8L()); + if (error == KErrNone) + { + if (valueTextsRequested.Append(requestedValueText) != KErrNone) + { + readStream.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); // Try to send internal error if OOM + } + } + } + + readStream.Close(); + + // format the response in a RRemConGetPlayerApplicationTextResponse + RRemConGetPlayerApplicationTextResponse response; + response.iNumberAttributes = 0; + + // for every attribute text requested + RPointerArray* textValues = thisSetting->GetValuesTexts(); + RArray* values = thisSetting->GetValues(); + TInt numRequested = valueTextsRequested.Count(); + for (TInt i = 0; i < numRequested; i++) + { + // start with the attribute id requested and the character set + RSettingWithCharset setting; + TInt valueToSend = valueTextsRequested[i]; + setting.iAttributeId = valueToSend; + setting.iCharset = KUtf8MibEnum; + + // text length followed by the text + TInt found = values->Find(valueToSend); + if (found != KErrNotFound) + { + HBufC8* text = (*textValues)[found]; + setting.iStringLen = text->Length(); + setting.iString = text->Alloc(); + + // If OOM, try to return an internal error. + if (setting.iString == NULL) + { + response.Close(); + valueTextsRequested.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + // If OOM, try to return an internal error. Of course, this could fail too + if (response.iAttributes.Append(setting) != KErrNone) + { + response.Close(); + setting.Close(); + valueTextsRequested.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + response.iNumberAttributes++; + } + } + valueTextsRequested.Close(); + + // Make sure that we always have at least one result to return + // Table 5.18 says that the number of results provided has an + // allowed value of 1-255, so we cannot return zero results. + if (response.iNumberAttributes == 0) + { + response.Close(); + return SendError(KErrAvrcpMetadataInvalidParameter, aOperationId); + } + + // Allocate a buffer for the formatted message + RBuf8 messageBuffer; + if ( messageBuffer.Create(response.Size()) != KErrNone ) + { + // On OOM drop the message + response.Close(); + return; + } + + // send the response back to the CT + TRAP(error, response.WriteL(messageBuffer)); // Try to send internal error if OOM + response.Close(); + if (error != KErrNone) + { + messageBuffer.Close(); + return SendError(KErrAvrcpMetadataInternalError, aOperationId); + } + + InterfaceSelector().SendUnreliable(TUid::Uid(KRemConPlayerInformationUid), + aOperationId, ERemConResponse, messageBuffer ); + messageBuffer.Close(); + } + +TBool CPlayerInfoTarget::AttributeSettingExists(TUint anAttributeID) + { + if (GetSetting(anAttributeID) == NULL) + { + return EFalse; + } + else + { + return ETrue; + } + } + +TBool CPlayerInfoTarget::IsValidAttributeValue(TUint anAttributeID, TUint anAttributeValue) + { + // As defined in Appendix F of the AVRCP specification, page 81 + // Attribute 0x01 - range 0x01 to 0x02 + // Attribute 0x02 - range 0x01 to 0x04 + // Attribute 0x03 - range 0x01 to 0x03 + // Attribute 0x04 - range 0x01 to 0x03 + // Attribute 0x05 - 0x7f -- invalid; reserved for future use + // Attribute 0x80 - 0xff -- vendor dependent + if (anAttributeID >= 0x80 && anAttributeID <= 0xff && anAttributeValue <= 0xff ) + { + return ETrue; + } + + if (anAttributeID == 0x01 && anAttributeValue >= 0x01 && anAttributeValue <= 0x02) + { + return ETrue; + } + + if (anAttributeID == 0x02 && anAttributeValue >= 0x01 && anAttributeValue <= 0x04) + { + return ETrue; + } + + if ((anAttributeID == 0x03 || anAttributeID == 0x04) + && anAttributeValue >= 0x01 && anAttributeValue <= 0x03) + { + return ETrue; + } + + // Everything else is invalid, as defined by the specification + return EFalse; + } + +// Check that anAttributeValue is in the valid value list for anAttributeID +TBool CPlayerInfoTarget::AttributeValueCanBeSet(TUint anAttributeID, TUint anAttributeValue) + { + CPlayerApplicationSettings* thisSetting = GetSetting(anAttributeID); + if (thisSetting == NULL) + { + return EFalse; + } + + RArray* values = thisSetting->GetValues(); + if (values == NULL) + { + return EFalse; + } + + if (values->Find(anAttributeValue) == KErrNotFound) + { + return EFalse; + } + + // This attribute id and value has been already defined by the RSS + // file, and checked that it conforms to the specification when the + // RSS file was loaded. Now allow this value to be set over the air. + return ETrue; + } + +CPlayerApplicationSettings* CPlayerInfoTarget::GetSetting(TUint anAttributeID) + { + // Will return NULL if anAttributeID is not found + CPlayerApplicationSettings** settings = iPlayerApplicationSettings.Find(anAttributeID); + if (settings == NULL) + { + return NULL; + } + + return *settings; + } + + +// from MPlayerApplicationSettingsObserver +// exported function wrapper for internal pure virtual +EXPORT_C void MPlayerApplicationSettingsObserver::DefineAttributeL(TUint aAttributeID, + TDesC8& aAttributeText, + RArray& aValues, + RArray& aValueTexts, + TUint aInitialValue) + { + DoDefineAttributeL(aAttributeID, aAttributeText, aValues, aValueTexts, aInitialValue); + } + +EXPORT_C void MPlayerApplicationSettingsObserver::SetAttributeL(TUint aAttributeID, TUint aValue) + { + DoSetAttributeL(aAttributeID, aValue ); + } + +void CPlayerInfoTarget::DoDefineAttributeL(TUint aAttributeID, + TDesC8& aAttributeText, + RArray& aValues, + RArray& aValueTexts, + TUint aInitialValue) + { + //Check Length of the player application setting attribute string is 1-255 + if(aAttributeText.Length() > KMaxPlayerApplicationSettingsValue || + aAttributeText.Length() < KMinPlayerApplicationSettingsValue ) + { + User::Leave(KErrNotSupported); + } + + //Check the number of player application setting values is 1-255 + if(aValues.Count() > KMaxPlayerApplicationSettingsValue || + aValues.Count() < KMinPlayerApplicationSettingsValue ) + { + User::Leave(KErrNotSupported); + } + + //Check the numbers of player application setting values and + //player application setting value texts are equal + if(aValues.Count() != aValueTexts.Count()) + { + User::Leave(KErrNotSupported); + } + + //Check Length of the player application setting value string is 1-255 + for(TInt i = 0; i < aValueTexts.Count(); i++ ) + { + if(aValueTexts[i].Length() > KMaxPlayerApplicationSettingsValue || + aValueTexts[i].Length() < KMinPlayerApplicationSettingsValue ) + { + User::Leave (KErrNotSupported); + } + } + + for (TInt i = 0; i < aValues.Count(); i++) + { + // The user cannot define certain attribute ids or values; see Appendix F + if ( ! IsValidAttributeValue(aAttributeID, aValues[i])) + { + User::Leave(KErrNotSupported); + } + } + + // Check the initial value, too + if ( ! IsValidAttributeValue(aAttributeID, aInitialValue)) + { + User::Leave(KErrNotSupported); + } + + // check that aInitialValue is in aValues + if (aValues.Find(aInitialValue) == KErrNotFound) + { + User::Leave(KErrNotSupported); + } + + // create a new TPlayerApplicationSettings + CPlayerApplicationSettings* newSetting = CPlayerApplicationSettings::NewL(aAttributeID, aAttributeText, aValues, aValueTexts, aInitialValue); + CleanupStack::PushL(newSetting); + + // Backup the settings of aAttributeID if they exist, return NULL if the attribute ID cannot be found + CPlayerApplicationSettings* backupSetting = GetSetting(aAttributeID); + + // and save it + iPlayerApplicationSettings.InsertL(aAttributeID, newSetting); + + //Delete backupSetting, as the InsertL will replace the old objects by the provided objects + delete backupSetting; + + CleanupStack::Pop(newSetting); + } + +void CPlayerInfoTarget::DoSetAttributeL(TUint aAttributeID, TUint aValue) + { + // Will return NULL if the attribute ID cannot be found + CPlayerApplicationSettings* setting = GetSetting(aAttributeID); + if (setting == NULL) + { + User::Leave(KErrNotFound); + } + + if ( ! IsValidAttributeValue(aAttributeID, aValue)) + { + User::Leave(KErrNotSupported); + } + + setting->SetCurrentValue(aValue); + + if ( KErrNotFound != iPendingNotificationEventList.Find( ERegisterNotificationPlayerApplicationSettingChanged )) + { + // send response + SendNotificationResponse( ERegisterNotificationPlayerApplicationSettingChanged, ERemConNotifyResponseChanged ); + } + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/playerinformation/src/settingsresource.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/playerinformation/src/settingsresource.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +// Copyright (c) 2008-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include + + +// AVRCP resource files must only contain one top level resource. +static const int KAVRCPResourceId = 1; +static const TInt KAVRCPFormatVersion = 1; + + +EXPORT_C void PlayerApplicationSettingsResourceInit::DefineAttributesL(MPlayerApplicationSettingsObserver& aSettings, + CResourceFile& aResourceFile) + { + // Read the settings from the resource file + RResourceReader reader; + reader.OpenLC(&aResourceFile, KAVRCPResourceId); + + // Check the version of this resource file + TUint16 formatVersion = reader.ReadUint16L(); + if (formatVersion != KAVRCPFormatVersion) + { + reader.Close(); + User::Leave(KErrCorrupt); + } + + // Find out how many settings this resource file contains + TInt settingsCount = reader.ReadUint16L(); + if (settingsCount < 0) + { + reader.Close(); + User::Leave(KErrCorrupt); + } + + // read the settings from aResource + RArray values; + RArray valueTexts; + CleanupClosePushL(values); + CleanupClosePushL(valueTexts); + + // Read each AVRCP attribute setting in turn + for (int i = 0; i < settingsCount; i++) + { + values.Reset(); + valueTexts.Reset(); + + // Read attribute, description text, initial value and defined values + TUint attributeID(reader.ReadUint8L()); + TUint initialValue(reader.ReadUint8L()); + TPtrC8 attributeText(reader.ReadTPtrC8L()); + TInt valuesCount(reader.ReadUint16L()); + + for (int j = 0; j < valuesCount; j++) + { + TUint thisValue = reader.ReadUint8L(); + TPtrC8 thisDescription = reader.ReadTPtrC8L(); + + values.AppendL(thisValue); + valueTexts.AppendL(thisDescription); + } + + // Now define this attribute, then continue to next attribute + aSettings.DefineAttributeL(attributeID, attributeText, values, valueTexts, initialValue); + } + // cleaning up values and valueTexts + CleanupStack::PopAndDestroy(3); // values, valueTexts, reader + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +// Copyright (c) 2007-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: +// + + + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconbeareravrcp.mmp + +PRJ_EXPORTS +../public/remconbeareravrcp.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconbeareravrcp.h) + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/group/remconbeareravrcp.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/group/remconbeareravrcp.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +// Copyright (c) 2004-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: +// remconbeareravrcp.dll and resource file. AVRCP bearer plugin for Rem Con server. +// + + + +/** + @file +*/ + +#include "../../../../../../os/bt/bluetoothmgmt/btcommon/config.cfg" + +#include + +TARGET remconbeareravrcp.dll +TARGETTYPE plugin + +UID 0x10009d8d 0x1020685e +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE avrcpcommandframer.cpp +SOURCE avrcpfragmenter.cpp +SOURCE avrcpimplementationproxy.cpp +SOURCE avrcpincomingcommandhandler.cpp +SOURCE avrcpoutgoingcommandhandler.cpp +SOURCE avrcpremotedevice.cpp +SOURCE avrcprouter.cpp +SOURCE avrcputils.cpp +SOURCE remconbeareravrcp.cpp +SOURCE avrcpMetadataTransfer.cpp +SOURCE avrcpbrowsingcommandhandler.cpp +SOURCE browsingframe.cpp +SOURCE browsecommand.cpp +SOURCE avrcpadvancedcontrol.cpp +SOURCE avrcpplayerinfomanager.cpp +SOURCE playerbitmasks.cpp +SOURCE avrcpsdputils.cpp +SOURCE bulkbearer.cpp +SOURCE avrcpcommand.cpp +SOURCE playerstatewatcher.cpp +SOURCE controlcommand.cpp +SOURCE internalcommand.cpp +SOURCE passthroughhelper.cpp + + +START RESOURCE 1020685e.rss +TARGET remconbeareravrcp.rsc +END + +USERINCLUDE ../inc +USERINCLUDE ../../common + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../../../../../../os/bt/bluetoothmgmt/btcommon/inc + +LIBRARY avc.lib +LIBRARY ecom.lib +LIBRARY estor.lib +LIBRARY euser.lib +LIBRARY bluetooth.lib +LIBRARY bluetoothav.lib +LIBRARY sdpdatabase.lib +LIBRARY avctpservices.lib +LIBRARY remconbearerplugin.lib +LIBRARY remcontypes.lib +LIBRARY avrcpipc.lib +LIBRARY remconabsolutevolume.lib + +#include + + +UNPAGED + +SMPSAFE + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcp.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +// Copyright (c) 2004-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: +// + + +#ifndef AVRCP_H +#define AVRCP_H + +/** +@file +@internalComponent +@released +*/ + +namespace AvrcpStatus + { + enum TCode + { + EInvalidCommand = 0, + EInvalidParameter = 1, + EParameterNotFound = 2, + EInternalError = 3, + ESuccess = 4, + EUidChanged = 5, + EReserved = 6, + EInvalidDirection = 7, + ENotADirectory = 8, + EDoesNotExist = 9, + EInvalidScope = 0xa, + ERangeOutOfBounds = 0xb, + EUidIsADirectory = 0xc, + EMediaInUse = 0xd, + ENowPlayingListFull = 0xe, + ESearchNotSupported = 0xf, + ESearchInProgress = 0x10, + EInvalidPlayerId = 0x11, + EPlayerNotBrowesable = 0x12, + EPlayerNotAddressed = 0x13, + ENoValidSearchResults = 0x14, + ENoAvailablePlayers = 0x15, + EAddressedPlayerChanged = 0x16, + }; + } + + +#endif // AVRCP_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpbearerinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpbearerinterface.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,42 @@ +// Copyright (c) 2008-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: +// + +#ifndef AVRCPBEARERINTERFACE_H +#define AVRCPBEARERINTERFACE_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include + +class MIncomingCommandHandler; +class MOutgoingCommandHandler; +NONSHARABLE_CLASS(MAvrcpBearer) + { +public: + virtual MIncomingCommandHandler* IncomingHandler(const TBTDevAddr& aAddr) = 0; + virtual MOutgoingCommandHandler* OutgoingHandler(const TBTDevAddr& aAddr) = 0; + + virtual void ConnectIndicate(const TBTDevAddr& aBTDevice) = 0; + virtual void ConnectConfirm(const TBTDevAddr& aBTDevice, TInt aError) = 0; + virtual void DisconnectIndicate(const TBTDevAddr& aBTDevice) = 0; + virtual void DisconnectConfirm(const TBTDevAddr& aBTDevice, TInt aError) = 0; + }; + +#endif //AVRCPBEARERINTERFACE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpbrowsingcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpbrowsingcommandhandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,87 @@ +// Copyright (c) 2008-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: +// avrcpbrowsingincomingcommandhandler.h +// + +#ifndef AVRCPBROWSINGINCOMINGCOMMANDHANDLER_H +#define AVRCPBROWSINGINCOMINGCOMMANDHANDLER_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include "avrcpplayerinfomanager.h" +#include "commandhandlerinterface.h" +#include "remconcommandinterface.h" + +class CBulkRouter; +class CAvrcpBulkBearer; +class TBTDevAddr; +class CBrowseCommand; +NONSHARABLE_CLASS(CRcpBrowsingCommandHandler) : public CBase, public MIncomingCommandHandler + { +public: + static CRcpBrowsingCommandHandler* NewL(MRemConBulkCommandInterface& aCommandInterface, + CBulkRouter& aRouter, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + const TBTDevAddr& aAddr); + ~CRcpBrowsingCommandHandler(); + + void Disconnect(); + const TBTDevAddr& BtAddr() const; + +private: // from MIncomingCommandHandler + void MessageSent(CAvrcpCommand& aCommand, TInt aSendResult); + void MaxPacketSize(TInt aMtu); + void ReceiveCommandL(const TDesC8& aMessageInformation, SymbianAvctp::TTransactionLabel aTransLabel, const TBTDevAddr& aAddr); + + TInt SendRemConResponse(TUid aInterfaceUid, TUint aId, RBuf8& aData); + void SendReject(TUid aInterfaceUid, TUint aTransactionId); + +private: + CRcpBrowsingCommandHandler(MRemConBulkCommandInterface& aCommandInterface, + CBulkRouter& aRouter, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + const TBTDevAddr& aAddr); + + void Respond(CBrowseCommand& aCommand, TInt aErr); + void HandledCommand(CBrowseCommand& aCommand); + + void HandleInternalCommand(CBrowseCommand& aCommand); + TInt HandleGetFolderItems(TUint aId, RBuf8& aCommandData); + void DoHandleGetFolderItemsL(RBuf8& aCommandData, RBuf8& aResponseData); + + TInt SendInternalResponse(TUint aId, RBuf8& aData); + TInt SendResponse(TDblQue& aCommandQueue, TUint aId, RBuf8& aData); + + TBool HandleSetBrowsedPlayer(CBrowseCommand& aCommand); + +private: + TDblQue iCommandQueue; + TDblQue iInternalCommandQueue; + + MRemConBulkCommandInterface& iCommandInterface; + CBulkRouter& iRouter; + + TInt iMtu; + + CAvrcpPlayerInfoManager& iPlayerInfoManager; + TBTDevAddr iAddr; + }; + +#endif //AVRCPBROWSINGINCOMINGCOMMANDHANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommand.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +// Copyright (c) 2008-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: +// + +#ifndef AVRCPCOMMAND_H +#define AVRCPCOMMAND_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include +#include "internaltypes.h" + +class CAvrcpPlayerInfoManager; +/** +This class is a base class for all AVRCP commands. It provides +the functionality that is common between the AV/C and Browse +commands. +*/ +NONSHARABLE_CLASS(CAvrcpCommand) : public CBase + { +public: + // called from Router + void Sent(); + virtual SymbianAvctp::TMessageType MessageType() const = 0; + + // Called by users of command + void DecrementUsers(); + void IncrementUsers(); + + // Called from bearer + void GetCommandInfo(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TBTDevAddr& aAddr); + + virtual const TDesC8& Data() const = 0; + + const TBTDevAddr& RemoteAddress() const; + SymbianAvctp::TTransactionLabel TransactionLabel() const; + TUint RemConCommandId() const; + + const TUid& RemConInterfaceUid() const; + TUint RemConOperationId() const; + + TBool KnownToBearer() const; + +protected: + explicit CAvrcpCommand(TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransactionLabel, + const TBTDevAddr& aAddr); + +public: + TBTDblQueLink iHandlingLink; // Used to form handling queue in command handlers + TBTDblQueLink iReadyLink; // Used to form ready command queue in CRemConBearerAvrcp + TBTDblQueLink iSendLink; // Used to form send queue in CRcpRouter + +protected: + TUint iRemConId; + SymbianAvctp::TTransactionLabel iTransactionLabel; + + TBTDevAddr iRemoteAddr; + + TUid iInterfaceUid; + TUint iOperationId; + RBuf8 iCommandData; + + TUint iUsers; + TBool iKnownToBearer; + + CAvrcpPlayerInfoManager* iPlayerInfoManager; + }; + +#endif //AVRCPCOMMAND_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommandframer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommandframer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPCOMMANDFRAMER_H +#define AVRCPCOMMANDFRAMER_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include + +class CAVCFrame; +NONSHARABLE_CLASS(AvrcpCommandFramer) + { +public: + static CAVCFrame* PassthroughL(AVCPanel::TOperationId aOperationId, + AVCPanel::TButtonAction aButtonAction); + + static CAVCFrame* UnitInfoResponseL(); + static CAVCFrame* SubunitInfoResponseL(); + static CAVCFrame* SetAbsoluteVolumeCommandL(TUint8 aAbsVol); + static CAVCFrame* NotifyVolumeChangeCommandL(); + }; + +#endif // AVRCPCOMMANDFRAMER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpfragmenter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpfragmenter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +// Copyright (c) 2007-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: +// + +#ifndef AVRCPFRAGMENTER_H +#define AVRCPFRAGMENTER_H + +/** +@file +@internalComponent +@released +*/ + +#define KAVRCPMinVendorDependentResponseLen 4 + +#include + +NONSHARABLE_CLASS(CAVRCPFragmenter) : public CBase + { +public: + static CAVRCPFragmenter* NewL(); + void Reset(); + void AssignPayload(const RBuf8& aPayload); + TBool InFragmentedState(); + TPtr8 GetNextFragmentHeader(); + TPtr8 GetNextFragment(); + TBool LastFragment(); + TInt GetPDU(); + ~CAVRCPFragmenter() { iPayload.Close(); } + +private: + CAVRCPFragmenter() {} + void Construct(); + +private: + RBuf8 iPayload; + TBool iInFragmentedState; + TInt iStart; + }; + +#endif // AVRCPFRAGMENTER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpincomingcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpincomingcommandhandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,125 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPINCOMINGCOMMANDHANDLER_H +#define AVRCPINCOMINGCOMMANDHANDLER_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include + +#include "controlcommand.h" +#include "avrcpplayerinfomanager.h" +#include "commandhandlerinterface.h" + +class CPassthroughHelper; +class CRcpRouter; +class CRemConBearerAvrcp; +class CAVCFrame; +class TBTDevAddr; +NONSHARABLE_CLASS(CRcpIncomingCommandHandler) : public CBase, public MPlayerChangeObserver, public MIncomingCommandHandler + { +public: + static CRcpIncomingCommandHandler* NewL(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer, + CAvrcpPlayerInfoManager& aPlayerInfoManager, TBTDevAddr& aDevice); + void ConstructL(); + ~CRcpIncomingCommandHandler(); + + void Disconnect(); + + inline CAvrcpPlayerInfoManager& AvrcpPlayerInfoManager() const; + +private: // from MIncomingCommandHandler + void MaxPacketSize(TInt aMtu); + void ReceiveCommandL(const TDesC8& aMessageInformation, SymbianAvctp::TTransactionLabel aTransLabel, const TBTDevAddr& aAddr); + void MessageSent(CAvrcpCommand& aCommand, TInt aSendResult); + + TInt SendRemConResponse(TUid aInterfaceUid, TUint aId, RBuf8& aData); + void SendReject(TUid aInterfaceUid, TUint aId); + +private: + CRcpIncomingCommandHandler(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + TBTDevAddr& aDevice); + + // From MPlayerChangeObserver + void MpcoAvailablePlayersChanged(); + void MpcoAddressedPlayerChangedLocally(TRemConClientId aClientId); + void MpcoUidCounterChanged(TRemConClientId aClientId); + + void Respond(CControlCommand& aCommand, TInt aErr); + void HandledCommand(CControlCommand& aCommand); + + void HandleInternalCommand(CControlCommand& aCommand); + void HandleRemConCommand(CControlCommand& aCommand); + + TInt HandleSetAddressedPlayer(TUint aId, RBuf8& aCommandData); + void DoHandleSetAddressedPlayerL(RBuf8& aCommandData); + void AddressedPlayerChangedL(TRemConClientId aClientId); + + TInt HandleRegisterAvailablePlayersNotification(CControlCommand& aCommand); + void DoHandleRegisterAvailablePlayersNotificationL(RBuf8& aResponseData, CControlCommand& aCommand); + + TInt HandleRegisterAddressedPlayerNotification(CControlCommand& aCommand); + void DoHandleRegisterAddressedPlayerNotificationL(RBuf8& aResponseData, CControlCommand& aCommand); + + TInt HandleUidChangedNotification( CControlCommand& aCommand); + void DoHandleUidChangedNotificationL(RBuf8& aResponseData, TUint16 aUidCounter); + + void SendInternalResponse(TUint aId, RBuf8& aData); + void SendResponse(TDblQue& aCommandQueue, TUint aId, RBuf8& aData); + + // Timer functions + TBool DuplicateNotify(TDblQue& aCommandQueue, const CControlCommand& aCommand) const; + CControlCommand* FindNotify(TDblQue& aCommandQueue, TUid aInterfaceUid, TUint aOperationId); +private: + TDblQue iCommandQueue; + TDblQue iInternalCommandQueue; + + CAVRCPFragmenter* iFragmenter; + CRemConBearerAvrcp& iBearer; + MRemConBearerObserver& iObserver; + CRcpRouter& iRouter; + CDeltaTimer& iTimer; + TRemConClientId iClientId; // We store the client id even if we aren't + // in addressed mode as we may switch into + // it and need to know the current local + // addressed player + TBool iAddressedMode; + + CAvrcpPlayerInfoManager& iPlayerInfoManager; + TBTDevAddr& iDevice; + + CPassthroughHelper* iPassthroughHelper; + }; + +CAvrcpPlayerInfoManager& CRcpIncomingCommandHandler::AvrcpPlayerInfoManager() const + { + return iPlayerInfoManager; + } + +#endif // AVRCPINCOMINGCOMMANDHANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcplog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcplog.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +// Copyright (c) 2005-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: +// Declares logging and instrumentation for avrcp (when flogging active) +// + + + +/** + @file + @internalComponent +*/ + +#ifndef AVRCPLOG_H +#define AVRCPLOG_H + +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_BEARER); +#endif // __FLOG_ACTIVE + +#define AVRCPLOG(A) LOG(A) +#define AVRCPLOG2(A,B) LOG1(A,B) +#define AVRCPLOG3(A,B,C) LOG2(A,B,C) +#define AVRCPLOG4(A,B,C,D) LOG3(A,B,C,D) +#define AVRCPLOG5(A,B,C,D,E) LOG4(A,B,C,D,E) + +#endif //AVRCPLOG_H + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpoutgoingcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpoutgoingcommandhandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,122 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPOUTGOINGCOMMANDHANDLER_H +#define AVRCPOUTGOINGCOMMANDHANDLER_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include "commandhandlerinterface.h" + +using namespace SymbianAvctp; + +class CControlCommand; +class CRcpRouter; +class CRemConBearerAvrcp; +class MRemConBearerObserver; +NONSHARABLE_CLASS(CRcpOutgoingCommandHandler) : public CBase, public MOutgoingCommandHandler + { +public: + // Construction/Destruction + static CRcpOutgoingCommandHandler* NewL(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer); + ~CRcpOutgoingCommandHandler(); + + // Called from bearer + void Disconnect(TBool aClearQueue); + + // Delta timer callback functions + static TInt ResponseExpiry(TAny* aExpiryInfo); + static TInt ReleaseExpiry(TAny* aExpiryInfo); + +private: + // From MOutgoingCommandHandler + void MaxPacketSize(TInt aMtu); + void ReceiveResponse(const TDesC8& aMessageInformation, TTransactionLabel aTransLabel, TBool aIpidBitSet); + void MessageSent(CAvrcpCommand& aCommand, TInt aSendResult); + + void SendCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr); + + void SendNotifyCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr); + +private: + CRcpOutgoingCommandHandler(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer); + + // Internal send utility funcs + void CleanupUnreleased(); + CControlCommand& SendCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + TBool isClick, + const TBTDevAddr& aAddr, + TBool aKnownToBearer, + TBool aNotify); + + void HandleCoreApiCommandL(TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr); + + void GenerateFailureResult(CControlCommand& aCommand, TInt aResult); + void GenerateCommandL(CControlCommand& aCommand, TRemConCoreApiButtonAction aButtonAct); + + // Timer functions + void ResponseExpiry(CControlCommand& aCommand); + void ReleaseExpiry(CControlCommand& aCommand); + void StartResponseTimer(CControlCommand& aCommand); + void StartReleaseTimer(CControlCommand& aCommand); + void ClearQueue(TDblQue& aQue); + void ProcessDisconnect(TDblQue& aQue, TBool aClearQueue); + CControlCommand* FindInQueue(TDblQue& aQue, SymbianAvctp::TTransactionLabel aTransLabel); + void ProcessReceiveResponse(CAVCFrame* aFrame, + TBool aIpidBitSet, + CControlCommand* aCommand, + TBool aNotify); +private: + TTransactionLabel iCurrentTrans; + TDblQue iCommandQueue; + TDblQue iNotifyCommandQueue; + + CRemConBearerAvrcp& iBearer; + MRemConBearerObserver& iObserver; + CRcpRouter& iRouter; + CDeltaTimer& iTimer; + + CControlCommand* iUnreleasedCommand; + TBool iUnreleasedHasResponse; + TInt iReleaseTimerExpiryCount; + }; + +#endif // AVRCPOUTGOINGCOMMANDHANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpplayerinfomanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpplayerinfomanager.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,171 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#ifndef AVRCPPLAYERINFOMANAGER_H +#define AVRCPPLAYERINFOMANAGER_H + +#include +#include +#include +#include +#include +#include +#include +#include "avrcpinternalinterface.h" +#include "avrcputils.h" +#include "playerbitmasks.h" +#include "playerstatewatcher.h" + +const TInt KAvrcpMediaPlayerItemBaseSize = 28; + +NONSHARABLE_CLASS(MPlayerChangeObserver) + { +public: + virtual void MpcoAvailablePlayersChanged() = 0; + virtual void MpcoAddressedPlayerChangedLocally(TRemConClientId aClientId) = 0; + virtual void MpcoUidCounterChanged(TRemConClientId aClientId) = 0; + }; + +NONSHARABLE_STRUCT(TAvrcpMediaPlayerItem) + { +public: + TRemConClientId iId; + TUint8 iPlayerType; + TUint32 iPlayerSubType; + TPlayerFeatureBitmask iFeatureBitmask; + TPtrC8 iName; + // iUidCounter is set from the bulk thread and read from the control thread + TUint16 iUidCounter; + // iLastUpdatedUidCounter is only accessed from the control thread to see if an update + // is needed + TUint16 iLastUpdatedUidCounter; + MPlayerEventsObserver::TPlaybackStatus iPlaybackStatus; + TUint8 iSdpFeatures; + TBool iBulkClientAvailable; + // We store absolute volume support because it's returned as part of + // a GetCapabilities(EventIds) response. Some implementations poll + // for changes to this value so it's probably worthwhile avoiding + // having to ask RemCon for it repeatedly. + TBool iAbsoluteVolumeSupport; + }; + +class MIncomingCommandHandler; +class MRemConCommandInterface; +class CUidWatcher; +NONSHARABLE_CLASS(CAvrcpPlayerInfoManager) + : public CBase, public MUidObserver, public MPlayStatusObserver + { +//--------------------------------------------------------- +// Control thread only functions +//--------------------------------------------------------- +public: + static CAvrcpPlayerInfoManager* NewL(MRemConBearerObserver& aObserver, MRemConCommandInterface& aCommandInterface); + ~CAvrcpPlayerInfoManager(); + + // Interface to bearer/remcon + void ClientAvailable(const TRemConClientId& aId, TPlayerType aClientType, TPlayerSubType aClientSubType, const TDesC8& aName); + void ClientNotAvailable(const TRemConClientId& aId); + void ClientStatus(TBool aControllerPresent, TBool aTargetPresent); + TInt SetLocalAddressedClient(const TRemConClientId& aId); + void ControllerFeaturesUpdatedL(RArray& aSupportedInterfaces); + MIncomingCommandHandler& InternalCommandHandler(); + + // Interface to command handler + void AddObserverL(MPlayerChangeObserver& aObserver); + void RemoveObserver(MPlayerChangeObserver& aObserver); + TUint16 UidCounterL(const TRemConClientId& aClientId) const; + TBool AbsoluteVolumeSupportedL(const TRemConClientId& aClientId) const; + TBool BrowsingSupportedL(const TRemConClientId& aClientId) const; + +private: + // Interface to uid counter updates + static TInt PlayerUpdateCallBack(TAny* aPlayerInfoMgr); + void UidCounterUpdate(); + + // from MPlayStatusObserver + void MpsoPlayStatusChanged(TRemConClientId aId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus); + void MpsoError(TRemConClientId aId); + + +//--------------------------------------------------------- +// Bulk thread only functions +//--------------------------------------------------------- +public: + // Interface to bearer/remcon + void BulkClientAvailable(const TRemConClientId& aId); + void BulkClientNotAvailable(const TRemConClientId& aId); + MIncomingCommandHandler* BulkStartedL(MRemConCommandInterface& aCommandInterface); + void BulkStopped(); + + // Interface to command handler + void MediaPlayerItemL(const TUint16& aAvrcpPlayerId, RMediaPlayerItem& aItem); + + +private: // from MUidObserver + void MuoUidChanged(TRemConClientId aId, TUint16 aUidCounter); + void MuoError(TRemConClientId aId); + + + +//--------------------------------------------------------- +// Common functions +//--------------------------------------------------------- +public: + // Used to map between AVRCP player ids and RemCon client ids + TRemConClientId ClientL(TUint16 aAvrcpPlayerId) const; + TRemConClientId Client(TUint16 aAvrcpPlayerId) const; + TUint16 PlayerL(const TRemConClientId& aClientId) const; + + // Used to retrieve list of current players + TInt PlayerListing(TUint aStartItem, TUint aEndItem, RArray& aPlayers); + TInt PlayerListing(RArray& aPlayers); + +private: + CAvrcpPlayerInfoManager(MRemConBearerObserver& aObserver); + void ConstructL(MRemConCommandInterface& aCommandInterface); + + TBool ValidPlayer(const TUint16& aAvrcpPlayerId) const; + TInt NextPlayerIndex(); + TInt SetPlayerFeatures(const TRemConClientId& aId, TPlayerFeatureBitmask& aBitmask, TUint8& aSdpFeatures, TBool& aAbsoluteVolumeSupported); + void UpdateTgServiceRecordL(); + +private: + RPointerArray iObservers; + RArray iPlayers; + CUidWatcher* iUidWatcher; + CPlayStatusWatcher* iPlayStatusWatcher; + MRemConBearerObserver& iControlBearerObserver; // unowned - used to determine features of players + RSpecificThreadCallBack iControlThreadCallBack; + + RSdp iSdp; + RSdpDatabase iSdpDatabase; + TSdpServRecordHandle iControllerRecord; + TSdpServRecordHandle iTargetRecord; + + mutable RFastLock iLock; // for use in const functions + }; + +// The lock is only used for the following members.... +// + +#endif //AVRCPPLAYERINFOMANAGER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpremotedevice.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpremotedevice.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPREMOTEDEVICE_H +#define AVRCPREMOTEDEVICE_H + +/** +@file +@internalComponent +@released +*/ + +#include + +class CRemConBearerAvrcp; +class MIncomingCommandHandler; +class MOutgoingCommandHandler; +class CRcpIncomingCommandHandler; +class CRcpOutgoingCommandHandler; +class CRcpRouter; +class MRemConBearerObserver; +/** +CRcpRemoteDevice represents one remote RCP device. It manages +the sending and receiving of commands between that device and the +local device. +*/ +NONSHARABLE_CLASS(CRcpRemoteDevice) : public CBase + { +public: + static CRcpRemoteDevice* NewL(const TBTDevAddr& aAddr, + CRcpRouter& aRouter, + CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CDeltaTimer& aTimer, + CAvrcpPlayerInfoManager& aPlayerInfoManager); + + virtual ~CRcpRemoteDevice(); + + void Disconnect(TBool aClearQueue); + + // Utility + const TBTDevAddr& RemoteAddress() const; + MIncomingCommandHandler& IncomingHandler() const; + MOutgoingCommandHandler& OutgoingHandler() const; + +private: + CRcpRemoteDevice(const TBTDevAddr& aAddr, + CRcpRouter& aRouter, + CRemConBearerAvrcp& aBearer, + CDeltaTimer& aTimer); + + void ConstructL(MRemConBearerObserver& aObserver, + CAvrcpPlayerInfoManager& aPlayerInfoManager); + +public: + TDblQueLink iLink; // Used by bearer and router to manage remotes +private: + TBTDevAddr iDevice; + + CRcpIncomingCommandHandler* iIncoming; + CRcpOutgoingCommandHandler* iOutgoing; + + CRcpRouter& iRouter; + CRemConBearerAvrcp& iBearer; + CDeltaTimer& iTimer; + }; + + +#endif // AVRCPREMOTEDEVICE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcprouter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcprouter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,123 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPROUTER_H +#define AVRCPROUTER_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include "avrcp.h" +#include "avrcpbearerinterface.h" + + +class CAvrcpCommand; +class CBrowseCommand; + +NONSHARABLE_CLASS(CRcpRouter) : public CBase, public MAvctpEventNotify + { +private: + enum TAvrcpRouterState + { + EAvrcpRouterSending, + EAvrcpRouterCanSend + }; + +public: + ~CRcpRouter(); + + // Data functions called from command handlers + void AddToSendQueue(CAvrcpCommand& aCommand); + void RemoveFromSendQueue(CAvrcpCommand& aCommand); + + // Control functions called from bearer + TInt ConnectRequest(const TBTDevAddr& aAddr); + TInt DisconnectRequest(const TBTDevAddr& aAddr); + + // MAvctpEventNotify functions + virtual void MaenAttachIndicate(const TBTDevAddr& aBTDevice, TInt aMtu, TBool& aAccept); + + virtual void MaenAttachConfirm(const TBTDevAddr& aBTDevice, TInt aMtu, TInt aConnectResult); + + virtual void MaenDetachIndicate(const TBTDevAddr& aBTDevice); + + virtual void MaenDetachConfirm(const TBTDevAddr& aBTDevice, TInt aDisconnectResult); + + virtual void MaenMessageReceivedIndicate(const TBTDevAddr& aBTDevice, + SymbianAvctp::TTransactionLabel aTransactionLabel, + SymbianAvctp::TMessageType aType, + TBool aIpidBitSet, + const TDesC8& aMessageInformation); + + virtual void MaenMessageSendComplete(const TBTDevAddr& aBTDevice, + SymbianAvctp::TTransactionLabel aTransactionLabel, + TInt aSendResult); + + virtual void MaenCloseComplete(); + + virtual void MaenErrorNotify(const TBTDevAddr& aBTDevice, TInt aError); + + virtual void MaenExtensionInterfaceL(TUid aInterface, void*& aObject); + +protected: + explicit CRcpRouter(MAvrcpBearer& aBearer); + +private: + // Utility functions + void Send(); + +protected: + MAvctpChannel* iChannel; + MAvrcpBearer& iBearer; + + TDblQue iSendQueue; + TAvrcpRouterState iState; +// TAvctpChannel iChannel; + + }; + +NONSHARABLE_CLASS(CControlRouter) : public CRcpRouter + { +public: + static CControlRouter* NewL(RAvctp& aAvctp, MAvrcpBearer& aBearer); + ~CControlRouter(); + +private: + explicit CControlRouter(RAvctp& aAvctp, MAvrcpBearer& aBearer); + void ConstructL(); + +private: + RAvctp& iAvctp; + }; + +NONSHARABLE_CLASS(CBulkRouter) : public CRcpRouter + { +public: + static CBulkRouter* NewL(RAvctp& aAvctp, MAvrcpBearer& aBearer); + ~CBulkRouter(); + +private: + explicit CBulkRouter(RAvctp& aAvctp, MAvrcpBearer& aBearer); + void ConstructL(); + +private: + RAvctp& iAvctp; + }; +#endif // AVRCPROUTER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpsdputils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpsdputils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent +*/ + +#ifndef AVRCPSDPUTILS_H +#define AVRCPSDPUTILS_H + +#include +#include + +namespace AvrcpSdp + { + enum TRecordType + { + ERemoteControl, + ERemoteControlTarget, + }; + + _LIT8(KAvrcpProviderName, "Symbian OS"); + _LIT8(KAvrcpTargetServiceName, "AVRCP Target"); + _LIT8(KAvrcpControllerServiceName, "AVRCP Controller"); + _LIT8(KAvrcpServiceDescription, "Audio Video Remote Control"); + + const TUint16 KAvrcpProfileVersion14 = 0x0104; + const TUint16 KAvrcpProfileVersion13 = 0x0103; + const TUint16 KAvctpProtocolVersion13 = 0x103; + const TUint16 KAvctpProtocolVersion12 = 0x102; + + enum TAvrcpFeature + { + EPlayerRecorder = 1 << 0, + EMonitorAmplifier = 1 << 1, + ETuner = 1 << 2, + EMenu = 1 << 3, + EPlayer = 1 << 4, + EGroupNavigation = 1 << 5, + EBrowsing = 1 << 6, + EMultiplePlayers = 1 << 7, + }; + + const TUint16 KAvrcpBaseCtFeatures = EPlayerRecorder | + EMonitorAmplifier | + ETuner | + EMenu; + + const TUint16 KAvrcpBaseTgFeatures = EPlayerRecorder | + EMonitorAmplifier | + ETuner | + EMenu | + EMultiplePlayers; + } + +NONSHARABLE_CLASS(AvrcpSdpUtils) + { +public: + static void CreateServiceRecordL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TBool aTarget, TUint16 aProfileVersion); + static void UpdateProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProtocolVersion); + static void UpdateAdditionalProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle); + static void UpdateBrowseListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle); + static void UpdateProfileDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProfileVersion); + static void UpdateSupportedFeaturesL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, AvrcpSdp::TRecordType aType, TUint16 aFeatures); + }; + +#endif // AVRCPSDPUTILS_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcptimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcptimer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPTIMER_H +#define AVRCPTIMER_H + +/** +@file +@internalComponent +@released +*/ + +#include + +class CControlCommand; +NONSHARABLE_CLASS(TAvrcpTimerExpiryInfo) + { +public: + inline TAvrcpTimerExpiryInfo(CBase* aHandler, CControlCommand& aCommand); +public: + CBase* iHandler; + CControlCommand& iCommand; + }; + + +//------------------------------------------------------------------------------------ +// TAvrcpTimerEntry +//------------------------------------------------------------------------------------ + +/** Constructor. + +@param aHandler The CommandHandler to be informed on timer expiry. +@param aCommand The CControlCommand that this timer event relates to. +@return A fully constructed TAvrcpTimerExpiryInfo. +*/ +inline TAvrcpTimerExpiryInfo::TAvrcpTimerExpiryInfo(CBase* aHandler, CControlCommand& aCommand) + : iHandler(aHandler), iCommand(aCommand) + { + } + +#endif // AVRCPTIMER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcputils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcputils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,173 @@ +// Copyright (c) 2004-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: +// + +#ifndef AVRCPUTILS_H +#define AVRCPUTILS_H + +/** +@file +@internalComponent +@released +*/ + +_LIT(KAvrcpPanicName, "AVRCP Panic"); + +enum TAvrcpPanic + { + EAvrcpNoAVCFrame = 0, + EAvrcpNotConnected = 1, + EAvrcpNoOutstandingSend = 2, + EAvrcpHoldExpiryForRelease = 3, + EAvrcpReleaseExpiryForRelease = 4, + EAvrcpUnknownAvctpTransId = 5, + EAvrcpNoResponsesAvailable = 6, + EAvrcpResponseToUnknownCommand = 7, + EAvrcpBadBTAddr = 8, + EAvrcpCommandStillInUse = 9, + EAvrcpCommandDataTooLong = 10, + EAvrcpFunnyLengthData = 11, + EAvrcpTimerNotCancelled = 12, + EAvrcpNotVendorDependent = 13, + EAvrcpMismatchedConnectDisconnect = 14, + EAvrcpDummyCallbackCalled = 15, + EAvrcpUnknownButtonAction = 16, + EAvrcpPressHasPhantomResponse = 17, + EAvrcpReleaseTimerStartedWithoutResponse = 18, + EAvrcpReleaseExpiryForOldCommand = 19, + EAvrcpSendingMessageFailed = 20, + EAvrcpDisconnectRequestWhilePartiallyConstructed = 21, + EAvrcpReleaseExpiryForClick = 22, + EAvrcpIncomingCommandsNotHandled = 23, + EAvrcpCommandStillQueuedForHandling = 24, + EAvrcpCommandStillQueuedAsReady = 25, + EAvrcpCommandStillQueuedForSending = 26, + EAvrcpPressNotPreviousPassthroughCommand = 27, + EAvrcpInterfaceUidNotSet = 28, + EAvrcpCTypeNotSet = 29, + EAvrcpCompanyIDNotSet = 30, + EAvrcpNotFullyConstructed = 31, + EAvrcpInternalHandlingRequestedOnWrongInterface = 32, + EAvrcpVolumeBeyondMaxVolume = 33, + EAvrcpInvalidEventId = 34, + EAvrcpInvalidPlayerId = 35, + EAvrcpConnectConfirmOnBrowseChannel = 36, + EAvrcpDisconnectConfirmOnBrowseChannel = 37, + EAlreadyWatchingPlayer = 38, + ENotWatchingPlayer = 39, + EAvctpMessageTypeRequestedForInternalCommand = 40, + ELowerInterfaceUsedOnInternalHandler = 41, + EFurtherProcessingRequiredForNonSetBrowsedPlayer = 42, + ESetBrowsePlayerRequestCorruptedLocally = 43, + ESpecificAddressUsedForBrowsingCommand = 44, + EUidUpdateRequestWriteFailure = 45, + EUnmatchedResponseFromRemCon = 46, + EResponseForWrongInterface = 47, + EInvalidBtAddrInResponse = 48, + EInvalidPlayerId = 49, + EMysteryInternalResponse = 50, + ECommandAlreadyQueuedForSending = 52, + EPassthroughQueueNotEmptyAfterDisconnect = 53, + EPreviousPassthroughNonNullReplacing = 54, + }; + +template +struct TAvrcpPanicCodeTypeChecker + { + inline static void Check(XAny) { } + }; + +#define AVRCP_PANIC(CODE) \ + TAvrcpPanicCodeTypeChecker::Check(CODE), \ + PANIC(KAvrcpPanicName, CODE) + + +class TBTDevAddr; +class TRemConAddress; +class AvrcpUtils + { +public: + static void Panic(TAvrcpPanic aPanic); // The macro is probably more useful so this can be removed + + static void SetCommandDataFromInt(RBuf8& aCommandData, TInt aOffset, TInt aLength, TInt aValue); + static void ReadCommandDataToInt(const RBuf8& aCommandData, TInt aOffset, TInt aLength, TInt& aValue); + + static TInt RemConToBTAddr(const TRemConAddress& aRemoteAddress, TBTDevAddr& aBTAddr); + static void BTToRemConAddr(const TBTDevAddr& aBTAddr, TRemConAddress& aRemConAddress); + }; + +// +// Thread Assertions +// + +enum TAvrcpThreadId + { + EControlThread = 0x00000001, + EBulkThread = 0x00000002, + }; + +#define ASSERT_THREAD(aaa) ASSERT_DEBUG(reinterpret_cast(Dll::Tls()) == aaa) +#define WEAK_ASSERT_THREAD(aaa) if(Dll::Tls()) { ASSERT_THREAD(aaa); } +#define ASSERT_CONTROL_THREAD ASSERT_THREAD(EControlThread) +#define ASSERT_BULK_THREAD ASSERT_THREAD(EBulkThread) +#define WEAK_ASSERT_BULK_THREAD WEAK_ASSERT_THREAD(EBulkThread) + +// +// Cleanup Stack utils +// + +template +class CleanupSignal + { +public: + inline static void PushL(T& aRef) {CleanupStack::PushL(TCleanupItem(&Signal,&aRef));}; +private: + static void Signal(TAny *aPtr) {(static_cast(aPtr))->Signal();}; + }; + +template +inline void CleanupSignalPushL(T& aRef) + {CleanupSignal::PushL(aRef);} + +template +class CleanupDeleteAndNull + { +public: + inline static void PushL(T*& aRef) {CleanupStack::PushL(TCleanupItem(&DeleteAndNull,&aRef));}; +private: + static void DeleteAndNull(TAny *aPtr) {T*& ptr = *static_cast(aPtr); delete ptr; ptr = NULL;}; + }; + +template +inline void CleanupDeleteAndNullPushL(T*& aRef) + {CleanupDeleteAndNull::PushL(aRef);} + +class CSpecificThreadCallBackBody; +NONSHARABLE_CLASS(RSpecificThreadCallBack) + { +public: + RSpecificThreadCallBack(); + + TInt Create(const TCallBack& aCallBack, TInt aPriority); + void Close(); + + TInt Start(); + TInt CallBack(); + void Cancel(); + +private: + CSpecificThreadCallBackBody* iBody; + }; + +#endif // AVRCPUTILS_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/browsecommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/browsecommand.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +// Copyright (c) 2008-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: +// + +#ifndef BROWSECOMMAND_H +#define BROWSECOMMAND_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include +#include "avrcpcommand.h" +#include "avrcpplayerinfomanager.h" + +const TInt KMinLengthSetBrowsedPlayerPdu = 2; // PDU 0x70 +const TInt KMinLengthGetFolderItemsPdu = 10; // PDU 0x71 +const TInt KMinLengthChangePathPdu = 3; // PDU 0x72 +const TInt KMinLengthGetItemAttributesPdu = 12; // PDU 0x73 +const TInt KMinLengthSearchPdu = 4; // PDU 0x80 +const TInt KMinLengthGeneralReject = 4; // PDU 0xa0 + +class CRcpRemoteDevice; +class MRemConBearerObserver; +NONSHARABLE_CLASS(CBrowseCommand) : public CAvrcpCommand + { +public: + static CBrowseCommand* NewL(const TDesC8& aMessageInformation, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + CAvrcpPlayerInfoManager* aPlayerInfoManager); + + // Called from handlers + TInt ProcessIncomingCommandL(TInt aMaxResponse); + void ProcessOutgoingResponse(RBuf8& aCommandData); + void SetResult(TInt aErr); + const TDesC8& CommandData() const; + + const TDesC8& Data() const; + virtual SymbianAvctp::TMessageType MessageType() const; + +private: + CBrowseCommand(TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + CAvrcpPlayerInfoManager* aPlayerInfoManager); + + ~CBrowseCommand(); + void ConstructL(const TDesC8& aMessageInformation); + + TInt HandleSetBrowsedPlayer(); + TInt HandleGetFolderItems(); + TInt HandleChangePath(); + TInt HandleGetItemAttributes(); + TInt HandleSearch(); + TInt HandleUnknownPdu(); + + TInt AppendIncomingPayload(const TPtrC8& aPayload); + void GenerateRejectPayloadL(TInt aErr); + +private: + RBuf8 iFrame; + TInt iMaxResponse; + }; + +#endif //BROWSECOMMAND_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,109 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#ifndef BULKBEARER_H +#define BULKBEARER_H + +#include +#include + +#include "remconcommandinterface.h" + +class CBrowseCommand; +class CRcpBrowsingCommandHandler; +class TBTDevAddr; +class TRemConAddress; + +NONSHARABLE_CLASS(CAvrcpBulkBearer) : public CBase, public MRemConBearerBulkInterface, + public MAvrcpBearer, public MRemConBulkCommandInterface + { +public: + static CAvrcpBulkBearer* NewL(RAvctp& aAvctp, CAvrcpPlayerInfoManager& aPlayerInfoManager); + ~CAvrcpBulkBearer(); + +private: // Interface to command handlers, from MRemConCommandInterface + void MrcciNewCommand(CAvrcpCommand& aCommand); + void MrcciNewCommand(CAvrcpCommand& aCommand,const TRemConClientId& aClientId); + + TUint MrcciNewTransactionId(); + + TInt MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient); + void MrcbciRemoveAddressing(const TRemConAddress& aAddr); + +private: // Interface to router, from MAvrcpBearer + MIncomingCommandHandler* IncomingHandler(const TBTDevAddr& aAddr); + MOutgoingCommandHandler* OutgoingHandler(const TBTDevAddr& aAddr); + + void ConnectIndicate(const TBTDevAddr& aBTDevice); + void ConnectConfirm(const TBTDevAddr& aBTDevice, TInt aError); + void DisconnectIndicate(const TBTDevAddr& aBTDevice); + void DisconnectConfirm(const TBTDevAddr& aBTDevice, TInt aError); + +private: // interface to RemCon, from MRemConBulkBearerInterface + virtual TInt MrcbbiGetCommand(TUid& aInterfaceUid, + TUint& aTransactionId, + TUint& aOperationId, + RBuf8& aData, + TRemConAddress& aAddr); + + virtual TInt MrcbbiSendResponse(TUid aInterfaceUid, + TUint aOperationId, + TUint aTransactionId, + RBuf8& aData, + const TRemConAddress& aAddr); + + virtual void MrcbbiSendReject(TUid aInterfaceUid, + TUint aOperationId, + TUint aTransactionId, + const TRemConAddress& aAddr); + + virtual TInt MrcbbiStartBulk(MRemConBearerBulkObserver& aObserver); + virtual void MrcbbiStopBulk(); + + virtual void MrcbbiBulkClientAvailable(const TRemConClientId& aId); + virtual void MrcbbiBulkClientNotAvailable(const TRemConClientId& aId); + +private: + explicit CAvrcpBulkBearer(CAvrcpPlayerInfoManager& aPlayerInfoManager, RAvctp& aAvctp); + + // utility functions + TBool Operational() const; + void DoConnectIndicateL(const TBTDevAddr& aBTDevice); + void DoStartBulkL(); + static TBool CompareBrowsingCommandHandlerByBDAddr(const TBTDevAddr* aKey, const CRcpBrowsingCommandHandler& aHandler); + void DoNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId); +private: // unowned + MRemConBearerBulkObserver* iObserver; + CAvrcpPlayerInfoManager& iPlayerInfoManager; + RAvctp& iAvctp; + MIncomingCommandHandler* iInternalHandler; + + TDblQue iReadyBrowseCommands; + +private: // owned + CBulkRouter* iRouter; + RPointerArray iBrowseHandlers; + + }; + +#endif //BULKBEARER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/commandhandlerinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/commandhandlerinterface.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,66 @@ +// Copyright (c) 2008-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: +// + +#ifndef COMMANDHANDLERINTERFACE_H +#define COMMANDHANDLERINTERFACE_H + +/** +@file +@internalComponent +@released +*/ + +#include + +class CAvrcpCommand; +NONSHARABLE_CLASS(MAvrcpCommandHandler) + { +public: + virtual void MessageSent(CAvrcpCommand& aCommand, TInt aSendResult) = 0; + }; + +NONSHARABLE_CLASS(MIncomingCommandHandler) : public MAvrcpCommandHandler + { +public: + // lower interface + virtual void MaxPacketSize(TInt aMtu) = 0; + virtual void ReceiveCommandL(const TDesC8& aMessageInformation, SymbianAvctp::TTransactionLabel aTransLabel, const TBTDevAddr& aAddr) = 0; + + // upper interface + virtual TInt SendRemConResponse(TUid aInterfaceUid, TUint aId, RBuf8& aData) = 0; + virtual void SendReject(TUid aInterfaceUid, TUint aTransactionId) = 0; + }; + +NONSHARABLE_CLASS(MOutgoingCommandHandler) : public MAvrcpCommandHandler + { +public: + // lower interface + virtual void ReceiveResponse(const TDesC8& aMessageInformation, SymbianAvctp::TTransactionLabel aTransLabel, TBool aIpidBitSet) = 0; + + // upper interface + virtual void SendCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr) = 0; + + virtual void SendNotifyCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr) = 0; + }; + +#endif // COMMANDHANDLERINTERFACE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,187 @@ +// Copyright (c) 2008-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: +// + +#ifndef CONTROLBEARER_H +#define CONTROLBEARER_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "avrcpbearerinterface.h" +#include "remconcommandinterface.h" + +class CControlCommand; +class CRcpRemoteDevice; +class CControlRouter; +class TBTDevAddr; +class CBrowseCommand; +class CAvrcpPlayerInfoManager; +class CAvrcpBulkBearer; + +NONSHARABLE_CLASS(CRemConBearerAvrcp) : public CRemConBearerPlugin, public MRemConBearerInterfaceV3, + public MAvrcpBearer, public MRemConControlCommandInterface + { +public: + static CRemConBearerAvrcp* NewL(TBearerParams& aParams); + virtual ~CRemConBearerAvrcp(); + +public: // Interface to command handlers, from MRemConCommandInterface + void MrcciNewCommand(CAvrcpCommand& aCommand); + void MrcciNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId); + void MrccciNewNotifyCommand(CAvrcpCommand& aCommand); + void MrccciNewNotifyCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId); + + void MrccciNewResponse(CAvrcpCommand& aCommand); + void MrccciNewNotifyResponse(CControlCommand& aCommand); + + TUint MrcciNewTransactionId(); + void MrccciSetAddressedClient(const TRemConClientId& aClient); + +private: // MRemConBearerInterfaceV3 functions called from RemCon + virtual TInt GetResponse(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr); + + virtual TInt SendCommand(TUid aInterfaceUid, + TUint aOperationId, + TUint aId, + RBuf8& aData, + const TRemConAddress& aAddr); + + virtual TInt GetCommand(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr); + + virtual TInt GetNotifyCommand(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr); + + virtual CAvrcpCommand* GetFirstCommand(TDblQue& aQue, + TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr); + + virtual TInt SendResponse(TUid aInterfaceUid, + TUint aOperationId, + TUint aId, + RBuf8& aData, + const TRemConAddress& aAddr); + + virtual void SendReject(TUid aInterfaceUid, + TUint aOperationId, + TUint aTransactionId, + const TRemConAddress& aAddr); + virtual void ConnectRequest(const TRemConAddress& aAddr); + virtual void DisconnectRequest(const TRemConAddress& aAddr); + + virtual TSecurityPolicy SecurityPolicy() const; + void ClientStatus(TBool aControllerPresent, TBool aTargetPresent); + virtual void ClientAvailable(TRemConClientId& aId, TPlayerType aClientType, TPlayerSubType aClientSubType, const TDesC8& aName); + virtual void ClientNotAvailable(TRemConClientId& aId); + virtual void ControllerFeaturesUpdated(RArray& aSupportedInterfaces); + + virtual TInt SetLocalAddressedClient(TRemConClientId& aId); + +private: // from CRemConBearerPlugin + TAny* GetInterface(TUid aUid); + +private: + // from MAvrcpBearer called from router + void ConnectIndicate(const TBTDevAddr& aBTDevice); + void ConnectConfirm(const TBTDevAddr& aBTDevice, TInt aError); + void DisconnectIndicate(const TBTDevAddr& aBTDevice); + void DisconnectConfirm(const TBTDevAddr& aBTDevice, TInt aError); + + MIncomingCommandHandler* IncomingHandler(const TBTDevAddr& aAddr); + MOutgoingCommandHandler* OutgoingHandler(const TBTDevAddr& aAddr); + +private: + // MRemConBearerInterfaceV3 plugin functions called from RemCon + virtual TInt SendNotifyCommand(TUid aInterfaceUid, + TUint aOperationId, + TUint aId, + RBuf8& aData, + const TRemConAddress& aAddr); + + virtual TInt GetNotifyResponse(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr, + TRemConMessageSubType& aSubMessageType); + +private: + enum TAvrcpRecordType + { + EAvrcpRemoteControlRecord, + EAvrcpRemoteControlTargetRecord, + }; + +private: + CRemConBearerAvrcp(TBearerParams& aParams); + void ConstructL(); + + // utility functions + CRcpRemoteDevice* RemoteDevice(const TBTDevAddr& aAddr); + + void UpdateServiceRecordL(RSdpDatabase& aSdpDatabase, + TBool aController, + TBool aTarget); + void RegisterServiceRecordL(RSdpDatabase& aSdpDatabase, + TAvrcpRecordType aType); + + void HandleUndeliveredCommand(CAvrcpCommand& aCommand, const TRemConAddress& aAddr); + +private: + TDblQue iRemotes; + TDblQue iReadyCommands; + TDblQue iReadyResponses; + TDblQue iReadyNotifyResponses; + TDblQue iReadyNotifyCommands; + CControlRouter* iRouter; + CDeltaTimer* iTimer; + RSdp iSdp; + TSdpServRecordHandle iControllerSdpRecordHandle; + TSdpServRecordHandle iTargetSdpRecordHandle; + TBool iConstructionComplete; + CAvrcpPlayerInfoManager* iPlayerInfoManager; + MIncomingCommandHandler* iInternalHandler; + + CAvrcpBulkBearer* iBulkBearer; + + RAvctp iAvctp; + }; + +#endif //CONTROLBEARER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlcommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlcommand.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,277 @@ +// Copyright (c) 2004-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: +// + +#ifndef CONTROLCOMMAND_H +#define CONTROLCOMMAND_H + +/** +@file +@internalComponent +@released +*/ + +#include +#include +#include +#include +#include +#include "internaltypes.h" + +#include + +#include "avrcpcommand.h" +#include "avrcptimer.h" +#include "avrcpfragmenter.h" + +const TInt KRcpResponseTimeOut = 30000000; // Allow remote 300ms to respond +const TInt KRcpHoldThreshold = 300000; // After 300ms we may assume an unreleased button + // action is a press and hold +const TInt KRcpIncomingButtonReleaseTimeout = 1700000; // 1.7s (ie 2s - 300ms), if a button press + // has not been released after 2s we assume the release + // has been lost (and generate one internally) +const TInt KRcpOutgoingButtonReleaseTimeout = 1000000; // The remote expects a press refresh within + // 2s, it's fine to send one before that. + +const TUint KRemConStatusApiDefaultPageDataLength = 4; +const TUint KRemConMetadataHeaderLength = 4; + +// Absolute lengths of Vendor Dependent PDU requests +const TUint8 KLengthGetCapabilitiesPdu = 1; // PDU 0x10 +const TUint8 KLengthListPASAttributesPdu = 0; // PDU 0x11 +const TUint8 KLengthListPASValuesPdu = 1; // PDU 0x12 +const TUint8 KLengthInformBatteryStatusOfCTPdu = 1; // PDU 0x18 +const TUint8 KLengthGetPlayStatusPdu = 0; // PDU 0x30 +const TUint8 KLengthRegisterNotification = 5; // PDU 0x31 +const TUint8 KLengthSetAddressedPlayerPdu = 2; // PDU 0x60 + +// Minimum lengths of Vendor Dependent PDU requests +const TUint8 KMinLengthGetCurrentPASValuePdu = 2; // PDU 0x13 +const TUint8 KMinLengthSetPASValuePdu = 1; // PDU 0x14 +const TUint8 KMinLengthGetPASAttributeTextPdu = 2; // PDU 0x15 +const TUint8 KMinLengthGetPASValueTextPdu = 3; // PDU 0x16 +const TUint8 KMinLengthGetElementAttributesPdu = 9; // PDU 0x20 +const TUint8 KMinLengthAddToNowPlayingPdu = 11; // PDU 0x90 + +// Other lengths +const TUint8 KLengthPlaybackPosChangedParam = 4; // Parameter length for this event (section 5.4.2) +const TUint8 KVendorDependentNumberAttributes = 0; // Index to Number of attributes (the first byte) +const TUint8 KVendorDependentNumberAttribsPdu16 = 1; // Index to Number of attributes for PDU 0x16 (the second byte) +const TUint8 KVendorDependentEventId = 0; // Index to Event Id (the first byte) + +enum TMetadataTransferErrorCodes + { + EInvalidCommand = 0x0, + EInvalidParameter = 0x1, + EParameterNotFound = 0x2, + EInternalError = 0x3, + }; + +enum TMetaDataTransferPacketType + { + EUnfragmented = 0x0, + EFragmentStart = 0x1, + EFragmentContinue = 0x2, + EFragmentEnd = 0x3, + }; + +// Format of the first 3 bytes of a Vendor Dependent Request +// See example packets in AVRCP Specification Appendix I (page 84) +const TUint8 KVendorDependentRequestPDUId = 0; +const TUint8 KVendorDependentRequestReservedByte = 1; +const TUint8 KVendorDependentRequestParamLenMSB = 2; +const TUint8 KVendorDependentRequestParamLenLSB = 3; + +//See example packets in AVRCP Specification Appendix D (Volume Change Notification) +const TUint8 KVendorDependentNotifyEventIdOffset = 4; + +// Format of the first 2 bytes of a Pass Through Request +// See example packets in AVRCP Specification Appendix I (page 89) +const TUint8 KPassThroughRequestOperationIdMSB = 0; +const TUint8 KPassThroughRequestOperationIdLSB = 1; + +const TInt KSetAddressedPlayerPlayerIdOffset = 0; + +const TInt KCapabilityIdOffset = 0; + +const TInt KNumberEventsNotInPlayerInfoApi = 5; + +typedef TUint8 TMetadataTransferPDUID; +typedef TUint8 TMetadataTransferNotifyEventID; + +class CRcpRemoteDevice; +class CAVRCPFragmenter; +class CRcpIncomingCommandHandler; +class MRemConBearerObserver; +class CAvrcpPlayerInfoManager; +class CAvrcpPlayerInfoManager; +NONSHARABLE_CLASS(CControlCommand) : public CAvrcpCommand + { +public: + static CControlCommand* NewL(TUid aInterfaceUid, + TUint aCommand, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransactionLabel, + RBuf8& aCommandData, + TBool aIsClick, + const TBTDevAddr& aAddr, + TBool aKnownToBearer); + + static CControlCommand* NewL(CAVCFrame* aFrame, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + const TRemConClientId& aClientId, + CAvrcpPlayerInfoManager* aPlayerInfoManager); + + SymbianAvctp::TMessageType MessageType() const; + const TDesC8& Data() const; + + // Called from bearer + const TRemConClientId& ClientId() const; + + // Called from handlers + TInt ParseIncomingCommandL(MRemConBearerObserver& aObserver, CAVRCPFragmenter& aFragmenter); + void ProcessOutgoingCommandL(MRemConBearerObserver& aObserver); + TInt ParseIncomingResponse(MRemConBearerObserver& aObserver, const CAVCFrame& aFrame); + TInt ProcessOutgoingResponse(MRemConBearerObserver& aObserver, RBuf8& aCommandData, CAVRCPFragmenter& aFragmenter); + void SetResponseType(TInt aErr); + + TDeltaTimerEntry* TimerEntry(); + TAvrcpTimerExpiryInfo* TimerExpiryInfo(); + void CancelTimer(CDeltaTimer& aTimer); + + const CAVCFrame& Frame() const; + AVCPanel::TButtonAction ButtonAct() const; + TBool Click() const; + void SetClick(TBool aIsClick); + void ReSetCoreButtonActionL(TRemConCoreApiButtonAction aButtonAct, TBool aCommand); + + void SetCoreButtonAction(TRemConCoreApiButtonAction aButtonAct, TBool aCommand); + TInt InsertCoreResult(TInt aResult); + TBool IsAvrcpPassthrough() const; + TBool IsPassthrough() const; + TInt SetSetAbsoluteVolumeResult(const CAVCFrame& aFrame); + TInt SetNotifyVolumeChangeResult(const CAVCFrame& aFrame); + TBool PlayerSpecificNotify() const; + TBool NormalCommand(); + + CControlCommand* InterimResponseL(); + +private: + CControlCommand(TUid aInterfaceUid, + TUint aCommand, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransactionLabel, + RBuf8& aCommandData, + TBool aIsClick, + const TBTDevAddr& aAddr, + TBool aKnownToBearer); + + CControlCommand(CAVCFrame* aFrame, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + const TRemConClientId& aClientId, + CAvrcpPlayerInfoManager* aPlayerInfoManager); + + void ConstructL(); + ~CControlCommand(); + + TInt ParseIncomingKnownOpcodeL(MRemConBearerObserver& aObserver); + TInt ParseIncomingVendorCommandL(MRemConBearerObserver& aObserver, CAVRCPFragmenter& aFragmenter); + + void ParseIncomingUnknownResponse(MRemConBearerObserver& aObserver, const CAVCFrame& aFrame); + + TInt ParseInformBatteryStatusOfCT( TPtrC8& mtPayload); + + TInt ParseContinuingResponse(TPtrC8& mtPayload, + CAVRCPFragmenter& aFragmenter); + + TInt ParseAbortContinuingResponse(TPtrC8& mtPayload, + CAVRCPFragmenter& aFragmenter); + + TInt ParseSetPlayerApplicationSettingValue(TPtrC8& mtPayload); + TInt ParseGetCapabilities(TPtrC8& aMtPayload); + TInt ParseGetPlayStatus(TPtrC8& aMtPayload); + TInt ParseListPlayerApplicationSettingAttributes(TPtrC8& aMtPayload); + TInt ParseListPlayerApplicationSettingValues(TPtrC8& aMtPayload); + TInt ParseGetCurrentPlayerApplicationSettingValue(TPtrC8& aMtPayload); + TInt ParseGetPlayerApplicationSettingAttributeText(TPtrC8& aMtPayload); + TInt ParseGetPlayerApplicationSettingValueText(TPtrC8& aMtPayload); + TInt ParseGetElementAttributes(TPtrC8& aMtPayload); + TInt ParseSetAddressedPlayer(TPtrC8& aMtPayload); + TInt ParsePlayItem(TPtrC8& aMtPayload); + TInt ParseAddToNowPlaying(TPtrC8& aMtPayload); + TInt ParseUidsChangedNotification(TPtrC8& aMtPayload); + TInt ParseInternalUidsChangedNotification(TPtrC8& aMtPayload); + TInt ParseVolumeChangedNotification(TPtrC8& aMtPayload); + TInt ParseSetAbsoluteVolume(TPtrC8& aMtPayload); + void DoParseSetAbsoluteVolumeL(const TPtrC8& aMtPayload, TDes8& aPayload); + + TInt ParseMetadataTransferVendorCommand(CAVRCPFragmenter& aFragmenter); + TInt ParseVendorUniquePassthroughCommand(MRemConBearerObserver& aObserver); + TInt ParseMetadataTransferPassthroughCommand(); + TInt GenerateMetadataResponsePayload(MRemConBearerObserver& aObserver, RBuf8& aFramePayload, const RBuf8& aResponseData); + TInt GenerateMetadataGetCapabilitiesResponsePayloadL(MRemConBearerObserver& aObserver, RBuf8& aFramePayload, const RBuf8& aResponseData); + void GenerateSetAbsoluteVolumeResponsePayloadL(RBuf8& aFramePayload, const TDesC8& responseData); + void DoGenerateNotifyVolumeChangeResponsePayloadL(RBuf8& aFramePayload, const TDesC8& responseData); + TInt GenerateNotificationResponsePayload(RBuf8& aFramePayload, const TDesC8& aResponseData); + void GenerateMetadataRejectPayloadL(TInt aError); + void SetVendorInfoL(TBool aIsPassthrough); + + void DoProcessOutgoingResponseL(MRemConBearerObserver& aObserver, RBuf8& aCommandData, + CAVRCPFragmenter& aFragmenter); + + TUint8 GetPDUIdFromIPCOperationId(TInt aOperationId); + TUint8 GetEventIdFromIPCOperationId(TInt aOperationId); + + TInt RespondToInforms(TMetadataTransferPDUID aMetadataPDUID); + TInt AppendIncomingPayload(const TPtrC8& aPayload); + + static TInt AvrcpToRemConOperation(TUint aAvrcpOp, TUint& aRemConOp, TUid& aRemConIf); + static TInt RemConToAvrcpOperation(TUint aRemConOp, AVCPanel::TOperationId& aAvrcpOp); + + TUint16 Get16(const TPtrC8& aPtr); + + static TInt DummyCallback(TAny*); + + void DoSetAbsoluteVolumeResultL(const CAVCFrame& aFrame); + void DoSetNotifyVolumeChangeResultL(const CAVCFrame& aFrame); + +private: + TBool iIsClick; + + TDeltaTimerEntry* iTimerEntry; + TAvrcpTimerExpiryInfo* iTimerExpiryInfo; + + CAVCFrame* iFrame; + AVC::TAVCVendorId iVendorId; + TPtrC8 iVendorPayloadData; // ptr to the vendor data in iFrame; + + TRemConClientId iClientId; + }; + +class MetadataTransferParser + { +public: + static AVC::TAVCVendorId GetVID(const CAVCFrame& aFrame); // could be elsewhere really! + static TMetadataTransferPDUID GetPDUID(const TPtrC8& aData); + static TUint16 GetParamLength(const TPtrC8& aData); + static TUint16 GetPassThroughOperationId(const TPtrC8& aData); + static TMetadataTransferPDUID GetNotifyEventID(const TPtrC8& aData); + }; + + +#endif // CONTROLCOMMAND_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/internalcommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/internalcommand.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +// Copyright (c) 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: +// + +#ifndef INTERNALCOMMAND_H +#define INTERNALCOMMAND_H + +#include "avrcpcommand.h" + +const SymbianAvctp::TTransactionLabel KDummyTransactionLabel = 0; + +NONSHARABLE_CLASS(CInternalCommand) : public CAvrcpCommand + { +public: + static CInternalCommand* NewL(TUid aInterfaceUid, + TUint aId, + TUint aOperationId, + const TDesC8& aCommandData); + + void ResetL(TUint& aId, const TDesC8& aCommandData); + virtual SymbianAvctp::TMessageType MessageType() const; + virtual const TDesC8& Data() const; + +private: + CInternalCommand(TUid aInterfaceUid, + TUint aId, + TUint aOperationId); + ~CInternalCommand(); + void ConstructL(const TDesC8& aCommandData); + }; + +#endif //INTERNALCOMMAND_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/internalhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/internalhelper.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +// Copyright (c) 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: +// + +#ifndef INTERNALHELPER_H +#define INTERNALHELPER_H + +#include +#include "avrcpplayerinfomanager.h" + +class CControlCommand; +class CRemConBearerAvrcp; +class CRcpRouter; +NONSHARABLE_CLASS(CInternalCommandHelper) : public CBase, public MPlayerChangeObserver + { +public: + static CInternalCommandHelper* NewL(CRemConBearerAvrcp& aBearer, + CRcpRouter& aRouter, TRemConClientId& aClientId, + CAvrcpPlayerInfoManager& aPlayerInfoManager); + ~CInternalCommandHelper(); + + void Disconnect(); + void HandleInternalCommand(CControlCommand& aCommand); + +private: + CInternalCommandHelper(CRemConBearerAvrcp& aBearer, + CRcpRouter& aRouter, TRemConClientId& aClientId, + CAvrcpPlayerInfoManager& aPlayerInfoManager); + void ConstructL(); + + // From MPlayerChangeObserver + void MpcoAvailablePlayersChanged(); + void MpcoAddressedPlayerChangedLocally(TRemConClientId aClientId); + void MpcoUidCounterChanged(TRemConClientId aClientId); + + void Respond(CControlCommand& aCommand, TInt aErr); + void HandledCommand(CControlCommand& aCommand); + + TInt HandleSetAddressedPlayer(TUint aId, RBuf8& aCommandData); + void DoHandleSetAddressedPlayerL(RBuf8& aCommandData); + void AddressedPlayerChangedL(TRemConClientId aClientId); + + TInt HandleRegisterAvailablePlayersNotification(CControlCommand& aCommand); + void DoHandleRegisterAvailablePlayersNotificationL(RBuf8& aResponseData, CControlCommand& aCommand); + + TInt HandleRegisterAddressedPlayerNotification(CControlCommand& aCommand); + void DoHandleRegisterAddressedPlayerNotificationL(RBuf8& aResponseData, CControlCommand& aCommand); + + TInt HandleUidChangedNotification( CControlCommand& aCommand); + void DoHandleUidChangedNotificationL(RBuf8& aResponseData, TUint16 aUidCounter); + + void SendResponse(TUint aId, RBuf8& aData); + +private: + CRemConBearerAvrcp& iBearer; + CRcpRouter& iRouter; + TRemConClientId& iClientId; + + CAvrcpPlayerInfoManager& iPlayerInfoManager; + + TDblQue iInternalCommandQueue; + }; + +#endif // INTERNALHELPER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/passthroughhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/passthroughhelper.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +// Copyright (c) 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: +// + +#ifndef PASSTHROUGHHELPER_H +#define PASSTHROUGHHELPER_H + +#include + +class CRcpRouter; +class CRemConBearerAvrcp; +class CControlCommand; +NONSHARABLE_CLASS(CPassthroughHelper) : public CBase + { +public: + static CPassthroughHelper* NewL(CRcpRouter& aRouter, CRemConBearerAvrcp& aBearer, CDeltaTimer& aTimer); + ~CPassthroughHelper(); + + void Disconnect(); + + void HandlePassthrough(CControlCommand& aCommand); // FIXME for now +private: + CPassthroughHelper(CRcpRouter& aRouter, CRemConBearerAvrcp& aAvrcp, CDeltaTimer& aTimer); + void ConstructL(); + + void Respond(CControlCommand& aCommand, TInt aErr); + void HandledCommand(CControlCommand& aCommand); + + void NewPress(CControlCommand& aCommand); + void BalanceHandledCommand(CControlCommand& aCommand); + + // Timer functions + void HoldExpiry(CControlCommand& aCommand); + void ReleaseExpiry(CControlCommand& aCommand); + void StartHoldTimer(CControlCommand& aCommand); + void StartReleaseTimer(CControlCommand& aCommand); + + // Delta timer callback functions + static TInt HoldExpiry(TAny* aExpiryInfo); + static TInt ReleaseExpiry(TAny* aExpiryInfo); + +private: + CRcpRouter& iRouter; + CRemConBearerAvrcp& iBearer; + CDeltaTimer& iTimer; + CControlCommand* iPreviousPassthrough; + }; + +#endif // PASSTHROUGHHELPER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/playerbitmasks.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/playerbitmasks.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,196 @@ +// Copyright (c) 2008-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: +// TPlayerFeatureBitmask.h +// + +#ifndef PLAYERBITMASKS_H_ +#define PLAYERBITMASKS_H_ + +/** +@file +@internalComponent +@released +*/ +#include + +const TInt KFeatureBitmaskLength = 16; + +enum TByteOffsets + { + ESelectByteOffset = 0, + EUpByteOffset = 0, + EDownByteOffset = 0, + ELeftByteOffset = 0, + ERightByteOffset = 0, + ERightUpByteOffset = 0, + ERightDownByteOffset = 0, + ELeftUpByteOffset = 0, + ELeftDownByteOffset = 1, + ERootMenuByteOffset = 1, + ESetupMenuByteOffset = 1, + EContentsMenuByteOffset = 1, + EFavoriteMenuByteOffset = 1, + EExitByteOffset = 1, + E0ByteOffset = 1, + E1ByteOffset = 1, + E2ByteOffset = 2, + E3ByteOffset = 2, + E4ByteOffset = 2, + E5ByteOffset = 2, + E6ByteOffset = 2, + E7ByteOffset = 2, + E8ByteOffset = 2, + E9ByteOffset = 2, + EDotByteOffset = 3, + EEnterByteOffset = 3, + EClearByteOffset = 3, + EChannelUpByteOffset = 3, + EChannelDownByteOffset = 3, + EPreviousChannelByteOffset = 3, + ESoundSelectByteOffset = 3, + EInputSelectByteOffset = 3, + EDisplayInformationByteOffset = 4, + EHelpByteOffset = 4, + EPageUpByteOffset = 4, + EPageDownByteOffset = 4, + EPowerByteOffset = 4, + EVolumeUpByteOffset = 4, + EVolumeDownByteOffset = 4, + EMuteByteOffset = 4, + EPlayByteOffset = 5, + EStopByteOffset = 5, + EPauseByteOffset = 5, + ERecordByteOffset = 5, + ERewindByteOffset = 5, + EFastForwardByteOffset = 5, + EEjectByteOffset = 5, + EForwardByteOffset = 5, + EBackwardByteOffset = 6, + EAngleByteOffset = 6, + ESubpictureByteOffset = 6, + EF1ByteOffset = 6, + EF2ByteOffset = 6, + EF3ByteOffset = 6, + EF4ByteOffset = 6, + EF5ByteOffset = 6, + EVendorUniqueByteOffset = 7, + EGroupNavigationByteOffset = 7, + EAdvancedControlPlayerByteOffset = 7, + EBrowsingByteOffset = 7, + ESearchByteOffset = 7, + EAddToNowPlayingByteOffset = 7, + EDatabaseAwareByteOffset = 7, + EBrowsableOnlyWhenAddressedByteOffset = 7, + ESearchableOnlyWhenAddressedByteOffset = 8, + ENowPlayingByteOffset = 8, + EUidPersistencyByteOffset = 8, + }; + +enum TBitOffset + { + ESelectBitOffset = 0, + EUpBitOffset = 1, + EDownBitOffset = 2, + ELeftBitOffset = 3, + ERightBitOffset = 4, + ERightUpBitOffset = 5, + ERightDownBitOffset = 6, + ELeftUpBitOffset = 7, + ELeftDownBitOffset = 0, + ERootMenuBitOffset = 1, + ESetupMenuBitOffset = 2, + EContentsMenuBitOffset = 3, + EFavoriteMenuBitOffset = 4, + EExitBitOffset = 5, + E0BitOffset = 6, + E1BitOffset = 7, + E2BitOffset = 0, + E3BitOffset = 1, + E4BitOffset = 2, + E5BitOffset = 3, + E6BitOffset = 4, + E7BitOffset = 5, + E8BitOffset = 6, + E9BitOffset = 7, + EDotBitOffset = 0, + EEnterBitOffset = 1, + EClearBitOffset = 2, + EChannelUpBitOffset = 3, + EChannelDownBitOffset = 4, + EPreviousChannelBitOffset = 5, + ESoundSelectBitOffset = 6, + EInputSelectBitOffset = 7, + EDisplayInformationBitOffset = 0, + EHelpBitOffset = 1, + EPageUpBitOffset = 2, + EPageDownBitOffset = 3, + EPowerBitOffset = 4, + EVolumeUpBitOffset = 5, + EVolumeDownBitOffset = 6, + EMuteBitOffset = 7, + EPlayBitOffset = 0, + EStopBitOffset = 1, + EPauseBitOffset = 2, + ERecordBitOffset = 3, + ERewindBitOffset = 4, + EFastForwardBitOffset = 5, + EEjectBitOffset = 6, + EForwardBitOffset = 7, + EBackwardBitOffset = 0, + EAngleBitOffset = 1, + ESubpictureBitOffset = 2, + EF1BitOffset = 3, + EF2BitOffset = 4, + EF3BitOffset = 5, + EF4BitOffset = 6, + EF5BitOffset = 7, + EVendorUniqueBitOffset = 0, + EGroupNavigationBitOffset = 1, + EAdvancedControlPlayerBitOffset = 2, + EBrowsingBitOffset = 3, + ESearchBitOffset = 4, + EAddToNowPlayingBitOffset = 5, + EDatabaseAwareBitOffset = 6, + EBrowsableOnlyWhenAddressedBitOffset = 7, + ESearchableOnlyWhenAddressedBitOffset = 0, + ENowPlayingBitOffset = 1, + EUidPersistencyBitOffset = 2, + }; + +class TPlayerFeatureBitmask + { +public: + TPlayerFeatureBitmask(); + TPlayerFeatureBitmask(const TPlayerFeatureBitmask& aFeatureBitmask); + + inline const TDesC8& FeatureBitmask() const; + + void SetCoreApiFeatures(RArray aOperation); + void SetAbsoluteVolumeApiFeatures(RArray aOperation); + void SetGroupNavigationApiFeatures(RArray aOperation); + void SetNowPlayingApiFeatures(RArray aOperation); + void SetMediaBrowseApiFeatures(RArray aOperation); + +private: + void SetCoreApiFeatures(); + +private: + TBuf8 iFeatureBitmask; + }; + +const TDesC8& TPlayerFeatureBitmask::FeatureBitmask() const + { + return iFeatureBitmask; + } +#endif /*PLAYERBITMASKS_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/playerstatewatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/playerstatewatcher.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,121 @@ +// Copyright (c) 2008-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: +// + +#ifndef PLAYERSTATEWATCHER_H +#define PLAYERSTATEWATCHER_H + +#include +#include +#include +#include +#include "commandhandlerinterface.h" + +class MRemConCommandInterface; +class CInternalCommand; +class CAvrcpCommand; +NONSHARABLE_CLASS(CPlayerWatcherBase) : public CBase, public MIncomingCommandHandler + { +public: + virtual void StartWatchingPlayerL(TRemConClientId aClientId) = 0; + void StopWatchingPlayer(TRemConClientId aClientId); + +protected: + virtual void ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData) = 0; + virtual void ReceiveReject(TRemConClientId aClientId) = 0; + +private: // from MIncomingCommandHandler + + // lower interface + void MessageSent(CAvrcpCommand& aCommand, TInt aSendResult); + void MaxPacketSize(TInt aMtu); + void ReceiveCommandL(const TDesC8& aMessageInformation, SymbianAvctp::TTransactionLabel aTransLabel, const TBTDevAddr& aAddr); + + // upper interface + TInt SendRemConResponse(TUid aInterfaceUid, TUint aTransactionId, RBuf8& aData) ; + void SendReject(TUid aInterfaceUid, TUint aTransactionId); + void Disconnect(); + +protected: + CPlayerWatcherBase(MRemConCommandInterface& aCommandInterface); + ~CPlayerWatcherBase(); + +private: + CInternalCommand& FindCommand(TUid aInterfaceUid, TUint aTransactionId, + TRemConClientId& aFoundClientId); + + +protected: + MRemConCommandInterface& iCommandInterface; + RHashMap iCommands; + }; + +NONSHARABLE_CLASS(MPlayStatusObserver) + { +public: + virtual void MpsoPlayStatusChanged(TRemConClientId aId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus) = 0; + virtual void MpsoError(TRemConClientId aId) = 0; + }; + +NONSHARABLE_CLASS(CPlayStatusWatcher) : public CPlayerWatcherBase + { +public: + static CPlayStatusWatcher* NewL(MPlayStatusObserver& aObserver, + MRemConCommandInterface& aCommandInterface); + ~CPlayStatusWatcher(); + + void StartWatchingPlayerL(TRemConClientId aClientId); + +private: + CPlayStatusWatcher(MPlayStatusObserver& aObserver, + MRemConCommandInterface& aCommandInterface); + + void SendPlayStatusUpdateRequest(CInternalCommand& aCommand, TRemConClientId& aClientId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus); + void ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData); + void ReceiveReject(TRemConClientId aClientId); + +private: + MPlayStatusObserver& iObserver; + }; + + +NONSHARABLE_CLASS(MUidObserver) + { +public: + virtual void MuoUidChanged(TRemConClientId aId, TUint16 aUidCounter) = 0; + virtual void MuoError(TRemConClientId aId) = 0; + }; + +NONSHARABLE_CLASS(CUidWatcher) : public CPlayerWatcherBase + { +public: + static CUidWatcher* NewL(MUidObserver& aObserver, + MRemConCommandInterface& aCommandInterface); + ~CUidWatcher(); + + void StartWatchingPlayerL(TRemConClientId aClientId); + +private: + CUidWatcher(MUidObserver& aObserver, + MRemConCommandInterface& aCommandInterface); + + void SendUidUpdateRequest(CInternalCommand& aCommand, TRemConClientId& aClientId, TUint16 aUidCounter); + void ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData); + void ReceiveReject(TRemConClientId aClientId); + +private: + MUidObserver& iObserver; + }; + +#endif //PLAYERSTATEWATCHER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,56 @@ +// Copyright (c) 2008-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: +// + +#ifndef REMCONCOMMANDINTERFACE_H +#define REMCONCOMMANDINTERFACE_H + +#include +#include + +class CControlCommand; +class CAvrcpCommand; +class TBTDevAddr; +class TRemConAddress; + +NONSHARABLE_CLASS(MRemConCommandInterface) + { +public: + virtual void MrcciNewCommand(CAvrcpCommand& aCommand) = 0; + virtual void MrcciNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) = 0; + + virtual TUint MrcciNewTransactionId() = 0; + }; + +NONSHARABLE_CLASS(MRemConBulkCommandInterface) : public MRemConCommandInterface + { +public: + virtual TInt MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient) = 0; + virtual void MrcbciRemoveAddressing(const TRemConAddress& aAddr) = 0; + }; + +NONSHARABLE_CLASS(MRemConControlCommandInterface) : public MRemConCommandInterface + { +public: + virtual void MrccciNewNotifyCommand(CAvrcpCommand& aCommand) = 0; + virtual void MrccciNewNotifyCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) = 0; + + virtual void MrccciNewResponse(CAvrcpCommand& aCommand) = 0; + virtual void MrccciNewNotifyResponse(CControlCommand& aCommand) = 0; + + virtual void MrccciSetAddressedClient(const TRemConClientId& aClient) = 0; + + }; + +#endif //REMCONCOMMANDINTERFACE_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/public/remconbeareravrcp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/public/remconbeareravrcp.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +// Copyright (c) 2004-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: +// + +#ifndef REMCONBEARERAVRCP_H +#define REMCONBEARERAVRCP_H + +/** +@file +@internalComponent +@released +*/ + +#include + +const TInt KRemConBearerAvrcpImplementationUid = 0x1020685f; + +#endif // REMCONBEARERAVRCP_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/1020685e.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/1020685e.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent +*/ + +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x1020685E; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10204546; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020685F; + version_no = 1; + display_name = "RCP"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpMetadataTransfer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpMetadataTransfer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1078 @@ +// Copyright (c) 2006-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: +// + + + +/** + @file + @internalComponent + @prototype +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "avrcp.h" +#include "controlcommand.h" +#include "avrcpcommandframer.h" +#include "avrcpinternalinterface.h" +#include "avrcpipc.h" +#include "avrcplog.h" +#include "avrcputils.h" +#include "avrcpincomingcommandhandler.h" +#include "mediabrowse.h" +#include "mediainformation.h" +#include "nowplaying.h" +#include "playerinformation.h" +#include "remconbattery.h" +#include "remcongroupnavigation.h" + +TInt CControlCommand::ParseMetadataTransferPassthroughCommand() + { + // company id and frame type should already be set before here + __ASSERT_DEBUG(iFrame->Type() == AVC::EControl, AvrcpUtils::Panic(EAvrcpCTypeNotSet)); + __ASSERT_DEBUG(iVendorId == KBluetoothSIGVendorId, AvrcpUtils::Panic(EAvrcpCompanyIDNotSet)); + + TInt ret = KErrNotSupported; + TUint16 operation = MetadataTransferParser::GetPassThroughOperationId(iVendorPayloadData); + if (operation == ENextGroup) + { + iOperationId = ENextGroup; + iInterfaceUid = TUid::Uid(KRemConGroupNavigationApiUid); + ret = KErrNone; + } + else if (operation == EPreviousGroup) + { + iOperationId = EPreviousGroup; + iInterfaceUid = TUid::Uid(KRemConGroupNavigationApiUid); + ret = KErrNone; + } + return ret; + } + +/* Before calling this method, the following MUST be set: + * - Vendor Payload data + * - Opcode == Vendor Dependent + * - Subunit Type == Panel + * - Subunit Id == 0 + */ + +TInt CControlCommand::ParseMetadataTransferVendorCommand(CAVRCPFragmenter& aFragmenter) + { + __ASSERT_DEBUG(iFrame->Opcode() == AVC::EVendorDependent, AvrcpUtils::Panic(EAvrcpNotFullyConstructed)); + __ASSERT_DEBUG(iFrame->SubunitType() == AVC::EPanel, AvrcpUtils::Panic(EAvrcpNotFullyConstructed)); + __ASSERT_DEBUG(iFrame->SubunitID() == 0, AvrcpUtils::Panic(EAvrcpNotFullyConstructed)); + + TInt ret = KErrNotSupported; + iInterfaceUid = TUid::Uid(0); + + TMetadataTransferPDUID metadataPDUID = MetadataTransferParser::GetPDUID(iVendorPayloadData); + + TPtrC8 mtPayload(iVendorPayloadData.Mid(KRemConMetadataHeaderLength)); + + TUint paramLength = MetadataTransferParser::GetParamLength(iVendorPayloadData); + + if (mtPayload.Length() != paramLength) + { + return KErrAvrcpMetadataInvalidCommand; + } + + // If we're in a fragmented state, and we receive an un-expected + // PDU (i.e. not CONTINUE or ABORT) then throw away the fragment + // and just process the request. The specification (section 5.5.1) + // isn't entirely clear as to what should happen, but Sian reckons + // this is probably the most polite thing to do (be liberal, etc) + if (aFragmenter.InFragmentedState()) + { + if ( metadataPDUID != ERequestContinuingResponse + && metadataPDUID != EAbortContinuingResponse) + { + aFragmenter.Reset(); + } + } + + switch (iFrame->Type()) + { + case AVC::EControl: + { + switch (metadataPDUID) + { + case ERequestContinuingResponse: + ret = ParseContinuingResponse(mtPayload, aFragmenter); + break; + case EAbortContinuingResponse: + ret = ParseAbortContinuingResponse(mtPayload, aFragmenter); + break; + case ESetPlayerApplicationSettingValue: + ret = ParseSetPlayerApplicationSettingValue(mtPayload); + break; + + case EInformBatteryStatusOfCT: + ret = ParseInformBatteryStatusOfCT(mtPayload); + break; + + case EInformDisplayableCharacterSet: + ret = KErrNotSupported; + break; + case ESetAddressedPlayer: + ret = ParseSetAddressedPlayer(mtPayload); + break; + case EPlayItem: + ret = ParsePlayItem(mtPayload); + break; + case EAddToNowPlaying: + ret = ParseAddToNowPlaying(mtPayload); + break; + + case ESetAbsoluteVolume: + ret =ParseSetAbsoluteVolume(mtPayload); + break; + default: + // not allowed PDUID for Control + ret = KErrAvrcpMetadataInvalidCommand; + } + break; + } + case AVC::EStatus: + { + switch (metadataPDUID) + { + case EGetCapabilities: + ret = ParseGetCapabilities( mtPayload ); + break; + + case EGetPlayStatus: + ret = ParseGetPlayStatus( mtPayload ); + break; + + case EListPlayerApplicationSettingAttributes: + ret = ParseListPlayerApplicationSettingAttributes( mtPayload ); + break; + + case EListPlayerApplicationSettingValues: + ret = ParseListPlayerApplicationSettingValues( mtPayload ); + break; + + case EGetCurrentPlayerApplicationSettingValue: + ret = ParseGetCurrentPlayerApplicationSettingValue( mtPayload ); + break; + + case EGetPlayerApplicationSettingAttributeText: + ret = ParseGetPlayerApplicationSettingAttributeText( mtPayload ); + break; + + case EGetPlayerApplicationSettingValueText: + ret = ParseGetPlayerApplicationSettingValueText( mtPayload ); + break; + + case EGetElementAttributes: + ret = ParseGetElementAttributes(mtPayload ); + break; + + case ESetAddressedPlayer: + ret = ParseSetAddressedPlayer(mtPayload ); + break; + + case EPlayItem: + ret = ParsePlayItem(mtPayload ); + break; + + case EAddToNowPlaying: + ret = ParseAddToNowPlaying(mtPayload ); + break; + default: + // not allowed PDUID for Status + ret = KErrAvrcpMetadataInvalidCommand; + } + + break; + } + case AVC::ENotify: + { + if (metadataPDUID==ERegisterNotification) + { + if (mtPayload.Length() != KLengthRegisterNotification) + { + ret = KErrAvrcpMetadataInvalidCommand; + } + else + { + ret = KErrNone; + TRegisterNotificationEvent eventId = static_cast(mtPayload[KVendorDependentEventId]); + switch (eventId) + { + case ERegisterNotificationPlaybackStatusChanged: + case ERegisterNotificationTrackChanged: + case ERegisterNotificationTrackReachedEnd: + case ERegisterNotificationTrackReachedStart: + case ERegisterNotificationBatteryStatusChanged: + case ERegisterNotificationPlayerApplicationSettingChanged: + { + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + iOperationId = RAvrcpIPC::SetIPCOperationIdFromEventId(eventId); + break; + } + // Note: ERegisterNotificationPlaybackPosChanged takes a 4 byte parameter + case ERegisterNotificationPlaybackPosChanged: + { + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + iOperationId = RAvrcpIPC::SetIPCOperationIdFromEventId(eventId); + iCommandData.Close(); + ret = iCommandData.Create(KLengthPlaybackPosChangedParam); + if (ret == KErrNone) + { + iCommandData.Append(mtPayload.Right(KLengthPlaybackPosChangedParam)); + } + else + { + ret = KErrAvrcpMetadataInternalError; + } + break; + } + + // Note ERegisterNotificationSystemStatusChanged is not supported + case ERegisterNotificationSystemStatusChanged_NotSupported: + { + ret = KErrNotSupported; + break; + } + + case ERegisterNotificationNowPlayingContentChanged: + { + iInterfaceUid = TUid::Uid(KRemConNowPlayingApiUid); + iOperationId = RAvrcpIPC::SetIPCOperationIdFromEventId(eventId); + break; + } + case ERegisterNotificationAvailablePlayersChanged: + case ERegisterNotificationAddressedPlayerChanged: + case ERegisterNotificationUidsChanged: + { + iInterfaceUid = TUid::Uid(KUidAvrcpInternalInterface); + iOperationId = RAvrcpIPC::SetIPCOperationIdFromEventId(eventId); + ret = KErrAvrcpInternalCommand; + break; + } + case ERegisterNotificationVolumeChanged : + { + ret = ParseVolumeChangedNotification(mtPayload); + break; + } + default: + { + ret = KErrAvrcpMetadataInvalidParameter; + } + } + } + } + else + { + ret = KErrAvrcpMetadataInvalidCommand; + } + break; + } + case AVC::EReserved1: + case AVC::EReserved2: + case AVC::EReserved3: + case AVC::EReserved4: + { + ret = KErrAvrcpInvalidCType; + break; + } + default: + ret = KErrAvrcpMetadataInvalidCommand; + } + + return ret; + } + +/** Allocate correct space and append the payload to iCommandData + */ +TInt CControlCommand::AppendIncomingPayload(const TPtrC8& aPayload) + { + iCommandData.Close(); + if (iCommandData.Create(aPayload.Length()) != KErrNone) + { + return KErrAvrcpMetadataInternalError; + } + iCommandData.Append(aPayload); + return KErrNone; + } + +/** Decode a InformBatteryStatusOfCT PDU ID: 0x18 and call the BatteryStatus API + */ +TInt CControlCommand::ParseInformBatteryStatusOfCT(TPtrC8& aMtPayload) + + { + if (aMtPayload.Length() != KLengthInformBatteryStatusOfCTPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + TUint8 batteryStatus = aMtPayload[0]; + if (batteryStatus > EFullCharge) + { + return KErrAvrcpMetadataInvalidParameter; + } + + if (AppendIncomingPayload(aMtPayload) != KErrNone) + { + return KErrAvrcpMetadataInvalidParameter; + } + + iOperationId = EInformBatteryStatusOfCT; + iInterfaceUid = TUid::Uid(KRemConBatteryApiUid); + + TInt ret = RespondToInforms(EInformBatteryStatusOfCT); + if (ret != KErrNone) + { + return ret; + } + + return KErrAvrcpHandledInternallyInformRemCon; + } + + +/** Decode PDU ID 0x40 - fragmentation support + */ +TInt CControlCommand::ParseContinuingResponse(TPtrC8& aMtPayload, + CAVRCPFragmenter& aFragmenter) + { + // Check if in fragmentation state, return error if not + if (! aFragmenter.InFragmentedState()) + { + return KErrAvrcpMetadataInvalidCommand; + } + + // Check if the parameter matches the fragmented response + TMetadataTransferPDUID pduId = MetadataTransferParser::GetPDUID(aMtPayload); + if (pduId != aFragmenter.GetPDU()) + { + return KErrAvrcpMetadataInvalidParameter; + } + + RBuf8 respPayload; + CAVCFrame* frame = NULL; + TRAPD(err, frame = CAVCVendorDependentResponse::NewL(KBluetoothSIGVendorId)); + err = respPayload.Create(KAVCMaxVendorDependentPayload); //longest resp + if (err == KErrNone) + { + respPayload.Append(aFragmenter.GetNextFragmentHeader()); + respPayload.Append(aFragmenter.GetNextFragment()); + frame->SetType(AVC::EStable); + frame->Append(respPayload); + delete iFrame; + iFrame = frame; + respPayload.Close(); + } + else + return KErrAvrcpMetadataInternalError; + + return KErrAvrcpHandledInternallyRespondNow; + } + + +/** Decode PDU ID 0x41 - fragmentation support + */ +TInt CControlCommand::ParseAbortContinuingResponse(TPtrC8& aMtPayload, + CAVRCPFragmenter& aFragmenter) + { + // Check if in fragmentation state, return error if not + if (! aFragmenter.InFragmentedState()) + { + return KErrAvrcpMetadataInvalidCommand; + } + + // Check if the parameter matches the fragmented response + TMetadataTransferPDUID pduId = MetadataTransferParser::GetPDUID(aMtPayload); + if (pduId != aFragmenter.GetPDU()) + { + return KErrAvrcpMetadataInvalidParameter; + } + + aFragmenter.Reset(); + + CAVCFrame* frame = NULL; + TRAPD(err, frame = CAVCVendorDependentResponse::NewL(KBluetoothSIGVendorId)); + if (err == KErrNone) + { + frame->Append(EAbortContinuingResponse); + frame->Append(EUnfragmented); + // the package length is 0 + frame->Append( 0 ); + frame->Append( 0 ); + frame->SetType(AVC::EStable); + delete iFrame; + iFrame = frame; + } + else + { + return KErrAvrcpMetadataInternalError; + } + + return KErrAvrcpHandledInternallyRespondNow; + } + + +/** Decode a SetPlayerApplicationSettingValue PDU ID: 0x14 and call the PlayerInformation API + */ +TInt CControlCommand::ParseSetPlayerApplicationSettingValue(TPtrC8& aMtPayload) + { + if (aMtPayload.Length() < KMinLengthSetPASValuePdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + // get the number of attributes contained + TUint8 numAttributes = aMtPayload[KVendorDependentNumberAttributes]; + + // Each attribute is 16 bits long + if (sizeof(numAttributes) + numAttributes*sizeof(TUint16) != aMtPayload.Length()) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = ESetPlayerApplicationSettingValue; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return AppendIncomingPayload(aMtPayload); + } + +/** Decode a GetCapabilities PDU ID: 0x10 and call the PlayerInformation API + */ +TInt CControlCommand::ParseGetCapabilities(TPtrC8& aMtPayload) + { + // check enough data available + if (aMtPayload.Length() != KLengthGetCapabilitiesPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + // pass one byte of data to Player Information API + iOperationId = EGetCapabilities; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return AppendIncomingPayload(aMtPayload); + } + +/** Decode a GetPlayStatus PDU ID: 0x30 and call the PlayerInformation API + */ +TInt CControlCommand::ParseGetPlayStatus(TPtrC8& aMtPayload) + { + // no payload in this command + if (aMtPayload.Length()!=KLengthGetPlayStatusPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EGetPlayStatus; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return KErrNone; + } + +/** Decode a ListPlayerApplicationSettingAttributes PDU ID: 0x11 and call the PlayerInformation API + */ +TInt CControlCommand::ParseListPlayerApplicationSettingAttributes(TPtrC8& aMtPayload) + { + // check length, there should be no parameters + if (aMtPayload.Length()!=KLengthListPASAttributesPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EListPlayerApplicationSettingAttributes; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return KErrNone; + } + +/** Decode a ListPlayerApplicationSettingValues PDU ID: 0x12 and call the PlayerInformation API + */ +TInt CControlCommand::ParseListPlayerApplicationSettingValues(TPtrC8& aMtPayload) + { + // check length, there should be 1 byte of data + if (aMtPayload.Length() != KLengthListPASValuesPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EListPlayerApplicationSettingValues; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return AppendIncomingPayload(aMtPayload); + } + +/** Decode a GetCurrentPlayerApplicationSettingValue PDU ID: 0x13 and call the PlayerInformation API + */ +TInt CControlCommand::ParseGetCurrentPlayerApplicationSettingValue(TPtrC8& aMtPayload) + { + // check the length + if (aMtPayload.Length() < KMinLengthGetCurrentPASValuePdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + TUint8 numAttributes = aMtPayload[KVendorDependentNumberAttributes]; + if (sizeof(numAttributes) + numAttributes != aMtPayload.Length()) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EGetCurrentPlayerApplicationSettingValue; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return AppendIncomingPayload(aMtPayload); + } + +/** Decode a GetPlayerApplicationSettingAttributeText PDU ID: 0x15 and call the PlayerInformation API + */ +TInt CControlCommand::ParseGetPlayerApplicationSettingAttributeText(TPtrC8& aMtPayload) + { + if (aMtPayload.Length() < KMinLengthGetPASAttributeTextPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + // get the number of attributes contained + TUint8 numAttributes = aMtPayload[KVendorDependentNumberAttributes]; + if (sizeof(numAttributes) + numAttributes != aMtPayload.Length()) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EGetPlayerApplicationSettingAttributeText; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return AppendIncomingPayload(aMtPayload); + } + +/** Decode a GetPlayerApplicationSettingValueText PDU ID: 0x16 and call the PlayerInformation API + */ +TInt CControlCommand::ParseGetPlayerApplicationSettingValueText(TPtrC8& aMtPayload) + { + if (aMtPayload.Length() < KMinLengthGetPASValueTextPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + // get number of values; preceded by attributeId (1byte) and numValues (1byte) + TUint8 numValues = aMtPayload[KVendorDependentNumberAttribsPdu16]; + if (sizeof(TUint8) + sizeof(numValues) + numValues != aMtPayload.Length()) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EGetPlayerApplicationSettingValueText; + iInterfaceUid = TUid::Uid(KRemConPlayerInformationUid); + return AppendIncomingPayload(aMtPayload); + } + +/** Decode a GetElementAttributes PDU ID: 0x20 and call the PlayerInformation API + */ +TInt CControlCommand::ParseGetElementAttributes(TPtrC8& aMtPayload) + { + LOG_FUNC + + if (aMtPayload.Length() < KMinLengthGetElementAttributesPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EGetElementAttributes; + iInterfaceUid = TUid::Uid(KRemConMediaInformationApiUid); + return AppendIncomingPayload(aMtPayload); + } + +TInt CControlCommand::ParseSetAddressedPlayer(TPtrC8& aMtPayload) + { + LOG_FUNC + + if (aMtPayload.Length() < KLengthSetAddressedPlayerPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EAvrcpInternalSetAddressedPlayer; + iInterfaceUid = TUid::Uid(KUidAvrcpInternalInterface); + TInt err = AppendIncomingPayload(aMtPayload); + + return err == KErrNone ? KErrAvrcpInternalCommand : err; + } + +TInt CControlCommand::ParsePlayItem(TPtrC8& aMtPayload) + { + LOG_FUNC + + if (aMtPayload.Length() < KMinLengthAddToNowPlayingPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EPlayItem; + iInterfaceUid = TUid::Uid(KRemConNowPlayingApiUid); + return AppendIncomingPayload(aMtPayload); + } + +TInt CControlCommand::ParseAddToNowPlaying(TPtrC8& aMtPayload) + { + LOG_FUNC + + if (aMtPayload.Length() < KMinLengthAddToNowPlayingPdu) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = EAddToNowPlaying; + iInterfaceUid = TUid::Uid(KRemConNowPlayingApiUid); + return AppendIncomingPayload(aMtPayload); + } + +TInt CControlCommand::ParseUidsChangedNotification(TPtrC8& /*aMtPayload*/) + { + LOG_FUNC + iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid); + iOperationId = RAvrcpIPC::SetIPCOperationIdFromEventId(ERegisterNotificationUidsChanged); + + return KErrAvrcpHandledInternallyRespondNow; + } + +TInt CControlCommand::ParseVolumeChangedNotification(TPtrC8& /*aMtPayload*/) + { + LOG_FUNC + iInterfaceUid = TUid::Uid(KRemConAbsoluteVolumeTargetApiUid); + iOperationId = KRemConAbsoluteVolumeNotification; + + return KErrNone; + } + +TInt CControlCommand::GenerateMetadataResponsePayload(MRemConBearerObserver& aObserver, RBuf8& aFramePayload, const RBuf8& aResponseData) + { + TInt err = KErrNone; + + // If it's a very large response; this requires re-allocating the buffer + if (aResponseData.Length() > KAVCFrameMaxLength) + { + aFramePayload.Close(); + if (aFramePayload.Create(aResponseData.Length()) != KErrNone) + return KErrAvrcpMetadataInternalError; + } + + // Obtain the PDU from the combined PDU + (possible) notification eventId + TMetadataTransferPDU pduId = RAvrcpIPC::GetPDUIdFromIPCOperationId(iOperationId); + aFramePayload.Zero(); + aFramePayload.Append(pduId); + aFramePayload.Append(EUnfragmented); + + //Check whether it is absolute volume response. + TBool absoluteVolumeResponse = EFalse; + if (pduId == ESetAbsoluteVolume) + { + absoluteVolumeResponse = ETrue; + } + else if (pduId == ERegisterNotification) + { + TRegisterNotificationEvent eventId = RAvrcpIPC::GetEventIdFromIPCOperationId(iOperationId); + if (eventId == ERegisterNotificationVolumeChanged) + { + absoluteVolumeResponse = ETrue; + } + } + + TPtr8 responseData(NULL, 0); + if (absoluteVolumeResponse) + { + responseData.Set(aResponseData.RightTPtr(aResponseData.Length())); + } + else + { + // Read 4 byte Big-Endian error code before the payload + RAvrcpIPCError response; + TRAP(err, response.ReadL(aResponseData)); + + // If we couldn't parse the response via IPC, send an internal error + if (err != KErrNone) + { + return KErrAvrcpMetadataInternalError; + } + + // If an error occurred, return it (now that we've filled in the PDU id) + if (response.iError != KErrNone) + { + return response.iError; + } + + // Pass the rest of the response (minus error code) to be parsed + responseData.Set(aResponseData.RightTPtr(aResponseData.Length() - KLengthErrorResponse)); + } + + switch (pduId) + { + case ESetPlayerApplicationSettingValue: + { + // the package length is 0 + aFramePayload.Append( 0 ); + aFramePayload.Append( 0 ); + break; + } + + case EGetCapabilities: + { + TRAP(err,GenerateMetadataGetCapabilitiesResponsePayloadL(aObserver, aFramePayload, aResponseData)); + if(err != KErrNone) + { + return KErrAvrcpMetadataInternalError; + } + break; + } + case EListPlayerApplicationSettingAttributes: + case EListPlayerApplicationSettingValues: + case EGetCurrentPlayerApplicationSettingValue: + case EGetPlayerApplicationSettingAttributeText: + case EGetPlayerApplicationSettingValueText: + case EGetElementAttributes: + case EGetPlayStatus: + case EPlayItem: + case EAddToNowPlaying: + case ESetAddressedPlayer: + { + // the package length is the response length + TInt packageLength = responseData.Length(); + aFramePayload.Append(packageLength>>8); + aFramePayload.Append(packageLength); + aFramePayload.Append(responseData); + break; + } + case ESetAbsoluteVolume: + { + TRAPD(err, GenerateSetAbsoluteVolumeResponsePayloadL(aFramePayload,responseData)); + if (err != KErrNone) + { + return KErrAvrcpMetadataInternalError; + } + break; + } + case ERegisterNotification: + { + GenerateNotificationResponsePayload(aFramePayload, responseData); + break; + } + default: + { + return KErrNotSupported; + } + } + + // Success. Error conditions have been handled previously + return KErrNone; + } + +void CControlCommand::GenerateSetAbsoluteVolumeResponsePayloadL( + RBuf8& aFramePayload, + const TDesC8& responseData) + { + RRemConAbsoluteVolumeResponse response; + CleanupClosePushL(response); + + response.ReadL(responseData); + if (response.iError != KErrNone) + { + User::Leave(response.iError); + } + TUint8 absVol = KAvrcpMaxAbsoluteVolume * response.iVolume / response.iMaxVolume; + TUint16 len = KLengthSetAbsoluteVolumeResponseParamter<<8 & 0xffff; + TPckgBuf parameterLength(len); + aFramePayload.Append(parameterLength); + aFramePayload.Append( absVol ); + + CleanupStack::PopAndDestroy(&response); + } + +void CControlCommand::DoGenerateNotifyVolumeChangeResponsePayloadL( + RBuf8& aFramePayload, + const TDesC8& responseData) + { + RRemConAbsoluteVolumeResponse response; + CleanupClosePushL(response); + + response.ReadL(responseData); + if (response.iError != KErrNone) + { + User::Leave(response.iError); + } + TUint8 absVol = KAvrcpMaxAbsoluteVolume * response.iVolume / response.iMaxVolume; + TRegisterNotificationEvent eventId = RAvrcpIPC::GetEventIdFromIPCOperationId(iOperationId); + TUint16 len = KLengthNotifyVolumeChangeResponseParameter<<8 & 0xffff; + TPckgBuf parameterLength(len); + aFramePayload.Append( parameterLength ); + aFramePayload.Append( eventId ); + aFramePayload.Append( absVol ); + + CleanupStack::PopAndDestroy(&response); + } + +TInt CControlCommand::GenerateNotificationResponsePayload(RBuf8& aFramePayload, const TDesC8& responseData) + { + TInt err = KErrNone; + + TRegisterNotificationEvent eventId = RAvrcpIPC::GetEventIdFromIPCOperationId(iOperationId); + switch(eventId) + { + case ERegisterNotificationVolumeChanged: + { + TRAPD(err, DoGenerateNotifyVolumeChangeResponsePayloadL(aFramePayload, responseData)); + if (err != KErrNone) + { + return KErrAvrcpMetadataInternalError; + } + break; + } + case ERegisterNotificationPlaybackStatusChanged: + case ERegisterNotificationTrackChanged: + case ERegisterNotificationTrackReachedEnd: + case ERegisterNotificationTrackReachedStart: + case ERegisterNotificationPlaybackPosChanged: + case ERegisterNotificationBatteryStatusChanged: + case ERegisterNotificationPlayerApplicationSettingChanged: + case ERegisterNotificationNowPlayingContentChanged: + case ERegisterNotificationAvailablePlayersChanged: + case ERegisterNotificationAddressedPlayerChanged: + case ERegisterNotificationUidsChanged: + { + TUint paramLength = responseData.Length() + 1; + aFramePayload.Append( paramLength >>8 ); + aFramePayload.Append( paramLength ); + aFramePayload.Append( eventId ); + aFramePayload.Append( responseData ); + break; + } + default: + { + err = KErrNotSupported; + break; + } + }; + + return err; + } + +TInt CControlCommand::GenerateMetadataGetCapabilitiesResponsePayloadL(MRemConBearerObserver& /* aObserver */, RBuf8& aFramePayload, const RBuf8& aResponseData) + { + LOG_FUNC + __ASSERT_DEBUG( iPlayerInfoManager != NULL, AvrcpUtils::Panic(EAvrcpNotFullyConstructed)); + TPtr8 responseData = aResponseData.RightTPtr(aResponseData.Length() - KLengthErrorResponse); + + if(responseData[KCapabilityIdOffset] == ECapabilityIdEventsSupported) + { + RBuf8 eventsBuf; + eventsBuf.CreateL(KNumberEventsNotInPlayerInfoApi); + CleanupClosePushL(eventsBuf); + TInt count = 0; + + // if ClientId has been set it means that we've told the remote that + // commands are being addressed to a particular player, so return + // player specific info. Otherwise return generic support. + if(ClientId() == KNullClientId || iPlayerInfoManager->AbsoluteVolumeSupportedL(ClientId())) + { + count++; + eventsBuf.Append(ERegisterNotificationVolumeChanged ); + } + + if(ClientId() == KNullClientId || iPlayerInfoManager->BrowsingSupportedL(ClientId())) + { + count += 2; + eventsBuf.Append(ERegisterNotificationNowPlayingContentChanged ); + eventsBuf.Append(ERegisterNotificationUidsChanged ); + } + + // Always mark support for stuff that's handled internally rather than + // by the player + count+= 2; + eventsBuf.Append(ERegisterNotificationAvailablePlayersChanged ); + eventsBuf.Append(ERegisterNotificationAddressedPlayerChanged ); + + responseData[1] += count; + + TInt packageLength = responseData.Length()+ count; + aFramePayload.Append(packageLength>>8); + aFramePayload.Append(packageLength); + aFramePayload.Append(responseData); + aFramePayload.Append(eventsBuf); + + CleanupStack::PopAndDestroy(&eventsBuf); + } + else + { + TInt packageLength = responseData.Length(); + aFramePayload.Append(packageLength>>8); + aFramePayload.Append(packageLength); + aFramePayload.Append(responseData); + } + return KErrNone; + } +TMetadataTransferPDUID MetadataTransferParser::GetNotifyEventID(const TPtrC8& aData) + { + return static_cast(aData[KVendorDependentNotifyEventIdOffset]); + } + +TMetadataTransferPDUID MetadataTransferParser::GetPDUID(const TPtrC8& aData) + { + return static_cast(aData[KVendorDependentRequestPDUId]); + } + +TUint16 MetadataTransferParser::GetParamLength(const TPtrC8& aData) + { + TUint16 paramLength; + paramLength = aData[KVendorDependentRequestParamLenMSB] << 8; + paramLength += aData[KVendorDependentRequestParamLenLSB]; + return paramLength; + } + +TUint16 MetadataTransferParser::GetPassThroughOperationId(const TPtrC8& aData) + { + TUint16 operation; + operation = aData[KPassThroughRequestOperationIdMSB] << 8; + operation += aData[KPassThroughRequestOperationIdLSB]; + return operation; + } + + +TInt CControlCommand::RespondToInforms(TMetadataTransferPDUID aMetadataPDUID) + { + CAVCFrame* frame = NULL; + TRAPD(err, frame = CAVCVendorDependentResponse::NewL(KBluetoothSIGVendorId)); + + RBuf8 respPayload; + err = respPayload.Create(KAVRCPMinVendorDependentResponseLen); + if (err == KErrNone) + { + respPayload.Append(aMetadataPDUID); + respPayload.Append(EUnfragmented); // No fragmentation needed + respPayload.Append(0); // no params + respPayload.Append(0); // no params + + frame->SetType(AVC::EAccepted); + frame->Append(respPayload); + + delete iFrame; + iFrame = frame; + respPayload.Close(); + } + else + { + err = KErrAvrcpMetadataInternalError; + } + return err; + } + +void CControlCommand::GenerateMetadataRejectPayloadL(TInt aError) + { + CAVCFrame* frame = CAVCVendorDependentResponse::NewL(KBluetoothSIGVendorId); + frame->SetType(AVC::ERejected); + + frame->Append(iFrame->Data()[6]); // PDU ID + frame->Append(EUnfragmented); + + // Param length - 2 bytes + frame->Append(0x0); + frame->Append(0x1); + + TUint8 avcError = 0; + switch (aError) + { + case KErrAvrcpMetadataInvalidCommand: + { + avcError = EInvalidCommand; + break; + } + case KErrAvrcpMetadataInvalidParameter: + { + avcError = EInvalidParameter; + break; + } + case KErrAvrcpMetadataParameterNotFound: + { + avcError = EParameterNotFound; + break; + } + case KErrAvrcpMetadataInternalError: + { + avcError = EInternalError; + break; + } + case KErrAvrcpAirInvalidCommand: + case KErrAvrcpAirInvalidParameter: + case KErrAvrcpAirParameterNotFound: + case KErrAvrcpAirInternalError: + case KErrAvrcpAirSuccess: + case KErrAvrcpAirUidChanged: + case KErrAvrcpAirReserved: + case KErrAvrcpAirInvalidDirection: + case KErrAvrcpAirNotADirectory: + case KErrAvrcpAirDoesNotExist: + case KErrAvrcpAirInvalidScope: + case KErrAvrcpAirRangeOutOfBounds: + case KErrAvrcpAirUidIsADirectory: + case KErrAvrcpAirMediaInUse: + case KErrAvrcpAirNowPlayingListFull: + case KErrAvrcpAirSearchNotSupported: + case KErrAvrcpAirSearchInProgress: + case KErrAvrcpAirInvalidPlayerId: + case KErrAvrcpAirPlayerNotBrowesable: + case KErrAvrcpAirPlayerNotAddressed: + case KErrAvrcpAirNoValidSearchResults: + case KErrAvrcpAirNoAvailablePlayers: + case KErrAvrcpAirAddressedPlayerChanged: + { + avcError = KErrAvrcpAirBase - aError; + break; + } + } + frame->Append(avcError); + delete iFrame; + iFrame = frame; + } + +/** Decode a SetAbsoluteVolume PDU ID: 0x50 and SetAbsoluteTarget call the API + */ +TInt CControlCommand::ParseSetAbsoluteVolume(TPtrC8& aMtPayload) + { + if (aMtPayload.Length() != KLengthSetAbsoluteVolumeRequestParameter) + { + return KErrAvrcpMetadataInvalidCommand; + } + + iOperationId = KRemConSetAbsoluteVolume; + iInterfaceUid = TUid::Uid(KRemConAbsoluteVolumeTargetApiUid); + + TBuf8 payload; + TRAPD(err, DoParseSetAbsoluteVolumeL(aMtPayload, payload)); + if (err != KErrNone) + { + return KErrAvrcpMetadataInternalError; + } + + return AppendIncomingPayload(payload); + } + +void CControlCommand::DoParseSetAbsoluteVolumeL(const TPtrC8& aMtPayload, TDes8& aPayload) + { + RRemConAbsoluteVolumeRequest request; + CleanupClosePushL(request); + request.iVolume = KAbsoluteVolumeMask & aMtPayload[KLengthSetAbsoluteVolumeRequestParameter - 1]; + request.iMaxVolume = KAvrcpMaxAbsoluteVolume; + request.WriteL(aPayload); + CleanupStack::PopAndDestroy(&request); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpadvancedcontrol.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpadvancedcontrol.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,161 @@ +// Copyright (c) 2008-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 "avrcpinternalinterface.h" +#include "avrcplog.h" +#include "avrcputils.h" +#include "browsecommand.h" +#include "browsingframe.h" +#include "mediabrowse.h" +#include "nowplaying.h" + +TInt CBrowseCommand::HandleSetBrowsedPlayer() + { + LOG_FUNC + + TPtrC8 payload; + AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload); + if (payload.Length() < KMinLengthSetBrowsedPlayerPdu) + { + return KErrAvrcpAirInvalidCommand; + } + + iOperationId = ESetBrowsedPlayerOperationId; + iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid); + + RRemConSetBrowsedPlayerRequest request; + request.iPlayerId = static_cast(payload[0]) << 8; + request.iPlayerId |= payload[1]; + request.iMaxResponse = iMaxResponse; + TBuf8 buf; + // Only reason for WriteL to leave is insufficently large buffer + TRAP_IGNORE(request.WriteL(buf)); + TInt err = AppendIncomingPayload(buf); + return (err == KErrNone) ? KErrAvrcpFurtherProcessingRequired : err; + } + +TInt CBrowseCommand::HandleGetFolderItems() + { + LOG_FUNC + + TPtrC8 payload; + AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload); + if (payload.Length() < KMinLengthGetFolderItemsPdu) + { + return KErrAvrcpAirInvalidCommand; + } + + TInt err = KErrAvrcpInvalidScope; + switch(iFrame[3]) + { + case AvrcpBrowsing::KMediaPlayerScope: + { + iOperationId = EAvrcpInternalGetFolderItems; + iInterfaceUid = TUid::Uid(KUidAvrcpInternalInterface); + err = (AppendIncomingPayload(payload) == KErrNone) ? KErrAvrcpInternalCommand : err; + break; + } + case AvrcpBrowsing::KVirtualFilesystemScope: + case AvrcpBrowsing::KSearchScope: + case AvrcpBrowsing::KNowPlayingScope: + { + iOperationId = EGetFolderItemsOperationId; + iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid); + err = AppendIncomingPayload(payload); + break; + } + }; + + return err; + } + +TInt CBrowseCommand::HandleChangePath() + { + LOG_FUNC + + TPtrC8 payload; + AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload); + if (payload.Length() < KMinLengthChangePathPdu) + { + return KErrAvrcpAirInvalidCommand; + } + + iOperationId = EChangePathOperationId; + iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid); + return AppendIncomingPayload(payload); + } + +TInt CBrowseCommand::HandleGetItemAttributes() + { + LOG_FUNC + + TPtrC8 payload; + AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload); + if (payload.Length() < KMinLengthGetItemAttributesPdu) + { + return KErrAvrcpAirInvalidCommand; + } + + iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid); + iOperationId = EGetItemAttributesOperationId; + return AppendIncomingPayload(payload); + } + +TInt CBrowseCommand::HandleSearch() + { + LOG_FUNC + + TPtrC8 payload; + AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload); + if (payload.Length() < KMinLengthSearchPdu) + { + return KErrAvrcpAirInvalidCommand; + } + + iOperationId = ESearchOperationId; + iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid); + return AppendIncomingPayload(payload); + } + +/** Allocate correct space and append the payload to iCommandData + */ +TInt CBrowseCommand::AppendIncomingPayload(const TPtrC8& aPayload) + { + iCommandData.Close(); + if (iCommandData.Create(aPayload.Length()) != KErrNone) + { + return KErrAvrcpAirInternalError; + } + + iCommandData.Append(aPayload); + + return KErrNone; + } + +TInt CBrowseCommand::HandleUnknownPdu() + { + iFrame.Close(); + TInt err = iFrame.CreateMax(KMinLengthGeneralReject); + if(!err) + { + iFrame[0] = AvrcpBrowsing::EGeneralReject; + iFrame[1] = (KMinLengthGeneralReject - AvrcpBrowsing::KHeaderLength) >> 8; + iFrame[2] = (KMinLengthGeneralReject - AvrcpBrowsing::KHeaderLength); + iFrame[3] = KErrAvrcpAirInvalidCommand - KErrAvrcpAirBase; + } + return err ? err : KErrAvrcpHandledInternallyRespondNow; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpbrowsingcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpbrowsingcommandhandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,489 @@ +// Copyright (c) 2004-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: +// avrcpincomingcommandhandler.cpp +// + + + +/** + @file + @internalComponent + @released +*/ +#include +#include +#include + +#include "browsecommand.h" +#include "avrcpbrowsingcommandhandler.h" +#include "avrcpinternalinterface.h" +#include "avrcplog.h" +#include "avrcprouter.h" +#include "avrcputils.h" +#include "browsingframe.h" +#include "bulkbearer.h" +#include "mediabrowse.h" +#include "remconcommandinterface.h" + +//------------------------------------------------------------------------------------ +// Construction/Destruction +//------------------------------------------------------------------------------------ + +/** Factory function. + +@param aCommandInterface The interface for providing commands that have been handled. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aPlayerInfoManager The central manager for player information. +@param aAddr The Bluetooth device address for the remote device handled by this handler. +@return A fully constructed CRcpBrowsingCommandHandler. +@leave System wide error codes. +*/ +CRcpBrowsingCommandHandler* CRcpBrowsingCommandHandler::NewL(MRemConBulkCommandInterface& aCommandInterface, + CBulkRouter& aRouter, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + const TBTDevAddr& aAddr) + { + LOG_STATIC_FUNC + CRcpBrowsingCommandHandler* handler = new(ELeave) CRcpBrowsingCommandHandler(aCommandInterface, aRouter, aPlayerInfoManager, aAddr); + return handler; + } + +/** +@param aCommandInterface The interface for providing commands that have been handled. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aPlayerInfoManager The central manager for player information. +@param aAddr The Bluetooth device address for the remote device handled by this handler. +@return A partially constructed CRcpBrowsingCommandHandler. +*/ +CRcpBrowsingCommandHandler::CRcpBrowsingCommandHandler(MRemConBulkCommandInterface& aCommandInterface, + CBulkRouter& aRouter, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + const TBTDevAddr& aAddr) + : iCommandQueue(_FOFF(CBrowseCommand, iHandlingLink)) + , iInternalCommandQueue(_FOFF(CBrowseCommand, iHandlingLink)) + , iCommandInterface(aCommandInterface) + , iRouter(aRouter) + , iMtu(335) // initialise to min for browse channel + , iPlayerInfoManager(aPlayerInfoManager) + , iAddr(aAddr) + { + LOG_FUNC + } + +CRcpBrowsingCommandHandler::~CRcpBrowsingCommandHandler() + { + LOG_FUNC + + while (!iCommandQueue.IsEmpty()) + { + CBrowseCommand *command = iCommandQueue.First(); + HandledCommand(*command); + } + + TRemConAddress remConAddr; + AvrcpUtils::BTToRemConAddr(iAddr, remConAddr); + iCommandInterface.MrcbciRemoveAddressing(remConAddr); + } + +//--------------------------------------------------------------------- +// Called from the bearer +//--------------------------------------------------------------------- + +/** Tell the handler to gracefully shutdown. + +*/ +void CRcpBrowsingCommandHandler::Disconnect() + { + LOG_FUNC + + while (!iCommandQueue.IsEmpty()) + { + CBrowseCommand* command = iCommandQueue.First(); + iRouter.RemoveFromSendQueue(*command); + + HandledCommand(*command); + } + } + +//------------------------------------------------------------------------------------ +// Called by router +//------------------------------------------------------------------------------------ + +/** Receive an incoming AVRCP browse command. + +@param aMessageInformation The command data from the AVCTP message. +@param aTransactionLabel AVCTP transaction label for this command. +@param aAddr The bluetooth device from which this command originated. +@leave System Wide Error code +*/ +void CRcpBrowsingCommandHandler::ReceiveCommandL(const TDesC8& aMessageInformation, + SymbianAvctp::TTransactionLabel aTransactionLabel, + const TBTDevAddr& aAddr) + { + LOG_FUNC + + // If there's nothing beyond a header this is bobs. Dump it now. + AvrcpBrowsing::BrowsingFrame::VerifyFrameL(aMessageInformation); + + TUint id = iCommandInterface.MrcciNewTransactionId(); + CBrowseCommand* command = CBrowseCommand::NewL(aMessageInformation, id, aTransactionLabel, aAddr, &iPlayerInfoManager); + CleanupStack::PushL(command); + + TInt result = command->ProcessIncomingCommandL(iMtu); + CleanupStack::Pop(command); + + command->IncrementUsers(); + + switch(result) + { + case KErrAvrcpFurtherProcessingRequired: + { + // The only command that we need to check out before sending on is + // SetBrowsedPlayer. Although it's been parsed to verify that it's + // a syntactically valid command we need to ensure that the selected + // player is available before sending it on. + + __ASSERT_DEBUG(command->RemConInterfaceUid() == TUid::Uid(KRemConMediaBrowseApiUid) && command->RemConOperationId() == ESetBrowsedPlayerOperationId, AVRCP_PANIC(EFurtherProcessingRequiredForNonSetBrowsedPlayer)); + TBool valid = HandleSetBrowsedPlayer(*command); + + if(!valid) + { + Respond(*command, result); + command->DecrementUsers(); + break; + } + else + { + result = KErrNone; + } + // valid case fallsthrough to be handled as normal + } + case KErrAvrcpHandledInternallyInformRemCon: // this case falls through + case KErrNone: + { + iCommandQueue.AddLast(*command); + iCommandInterface.MrcciNewCommand(*command); + + if (result == KErrNone) + { + break; + } + // KErrAvrcpHandledInternallyInformRemCon fallsthrough here + } + case KErrAvrcpHandledInternallyRespondNow: + { + // If the command has already set payload, just sent the command + iRouter.AddToSendQueue(*command); + command->DecrementUsers(); + break; + } + case KErrAvrcpInternalCommand: + { + iInternalCommandQueue.AddLast(*command); + HandleInternalCommand(*command); + break; + } + default: + { + Respond(*command, result); + command->DecrementUsers(); + break; + } + }; + } + +/** Called from the router to indicate send completion. + +@param aCommand The command that has been sent. +@param aSendResult KErrNone if the command was sent successfully. System wide + error code otherwise. +*/ +void CRcpBrowsingCommandHandler::MessageSent(CAvrcpCommand& /*aCommand*/, TInt /*aSendResult*/) + { + LOG_FUNC + // We try and send the response, but if we fail there's not a lot we can do about + // it. Just let the remote assume the response. + } + +void CRcpBrowsingCommandHandler::MaxPacketSize(TInt aMtu) + { + iMtu = aMtu-AvrcpBrowsing::KHeaderLength; + } + +//------------------------------------------------------------------------------------ +// Called by bearer +//------------------------------------------------------------------------------------ + +/** Send a response. + +@param aInterfaceUid The RemCon interface this response is from. +@param aId The RemCon transaction label of the command to respond to. +@param aData The command response data. +@return KErrNotFound if the command was not found on the queue. + System wide error codes. +*/ +TInt CRcpBrowsingCommandHandler::SendRemConResponse(TUid /*aInterfaceUid*/, TUint aId, RBuf8& aData) + { + LOG_FUNC + + return SendResponse(iCommandQueue, aId, aData); + } + +//------------------------------------------------------------------------------------ +// Internal command handling functions +//------------------------------------------------------------------------------------ + + +/** Sends a response to the remote device. + +@param aCommand The command to respond to. +@param aErr The result of handling the command. +*/ +void CRcpBrowsingCommandHandler::Respond(CBrowseCommand& aCommand, TInt aErr) + { + LOG_FUNC + aCommand.SetResult(aErr); + iRouter.AddToSendQueue(aCommand); + } + +/** To be called on completion of command handling. + +This aggregates the handler's tidying up of a finished +command. + +@param aCommand The command to tidy up. +*/ +void CRcpBrowsingCommandHandler::HandledCommand(CBrowseCommand& aCommand) + { + LOG_FUNC + + aCommand.iHandlingLink.Deque(); + aCommand.DecrementUsers(); + } + +void CRcpBrowsingCommandHandler::HandleInternalCommand(CBrowseCommand& aCommand) + { + LOG_FUNC + + TUid interfaceUid; + TUint id; + TUint operationId; + RBuf8 commandData; + TBTDevAddr addr; + + aCommand.GetCommandInfo(interfaceUid, id, operationId, commandData, addr); + + __ASSERT_DEBUG(interfaceUid == TUid::Uid(KUidAvrcpInternalInterface), AvrcpUtils::Panic(EAvrcpInternalHandlingRequestedOnWrongInterface)); + + TInt err = KErrNone; + switch(operationId) + { + case EAvrcpInternalGetFolderItems: + { + err = HandleGetFolderItems(id, commandData); + break; + } + }; + + if(err) + { + HandledCommand(aCommand); + } + + commandData.Close(); + } + +TInt CRcpBrowsingCommandHandler::HandleGetFolderItems(TUint aId, RBuf8& aCommandData) + { + LOG_FUNC + + RBuf8 responseBuf; + TRAPD(err, DoHandleGetFolderItemsL(aCommandData, responseBuf)); + + if(!err) + { + err = SendInternalResponse(aId, responseBuf); + } + + return err; + } + +void CRcpBrowsingCommandHandler::DoHandleGetFolderItemsL(RBuf8& aCommandData, RBuf8& aResponseData) + { + LOG_FUNC + + __ASSERT_DEBUG( &iPlayerInfoManager != NULL, AvrcpUtils::Panic(EAvrcpNotFullyConstructed)); + RAvrcpGetFolderItemsRequest request; + CleanupClosePushL(request); + request.ReadL(aCommandData); + + // Use 4 bytes even though player ids are 2 bytes becuase of + // restrictions on RArray preventing use of non-word aligned types + RArray players; + TInt err = iPlayerInfoManager.PlayerListing(request.iStartItem, request.iEndItem, players); + CleanupStack::PopAndDestroy(&request); + + RRemConMediaErrorResponse errResponse; + if(err != KErrNone) + { + CleanupClosePushL(players); + errResponse.iPduId = AvrcpBrowsing::EGetFolderItems; + errResponse.iStatus = (err == KErrArgument) ? AvrcpStatus::ERangeOutOfBounds : AvrcpStatus::EInternalError; + aResponseData.CreateL(KBrowseResponseBaseLength); + CleanupClosePushL(aResponseData); + errResponse.WriteL(aResponseData); + CleanupStack::Pop(&aResponseData); + CleanupStack::PopAndDestroy(&players); + return; + } + + RAvrcpGetFolderItemsResponse response; + CleanupClosePushL(response); + CleanupClosePushL(players); + for(TInt i = 0; i < players.Count(); i++) + { + RMediaPlayerItem item; + CleanupClosePushL(item); + iPlayerInfoManager.MediaPlayerItemL(players[i], item); + response.iItems.AppendL(item); + CleanupStack::Pop(&item); + } + + response.iPduId = AvrcpBrowsing::EGetFolderItems; + response.iStatus = AvrcpStatus::ESuccess; + response.iUidCounter = KMediaPlayerListUidCounter; + response.iNumberItems = players.Count(); + CleanupStack::PopAndDestroy(&players); + + //check this fits within MTU, Leave if the response size is bigger than max size + CleanupClosePushL(aResponseData); + if(response.Size() > iMtu) + { + + errResponse.iPduId = AvrcpBrowsing::EGetFolderItems; + errResponse.iStatus = AvrcpStatus::EInternalError; + aResponseData.CreateL(KBrowseResponseBaseLength); + errResponse.WriteL(aResponseData); + } + else + { + aResponseData.CreateL(response.Size()); + response.WriteL(aResponseData); + } + CleanupStack::Pop(&aResponseData); + CleanupStack::PopAndDestroy(&response); + } + +TInt CRcpBrowsingCommandHandler::SendInternalResponse(TUint aId, RBuf8& aData) + { + LOG_FUNC + + return SendResponse(iInternalCommandQueue, aId, aData); + } + +TInt CRcpBrowsingCommandHandler::SendResponse(TDblQue& aCommandQueue, TUint aId, RBuf8& aData) + { + LOG_FUNC + + TInt err = KErrNotFound; + + TDblQueIter iter(aCommandQueue); + CBrowseCommand* command = NULL; + + while (iter) + { + command = iter++; + if(command->RemConCommandId() == aId) + { + err = KErrNone; + command->ProcessOutgoingResponse(aData); + + Respond(*command, err); + aData.Close(); + HandledCommand(*command); + + break; + } + } + + return err; + } + +void CRcpBrowsingCommandHandler::SendReject(TUid /*aInterfaceUid*/, TUint aTransactionId) + { + LOG_FUNC; + + TDblQueIter iter(iCommandQueue); + CBrowseCommand* command = NULL; + + while (iter) + { + command = iter++; + if(command->RemConCommandId() == aTransactionId) + { + Respond(*command, KErrAvrcpAirInternalError); + HandledCommand(*command); + } + } + } + +const TBTDevAddr& CRcpBrowsingCommandHandler::BtAddr() const + { + return iAddr; + } + +TBool CRcpBrowsingCommandHandler::HandleSetBrowsedPlayer(CBrowseCommand& aCommand) + { + TInt err = KErrNone; + RRemConSetBrowsedPlayerRequest request; + + TRAP(err, request.ReadL(aCommand.CommandData())); + __ASSERT_DEBUG(err == KErrNone, AvrcpUtils::Panic(ESetBrowsePlayerRequestCorruptedLocally)); + + // Check if selected player exists + TUint16 playerId = request.iPlayerId; + TRemConClientId clientId; + TRAP(err, clientId = iPlayerInfoManager.ClientL(playerId)); + + if(err == KErrNone) + { + // Selected player exists, check with RemCon if we can use it + TRemConAddress remConAddr; + AvrcpUtils::BTToRemConAddr(iAddr, remConAddr); + + TInt err = iCommandInterface.MrcbciSetAddressedClient(remConAddr, clientId); + } + + if(err != KErrNone) + { + // Either the player was incorrect or is already in use, form a RemCon + // format response, then ask the command to process it for sending out + // on the air. + RBuf8 buf; + TInt bufErr = buf.Create(KMediaBrowseOutBufMaxLength); + + if(bufErr == KErrNone) + { + RRemConMediaErrorResponse response; + response.iPduId = 0x70; + response.iStatus = RAvrcpIPC::SymbianErrToStatus(KErrAvrcpAirInvalidPlayerId); + TRAP(bufErr, response.WriteL(buf)); + aCommand.ProcessOutgoingResponse(buf); + buf.Close(); + } + } + // else we will continue processing this command as normal + + return err == KErrNone ? ETrue : EFalse; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpcommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpcommand.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,164 @@ +// Copyright (c) 2008-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 "avrcpcommand.h" +#include "avrcplog.h" + +CAvrcpCommand::CAvrcpCommand(TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransactionLabel, + const TBTDevAddr& aAddr) + : iRemConId(aRemConId) + , iTransactionLabel(aTransactionLabel) + , iRemoteAddr(aAddr) + { + LOG_FUNC + } + +//------------------------------------------------------------------------------------ +// Called by handlers, router and bearer +//------------------------------------------------------------------------------------ + +/** Decrement the users of this command. + +This must be called by users of the command when they +no longer require the command to remain in existence. +When the number of users reaches zero, the command +is deleted. +*/ +void CAvrcpCommand::DecrementUsers() + { + LOG_FUNC + if(--iUsers < 1) + { + iHandlingLink.Deque(); + delete this; + } + } + +/** Increment the users of this command. + +This must be called by users of the command to signify +they require it to remain in existence. +*/ +void CAvrcpCommand::IncrementUsers() + { + LOG_FUNC + iUsers++; + } + +//------------------------------------------------------------------------------------ +// Called by bearer +//------------------------------------------------------------------------------------ + +/** Get info needed by RemCon for this command. + +@param aInterfaceUid On return, the RemCon interface of this command. +@param aId On return, the RemCon transaction id of this command. +@param aOperationId On return, the RemCon operation id of this command. +@param aCommandData On return, the command data for this operation. + Ownership is returned. +@param aAddr On return, the originating device for this command. +*/ +void CAvrcpCommand::GetCommandInfo(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TBTDevAddr& aAddr) + { + LOG_FUNC + aInterfaceUid = iInterfaceUid; + aId = iRemConId; + aOperationId = iOperationId; + + // RemCon will take ownership of command data + aCommandData.Assign(iCommandData); + iCommandData.Assign(NULL); + + aAddr = iRemoteAddr; + } + +//------------------------------------------------------------------------------------ +// Called by handlers +//------------------------------------------------------------------------------------ + +/** Gets the remote associated with this command. +This may be the source or the destination, depending +on if the originated locally or remotely. + +@return The BT address of the remote device. +*/ +const TBTDevAddr& CAvrcpCommand::RemoteAddress() const + { + LOG_FUNC + return iRemoteAddr; + } + +/** Gets the AVCTP transaction label for this command. +This is used to match commands with responses. + +@return The AVCTP transaction label for this command. +*/ +SymbianAvctp::TTransactionLabel CAvrcpCommand::TransactionLabel() const + { + LOG_FUNC + return iTransactionLabel; + } + +/** Gets the RemCon id of this command. +This is used to uniquely identify a transaction to RemCon. + +@return The RemCon command id. +*/ +TUint CAvrcpCommand::RemConCommandId() const + { + LOG_FUNC + return iRemConId; + } + +/** Gets the RemCon interface uid of this command. + +This is used with the operation id to uniquely identify an operation to RemCon. + +@param aOperation +@return The RemCon operation id. +*/ +const TUid& CAvrcpCommand::RemConInterfaceUid() const + { + LOG_FUNC + return iInterfaceUid; + } + +/** Gets the RemCon operation id of this command. + +This is used with the interface uid to uniquely identify an operation to RemCon. + +@param aOperation +@return The RemCon operation id. +*/ +TUint CAvrcpCommand::RemConOperationId() const + { + LOG_FUNC + return iOperationId; + } + + +/** +Whether the Bearer is aware of this command. If not we shouldn't +inform the bearer of responses. +*/ +TBool CAvrcpCommand::KnownToBearer() const + { + return iKnownToBearer; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpcommandframer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpcommandframer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,132 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include "avrcpcommandframer.h" +#include "avcframe.h" +#include "avrcplog.h" +#include +#include + +// The Bluetooth SIG registered VendorId, see table 4.7 +const AVC::TAVCVendorId KBluetoothSIGVendorId = 0x001958; + +/** Returns a new CAVCFrame representing an AV/C passthrough command. +@param aOperationId The AV/C operation id of this command. +@param aButtonAction The AV/C button action. +@return An AV/C frame representing a passthrough command. +@leave error +*/ +CAVCFrame* AvrcpCommandFramer::PassthroughL(AVCPanel::TOperationId aOperationId, AVCPanel::TButtonAction aButtonAction) + { + LOG_STATIC_FUNC + CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::EControl, AVC::EPanel, AVC::EID0); + frame->Append(TChar(AVC::EPassThrough)); + frame->Append(TChar(aOperationId | aButtonAction)); + frame->Append(TChar(0)); + return frame; + } + +/** Returns a new CAVCFrame representing an AV/C Unit Info response. +@return An AV/C frame representing a Unit Info response. +@leave error +*/ +CAVCFrame* AvrcpCommandFramer::UnitInfoResponseL() + { + LOG_STATIC_FUNC + CAVCFrame* frame = CAVCFrame::NewL(AVC::EResponse, AVC::EStable, AVC::EUnit, AVC::EIgnore); + frame->Append(TChar(AVC::EUnitInfo)); + frame->Append(TChar(0x7)); + frame->Append(TChar(0x48)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + return frame; + } + +/** Returns a new CAVCFrame representing an AV/C Subunit Info response. +@return An AV/C frame representing a Subunit Info response. +@leave error +*/ +CAVCFrame* AvrcpCommandFramer::SubunitInfoResponseL() + { + LOG_STATIC_FUNC + CAVCFrame* frame = CAVCFrame::NewL(AVC::EResponse, AVC::EStable, AVC::EUnit, AVC::EIgnore); + frame->Append(TChar(AVC::ESubunitInfo)); + frame->Append(TChar(0x7)); + frame->Append(TChar(0x48)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + return frame; + } + +/** Returns a new CAVCFrame representing an AV/C 'set absolute volume' command +@return An AV/C frame representing a 'set absolute volume' command. +@leave error +*/ +CAVCFrame* AvrcpCommandFramer::SetAbsoluteVolumeCommandL(TUint8 aAbsVol) + { + LOG_STATIC_FUNC + CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::EControl, AVC::EPanel, AVC::EID0); + frame->Append(TChar(AVC::EVendorDependent)); + frame->Append(KBluetoothSIGVendorId>>16 & 0xff); + frame->Append(KBluetoothSIGVendorId>>8 & 0xff); + frame->Append(KBluetoothSIGVendorId & 0xff); + + frame->Append(ESetAbsoluteVolume); + frame->Append(TChar(AVC::EASingle)); + + TUint16 len = KLengthSetAbsoluteVolumeRequestParameter<<8 & 0xffff; + TPckgBuf parameterLength(len); + frame->Append(parameterLength); + frame->Append(aAbsVol); + return frame; + } + +/** Returns a new CAVCFrame representing an AV/C 'Register notification absolute volume changed' command. +@return An AV/C frame representing a 'Register notification absolute volume changed' command. +@leave error +*/ +CAVCFrame* AvrcpCommandFramer::NotifyVolumeChangeCommandL() + { + LOG_STATIC_FUNC + CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::ENotify, AVC::EPanel, AVC::EID0); + frame->Append(TChar(AVC::EVendorDependent)); + frame->Append(KBluetoothSIGVendorId>>16 & 0xff); + frame->Append(KBluetoothSIGVendorId>>8 & 0xff); + frame->Append(KBluetoothSIGVendorId & 0xff); + + frame->Append(ERegisterNotification); + frame->Append(TChar(AVC::EASingle)); + + TUint16 len = KLengthNotifyVolumeChangeRequestParameter<<8 & 0xffff; + TPckgBuf parameterLength(len); + frame->Append(parameterLength); + frame->Append(ERegisterNotificationVolumeChanged); + + TBuf8<4> reservedBuffer(KLengthNotifyVolumeChangeRequestParameter - 1); + reservedBuffer.FillZ(); + frame->Append(reservedBuffer); + return frame; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpfragmenter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpfragmenter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +// Copyright (c) 2007-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include "avrcpfragmenter.h" +#include "controlcommand.h" +#include + +// Maximum size of data in a fragment response +static const int KFragmentDataLength = KAVCMaxVendorDependentPayload - KAVRCPMinVendorDependentResponseLen; + + +CAVRCPFragmenter* CAVRCPFragmenter::NewL() + { + CAVRCPFragmenter* self = new (ELeave) CAVRCPFragmenter(); + self->Construct(); + return self; + } + +TBool CAVRCPFragmenter::InFragmentedState() + { + return iInFragmentedState; + } + +void CAVRCPFragmenter::Reset() + { + iStart = KAVRCPMinVendorDependentResponseLen; + iInFragmentedState = EFalse; + } + +void CAVRCPFragmenter::AssignPayload(const RBuf8& aPayload) + { + // Assign the allocated memory containing the reponse to + // this class, allowing the caller to Close() aPayload. + iPayload.Close(); + iPayload.Assign(aPayload); + iInFragmentedState = ETrue; + } + +TPtr8 CAVRCPFragmenter::GetNextFragmentHeader() + { + if (! InFragmentedState()) + return TPtr8(0,0,0); + + // Fragmentation byte is 2nd byte of response; poke this + // and set the length correctly + if (iStart == KAVRCPMinVendorDependentResponseLen) + { + iPayload[1] = EFragmentStart; + iPayload[2] = (KFragmentDataLength >> 8) & 0xff; + iPayload[3] = (KFragmentDataLength) & 0xff; + } + else if (LastFragment()) + { + iPayload[1] = EFragmentEnd; + TInt length = iPayload.Length() - iStart; + iPayload[2] = (length >> 8) & 0xff; + iPayload[3] = (length) & 0xff; + } + else + { + iPayload[1] = EFragmentContinue; + iPayload[2] = (KFragmentDataLength >> 8) & 0xff; + iPayload[3] = (KFragmentDataLength) & 0xff; + } + + // Return the first 4 bytes, which contain the PDU id, + // fragmentation status and parameter length (2 bytes) + return iPayload.MidTPtr(0, KAVRCPMinVendorDependentResponseLen); + } + +TPtr8 CAVRCPFragmenter::GetNextFragment() + { + if (! InFragmentedState()) + return TPtr8(0,0,0); + + // Sigh. MidTPtr() PANICs if the 2nd argument is too large. + // Other APIs (e.g. Java, STL) just return to end of string. + TInt fragmentSize = KFragmentDataLength; + if (LastFragment()) + fragmentSize = iPayload.Length() - iStart; + + TPtr8 fragment = iPayload.MidTPtr(iStart, fragmentSize); + + if (LastFragment()) + Reset(); + else + iStart += fragmentSize; + return fragment; + } + +TBool CAVRCPFragmenter::LastFragment() + { + if (iStart + KFragmentDataLength > iPayload.Length()) + return ETrue; + else + return EFalse; + } + +TInt CAVRCPFragmenter::GetPDU() + { + return iPayload[0]; + } + +void CAVRCPFragmenter::Construct() + { + Reset(); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpimplementationproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpimplementationproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +// Copyright (c) 2004-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: +// rcpimplementationproxy.cpp +// + +#include +#include +#include +#include "controlbearer.h" + +// __________________________________________________________________________ +// Exported proxy for instantiation method resolution +// Define the interface UIDs + +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KRemConBearerAvrcpImplementationUid, CRemConBearerAvrcp::NewL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpincomingcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpincomingcommandhandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,872 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include +#include + +#include "controlcommand.h" +#include "avrcpcommandframer.h" +#include "avrcpincomingcommandhandler.h" +#include "avrcpinternalinterface.h" +#include "avrcplog.h" +#include "avrcprouter.h" +#include "avrcptimer.h" +#include "avrcputils.h" +#include "controlbearer.h" +#include "passthroughhelper.h" +#include "mediainformation.h" +#include "nowplaying.h" +#include "playerinformation.h" +#include "remconbattery.h" +#include "remcongroupnavigation.h" + +//------------------------------------------------------------------------------------ +// Construction/Destruction +//------------------------------------------------------------------------------------ + +/** Factory function. + +@param aBearer The CRemConBearerAvrcp this is to handle commands for. +@param aObserver The observer of the bearer. Used to acquire converters. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aTimer CDeltaTimer to use for queuing timed events. +@return A fully constructed CRcpIncomingCommandHandler. +@leave System wide error codes. +*/ +CRcpIncomingCommandHandler* CRcpIncomingCommandHandler::NewL(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + TBTDevAddr& aDevice) + { + LOG_STATIC_FUNC + CRcpIncomingCommandHandler* handler = new(ELeave)CRcpIncomingCommandHandler(aBearer, aObserver, aRouter, aTimer, aPlayerInfoManager, aDevice); + CleanupStack::PushL(handler); + handler->ConstructL(); + CleanupStack::Pop(handler); + return handler; + } + +/** Constructor. + +@param aBearer The CRemConBearerAvrcp this is to handle commands for. +@param aObserver The observer of the bearer. Used to aquire converters. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aTimer CDeltaTimer to use for queuing timed events. +@return A partially constructed CRcpIncomingCommandHandler. +@leave System wide error codes. +*/ +CRcpIncomingCommandHandler::CRcpIncomingCommandHandler(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer, + CAvrcpPlayerInfoManager& aPlayerInfoManager, + TBTDevAddr& aDevice) + : iCommandQueue(_FOFF(CControlCommand, iHandlingLink)) + , iInternalCommandQueue(_FOFF(CControlCommand, iHandlingLink)) + , iFragmenter(NULL) + , iBearer(aBearer) + , iObserver(aObserver) + , iRouter(aRouter) + , iTimer(aTimer) + , iAddressedMode(EFalse) + , iPlayerInfoManager(aPlayerInfoManager) + , iDevice(aDevice) + { + LOG_FUNC + } + +void CRcpIncomingCommandHandler::ConstructL() + { + LOG_FUNC + + iFragmenter = CAVRCPFragmenter::NewL(); + iPlayerInfoManager.AddObserverL(*this); + + RArray players; + iPlayerInfoManager.PlayerListing(players); + CleanupClosePushL(players); + + if(players.Count()) + { + // Start out with the first player as default. TSP will need to update + // us if it wants to set a different one. Note that this wont be used + // unless we enter addressed mode anyway. + iClientId = iPlayerInfoManager.ClientL(0); + } + // if no player have yet been registered we'll set the default when the + // first one is + + CleanupStack::PopAndDestroy(&players); + + iPassthroughHelper = CPassthroughHelper::NewL(iRouter, iBearer, iTimer); + } + +/** Destructor. +*/ +CRcpIncomingCommandHandler::~CRcpIncomingCommandHandler() + { + LOG_FUNC + + iPlayerInfoManager.RemoveObserver( *this ); + delete iFragmenter; + delete iPassthroughHelper; + + // All commands should have been handled by the time we reach here. + __ASSERT_ALWAYS(iCommandQueue.IsEmpty(), AvrcpUtils::Panic(EAvrcpIncomingCommandsNotHandled)); + __ASSERT_ALWAYS(iInternalCommandQueue.IsEmpty(), AvrcpUtils::Panic(EAvrcpIncomingCommandsNotHandled)); + } + +//--------------------------------------------------------------------- +// Called from the bearer +//--------------------------------------------------------------------- + +/** Tell the handler to gracefully shutdown. + +*/ +void CRcpIncomingCommandHandler::Disconnect() + { + LOG_FUNC + + iPassthroughHelper->Disconnect(); + + if(!iCommandQueue.IsEmpty()) + { + // Cleanup remaining commands + while(!iCommandQueue.IsEmpty()) + { + CControlCommand* command = iCommandQueue.First(); + // Tell RemCon the command is finished with + iObserver.CommandExpired(command->RemConCommandId()); + // And now remove the command from the bearer + iRouter.RemoveFromSendQueue(*command); + HandledCommand(*command); + } + } + if(!iInternalCommandQueue.IsEmpty()) + { + + // Cleanup remaining commands + while(!iInternalCommandQueue.IsEmpty()) + { + CControlCommand* command = iInternalCommandQueue.First(); + // Tell RemCon the command is finished with + iObserver.CommandExpired(command->RemConCommandId()); + // And now remove the command from the bearer + iRouter.RemoveFromSendQueue(*command); + HandledCommand(*command); + } + } + } + +//------------------------------------------------------------------------------------ +// Called by router +//------------------------------------------------------------------------------------ + +void CRcpIncomingCommandHandler::MaxPacketSize(TInt /*aMtu*/) + { + // ignore - we don't care if we use AVCTP fragmentation on the + // control channel + } + +/** Receive an incoming AVRCP command. + +The command is parsed from a CAVCFrame into a CControlCommand owned by the +command handler. + +@param aFrame The AVC frame contained within the AVCTP message. +@param aTransactionLabel AVCTP transaction label for this command. +@param aAddr The bluetooth device from which this command originated. +@leave System Wide Error code +*/ +void CRcpIncomingCommandHandler::ReceiveCommandL(const TDesC8& aMessageInformation, + SymbianAvctp::TTransactionLabel aTransactionLabel, + const TBTDevAddr& aAddr) + { + LOG_FUNC + + TUint id = iBearer.MrcciNewTransactionId(); + + // If there's nothing beyond a header this is bobs. Dump it now. + if(aMessageInformation.Length() <= KAVCFrameHeaderLength) + { + User::Leave(KErrCorrupt); + } + + // Parse it out into an AV/C frame + CAVCFrame* frame = CAVCFrame::NewL(aMessageInformation, AVC::ECommand); + + CControlCommand* command = CControlCommand::NewL(frame, id, aTransactionLabel, aAddr, iAddressedMode ? iClientId : KNullClientId, &AvrcpPlayerInfoManager()); + CleanupStack::PushL(command); + + TInt result = command->ParseIncomingCommandL(iObserver, *iFragmenter); + CleanupStack::Pop(command); + + command->IncrementUsers(); + + switch(result) + { + case KErrAvrcpHandledInternallyInformRemCon: + { + HandleRemConCommand(*command); + iRouter.AddToSendQueue(*command); + command->DecrementUsers(); + break; + } + case KErrNone: + { + if(! command->IsPassthrough()) + { + // add to iCommandQueue for non-passthrough commands + iCommandQueue.AddLast(*command); + } + HandleRemConCommand(*command); + break; + } + case KErrAvrcpInternalCommand: + { + iInternalCommandQueue.AddLast(*command); + HandleInternalCommand(*command); + break; + } + case KErrAvrcpInvalidCType: + { + // We should ignore commands with invalid ctype (AV/C v4.0 8.3.1). + command->DecrementUsers(); + break; + } + default: + { + Respond(*command, result); + command->DecrementUsers(); + break; + } + } + } + +/** Called from the router to indicate send completion. + +@param aCommand The command that has been sent. +@param aSendResult KErrNone if the command was sent successfully. System wide + error code otherwise. +*/ +void CRcpIncomingCommandHandler::MessageSent(CAvrcpCommand& /*aCommand*/, TInt /*aSendResult*/) + { + LOG_FUNC + // We try and send the response, but if we fail there's not a lot we can do about + // it. Just let the remote assume the response. + } + +//------------------------------------------------------------------------------------ +// Called by bearer +//------------------------------------------------------------------------------------ + +/** Send a response. + +@param aInterfaceUid The RemCon interface this response is from. +@param aId The RemCon transaction label of the command to respond to. +@param aData The command response data. +@return KErrNone. +*/ +TInt CRcpIncomingCommandHandler::SendRemConResponse(TUid /*aInterfaceUid*/, TUint aId, RBuf8& aData) + { + LOG_FUNC + + // We always take ownership of the response data in SendResponse, so we + // always return KErrNone. + SendResponse(iCommandQueue, aId, aData); + return KErrNone; + } + +void CRcpIncomingCommandHandler::SendReject(TUid aInterfaceUid, TUint aId) + { + LOG_FUNC + + TDblQueIter iter(iCommandQueue); + CControlCommand* command = NULL; + + while (iter) + { + command = iter++; + if(command->RemConCommandId() == aId) + { + TInt err = KErrGeneral; + if (aInterfaceUid.iUid == KRemConMediaInformationApiUid || aInterfaceUid.iUid == KRemConPlayerInformationUid) + { + err = KErrAvrcpMetadataInternalError; + } + + Respond(*command, err); + + HandledCommand(*command); + } + } + } + +//------------------------------------------------------------------------------------ +// MPlayerChangeObserver functions +//------------------------------------------------------------------------------------ +void CRcpIncomingCommandHandler::MpcoAvailablePlayersChanged() + { + LOG_FUNC + + TDblQueIter internalIter(iInternalCommandQueue); + CControlCommand* command = NULL; + TInt err = KErrNone; + + while(internalIter) + { + command = internalIter++; + if((command->RemConInterfaceUid() == TUid::Uid(KUidAvrcpInternalInterface)) && (command->RemConOperationId() == EAvrcpInternalAvailablePlayersNotification)) + { + // If this fails we cann't send the notification - just give up + err = HandleRegisterAvailablePlayersNotification(*command); + static_cast(err = err); // ignore this error (i.e. give up). + } + } + //register internal notification + //still need to optimize for avoid re-registering notification + RArray players; + err = iPlayerInfoManager.PlayerListing(players); + + if(err == KErrNone) + { + TBool currentClientAvailable = EFalse; + + for(TInt i = 0 ; i < players.Count() ; i++) + { + TRemConClientId clientId = 0; + clientId = iPlayerInfoManager.Client(players[i]); + if(clientId == iClientId) + { + currentClientAvailable = ETrue; + } + } + + if((iClientId == KNullClientId || !currentClientAvailable) && players.Count()) + { + // If this is the first target client we set our default client id + // to this + iClientId = iPlayerInfoManager.Client(players[0]); + } + } + + players.Close(); + } + +void CRcpIncomingCommandHandler::MpcoAddressedPlayerChangedLocally(TRemConClientId aClientId) + { + LOG_FUNC + + TRAP_IGNORE(AddressedPlayerChangedL(aClientId)); + } + +void CRcpIncomingCommandHandler::MpcoUidCounterChanged(TRemConClientId aClientId) + { + LOG_FUNC + + CControlCommand* command; + if(aClientId == iClientId) + { + command = FindNotify(iInternalCommandQueue, TUid::Uid(KUidAvrcpInternalInterface),EAvrcpInternalUidChangedNotification); + if(command) + { + // if we fail to send an update it is effectively the same condition + // as when the notification arrives after the controller uses the + // old UID counter + TInt err = HandleUidChangedNotification(*command); + + if(err != KErrNone) + { + Respond(*command, KErrAvrcpAirInternalError); + HandledCommand(*command); + } + } + } + } + +//------------------------------------------------------------------------------------ +// Internal command handling functions +//------------------------------------------------------------------------------------ + + +/** Sends a response to the remote device. + +Because of the 100ms timeout for responses we send a response to +passthrough commands as soon as we receive them. This means the real +response from RemCon is currently ignored. A real response is +only sent if this is a vendor dependent command. + +@param aCommand The command to respond to. +@param aErr The result of handling the command. KErrNone if successful. + KErrNotSupported if this operation is not supported. +*/ +void CRcpIncomingCommandHandler::Respond(CControlCommand& aCommand, TInt aErr) + { + LOG_FUNC + aCommand.SetResponseType(aErr); + iRouter.AddToSendQueue(aCommand); + } + +/** To be called on completion of command handling. + +This aggregates the handler's tidying up of a finished +command. + +@param aCommand The command to tidy up. +*/ +void CRcpIncomingCommandHandler::HandledCommand(CControlCommand& aCommand) + { + LOG_FUNC + aCommand.CancelTimer(iTimer); + aCommand.iHandlingLink.Deque(); + aCommand.DecrementUsers(); + } + +void CRcpIncomingCommandHandler::HandleInternalCommand(CControlCommand& aCommand) + { + LOG_FUNC + + TUid interfaceUid; + TUint id; + TUint operationId; + RBuf8 commandData; + TBTDevAddr addr; + + aCommand.GetCommandInfo(interfaceUid, id, operationId, commandData, addr); + + __ASSERT_DEBUG(interfaceUid == TUid::Uid(KUidAvrcpInternalInterface), AvrcpUtils::Panic(EAvrcpInternalHandlingRequestedOnWrongInterface)); + + TInt err = KErrNone; + switch(operationId) + { + case EAvrcpInternalSetAddressedPlayer: + { + err = HandleSetAddressedPlayer(id, commandData); + break; + } + case EAvrcpInternalAvailablePlayersNotification: + { + err = HandleRegisterAvailablePlayersNotification(aCommand); + break; + } + case EAvrcpInternalAddressedPlayerNotification: + { + err = HandleRegisterAddressedPlayerNotification(aCommand); + break; + } + case EAvrcpInternalUidChangedNotification: + { + err = HandleUidChangedNotification(aCommand); + break; + } + }; + + if(err != KErrNone) + { + Respond(aCommand, KErrAvrcpAirInternalError); + HandledCommand(aCommand); + } + + commandData.Close(); + } + +void CRcpIncomingCommandHandler::HandleRemConCommand(CControlCommand& aCommand) + { + LOG_FUNC + + if(aCommand.IsPassthrough()) + { + // This deals with button press/release stuff, + // queues the command and responds + iPassthroughHelper->HandlePassthrough(aCommand); + } + else + { + // can go directly to client (unlike passthrough which may need to map 2 commands to 1 click + if (aCommand.Frame().Type() == AVC::ENotify) + { + iBearer.MrccciNewNotifyCommand(aCommand, aCommand.ClientId()); + } + else + { + iBearer.MrcciNewCommand(aCommand, aCommand.ClientId()); + } + } + } + +TInt CRcpIncomingCommandHandler::HandleSetAddressedPlayer(TUint aId, RBuf8& aCommandData) + { + LOG_FUNC + + // Once we respond to this we've told the remote that we're using a particular player + iAddressedMode = ETrue; + + // SetAddressedPlayer involves not just responding to this command but + // also rejecting a bunch of notifies and completing the addressed player + // changed notify. We try as hard as we can to ensure our state remains + // consistent with the view of the remote. + + // Allocate the response buffer for the SetAddressedPlayer command first + RBuf8 responseBuf; + TInt err = responseBuf.Create(KSetAddressedPlayerResponseSize); + if(err == KErrNone) + { + // Now we know we can at least try and send a response to the remote + // do the other gubbins, which we can cope with failing + TRAPD(setResult, DoHandleSetAddressedPlayerL(aCommandData)); + + switch(setResult) + { + case KErrNotFound: + { + RAvrcpIPCError errorResponse; + errorResponse.iError = KErrAvrcpAirInvalidPlayerId; + + // Can ignore this as we know we have allocated a big enough buffer + TRAP_IGNORE(errorResponse.WriteL(responseBuf)); + break; + } + case KErrNone: + default: + // For any result other than KErrNotFound we managed to set the + // addressed client. Other errors indicate a failure in sending + // a changed response to the AddressedPlayerChanged notify. Even + // if we failed sending a changed response we should have been + // able to reject the outstanding notify so we are in a consistent + // state + { + RAvrcpSetAddressedPlayerResponse response; + response.iStatus = AvrcpStatus::ESuccess; + + // Can ignore this as we know we have allocated a big enough buffer + TRAP_IGNORE(response.WriteL(responseBuf)); + break; + } + }; + + SendInternalResponse(aId, responseBuf); + iBearer.MrccciSetAddressedClient(iClientId); + + responseBuf.Close(); + } + + return err; + } + +void CRcpIncomingCommandHandler::DoHandleSetAddressedPlayerL(RBuf8& aCommandData) + { + LOG_FUNC + + RAvrcpSetAddressedPlayerRequest request; + request.ReadL(aCommandData); + + TRemConClientId clientId = iPlayerInfoManager.ClientL(request.iPlayerId); + AddressedPlayerChangedL(clientId); + } + +void CRcpIncomingCommandHandler::AddressedPlayerChangedL(TRemConClientId aClientId) + { + LOG_FUNC + + if(aClientId == iClientId) + { + return; + } + + iClientId = aClientId; + + TDblQueIter iter(iCommandQueue); + CControlCommand* command = NULL; + + // Complete player specific notifications + while(iter) + { + command = iter++; + if(command->PlayerSpecificNotify()) + { + iObserver.CommandExpired(command->RemConCommandId()); + + Respond(*command, KErrAvrcpAirAddressedPlayerChanged); + + HandledCommand(*command); + } + } + + command = FindNotify(iInternalCommandQueue, TUid::Uid(KUidAvrcpInternalInterface),EAvrcpInternalAddressedPlayerNotification); + if(command) + { + User::LeaveIfError(HandleRegisterAddressedPlayerNotification(*command)); + } + } + +TInt CRcpIncomingCommandHandler::HandleRegisterAvailablePlayersNotification(CControlCommand& aCommand) + { + LOG_FUNC + + RBuf8 responseBuf; + TRAPD(err, DoHandleRegisterAvailablePlayersNotificationL(responseBuf, aCommand)); + + if(err == KErrNone) + { + SendInternalResponse(aCommand.RemConCommandId(), responseBuf); + } + + responseBuf.Close(); + return err; + } + +void CRcpIncomingCommandHandler::DoHandleRegisterAvailablePlayersNotificationL(RBuf8& aResponseData, CControlCommand& aCommand) + { + LOG_FUNC + + RAvrcpIPCError response; + response.iError = KErrNone; + + if(DuplicateNotify(iInternalCommandQueue, aCommand)) + { + response.iError = KErrAvrcpAirInvalidCommand; + } + + aResponseData.CreateL(KRegisterNotificationEmptyResponseSize); + CleanupClosePushL(aResponseData); + + response.WriteL(aResponseData); + CleanupStack::Pop(); + } + +TInt CRcpIncomingCommandHandler::HandleRegisterAddressedPlayerNotification(CControlCommand& aCommand) + { + LOG_FUNC + + // Once we respond to this we've told the remote that we're using a particular player + iAddressedMode = ETrue; + + RBuf8 responseBuf; + TRAPD(err, DoHandleRegisterAddressedPlayerNotificationL(responseBuf, aCommand)); + + if(!err) + { + SendInternalResponse(aCommand.RemConCommandId(), responseBuf); + } + + responseBuf.Close(); + return err; + } + +void CRcpIncomingCommandHandler::DoHandleRegisterAddressedPlayerNotificationL(RBuf8& aResponseData, CControlCommand& aCommand) + { + LOG_FUNC + + RAvrcpAddressedPlayerNotificationResponse response; + RAvrcpIPCError rejectResponse; + + if(DuplicateNotify(iInternalCommandQueue, aCommand)) + { + aResponseData.CreateL(KRegisterNotificationEmptyResponseSize); + rejectResponse.iError = KErrAvrcpAirInvalidCommand; + CleanupClosePushL(aResponseData); + rejectResponse.WriteL(aResponseData); + } + else + { + // Tricky situation thinking.Reject if at this moment the client just be shut down + TRAPD(err, response.iPlayerId = iPlayerInfoManager.PlayerL(iClientId)); + if(err != KErrNone) + { + aResponseData.CreateL(KRegisterNotificationEmptyResponseSize); + rejectResponse.iError = KErrAvrcpAirInvalidCommand; + CleanupClosePushL(aResponseData); + rejectResponse.WriteL(aResponseData); + } + else + { + // This line will never leave once the previous line pass + response.iUidCounter = iPlayerInfoManager.UidCounterL(iClientId); + aResponseData.CreateL(KRegisterNotificationAddressedPlayerResponseSize); + CleanupClosePushL(aResponseData); + response.WriteL(aResponseData); + } + } + + CleanupStack::Pop(); + } + +TInt CRcpIncomingCommandHandler::HandleUidChangedNotification(CControlCommand& aCommand) + { + LOG_FUNC + + // Although we haven't strictly told the remote which player we're using this is + // a 1.4 command, and implies use of a specific player so switch into addressed mode + iAddressedMode = ETrue; + + RBuf8 responseBuf; + TUint16 uidCounter = 0; + TRAPD(err, uidCounter = iPlayerInfoManager.UidCounterL(iClientId)); + + if(err == KErrNone && !DuplicateNotify(iInternalCommandQueue, aCommand)) + { + TRAP(err, DoHandleUidChangedNotificationL(responseBuf, uidCounter)); + } + + if(err == KErrNone) + { + SendInternalResponse(aCommand.RemConCommandId(), responseBuf); + } + + responseBuf.Close(); + return err; + } + +void CRcpIncomingCommandHandler::DoHandleUidChangedNotificationL(RBuf8& aResponseData, TUint16 aUidCounter) + { + LOG_FUNC + + RAvrcpUidCounterNotificationResponse response; + response.iUidCounter = aUidCounter; + aResponseData.CreateL(KRegisterNotificationUidChangedResponseSize); + CleanupClosePushL(aResponseData); + response.WriteL(aResponseData); + CleanupStack::Pop(); + } + +void CRcpIncomingCommandHandler::SendInternalResponse(TUint aId, RBuf8& aData) + { + LOG_FUNC + + SendResponse(iInternalCommandQueue, aId, aData); + } + +/** +This function always takes responsibility for the response. +*/ +void CRcpIncomingCommandHandler::SendResponse(TDblQue& aCommandQueue, TUint aId, RBuf8& aData) + { + LOG_FUNC + + TDblQueIter iter(aCommandQueue); + CControlCommand* command = NULL; + + while (iter) + { + command = iter++; + if(command->RemConCommandId() == aId) + { + TInt err = command->ProcessOutgoingResponse(iObserver, aData, *iFragmenter); + + if(command->Frame().Type() == AVC::ENotify) + { + // If the interim response was successful then create a new command + // to contain the final response when it arrives. The same command + // cannot be re-used as we may not have finished sending this before + // we get the final response. We won't have both the commands on + // the handling queue at one time though, so there is no ambiguity + // about which is which. We finish handling the interim response here. + if(err == KErrNone) + { + // Try creating the CControlCommand which will be used for the + // final response to the Notify. If it fails then we will just + // reject the notify straight away. + // + // To start with we set its AV/C frame to be an Interim response, + // since this will match the AV/C frame of the original CControlCommand + // once we send the interim response later in this function. + CControlCommand* finalResponse = NULL; + TRAP(err, finalResponse = command->InterimResponseL()); + + if(err == KErrNone) + { + finalResponse->IncrementUsers(); + aCommandQueue.AddLast(*finalResponse); + } + } + + if(err != KErrNone && command->NormalCommand()) + { + // If we had an unsuucessful interim response, we need to remove the command from remcon + iObserver.CommandExpired(aId); + } + } + + Respond(*command, err); + HandledCommand(*command); + break; // Exit while (iter) loop + } + } + + // Either we have created a response which took ownership of aData, or + // we didn't match a command, so this was a response to something we've + // already removed from our queue. We're telling RemCon that we dealt ok + // with this so we have resonsibility for tidying up the data. + aData.Close(); + } + +TBool CRcpIncomingCommandHandler::DuplicateNotify(TDblQue& aCommandQueue, const CControlCommand& aCommand) const + { + TUid interfaceUid = aCommand.RemConInterfaceUid(); + TUint operationId = aCommand.RemConOperationId(); + + CControlCommand* command = NULL; + TDblQueIter iter(aCommandQueue); + TInt count = 0; + TBool duplicate = EFalse; + + while(iter) + { + command = iter++; + if((interfaceUid == command->RemConInterfaceUid())&&(operationId == command->RemConOperationId())) + { + count++; + // this should be a reject if we've already got a notification outstanding + if(count > 1) + { + duplicate = ETrue; + break; + } + } + } + + return duplicate; + } + +CControlCommand* CRcpIncomingCommandHandler::FindNotify(TDblQue& aCommandQueue, TUid aInterfaceUid, TUint aOperationId) + { + CControlCommand* command = NULL; + TDblQueIter iter(aCommandQueue); + TBool found = EFalse; + + while(iter) + { + command = iter++; + + if((command->RemConInterfaceUid() == aInterfaceUid)&&(command->RemConOperationId() == aOperationId)) + { + found = ETrue; + break; + } + } + + return found ? command : NULL; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpoutgoingcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpoutgoingcommandhandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,768 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include + +#include "avcpanel.h" +#include "controlcommand.h" +#include "avrcpoutgoingcommandhandler.h" +#include "avrcplog.h" +#include "avrcprouter.h" +#include "avrcptimer.h" +#include "avrcputils.h" +#include "controlbearer.h" + +//--------------------------------------------------------------------- +// Construction/Destruction +//--------------------------------------------------------------------- + +/** Factory function. + +@param aBearer The CRemConBearerAvrcp this is to handle commands for. +@param aObserver The observer of the bearer. Used to aquire converters. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aTimer CDeltaTimer to use for queuing timed events. +@return A fully constructed CRcpOutgoingCommandHandler. +@leave System wide error codes. +*/ +CRcpOutgoingCommandHandler* CRcpOutgoingCommandHandler::NewL(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer) + { + LOG_STATIC_FUNC + CRcpOutgoingCommandHandler* handler = new(ELeave)CRcpOutgoingCommandHandler(aBearer, aObserver, aRouter, aTimer); + return handler; + } + +/** Constructor. + +@param aBearer The CRemConBearerAvrcp this is to handle commands for. +@param aObserver The observer of the bearer. Used to aquire converters. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aTimer CDeltaTimer to use for queuing timed events. +@return A partially constructed CRcpIncomingCommandHandler. +@leave System wide error codes. +*/ +CRcpOutgoingCommandHandler::CRcpOutgoingCommandHandler(CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CRcpRouter& aRouter, + CDeltaTimer& aTimer) : iCommandQueue(_FOFF(CControlCommand, iHandlingLink)), + iNotifyCommandQueue(_FOFF(CControlCommand, iHandlingLink)), + iBearer(aBearer), iObserver(aObserver), iRouter(aRouter), iTimer(aTimer) + { + LOG_FUNC + } + +/** Destructor. +*/ +CRcpOutgoingCommandHandler::~CRcpOutgoingCommandHandler() + { + LOG_FUNC + + ClearQueue(iCommandQueue); + ClearQueue(iNotifyCommandQueue); + } + +void CRcpOutgoingCommandHandler::ClearQueue(TDblQue& aQue) + { + while(!aQue.IsEmpty()) + { + CControlCommand* command = aQue.First(); + command->CancelTimer(iTimer); + command->iHandlingLink.Deque(); + command->DecrementUsers(); + } + } +//--------------------------------------------------------------------- +// Called from the bearer +//--------------------------------------------------------------------- + +/** Tell the handler to gracefully shutdown. + +@param aClearQueue Whether to clear the queue without handling the things + on it. If this is true the commands will be deleted. + If this is false then pending commands will have responses + generated to RemCon. +*/ +void CRcpOutgoingCommandHandler::Disconnect(TBool aClearQueue) + { + LOG_FUNC + ProcessDisconnect(iCommandQueue, aClearQueue); + ProcessDisconnect(iNotifyCommandQueue, aClearQueue); + } + +void CRcpOutgoingCommandHandler::ProcessDisconnect(TDblQue& aQue, TBool aClearQueue) + { + while(!aQue.IsEmpty()) + { + CControlCommand* command = aQue.First(); + iRouter.RemoveFromSendQueue(*command); + command->CancelTimer(iTimer); + + if(aClearQueue) + { + GenerateFailureResult(*command, KErrDisconnected); + } + + command->iHandlingLink.Deque(); + command->DecrementUsers(); + } + } +/** Sends a new command. + +@param aInterfaceUid The RemCon client interface this command is from. +@param aCommand The operation id within aInterfaceUid. +@param aId A unique identifier provided by RemCon. +@param aCommandData Data associated with this command. +@param aAddr Bluetooth address of device to send this command to. +@leave KErrNoMemory or system wide error code. +@leave Command parsing error. +*/ +void CRcpOutgoingCommandHandler::SendCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr) + { + LOG_FUNC + + if(aInterfaceUid.iUid == KRemConCoreApiUid) + { + // Passthrough commands are stateful, so we need to examine the + // history - we can't just blindly wham it on the queue. + HandleCoreApiCommandL(aCommand, aId, aCommandData, aAddr); + } + else + { + SendCommandL(aInterfaceUid, aCommand, aId, aCommandData, EFalse, aAddr, ETrue, EFalse); + } + } + +/** Sends a new notify command. + +@param aInterfaceUid The RemCon client interface this command is from. +@param aCommand The operation id within aInterfaceUid. +@param aId A unique identifier provided by RemCon, the transaction ID. +@param aCommandData Data associated with this command. +@param aAddr Bluetooth address of device to send this command to. +@leave KErrNoMemory or system wide error code. +@leave Command parsing error. +*/ +void CRcpOutgoingCommandHandler::SendNotifyCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr) + { + LOG_FUNC + SendCommandL(aInterfaceUid, aCommand, aId, aCommandData, EFalse, aAddr, ETrue, ETrue); + } + +//--------------------------------------------------------------------- +// Data notifications from the router +//--------------------------------------------------------------------- + +/** Called by the router to provide a new response. + +@param aFrame The AV/C frame for this response. Ownership is taken. +@param aTransLabel The AVCTP transaction id of this response. This is used + to match it with its command. +@param aAddr The remote from which this response originated +*/ +void CRcpOutgoingCommandHandler::ReceiveResponse(const TDesC8& aMessageInformation, + SymbianAvctp::TTransactionLabel aTransLabel, + TBool aIpidBitSet) + { + LOG_FUNC + + CAVCFrame* frame = NULL; + TInt err = KErrNone; + if(!aIpidBitSet) + { + TRAP(err, frame = CAVCFrame::NewL(aMessageInformation, AVC::EResponse)); + } + + if(!err) + { + CControlCommand* command = NULL; + command = FindInQueue(iCommandQueue, aTransLabel); + if ( command != NULL ) + { + //Found, so it is a normal command response. + ProcessReceiveResponse(frame, aIpidBitSet, command, EFalse); + } + else + { + //Try to find in the notify command queue. + command = FindInQueue(iNotifyCommandQueue, aTransLabel); + if( command != NULL ) + { + //Found, so it is a notify command response. + ProcessReceiveResponse(frame, aIpidBitSet, command, ETrue); + } + } + + delete frame; + } + } + +CControlCommand* CRcpOutgoingCommandHandler::FindInQueue(TDblQue& aQue, + SymbianAvctp::TTransactionLabel aTransLabel) + { + CControlCommand* command = NULL; + TDblQueIter iter(aQue); + while (iter) + { + command = iter++; + if(command->TransactionLabel() == aTransLabel) + { + return command; + } + } + + return NULL; + } + +void CRcpOutgoingCommandHandler::ProcessReceiveResponse(CAVCFrame* aFrame, + TBool aIpidBitSet, + CControlCommand* aCommand, + TBool aNotify) + { + aCommand->CancelTimer(iTimer); + + TInt err = KErrNone; + // Inform the bearer if this is something it knows about + // ie not a click release + if(aCommand->KnownToBearer()) + { + if(!aIpidBitSet) + { + if(aFrame->Data().Length() < KAVCFrameHeaderLength) + { + // Drop corrupt frames + return; + } + + err = aCommand->ParseIncomingResponse(iObserver, *aFrame); + } + else + { + // If aIpidBitSet is true that means AVRCP is not supported + // by the remote end. We handle this in the same way as not + // supported commands, passing them up to RemCon as not + // supported, so just map the ctype here, rather than setting + // up another path for ipid handling, but we need pass as the + // frame the original because we don't get one from AVCTP if + // ipid is set. + aCommand->SetResponseType(KErrNotSupported); + err = aCommand->ParseIncomingResponse(iObserver, aCommand->Frame()); + } + + if ( aNotify ) + {//This is a notify command + iBearer.MrccciNewNotifyResponse(*aCommand); + } + else + { + iBearer.MrccciNewResponse(*aCommand); + } + } + + TBool doDeque = ETrue; + if ( (!aIpidBitSet) && (err == KErrNone) && (aNotify) && (aFrame->Type() == AVC::EInterim)) + { + doDeque = EFalse; + } + + // If this a passthrough press that hasn't yet been released, we need + // to wait for a release before getting rid of this, otherwise we're done. + if(aCommand == iUnreleasedCommand) + { + iUnreleasedHasResponse = ETrue; + StartReleaseTimer(*iUnreleasedCommand); + doDeque = EFalse; + } + + if ( doDeque ) + { + aCommand->iHandlingLink.Deque(); + aCommand->DecrementUsers(); + } + } +/** Called by the router to complete a send. + +@param aCommand The command which has been sent. +@param aSendResult The result of the send. KErrNone if successful. +*/ +void CRcpOutgoingCommandHandler::MessageSent(CAvrcpCommand& aCommand, TInt aSendResult) + { + LOG_FUNC + + if(aSendResult == KErrNone) + { + // Set off response timer + StartResponseTimer(static_cast(aCommand)); + } + else + { + CControlCommand* command = FindInQueue(iNotifyCommandQueue, aCommand.TransactionLabel()); + + if(command) + { + command->SetNotifyVolumeChangeResult(command->Frame()); + iBearer.MrccciNewNotifyResponse(*command); + } + else + { + command = FindInQueue(iCommandQueue, aCommand.TransactionLabel()); + + // Generate error response up to RemCon + // if this is a core command we can set the result, + // otherwise we just return it as we got it. + if(command->Frame().Opcode() == AVC::EPassThrough) + { + // Need to insert before setting the button action so we have + // long enough data + if (!command->InsertCoreResult(aSendResult)) + { + if(command->Click()) + { + command->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue); + } + } + } + + iBearer.MrccciNewResponse(*command); + } + + command->iHandlingLink.Deque(); + command->DecrementUsers(); + } + } + +//--------------------------------------------------------------------- +// Internal Utility functions +//--------------------------------------------------------------------- + +void CRcpOutgoingCommandHandler::CleanupUnreleased() + { + iUnreleasedCommand->CancelTimer(iTimer); + iUnreleasedCommand->iHandlingLink.Deque(); + iUnreleasedCommand->DecrementUsers(); + iUnreleasedHasResponse = EFalse; + } + +/** Handle a command that is part of the Core API. + +@param aCommand The operation id within aInterfaceUid. +@param aId A unique identifier provided by RemCon. +@param aCommandData Data associated with this command. +@param aAddr Bluetooth address of device to send this command to. +@leave KErrNoMemory or system wide error code. +@leave Command parsing error. +*/ +void CRcpOutgoingCommandHandler::HandleCoreApiCommandL(TUint aCommand, + TUint aId, + RBuf8& aCommandData, + const TBTDevAddr& aAddr) + { + if(aCommandData.Length() < KRemConCoreApiButtonDataLength) + { + User::Leave(KErrCorrupt); + } + + TInt buttonData; + AvrcpUtils::ReadCommandDataToInt(aCommandData, + KRemConCoreApiButtonDataOffset, KRemConCoreApiButtonDataLength, buttonData); + + // First check if there's anything we need to do before sending this command, + // mainly releasing a previous press. + if(iUnreleasedCommand) + { + TUint prevOpId = iUnreleasedCommand->RemConOperationId(); + + if(aCommand == prevOpId) + { + // Either we've received a release, or we've refreshed the press. + // If the unreleased press has already been responded too we can + // dispose of it now. + // If the unreleased press has not been responded too we can + // treat it like a normal command on reception of response, so just + // set iUnreleased to NULL. + if(iUnreleasedHasResponse) + { + CleanupUnreleased(); + } + + iUnreleasedCommand = NULL; + } + else + { + // A new operation! + if(buttonData != ERemConCoreApiButtonRelease) + { + // Try and generate the release for the previous command, if + // if fails then the remote will just have to assume it. + // There's no point leaving this to the release timer, because + // we want to send another command now, so even if we send the + // release later the remote should ignore it. + TRAP_IGNORE(GenerateCommandL(*iUnreleasedCommand, ERemConCoreApiButtonRelease)); + + if(iUnreleasedHasResponse) + { + CleanupUnreleased(); + } + + iUnreleasedCommand = NULL; + } + else + { + // A release for a command other than iUnreleased. We can't + // send this now. + User::Leave(KErrNotReady); + } + } + } + else if(buttonData == ERemConCoreApiButtonRelease) + { + // We don't have an unreleased command. We must have already + // released this, either via the timer, or because we've sent + // another command in the meantime. We can't send this now. + // Leaving synchronously means we don't need to worry about generating + // a fake response, which may mislead the application. + User::Leave(KErrNotReady); + } + + if(buttonData == ERemConCoreApiButtonClick) + { + // aCommandData is still owned by RemCon until we return successfully. + // If we try the operations with the new data first we won't end up + // in a situation where the new CControlCommand thinks that it owns + // aCommandData, then the release operation leaves, so RemCon also + // thinks it owns aCommandData. + + RBuf8 pressBuf; + pressBuf.CreateL(aCommandData); + CleanupClosePushL(pressBuf); + + AvrcpUtils::SetCommandDataFromInt(pressBuf, + KRemConCoreApiButtonDataOffset, KRemConCoreApiButtonDataLength, ERemConCoreApiButtonPress); + SendCommandL(TUid::Uid(KRemConCoreApiUid), aCommand, aId, pressBuf, ETrue, aAddr, ETrue, EFalse); + + // Data has been taken ownership of by SendCommandL, so can just let + // pressbuf go out of scope. + CleanupStack::Pop(&pressBuf); + + AvrcpUtils::SetCommandDataFromInt(aCommandData, + KRemConCoreApiButtonDataOffset, KRemConCoreApiButtonDataLength, ERemConCoreApiButtonRelease); + SendCommandL(TUid::Uid(KRemConCoreApiUid), aCommand, aId, aCommandData, ETrue, aAddr, EFalse, EFalse); + } + else if(buttonData == ERemConCoreApiButtonPress) + { + iUnreleasedCommand = &SendCommandL(TUid::Uid(KRemConCoreApiUid), aCommand, aId, aCommandData, EFalse, aAddr, ETrue, EFalse); + iReleaseTimerExpiryCount = 0; + } + else + { + // Must be release + __ASSERT_DEBUG(buttonData == ERemConCoreApiButtonRelease, AvrcpUtils::Panic(EAvrcpUnknownButtonAction)); + SendCommandL(TUid::Uid(KRemConCoreApiUid), aCommand, aId, aCommandData, EFalse, aAddr, ETrue, EFalse); + } + } + +/** Creates a command from the RemCon data. + +This is an internal utility function. + +A CControlCommand will be created. Calling ProcessOutgoingCommandL on +this creates a CAVCFrame from the provided data. If an AV/C frame +can be created the command will be added to the outgoing queue to +wait a response from the remote. Otherwise this function will +leave. + +@param aInterfaceUid The RemCon client interface this command is from. +@param aCommand The operation id within aInterfaceUid. +@param aId A unique identifier provided by RemCon. +@param aCommandData Data associated with this command. +@param aIsClick Whether this is a button click. +@param aAddr Bluetooth address of device to send this command to. +@return The generated command. +@leave KErrNoMemory or system wide error code. +@leave Command parsing error. +*/ +CControlCommand& CRcpOutgoingCommandHandler::SendCommandL(TUid aInterfaceUid, + TUint aCommand, + TUint aId, + RBuf8& aCommandData, + TBool aIsClick, + const TBTDevAddr& aAddr, + TBool aKnownToBearer, + TBool aNotify) + { + LOG_FUNC + // Create a command and wham it on our queue, so we can match it up with its response + // CControlCommand::NewL takes ownership of the data in aCommandData then NULLs aCommandData + // so a leave later in the function won't cause double deletion. + CControlCommand* command = CControlCommand::NewL(aInterfaceUid, aCommand, aId, iCurrentTrans, + aCommandData, aIsClick, aAddr, aKnownToBearer); + CleanupStack::PushL(command); + + command->ProcessOutgoingCommandL(iObserver); + CleanupStack::Pop(command); + command->IncrementUsers(); + + if ( aNotify ) + { + iNotifyCommandQueue.AddLast(*command); + } + else + { + iCommandQueue.AddLast(*command); + } + + // Increment our transaction id + iCurrentTrans = (iCurrentTrans + 1) % SymbianAvctp::KMaxTransactionLabel; + + // Command stays on the queue till we've got the response + iRouter.AddToSendQueue(*command); + + return *command; + } + +/** Generate a failure response to RemCon. + +This sets the result for a passthrough command. +It informs the bearer of the new response. + +@param aCommand The command to finish off. +@param aResult The result (only valid for passthrough) +*/ +void CRcpOutgoingCommandHandler::GenerateFailureResult(CControlCommand& aCommand, TInt aResult) + { + // Response is only necessary if the bearer knows about this command. + if(aCommand.KnownToBearer() && (aCommand.Frame().Opcode() == AVC::EPassThrough)) + { + if (aCommand.InsertCoreResult(aResult) == KErrNone) + { + if(aCommand.Click()) + { + aCommand.SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue); + } + else if(aCommand.ButtonAct() == AVCPanel::EButtonPress) + { + aCommand.SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue); + } + else + { + aCommand.SetCoreButtonAction(ERemConCoreApiButtonRelease, ETrue); + } + + iBearer.MrccciNewResponse(aCommand); + } + } + } + +/** Generate a command to the remote. + +This is needed in situations where the application has not met the avrcp +button refresh requirements so we need to internally generate something +to stop the remote getting a bad impression of us. + +@param aCommand The command to be issue again. +*/ +void CRcpOutgoingCommandHandler::GenerateCommandL(CControlCommand& aCommand, TRemConCoreApiButtonAction aButtonAct) + { + LOG_FUNC + + RBuf8 commandData; + commandData.CreateMaxL(KRemConCoreApiButtonDataLength); + + AvrcpUtils::SetCommandDataFromInt(commandData, + KRemConCoreApiButtonDataOffset, KRemConCoreApiButtonDataLength, aButtonAct); + + // This will not leave before taking ownership of commandData. + SendCommandL(aCommand.RemConInterfaceUid(), aCommand.RemConOperationId(), aCommand.RemConCommandId(), commandData, EFalse, + aCommand.RemoteAddress(), EFalse, EFalse); + } + +//------------------------------------------------------------------------------------ +// Timer functions +//------------------------------------------------------------------------------------ + +/** Starts the response timer. + +AVRCP mandates a remote respond within 100ms of receiving a command. +This is the timer for that, and is started when a command has +successfully been sent. + +@param aCommand The command to start the timer for. +*/ +void CRcpOutgoingCommandHandler::StartResponseTimer(CControlCommand& aCommand) + { + LOG_FUNC + // These use placement new, so cannot fail + TAvrcpTimerExpiryInfo* timerInfo = new(aCommand.TimerExpiryInfo())TAvrcpTimerExpiryInfo(this, aCommand); + + TCallBack callback(ResponseExpiry, timerInfo); + TDeltaTimerEntry* timerEntry = new(aCommand.TimerEntry())TDeltaTimerEntry(callback); + + iTimer.Queue(KRcpResponseTimeOut, *timerEntry); + } + +/** Callback when response timer expires. + +This is a static forwarding function. + +@param aExpiryInfo The information used by the real ResponseExpiry to + deal with the timer expiry. +*/ +TInt CRcpOutgoingCommandHandler::ResponseExpiry(TAny* aExpiryInfo) + { + LOG_STATIC_FUNC + TAvrcpTimerExpiryInfo *timerInfo = reinterpret_cast(aExpiryInfo); + (reinterpret_cast(timerInfo->iHandler))->ResponseExpiry(timerInfo->iCommand); + + return KErrNone; + } + +/** Deals with response timeout. + +This sends a timeout response to RemCon. + +@param aCommand The CControlCommand that has expired. +*/ +void CRcpOutgoingCommandHandler::ResponseExpiry(CControlCommand& aCommand) + { + LOG_FUNC + + GenerateFailureResult(aCommand, KErrTimedOut); + + // Failed to get a response to this, don't bother about trying + // to release it. + if(iUnreleasedCommand == &aCommand) + { + iUnreleasedCommand = NULL; + __ASSERT_DEBUG(!iUnreleasedHasResponse, AvrcpUtils::Panic(EAvrcpPressHasPhantomResponse)); + } + + aCommand.iHandlingLink.Deque(); + aCommand.DecrementUsers(); + } + +/** Starts the release timer. + +AVRCP requires a press to be refreshed less than 2s after the first +press, if it is not to be assumed to have been released. We pass +this requirement on to RemCon clients as we don't know when they might +go away and we don't want to keep buttons pressed forever. If the +release timer expires we will assume a release, and generate it to +the remote. + +@param aCommand The command to start the timer for. +*/ +void CRcpOutgoingCommandHandler::StartReleaseTimer(CControlCommand& aCommand) + { + LOG_FUNC + + // These cannot fail as we use placement new + TAvrcpTimerExpiryInfo* timerInfo = new(aCommand.TimerExpiryInfo())TAvrcpTimerExpiryInfo(this, aCommand); + + TCallBack callback(ReleaseExpiry, timerInfo); + TDeltaTimerEntry* timerEntry = new(aCommand.TimerEntry())TDeltaTimerEntry(callback); + + iTimer.Queue(KRcpOutgoingButtonReleaseTimeout, *timerEntry); + } + +/** Callback when release timer expires. + +This is a static forwarding function. + +@param aExpiryInfo The information used by the real ReleaseExpiry to + deal with the timer expiry. +*/ +TInt CRcpOutgoingCommandHandler::ReleaseExpiry(TAny* aExpiryInfo) + { + LOG_STATIC_FUNC + TAvrcpTimerExpiryInfo *timerInfo = reinterpret_cast(aExpiryInfo); + (reinterpret_cast(timerInfo->iHandler))->ReleaseExpiry(timerInfo->iCommand); + + return KErrNone; + } + +/** Deals with expiry of release timer. + +1) Generate release for this command. +2) Send release to remote. + +@param aCommand The CControlCommand that has expired. +*/ +void CRcpOutgoingCommandHandler::ReleaseExpiry(CControlCommand& aCommand) + { + LOG_FUNC + __ASSERT_DEBUG((aCommand.ButtonAct() == AVCPanel::EButtonPress), AvrcpUtils::Panic(EAvrcpReleaseExpiryForRelease)); + __ASSERT_DEBUG(&aCommand == iUnreleasedCommand, AvrcpUtils::Panic(EAvrcpReleaseExpiryForOldCommand)); + __ASSERT_DEBUG(iUnreleasedHasResponse, AvrcpUtils::Panic(EAvrcpReleaseTimerStartedWithoutResponse)); + + iReleaseTimerExpiryCount++; + + TBool commandCompleted = ETrue; + // If the client is not yet obliged to refresh this, then send another press. Otherwise generate + // the release for them. + if((iReleaseTimerExpiryCount * KRcpOutgoingButtonReleaseTimeout) < KRemConCoreApiPressRefreshInterval) + { + // This will try and generate a press that is identical to the original + // aCommand, but with a new AVCTP transaction id. + TRAPD(err, GenerateCommandL(aCommand, ERemConCoreApiButtonPress)); + + if(!err) + { + // Start the timer again on the original command + StartReleaseTimer(aCommand); + commandCompleted = EFalse; + } + } + else + { + // Try an generate a release, but if it fails we just have to let the + // remote assume it. + TRAP_IGNORE(GenerateCommandL(aCommand, ERemConCoreApiButtonRelease)); + } + + // This condition may be true because + // - we have failed to generate a press, in which case the remote is entitled + // to assume this is released, so we just give up on it. + // or + // - the client has not met its press refresh obligation (whether we've + // successfully generated a release or not. + // In either case we won't do anything more with this command. + if(commandCompleted) + { + aCommand.iHandlingLink.Deque(); + aCommand.DecrementUsers(); + + iUnreleasedCommand = NULL; + iUnreleasedHasResponse = EFalse; + iReleaseTimerExpiryCount = 0; + } + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpplayerinfomanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpplayerinfomanager.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,780 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include // for AVCTP protocol version +#include // for PSM values +#include +#include +#include + +#include "avrcp.h" +#include "avrcpplayerinfomanager.h" +#include "avrcpsdputils.h" +#include "playerbitmasks.h" +#include "avrcputils.h" +#include "avrcplog.h" +#include "mediabrowse.h" +#include "nowplaying.h" +#include "playerinformation.h" +#include "remcongroupnavigation.h" + +#ifdef _DEBUG +PANICCATEGORY("playerinfo"); +#endif // _DEBUG + +static TBool PlayerCompare(const TRemConClientId* aId, const TAvrcpMediaPlayerItem& aItem) + { + LOG_STATIC_FUNC + return (aId && *aId == aItem.iId); + } + +CAvrcpPlayerInfoManager* CAvrcpPlayerInfoManager::NewL(MRemConBearerObserver& aObserver, MRemConCommandInterface& aCommandInterface) + { + LOG_STATIC_FUNC + CAvrcpPlayerInfoManager* info = new(ELeave) CAvrcpPlayerInfoManager(aObserver); + CleanupStack::PushL(info); + info->ConstructL(aCommandInterface); + CleanupStack::Pop(info); + return info; + } + +void CAvrcpPlayerInfoManager::ConstructL(MRemConCommandInterface& aCommandInterface) + { + LOG_FUNC + LEAVEIFERRORL(iLock.CreateLocal()); + LEAVEIFERRORL(iSdp.Connect()); + LEAVEIFERRORL(iSdpDatabase.Open(iSdp)); + + iPlayStatusWatcher = CPlayStatusWatcher::NewL(*this, aCommandInterface); + + TCallBack cb(PlayerUpdateCallBack, this); + iControlThreadCallBack.Create(cb, CActive::EPriorityStandard); + iControlThreadCallBack.Start(); + } + +CAvrcpPlayerInfoManager::~CAvrcpPlayerInfoManager() + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iLock.Wait();// serialise access... + iLock.Close(); + delete iPlayStatusWatcher; + ASSERT_DEBUG(!iUidWatcher); // created in bulk thread context... + iControlThreadCallBack.Close(); + iObservers.Close(); + iPlayers.Close(); + iSdpDatabase.Close(); + iSdp.Close(); + } + +CAvrcpPlayerInfoManager::CAvrcpPlayerInfoManager(MRemConBearerObserver& aObserver) + : iControlBearerObserver(aObserver) + { + LOG_FUNC + } + +/** +This function sets up the handling in the bulk thread. This involves creating the +player state watcher, which maintains an up to date view of the UID counter values +for each player with a bulk interface. It does this by acting as an internal +command handler. The bulk bearer expects the player info manager to provide it +with a command handling interface for commands on internal interfaces, so we provide +it with the interface for the state watcher, which is where all our internal commands +come from. +*/ +MIncomingCommandHandler* CAvrcpPlayerInfoManager::BulkStartedL(MRemConCommandInterface& aCommandInterface) + { + LOG_FUNC; + ASSERT_BULK_THREAD; + + iUidWatcher = CUidWatcher::NewL(*this, aCommandInterface); + return iUidWatcher; + } + +void CAvrcpPlayerInfoManager::BulkStopped() + { + LOG_FUNC; + ASSERT_BULK_THREAD; + delete iUidWatcher; + iUidWatcher = NULL; + } + +void CAvrcpPlayerInfoManager::ClientAvailable(const TRemConClientId& aId, TPlayerType aClientType, TPlayerSubType aClientSubType, const TDesC8& aName) + { + LOG_FUNC; + ASSERT_CONTROL_THREAD; + iLock.Wait(); + // Add this to our client list, using any holes in the client id array + TInt index = NextPlayerIndex(); + if(index < 0) + { + // Couldn't allocate memory to store this player, remote will just + // have to make do with the current set + iLock.Signal(); + return; + } + + TAvrcpMediaPlayerItem& item = iPlayers[index]; + item.iId = aId; + item.iPlayerType = aClientType; + item.iPlayerSubType = aClientSubType; + item.iName.Set(aName); + item.iBulkClientAvailable = EFalse; + item.iUidCounter = 0; + item.iLastUpdatedUidCounter = 0; + item.iPlaybackStatus = MPlayerEventsObserver::EStopped; + item.iFeatureBitmask = TPlayerFeatureBitmask(); + TInt err = SetPlayerFeatures(aId, item.iFeatureBitmask, item.iSdpFeatures, item.iAbsoluteVolumeSupport); + + // Release lock before calling out of player info manager in case + // anyone needs to call back in - we're finished updating the + // info now. + iLock.Signal(); + + if(!err) + { + TRAP(err, iPlayStatusWatcher->StartWatchingPlayerL(aId)); + + if(!err) + { + // Update SDP record, if this fails we carry on, it's non-fatal + TInt sdpErr = KErrNone; + if(!iTargetRecord) + { + TRAP(sdpErr, AvrcpSdpUtils::CreateServiceRecordL(iSdpDatabase, + iTargetRecord, + ETrue, + (item.iSdpFeatures & AvrcpSdp::EBrowsing) ? + AvrcpSdp::KAvrcpProfileVersion14 : + AvrcpSdp::KAvrcpProfileVersion13)); + } + + if(sdpErr == KErrNone) + { + TRAP_IGNORE(UpdateTgServiceRecordL()); + } + } + } + + + + if(!err) + { + for(TInt i = 0; iMpcoAvailablePlayersChanged(); + } + } + else + { + iLock.Wait(); + iPlayers[index].iId = KNullClientId; + iLock.Signal(); + } + } + +void CAvrcpPlayerInfoManager::ClientNotAvailable(const TRemConClientId& aId) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iLock.Wait(); + TInt index = iPlayers.Find(aId, PlayerCompare); + if(index < 0) + { + // May not be here if we couldn't allocate memory to store this + // when we were first told about it + iLock.Signal(); + return; + } + + iPlayStatusWatcher->StopWatchingPlayer(aId); + iPlayers[index].iId = KNullClientId; + + //Release lock as soon as we've stopped fiddling + iLock.Signal(); + + for(TInt i = 0; iMpcoAvailablePlayersChanged(); + } + + // Don't put requirement on ordering of ClientNotAvailable/ClientStatus calls + if(iTargetRecord) + { + TRAP_IGNORE(UpdateTgServiceRecordL()); + } + } + +void CAvrcpPlayerInfoManager::ClientStatus(TBool aControllerPresent, TBool aTargetPresent) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + // SDP only used in the control thread + + //If we have gone from 1->0 on either of these we can remove the record now, + // otherwise wait for more detail on ClientAvailable or ControllerFeaturesUpdatedL + if(!aControllerPresent && iControllerRecord) + { + iSdpDatabase.DeleteRecord(iControllerRecord); + iControllerRecord = 0; + } + + if(!aTargetPresent && iTargetRecord) + { + iSdpDatabase.DeleteRecord(iTargetRecord); + iTargetRecord = 0; + } + } + +TInt CAvrcpPlayerInfoManager::SetLocalAddressedClient(const TRemConClientId& aId) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + + TUint16 playerId = 0; + TRAPD(err, playerId = PlayerL(aId)); + static_cast(playerId==playerId); // We only want to check if the bearer knows about the client. + if(err == KErrNone) + { + for(TInt i = 0; iMpcoAddressedPlayerChangedLocally(aId); + } + } + + return err; + } + +void CAvrcpPlayerInfoManager::ControllerFeaturesUpdatedL(RArray& aSupportedInterfaces) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + // SDP only used in the control thread + + TUint16 avrcpVersion = AvrcpSdp::KAvrcpProfileVersion13; + TUint16 avctpVersion = AvrcpSdp::KAvctpProtocolVersion12; + + if(aSupportedInterfaces.Find(TUid::Uid(KRemConAbsoluteVolumeControllerApiUid)) >= 0) + { + avrcpVersion = AvrcpSdp::KAvrcpProfileVersion14; + avctpVersion = AvrcpSdp::KAvctpProtocolVersion13; + } + + if(!iControllerRecord) + { + AvrcpSdpUtils::CreateServiceRecordL(iSdpDatabase, iControllerRecord, EFalse, avrcpVersion); + AvrcpSdpUtils::UpdateBrowseListL(iSdpDatabase, iControllerRecord); + } + + AvrcpSdpUtils::UpdateProtocolDescriptorListL(iSdpDatabase, iControllerRecord, avctpVersion); + AvrcpSdpUtils::UpdateProfileDescriptorListL(iSdpDatabase, iControllerRecord, avrcpVersion); + AvrcpSdpUtils::UpdateSupportedFeaturesL(iSdpDatabase, iControllerRecord, AvrcpSdp::ERemoteControl, AvrcpSdp::KAvrcpBaseCtFeatures); + } + +MIncomingCommandHandler& CAvrcpPlayerInfoManager::InternalCommandHandler() + { + LOG_FUNC + ASSERT_CONTROL_THREAD + + return *iPlayStatusWatcher; + } + +void CAvrcpPlayerInfoManager::BulkClientAvailable(const TRemConClientId& aId) + { + LOG_FUNC + ASSERT_BULK_THREAD + iLock.Wait(); + TInt index = iPlayers.Find(aId, PlayerCompare); + if(index < 0) + { + iLock.Signal(); + return; + } + ASSERT(!iPlayers[index].iBulkClientAvailable); + + TRAPD(err, iUidWatcher->StartWatchingPlayerL(aId)); + + if(!err) + { + iPlayers[index].iBulkClientAvailable = ETrue; + } + + iLock.Signal(); + } + +void CAvrcpPlayerInfoManager::BulkClientNotAvailable(const TRemConClientId& aId) + { + LOG_FUNC + ASSERT_BULK_THREAD + iLock.Wait(); + TInt index = iPlayers.Find(aId, PlayerCompare); + if(index >= 0) + { + ASSERT(iPlayers[index].iBulkClientAvailable); + iPlayers[index].iBulkClientAvailable = EFalse; + } + iLock.Signal(); + iUidWatcher->StopWatchingPlayer(aId); + } + +void CAvrcpPlayerInfoManager::AddObserverL(MPlayerChangeObserver& aObserver) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iObservers.AppendL(&aObserver); + } + +void CAvrcpPlayerInfoManager::RemoveObserver(MPlayerChangeObserver& aObserver) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + TInt index = iObservers.Find(&aObserver); + if(index >= 0) + { + iObservers.Remove(index); + } + } + +TRemConClientId CAvrcpPlayerInfoManager::ClientL(TUint16 aAvrcpPlayerId) const + { + LOG_FUNC + // THREAD - Bulk and Control + + iLock.Wait(); + CleanupSignalPushL(iLock); + + TRemConClientId clientId = KNullClientId; + if(ValidPlayer(aAvrcpPlayerId)) + { + clientId = iPlayers[aAvrcpPlayerId].iId; + } + else + { + LEAVEL(KErrNotFound); + } + + CleanupStack::PopAndDestroy(&iLock); + + return clientId; + } + +TRemConClientId CAvrcpPlayerInfoManager::Client(TUint16 aAvrcpPlayerId) const + { + LOG_FUNC + // THREAD - Bulk and Control + + iLock.Wait(); + + TRemConClientId clientId = KNullClientId; + __ASSERT_DEBUG(ValidPlayer(aAvrcpPlayerId), AvrcpUtils::Panic(EInvalidPlayerId)); + + clientId = iPlayers[aAvrcpPlayerId].iId; + + iLock.Signal(); + return clientId; + } + +TUint16 CAvrcpPlayerInfoManager::PlayerL(const TRemConClientId& aClientId) const + { + LOG_FUNC + // THREAD - Bulk and Control + + iLock.Wait(); + + TUint16 player = 0; + TBool found = EFalse; + for(TInt i = 0; i < iPlayers.Count(); i++) + { + if(PlayerCompare(&aClientId, iPlayers[i])) + { + player = i; + found = ETrue; + } + } + + iLock.Signal(); + + if(!found) + { + LEAVEL(KErrNotFound); + } + + return player; + } + +TInt CAvrcpPlayerInfoManager::PlayerListing(TUint aStartItem, TUint aEndItem, RArray& aPlayers) + { + LOG_FUNC + ASSERT_BULK_THREAD + + if(aStartItem > aEndItem) + { + return KErrArgument; + } + + iLock.Wait(); + if(aStartItem >= iPlayers.Count()) + { + iLock.Signal(); + return KErrArgument; + } + + TInt err = KErrNone; + for(TUint i = aStartItem; i <= aEndItem && i < iPlayers.Count() && err == KErrNone; i++) + { + if(iPlayers[i].iId != KNullClientId) + { + err = aPlayers.Append(i); + } + } + + iLock.Signal(); + return err; + } + +TInt CAvrcpPlayerInfoManager::PlayerListing(RArray& aPlayers) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iLock.Wait(); + TInt err = KErrNone; + for(TInt i = 0; i < iPlayers.Count() && err == KErrNone; i++) + { + if(iPlayers[i].iId != KNullClientId) + { + err = aPlayers.Append(i); + } + } + + iLock.Signal(); + return err; + } + +void CAvrcpPlayerInfoManager::MediaPlayerItemL(const TUint16& aAvrcpPlayerId, RMediaPlayerItem& aItem) + { + LOG_FUNC + ASSERT_BULK_THREAD + iLock.Wait(); + CleanupSignalPushL(iLock); + + if(ValidPlayer(aAvrcpPlayerId)) + { + aItem.iType = AvrcpBrowsing::EMediaPlayer; + aItem.iPlayerId = aAvrcpPlayerId; + aItem.iPlayerType = iPlayers[aAvrcpPlayerId].iPlayerType; + aItem.iPlayerSubType = iPlayers[aAvrcpPlayerId].iPlayerSubType; + aItem.iPlayStatus = iPlayers[aAvrcpPlayerId].iPlaybackStatus; + aItem.iFeatureBitmask = iPlayers[aAvrcpPlayerId].iFeatureBitmask.FeatureBitmask(); + aItem.iCharset = KUtf8MibEnum; + aItem.iNameLength = iPlayers[aAvrcpPlayerId].iName.Length(); + // Takes a copy of media player name + aItem.iName.CreateL(iPlayers[aAvrcpPlayerId].iName); + + aItem.iLength = 28 + aItem.iNameLength; + } + else + { + LEAVEL(KErrNotFound); + } + + CleanupStack::PopAndDestroy(&iLock); + } + +TBool CAvrcpPlayerInfoManager::ValidPlayer(const TUint16& aAvrcpPlayerId) const + { + LOG_FUNC + + if(aAvrcpPlayerId >= iPlayers.Count() || iPlayers[aAvrcpPlayerId].iId == KNullClientId) + { + return EFalse; + } + else + { + return ETrue; + } + } + +TInt CAvrcpPlayerInfoManager::NextPlayerIndex() + { + LOG_FUNC + + TRemConClientId nullId = KNullClientId; + TInt index = iPlayers.Find(nullId, PlayerCompare); + + if(index < 0) + { + // No gaps to fill, add another item to the player list + TAvrcpMediaPlayerItem item; + TInt err = iPlayers.Append(item); + if(!err) + { + index = iPlayers.Count() - 1; + } + } + + return index; + } + +void CAvrcpPlayerInfoManager::MuoUidChanged(TRemConClientId aId, TUint16 aUidCounter) + { + LOG_FUNC; + ASSERT_BULK_THREAD + iLock.Wait(); + TInt index = iPlayers.Find(aId, PlayerCompare); + if(index >= 0) + { + iPlayers[index].iUidCounter = aUidCounter; + } + iLock.Signal(); + + iControlThreadCallBack.CallBack(); + } + +void CAvrcpPlayerInfoManager::MuoError(TRemConClientId aId) + { + // Narg. Tell everyone we can't use this player anymore + BulkClientNotAvailable(aId); + } + +void CAvrcpPlayerInfoManager::MpsoPlayStatusChanged(TRemConClientId aId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iLock.Wait(); + TInt index = iPlayers.Find(aId, PlayerCompare); + if(index >= 0) + { + iPlayers[index].iPlaybackStatus = static_cast(aPlaybackStatus); + } + iLock.Signal(); + } + +void CAvrcpPlayerInfoManager::MpsoError(TRemConClientId aId) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iLock.Wait(); + TInt index = iPlayers.Find(aId, PlayerCompare); + if(index >= 0) + { + iPlayers[index].iPlaybackStatus = MPlayerEventsObserver::EError; + } + iLock.Signal(); + } + +TUint16 CAvrcpPlayerInfoManager::UidCounterL(const TRemConClientId& aClientId) const + { + LOG_FUNC + ASSERT_CONTROL_THREAD + iLock.Wait(); + CleanupSignalPushL(iLock); + TUint16 uidCounter = KErrNone; + TInt index = iPlayers.Find(aClientId, PlayerCompare); + if(index < 0) + { + LEAVEL(KErrNotFound); + } + uidCounter = iPlayers[index].iUidCounter; + CleanupStack::PopAndDestroy(&iLock); + return uidCounter; + } + +TInt CAvrcpPlayerInfoManager::SetPlayerFeatures(const TRemConClientId& aId, TPlayerFeatureBitmask& aBitmask, TUint8& aSdpFeatures, TBool& aAbsoluteVolumeSupported) + { + LOG_FUNC + ASSERT_CONTROL_THREAD + + TInt err; + RArray operations; + + aAbsoluteVolumeSupported = EFalse; + aSdpFeatures = 0; + err = iControlBearerObserver.SupportedOperations(aId, TUid::Uid(KRemConCoreApiUid), operations); + if(!err) + { + aBitmask.SetCoreApiFeatures(operations); + } + else if(err != KErrNotSupported) + { + operations.Close(); + return err; + } + + err = iControlBearerObserver.SupportedOperations(aId, TUid::Uid(KRemConPlayerInformationUid), operations); + if(!err) + { + aSdpFeatures |= AvrcpSdp::EPlayer; + } + else if(err != KErrNotSupported) + { + operations.Close(); + return err; + } + + err = iControlBearerObserver.SupportedOperations(aId, TUid::Uid(KRemConGroupNavigationApiUid), operations); + if(!err) + { + aSdpFeatures |= AvrcpSdp::EGroupNavigation; + aBitmask.SetGroupNavigationApiFeatures(operations); + } + else if(err != KErrNotSupported) + { + return err; + } + + err = iControlBearerObserver.SupportedOperations(aId, TUid::Uid(KRemConAbsoluteVolumeTargetApiUid), operations); + if(!err) + { + aBitmask.SetAbsoluteVolumeApiFeatures(operations); + aAbsoluteVolumeSupported = ETrue; + } + else if(err != KErrNotSupported) + { + operations.Close(); + return err; + } + + err = iControlBearerObserver.SupportedOperations(aId, TUid::Uid(KRemConNowPlayingApiUid), operations); + if(!err) + { + aBitmask.SetNowPlayingApiFeatures(operations); + } + else if(err != KErrNotSupported) + { + operations.Close(); + return err; + } + + err = iControlBearerObserver.SupportedOperations(aId, TUid::Uid(KRemConMediaBrowseApiUid), operations); + if(!err) + { + aSdpFeatures |= AvrcpSdp::EBrowsing; + aBitmask.SetMediaBrowseApiFeatures(operations); + } + + operations.Close(); + return err == KErrNotSupported ? KErrNone : err; + } + +void CAvrcpPlayerInfoManager::UpdateTgServiceRecordL() + { + LOG_FUNC + ASSERT_CONTROL_THREAD + + TUint16 features = AvrcpSdp::KAvrcpBaseTgFeatures; + for(TInt i=0; iMpcoUidCounterChanged(clientId); + } + } + } + } + } + +TBool CAvrcpPlayerInfoManager::AbsoluteVolumeSupportedL(const TRemConClientId& aClientId) const + { + LOG_FUNC + ASSERT_CONTROL_THREAD + + iLock.Wait(); + CleanupSignalPushL(iLock); + + TInt index = iPlayers.Find(aClientId, PlayerCompare); + if(index < 0) + { + LEAVEL(KErrNotFound); + } + TBool supported = iPlayers[index].iAbsoluteVolumeSupport; + + CleanupStack::PopAndDestroy(&iLock); + + return supported; + } + +TBool CAvrcpPlayerInfoManager::BrowsingSupportedL(const TRemConClientId& aClientId) const + { + LOG_FUNC + ASSERT_CONTROL_THREAD + + iLock.Wait(); + CleanupSignalPushL(iLock); + + TInt index = iPlayers.Find(aClientId, PlayerCompare); + if(index < 0) + { + LEAVEL(KErrNotFound); + } + TBool supported = iPlayers[index].iSdpFeatures & AvrcpSdp::EBrowsing; + + CleanupStack::PopAndDestroy(&iLock); + + return supported; + } + +TInt CAvrcpPlayerInfoManager::PlayerUpdateCallBack(TAny* aPlayerInfoMgr) + { + static_cast(aPlayerInfoMgr)->UidCounterUpdate(); + return KErrNone; + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpremotedevice.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpremotedevice.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,129 @@ +// Copyright (c) 2004-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 "avrcpincomingcommandhandler.h" +#include "avrcpoutgoingcommandhandler.h" +#include "avrcpremotedevice.h" + +#include "avrcplog.h" + +/** Factory function. + +@param aAddr The remote device this manages transactions with. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aBearer The CRemConBearerAvrcp this is to handle commands for. +@param aObserver The observer of the bearer. Used to acquire converters. +@param aTimer CDeltaTimer to use for queuing timed events. +@return A fully constructed CRcpRemoteDevice. +@leave System wide error codes. +*/ +CRcpRemoteDevice* CRcpRemoteDevice::NewL(const TBTDevAddr& aAddr, + CRcpRouter& aRouter, + CRemConBearerAvrcp& aBearer, + MRemConBearerObserver& aObserver, + CDeltaTimer& aTimer, + CAvrcpPlayerInfoManager& aPlayerInfoManager) + { + LOG_STATIC_FUNC + CRcpRemoteDevice* engine = new(ELeave) CRcpRemoteDevice(aAddr, aRouter, aBearer, aTimer); + CleanupStack::PushL(engine); + engine->ConstructL(aObserver, aPlayerInfoManager); + CleanupStack::Pop(engine); + return engine; + } + +/** Constructor. + +@param aAddr The remote device this manages transactions with. +@param aRouter A CRcpRouter to use for communication with remote devices. +@param aBearer The CRemConBearerAvrcp this is to handle commands for. +@param aObserver The observer of the bearer. Used to acquire converters. +@param aTimer CDeltaTimer to use for queuing timed events. +@return A partially constructed CRcpRemoteDevice. +@leave System wide error codes. +*/ +CRcpRemoteDevice::CRcpRemoteDevice(const TBTDevAddr& aAddr, + CRcpRouter& aRouter, + CRemConBearerAvrcp& aBearer, + CDeltaTimer& aTimer) : + iDevice(aAddr), iRouter(aRouter), iBearer(aBearer), iTimer(aTimer) + { + LOG_FUNC + } + +/** Second phase construction. + +@param aObserver An observer to pass the handlers to allow them to + acquire converters. +*/ +void CRcpRemoteDevice::ConstructL(MRemConBearerObserver& aObserver, + CAvrcpPlayerInfoManager& aPlayerInfoManager) + { + LOG_FUNC + iIncoming = CRcpIncomingCommandHandler::NewL(iBearer, aObserver, iRouter, iTimer, aPlayerInfoManager, iDevice); + iOutgoing = CRcpOutgoingCommandHandler::NewL(iBearer, aObserver, iRouter, iTimer); + } + +/** Destructor. +*/ +CRcpRemoteDevice::~CRcpRemoteDevice() + { + LOG_FUNC + delete iIncoming; + delete iOutgoing; + } + +/** Stop handling for this remote device. + +@param aClearQueue Whether the outgoing queue should be cleared. +*/ +void CRcpRemoteDevice::Disconnect(TBool aClearQueue) + { + LOG_FUNC + iIncoming->Disconnect(); + iOutgoing->Disconnect(aClearQueue); + } + +/** Get the remote address of this device. + +@return the remote address of this device. +*/ +const TBTDevAddr& CRcpRemoteDevice::RemoteAddress() const + { + LOG_FUNC + return iDevice; + } + +/** Get the incoming handler for this device. + +@return The incoming handler for this device. +*/ +MIncomingCommandHandler& CRcpRemoteDevice::IncomingHandler() const + { + LOG_FUNC + return *iIncoming; + } + +/** Get the outgoing handler for this device. + +@return The outgoing handler for this device. +*/ +MOutgoingCommandHandler& CRcpRemoteDevice::OutgoingHandler() const + { + LOG_FUNC + return *iOutgoing; + } + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcprouter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcprouter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,499 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include + +#include "avrcpcommand.h" +#include "avrcplog.h" +#include "avrcprouter.h" +#include "avrcputils.h" +#include "commandhandlerinterface.h" + +using namespace SymbianAvctp; + +/** Constructor. + +@param aRemotes The list of remote devices known to AVRCP. +@param aBearer The bearer. +@return A partially constructed CRcpRouter. +*/ +CRcpRouter::CRcpRouter(MAvrcpBearer& aBearer) + : iChannel(NULL) + , iBearer(aBearer) + , iSendQueue(_FOFF(CAvrcpCommand, iSendLink)) + , iState(EAvrcpRouterCanSend) + { + LOG_FUNC + } + +/** Destructor. +*/ +CRcpRouter::~CRcpRouter() + { + LOG_FUNC + // The lifetime of the Router is the same as that of the bearer plugin. + // This means that there is no point worrying about the stuff on our + // send queue as we won't be around to pass the results up to RemCon. + while (!iSendQueue.IsEmpty()) + { + CAvrcpCommand *command = iSendQueue.First(); + command->iSendLink.Deque(); + command->DecrementUsers(); + } + } + +//------------------------------------------------------------------ +// Data functions called from command handlers +//------------------------------------------------------------------ + +/** Adds command to send queue. + +This message will be sent as soon as the iAvcp becomes +free for sending, unless the command is removed before +then. + +@param aCommand The command to send. +@see CRcpRouter::RemoveFromSendQueue +*/ +void CRcpRouter::AddToSendQueue(CAvrcpCommand& aCommand) + { + LOG_FUNC + + __ASSERT_ALWAYS(!aCommand.iSendLink.IsQueued(), AVRCP_PANIC(ECommandAlreadyQueuedForSending)); + + iSendQueue.AddLast(aCommand); + aCommand.IncrementUsers(); + + if(iState == EAvrcpRouterCanSend) + { + Send(); + } + } + +/** Remove command from send queue. + +@param aCommand The command that is not to be sent. +*/ +void CRcpRouter::RemoveFromSendQueue(CAvrcpCommand& aCommand) + { + LOG_FUNC + + if(iSendQueue.IsFirst(&aCommand)) + { + // If this is at the front of the queue it's currently being + // sent. Cancel that and start off the next thing. + iChannel->MacCancelSend(); + aCommand.iSendLink.Deque(); + iState = EAvrcpRouterCanSend; + if(!iSendQueue.IsEmpty()) + { + Send(); + } + } + else + { + // Still waiting to be sent so we can just sneak it out of + // the queue. + aCommand.iSendLink.Deque(); + } + } + +//------------------------------------------------------------------ +// Control functions called from bearer +//------------------------------------------------------------------ + +/** Try to bring up an explicit connection to a remote. + +@param aAddr The address of the remote. +@return System wide error. KErrNone if this request will be + attempted, and generate a ConnectConfirm. +*/ +TInt CRcpRouter::ConnectRequest(const TBTDevAddr& aAddr) + { + LOG_FUNC + return iChannel->MacAttachRequest(aAddr); + } + +/** Try to bring down an explicit connection to a remote. + +@param aAddr The address of the remote. +@return System wide error. KErrNone if the disconnect will be + attempted, and generate a DisconnectConfirm. +*/ +TInt CRcpRouter::DisconnectRequest(const TBTDevAddr& aAddr) + { + LOG_FUNC + return iChannel->MacDetachRequest(aAddr); + } + +//------------------------------------------------------------------ +// MAvctpEventNotify functions called from RAvctp +//------------------------------------------------------------------ + +/** AVCTP Connection Indicate. + +This is called when a remote device has connected +to us. NB we don't return the configuration status as +in Appendix A - AVCTP Upper Interface of [R2]. If aAccept +is not changed the connection will be refused however +this may not result in the actual disconnection of the +device if another RAvctp client did accept the connection. + +@param aBTDevice the address of the device connected to +@param aAccept this parameter is provided so that the client + of RAvctp can indicate whether they want to accept the + connection. The meaning of a refusal is that you don't + care whether or not the connection is there or not. +@see RAvctp +*/ +void CRcpRouter::MaenAttachIndicate(const TBTDevAddr& aBTDevice, TInt aMtu, TBool& aAccept) + { + LOG_FUNC + aAccept = ETrue; + + // if we have already received data from this device we will have + // informed RemCon about it already, so don't pass up the connection + // now + if(!iBearer.IncomingHandler(aBTDevice)) + { + iBearer.ConnectIndicate(aBTDevice); + } + + MIncomingCommandHandler* handler = iBearer.IncomingHandler(aBTDevice); + if(handler) + { + handler->MaxPacketSize(aMtu); + aAccept = ETrue; + } + else + { + aAccept = EFalse; + } + } + +/** AVCTP Connection Confirm. + +This is a response to RAvctp::ConnectRequest and passes on the +result of the Connection attempt. NB we don't return the +configuration status as in Appendix A - AVCTP Upper +Interface of [R2]. If the aConnectResult is KErrNone +then iAvctp is now connected. + +@param aBTDevice the address of the device connected to +@param aConnectResult connection result - one of the + system-wide error codes. +@see RAvctp +*/ +void CRcpRouter::MaenAttachConfirm(const TBTDevAddr& aBTDevice, TInt aMtu, TInt aConnectResult) + { + LOG_FUNC + iBearer.ConnectConfirm(aBTDevice, aConnectResult); + + MIncomingCommandHandler* handler = iBearer.IncomingHandler(aBTDevice); + if(handler) + { + handler->MaxPacketSize(aMtu); + } + } + +/** AVCTP Disconnection Indication. + +Indicates that a remote device has disconnected from us. +It is only called if the device had been explicitly Connected to. + +@param aBTDevice the address of the disconnecting device +@see RAvctp +*/ +void CRcpRouter::MaenDetachIndicate(const TBTDevAddr& aBTDevice) + { + LOG_FUNC + iBearer.DisconnectIndicate(aBTDevice); + } + +/** AVCTP Disconnection Confirm. + +@param aBTDevice the address of the disconnected device +@param aDisconnectResult will be one of the system-wide + error codes. If KErrTimedOut is + returned then the RAvctp will be + disconnected. +@see RAvctp +*/ +void CRcpRouter::MaenDetachConfirm(const TBTDevAddr& aBTDevice, TInt aDisconnectResult) + { + LOG_FUNC + iBearer.DisconnectConfirm(aBTDevice, aDisconnectResult); + } + +/** AVCTP Message received indication. + +This method is called when a message has been received from +the given device on the RAvctp's PID. + +Note that because AVCTP is a connectionless protocol, it is +perfectly possible to get a MaenMessageReceivedIndicate event +from a device that you have not either explicitly connected to. +For instance even if you don't accept a MaenConnectIndicate +you may still receive messages from that remote device. + +@param aBTDevice address of the device sending us an AVCTP message +@param aTransactionLabel message transaction label +@param aType type of message +@param aIpidBitSet this will be set to true only if a message has been received indicating + that the profile corresponding to the originally sent message is not valid. + If RAvctp was used to send the message then this response will have come from + the remote device aBTDevice. +@param aMessageInformation contains only the AVCTP Command / Response Message Information and not the whole packet. + Ownership transferred to client. +@see RAvctp +*/ +void CRcpRouter::MaenMessageReceivedIndicate(const TBTDevAddr& aBTDevice, + SymbianAvctp::TTransactionLabel aTransactionLabel, + SymbianAvctp::TMessageType aType, + TBool aIpidBitSet, + const TDesC8& aMessageInformation) + { + LOG_FUNC + AVRCPLOG(aMessageInformation) + + // Find the right handler + if(aType == ECommand) + { + MIncomingCommandHandler* handler = iBearer.IncomingHandler(aBTDevice); + + if(!handler) + { + iBearer.ConnectIndicate(aBTDevice); + + handler = iBearer.IncomingHandler(aBTDevice); + } + + if(handler) + { + // If this leaves the handler is rejecting handling this command, just + // ignore it. + TRAP_IGNORE(handler->ReceiveCommandL(aMessageInformation, aTransactionLabel, aBTDevice)); + } + } + else + { + MOutgoingCommandHandler* handler = iBearer.OutgoingHandler(aBTDevice); + if(handler) + { + handler->ReceiveResponse(aMessageInformation, aTransactionLabel, aIpidBitSet); + } + } + } + +/** AVCTP Message send complete. + +This method is called when a RAvctp has attempted to send +the message defined by aTransactionLabel and aBTDevice. +@param aTransactionLabel The transaction label of the message + that has been sent +@param aBTDevice the device to which the send has completed +@param aSendResult KErrNone if the send was successful or one + of the system-wide error codes +@see RAvctp +*/ +void CRcpRouter::MaenMessageSendComplete(const TBTDevAddr& aBTDevice, + SymbianAvctp::TTransactionLabel aTransactionLabel, + TInt aSendResult) + { + LOG_FUNC + __ASSERT_ALWAYS(!iSendQueue.IsEmpty(), AvrcpUtils::Panic(EAvrcpNoOutstandingSend)); + + CAvrcpCommand* command = iSendQueue.First(); + + __ASSERT_ALWAYS(command->TransactionLabel() == aTransactionLabel, AvrcpUtils::Panic(EAvrcpUnknownAvctpTransId)); + + MAvrcpCommandHandler* handler = NULL; + if(command->MessageType() == ECommand) + { + handler = iBearer.OutgoingHandler(aBTDevice); + } + else + { + handler = iBearer.IncomingHandler(aBTDevice); + } + + if(handler) + { + handler->MessageSent(*command, aSendResult); + } + + // Deque before calling Decrement because Decrement handling may involve + // deleting command + command->iSendLink.Deque(); + command->DecrementUsers(); + + // Now able to do another send. Toggle our state and check if there + // are any commands waiting. + iState = EAvrcpRouterCanSend; + if(!iSendQueue.IsEmpty()) + { + Send(); + } + } + +/** AVCTP Close Complete. + +This is the response to the CloseGracefully() that has been +called on a RAvctp object. It is the last event that will be +called until the RAvctp object is Open()'d again. +@see RAvctp +*/ +void CRcpRouter::MaenCloseComplete() + { + LOG_FUNC + } + +/** AVCTP error notification. + +Note an errored device does not indicate that the device has +been disconnected. If it has then a MaenDisconnectIndicate +event will be used to indicate this. + +@param aBTDevice the remote device associated with the error or TBTDevAddr(0) for a general error +@param aError system wide error +@see RAvctp +*/ +void CRcpRouter::MaenErrorNotify(const TBTDevAddr& /*aBTDevice*/, TInt /*aError*/) + { + LOG_FUNC + } + +/** +Returns a null aObject if the extension is not implemented, +or a pointer to another interface if it is. + +@param aInterface UID of the interface to return +@param aObject system wide error +@see RAvctp +*/ +void CRcpRouter::MaenExtensionInterfaceL(TUid /*aInterface*/, void*& aObject) + { + LOG_FUNC + aObject = NULL; + } + +//------------------------------------------------------------------ +// Utility functions +//------------------------------------------------------------------ + +/** Issue a send to AVCTP. + +This sends the first message on the command queue. +*/ +void CRcpRouter::Send() + { + LOG_FUNC + __ASSERT_ALWAYS(!iSendQueue.IsEmpty(), AvrcpUtils::Panic(EAvrcpNoOutstandingSend)); + + CAvrcpCommand* command = iSendQueue.First(); + +#ifdef _DEBUG + TInt err = +#endif // _DEBUG + iChannel->MacSendMessage(command->RemoteAddress(), + command->TransactionLabel(), + command->MessageType(), + command->Data()); + + __ASSERT_DEBUG(err == KErrNone, AvrcpUtils::Panic(EAvrcpSendingMessageFailed)); + + iState = EAvrcpRouterSending; + } + +/** Factory funtion. + +@param aAvctp An open RAvctp instance. +@param aBearer The bearer. +@return A fully constructed CRcpRouter. +@leave System wide error codes. +*/ +CControlRouter* CControlRouter::NewL(RAvctp& aAvctp, MAvrcpBearer& aBearer) + { + LOG_STATIC_FUNC + CControlRouter* router = new(ELeave) CControlRouter(aAvctp, aBearer); + CleanupStack::PushL(router); + router->ConstructL(); + CleanupStack::Pop(router); + return router; + } + +CControlRouter::~CControlRouter() + { + LOG_FUNC + iAvctp.Close(RAvctp::ENormal); + } + +CControlRouter::CControlRouter(RAvctp& aAvctp, MAvrcpBearer& aBearer) + : CRcpRouter(aBearer) + , iAvctp(aAvctp) + { + LOG_FUNC + } + +void CControlRouter::ConstructL() + { + LOG_FUNC + LEAVEIFERRORL(iAvctp.Open(*this, KAvrcpPid, iChannel)); + } + +/** Factory funtion. + +@param aAvctp An open RAvctp instance. +@param aBearer The bearer. +@return A fully constructed CRcpRouter. +@leave System wide error codes. +*/ +CBulkRouter* CBulkRouter::NewL(RAvctp& aAvctp, MAvrcpBearer& aBearer) + { + LOG_STATIC_FUNC + CBulkRouter* router = new(ELeave) CBulkRouter(aAvctp, aBearer); + CleanupStack::PushL(router); + router->ConstructL(); + CleanupStack::Pop(router); + return router; + } + +CBulkRouter::~CBulkRouter() + { + LOG_FUNC + iAvctp.UninstallSecondaryChannel(); + } + +CBulkRouter::CBulkRouter(RAvctp& aAvctp, MAvrcpBearer& aBearer) + : CRcpRouter(aBearer) + , iAvctp(aAvctp) + { + LOG_FUNC + } + +void CBulkRouter::ConstructL() + { + LOG_FUNC + LEAVEIFERRORL(iAvctp.InstallSecondaryChannel(*this, iChannel)); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpsdputils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpsdputils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,152 @@ +// Copyright (c) 2008-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 "avrcpsdputils.h" + +void AvrcpSdpUtils::CreateServiceRecordL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TBool aTarget, TUint16 aProfileVersion) + { + if(!aTarget) + { + // New service record with service class attribute containing + // 0x110e (for A/V Remote Control) + CSdpAttrValueDES* serviceClassUuids = CSdpAttrValueDES::NewDESL(NULL); + CleanupStack::PushL(serviceClassUuids); + + if(aProfileVersion == AvrcpSdp::KAvrcpProfileVersion13) + { + serviceClassUuids->StartListL() + ->BuildDESL()->StartListL() + ->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID))) + ->EndListL() + ->EndListL(); + } + else + { + serviceClassUuids->StartListL() + ->BuildDESL()->StartListL() + ->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID))) + ->BuildUUIDL(TUUID(TUint16(KAVRemoteControlControllerUUID))) + ->EndListL() + ->EndListL(); + } + + aSdpDatabase.CreateServiceRecordL(*serviceClassUuids, aRecHandle); + CleanupStack::PopAndDestroy(serviceClassUuids); + + aSdpDatabase.UpdateAttributeL(aRecHandle, + KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, + AvrcpSdp::KAvrcpControllerServiceName + ); + } + else + { + // New service record with service class attribute containing + // 0x110c (for A/V Remote Control Target) + aSdpDatabase.CreateServiceRecordL(KAVRemoteControlTargetUUID, aRecHandle); + + aSdpDatabase.UpdateAttributeL(aRecHandle, + KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, + AvrcpSdp::KAvrcpTargetServiceName + ); + } + + aSdpDatabase.UpdateAttributeL(aRecHandle, + KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetProviderName, + AvrcpSdp::KAvrcpProviderName + ); + aSdpDatabase.UpdateAttributeL(aRecHandle, + KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription, + AvrcpSdp::KAvrcpServiceDescription + ); + } + +void AvrcpSdpUtils::UpdateProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProtocolVersion) + { + CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); + CleanupStack::PushL(attrValDES); + attrValDES->StartListL() + ->BuildDESL()->StartListL() + ->BuildUUIDL(TUUID(TUint16(KL2CAP))) // L2CAP + ->BuildUintL(TSdpIntBuf(KAVCTP)) // PSM = AVCTP + ->EndListL() + ->BuildDESL()->StartListL() + ->BuildUUIDL(TUUID(TUint16(KAVCTP))) // AVCTP + ->BuildUintL(TSdpIntBuf(aProtocolVersion)) + ->EndListL() + ->EndListL(); + aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES); + CleanupStack::PopAndDestroy(attrValDES); + } + +void AvrcpSdpUtils::UpdateAdditionalProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle) + { + CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); + CleanupStack::PushL(attrValDES); + attrValDES->StartListL() + ->BuildDESL()->StartListL() + ->BuildUUIDL(TUUID(TUint16(KL2CAP))) // L2CAP + ->BuildUintL(TSdpIntBuf(0x1b)) // PSM = AVCTP_browse + ->EndListL() + ->BuildDESL()->StartListL() + ->BuildUUIDL(TUUID(TUint16(KAVCTP))) // AVCTP + ->BuildUintL(TSdpIntBuf(AvrcpSdp::KAvctpProtocolVersion13))// 0x0103 + ->EndListL() + ->EndListL(); + aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdAdditionalProtocolDescriptorList, *attrValDES); + CleanupStack::PopAndDestroy(attrValDES); + } + +void AvrcpSdpUtils::UpdateBrowseListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle) + { + CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); + CleanupStack::PushL(attrValDES); + attrValDES->StartListL() + ->BuildUUIDL(TUUID(TUint16(KPublicBrowseGroupUUID))) // Public browse group + ->EndListL(); + aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES); + CleanupStack::PopAndDestroy(attrValDES); + } + +void AvrcpSdpUtils::UpdateProfileDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProfileVersion) + { + CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); + CleanupStack::PushL(attrValDES); + attrValDES->StartListL() + ->BuildDESL()->StartListL() + //In the profile descriptor list the Control UUID is used + //for BOTH controller and target + ->BuildUUIDL(KAVRemoteControlUUID) + ->BuildUintL(TSdpIntBuf(aProfileVersion)) + ->EndListL() + ->EndListL(); + aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBluetoothProfileDescriptorList, *attrValDES); + CleanupStack::PopAndDestroy(attrValDES); + } + +void AvrcpSdpUtils::UpdateSupportedFeaturesL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, AvrcpSdp::TRecordType aType, TUint16 aFeatures) + { + // Supported Features + // For both target and controller roles if we support that role then + // indicate support for all categories that are available within that + // role. + CSdpAttrValue* attrVal = NULL; + TSdpIntBuf featureBuf = (aType==AvrcpSdp::ERemoteControl) ? AvrcpSdp::KAvrcpBaseCtFeatures | aFeatures : AvrcpSdp::KAvrcpBaseTgFeatures | aFeatures; + attrVal = CSdpAttrValueUint::NewUintL(featureBuf); + CleanupStack::PushL(attrVal); + aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdSupportedFeatures, *attrVal); + CleanupStack::PopAndDestroy(attrVal); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcputils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcputils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,360 @@ +// Copyright (c) 2004-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 +#include +#include +#include "avrcplog.h" +#include "avrcputils.h" + +/** +@file +@internalComponent +@released +*/ + +/** Utility AVRCP panic function. + +@param aPanic The panic number. +*/ +void AvrcpUtils::Panic(TAvrcpPanic aPanic) + { + User::Panic(KAvrcpPanicName, aPanic); + } + + +/** Set the command data. This overwrites the current +contents of the data buffer. + +@param aCommandData The buffer in which to set the data. +@param aOffset The offset within aCommandData to set the data. +@param aLength The length of data to replace. +@param aValue The new value for the replaced data. +*/ +void AvrcpUtils::SetCommandDataFromInt(RBuf8& aCommandData, + TInt aOffset, TInt aLength, TInt aValue) + { + LOG_STATIC_FUNC + __ASSERT_DEBUG(aLength <= 4, Panic(EAvrcpCommandDataTooLong)); + + for(TInt i = 0; i < aLength; i++) + { + aCommandData[aOffset+i] = aValue >> (8*i); + } + } + +/** Reads command data from the buffer to an int. + +@param aCommandData The buffer from which to read the data. +@param aOffset The offset within aCommandData read from. +@param aLength The length of data to read. This must not be + more than 4. +@param aValue On return, the value of the specified data section. +*/ +void AvrcpUtils::ReadCommandDataToInt(const RBuf8& aCommandData, + TInt aOffset, TInt aLength, TInt& aValue) + { + LOG_STATIC_FUNC + __ASSERT_DEBUG(aLength <= 4, Panic(EAvrcpCommandDataTooLong)); + + aValue = 0; + + for(TInt i = 0 ; i < aLength; i++) + { + aValue |= aCommandData[aOffset+i]<<(8*i); + } + } + +/** Convert from a RemCon address to a bluetooth device address. + +@param aRemoteAddress The RemCon format address to convert. +@param aBTAddr On return, the bluetooth device address. +@return Whether the conversion could be performed successfully. +*/ +TInt AvrcpUtils::RemConToBTAddr(const TRemConAddress& aRemoteAddress, TBTDevAddr& aBTAddr) + { + LOG_STATIC_FUNC + TInt err = KErrArgument; + + // Check client has provided us a valid address + if(aRemoteAddress.Addr().Length() == KBTDevAddrSize) + { + aBTAddr = TBTDevAddr(aRemoteAddress.Addr()); + err = KErrNone; + } + else + { + __ASSERT_DEBUG(EFalse, AvrcpUtils::Panic(EAvrcpBadBTAddr)); + } + + return err; + } + +/** Convert from a bluetooth device address to a RemCon address. + +We assume this cannot fail, as bluetooth addresses are generated +internally rather than by a client, so they should always be +valid, and so convertible. + +@param aBTAddr The bluetooth device address to convert. +@param aRemoteAddress On return, the RemCon format address. +*/ +void AvrcpUtils::BTToRemConAddr(const TBTDevAddr& aBTAddr, TRemConAddress& aRemConAddress) + { + LOG_STATIC_FUNC + aRemConAddress.Addr() = aBTAddr.Des(); + aRemConAddress.BearerUid() = TUid::Uid(KRemConBearerAvrcpImplementationUid); + } + +NONSHARABLE_CLASS(CSpecificThreadCallBackBody) + : public CActive + { +public: + static CSpecificThreadCallBackBody* NewL(const TCallBack& aCallBack, TInt aPriority); + ~CSpecificThreadCallBackBody(); + + TInt Start(); + TInt CallBack(); + void HandleCancel(); + +private: + CSpecificThreadCallBackBody(const TCallBack& aCallBack, TInt aPriority); + void ConstructL(); + + TInt AsyncMessage(TInt aParam); + +private: // from CActive + void RunL(); + void DoCancel(); + +private: + TCallBack iCallBack; + + RThread iLocalThread; + + RMsgQueue iInbound; + RMsgQueue iOutbound; + }; + +RSpecificThreadCallBack::RSpecificThreadCallBack() + : iBody(NULL) + { + LOG_FUNC + } + +TInt RSpecificThreadCallBack::Create(const TCallBack& aCallBack, TInt aPriority) + { + TRAPD(err, iBody = CSpecificThreadCallBackBody::NewL(aCallBack, aPriority)); + return err; + } + +void RSpecificThreadCallBack::Close() + { + LOG_FUNC + delete iBody; + iBody = NULL; + } + +TInt RSpecificThreadCallBack::Start() + { + return iBody->Start(); + } + +TInt RSpecificThreadCallBack::CallBack() + { + return iBody->CallBack(); + } + +void RSpecificThreadCallBack::Cancel() + { + return iBody->HandleCancel(); + } + +CSpecificThreadCallBackBody* CSpecificThreadCallBackBody::NewL(const TCallBack& aCallBack, TInt aPriority) + { + CSpecificThreadCallBackBody* self = new(ELeave) CSpecificThreadCallBackBody(aCallBack, aPriority); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CSpecificThreadCallBackBody::CSpecificThreadCallBackBody(const TCallBack& aCallBack, TInt aPriority) + : CActive(aPriority) + , iCallBack(aCallBack) + { + LOG_FUNC + } + +void CSpecificThreadCallBackBody::ConstructL() + { + User::LeaveIfError(iInbound.CreateLocal(1)); + User::LeaveIfError(iOutbound.CreateLocal(1)); + } + +CSpecificThreadCallBackBody::~CSpecificThreadCallBackBody() + { + LOG_FUNC + HandleCancel(); + iInbound.Close(); + iOutbound.Close(); + iLocalThread.Close(); + } + +TInt CSpecificThreadCallBackBody::Start() + { + TInt err = KErrNone; + if(!IsAdded()) + { + err = iLocalThread.Duplicate(RThread()); + if(err == KErrNone) + { + CActiveScheduler::Add(this); + iInbound.NotifyDataAvailable(iStatus); + SetActive(); + } + } + return err; + } + +TInt CSpecificThreadCallBackBody::CallBack() + { + TInt err = KErrUnknown; + if(iLocalThread.Id() == RThread().Id()) + { + // Simple synchronous case. + err = iCallBack.CallBack(); + } + else + { + RThread thisThread; + err = thisThread.Duplicate(RThread()); + if(err == KErrNone) + { + err = AsyncMessage(thisThread.Handle()); + } + } + return err; + } + +TInt CSpecificThreadCallBackBody::AsyncMessage(TInt aParam) + { + TInt err = KErrNone; + TRequestStatus logonStatus; + iLocalThread.Logon(logonStatus); + if(logonStatus == KErrNoMemory) + { + // This seems kludgy, but I think it is the most reliable way. + User::WaitForRequest(logonStatus); // Ensure the all requests are correct... + err = KErrNoMemory; + } + else + { + iInbound.SendBlocking(aParam); + TRequestStatus status; + iOutbound.NotifyDataAvailable(status); + User::WaitForRequest(status, logonStatus); + if(status == KRequestPending) + { + // Remote thread is dead + iOutbound.CancelDataAvailable(); + User::WaitForRequest(status); + err = KErrDied; + } + else + { + // Success (the thread may have subsequently died, but we are only concerned with this call). + iLocalThread.LogonCancel(logonStatus); + User::WaitForRequest(logonStatus); + err = status.Int(); + if(err == KErrNone) + { + iOutbound.ReceiveBlocking(err); + } + } + } + return err; + } + + +void CSpecificThreadCallBackBody::RunL() + { + TInt threadHandle; + iInbound.ReceiveBlocking(threadHandle); + if(threadHandle == 0) + { + // 0 is a cancel message + // therefore don't do anything + iOutbound.SendBlocking(KErrNone); + } + else + { + RThread remoteThread; + remoteThread.SetHandleNC(threadHandle); + + TInt result = iCallBack.CallBack(); + + // There doesn't seem to be a safe way of handling when the other thread + // dies...... + iOutbound.SendBlocking(result); + + remoteThread.Close(); + + iInbound.NotifyDataAvailable(iStatus); + SetActive(); + } + } + +void CSpecificThreadCallBackBody::DoCancel() + { + if(RThread().Id() == iLocalThread.Id()) + { + iInbound.CancelDataAvailable(); + } + else + { + // other thread cancelling - so just complete the + // request + TRequestStatus* status = &iStatus; + User::RequestComplete(status, KErrCancel); + } + } + +void CSpecificThreadCallBackBody::HandleCancel() + { + if(IsAdded()) + { + if(RThread().Id() == iLocalThread.Id()) + { + Cancel(); // synchronous cancel is fine in same thread... + } + else + { + // In a different thread - this is more interesting... + TInt err = AsyncMessage(0); // 0 is special as it means cancel. + if(err == KErrDied && IsActive()) + { + // Remote thread has already died so we need to tidy up the + // active object ourselves. + Cancel(); + } + } + } + // else shouldn't be active... + } + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/browsecommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/browsecommand.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,285 @@ +// Copyright (c) 2004-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: +// avrcpcommands.cpp +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include +#include +#include +#include + +#include "browsecommand.h" +#include "avrcpinternalinterface.h" +#include "avrcplog.h" +#include "avrcputils.h" +#include "browsingframe.h" +#include "mediabrowse.h" +#include "nowplaying.h" + + +//--------------------------------------------------------------------- +// Incoming command construction +//--------------------------------------------------------------------- + +/** Factory function. + +@param aFrame The frame this command is to represent. +@param aRemConId The RemCon transaction label. +@param aTransLabel The AVCTP transaction label. +@param aAddr The bluetooth address to send this command to. +@return A fully constructed CBrowseCommand. +@leave System wide error codes. +*/ +CBrowseCommand* CBrowseCommand::NewL(const TDesC8& aMessageInformation, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + CAvrcpPlayerInfoManager* aPlayerInfoManager) + { + LOG_STATIC_FUNC + CBrowseCommand* command = new(ELeave)CBrowseCommand(aRemConId, aTransLabel, aAddr, aPlayerInfoManager); + CleanupStack::PushL(command); + command->ConstructL(aMessageInformation); + CleanupStack::Pop(command); + return command; + } + +/** Constructor. + +@param aFrame The AV/C frame this command is to represent. +@param aRemConId The RemCon transaction label. +@param aTransLabel The AVCTP transaction label. +@param aAddr The bluetooth address to send this command to. +@return A partially constructed CBrowseCommand. +@leave System wide error codes. +*/ +CBrowseCommand::CBrowseCommand(TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + CAvrcpPlayerInfoManager* aPlayerInfoManager) + : CAvrcpCommand(aRemConId, aTransLabel, aAddr) + { + LOG_FUNC + iPlayerInfoManager = aPlayerInfoManager; + } + +/** Destructor. +*/ +CBrowseCommand::~CBrowseCommand() + { + LOG_FUNC + __ASSERT_DEBUG(iUsers == 0, AvrcpUtils::Panic(EAvrcpCommandStillInUse)); + iFrame.Close(); + iCommandData.Close(); + } + +/** Second phase construction. +*/ +void CBrowseCommand::ConstructL(const TDesC8& aMessageInformation) + { + iFrame.CreateL(aMessageInformation); + } + +//------------------------------------------------------------------------------------ +// Called by router +//------------------------------------------------------------------------------------ + +SymbianAvctp::TMessageType CBrowseCommand::MessageType() const + { + return SymbianAvctp::EResponse; + } + +//------------------------------------------------------------------------------------ +// Called by handlers +//------------------------------------------------------------------------------------ + +/** Fills in command info from iFrame. + +This must be called by the command handler before processing this +command. + +This functions sets iInterfaceUid, iOperationId and iCommandData +to the correct values according to iFrame. The format of iCommandData +is defined by RemCon and is dependent on iInterfaceUid and iOperationId. + +@return KErrNone If the frame has been parsed successfully. +@return KErrNotSupported This frame represents a command for which a + RemCon converter or client side interface + cannot be found. +@return KErrAvrcpInvalidCType The CType specified in this frame is invalid. +@return KErrCorrupt If the frame is corrupted(e.g invalid Operation Id). +@return System wide error code. +*/ +TInt CBrowseCommand::ProcessIncomingCommandL(TInt aMaxResponse) + { + LOG_FUNC + TInt result = KErrNotSupported; + iMaxResponse = aMaxResponse-5; + + // This command has already been verified as containing at least a header + // and an accurate length field + switch(AvrcpBrowsing::BrowsingFrame::PduId(iFrame)) // PDU ID + { + case AvrcpBrowsing::ESetBrowsedPlayer: + { + result = HandleSetBrowsedPlayer(); + break; + } + case AvrcpBrowsing::EGetFolderItems: + { + result = HandleGetFolderItems(); + break; + } + case AvrcpBrowsing::EChangePath: + { + result = HandleChangePath(); + break; + } + case AvrcpBrowsing::EGetItemAttributes: + { + result = HandleGetItemAttributes(); + break; + } + case AvrcpBrowsing::ESearch: + { + result = HandleSearch(); + break; + } + case AvrcpBrowsing::EGeneralReject: + // We only support the target role for browsing, so we should + // never receive a General Reject + // fallthrough + default: + { + result = HandleUnknownPdu(); + } + }; + return result; + } + + +/** Processes an outgoing response. + +This should only be called for vendor dependent commands as +we respond to passthrough commands internally. + +@param aFrame The command data for the response. +*/ +void CBrowseCommand::ProcessOutgoingResponse(RBuf8& aCommandData) + { + __ASSERT_DEBUG(( (iInterfaceUid == TUid::Uid(KRemConMediaBrowseApiUid)) + || (iInterfaceUid == TUid::Uid(KRemConNowPlayingApiUid)) + || (iInterfaceUid == TUid::Uid(KUidAvrcpInternalInterface))), + AvrcpUtils::Panic(EAvrcpResponseToUnknownCommand)); + + iFrame.Close(); + iFrame.Assign(aCommandData); + TInt length = aCommandData.Length() - 3; + iFrame[1] = length >> 8; + iFrame[2] = length; + aCommandData.Assign(NULL); + } + +/** Set the response type in the AV/C frame. + +@param aErr The result of processing the operation. KErrNone if + successful. KErrNotsupported if this operation is not + implemented, eg because no converter was found. +*/ +void CBrowseCommand::SetResult(TInt aErr) + { + LOG_FUNC + switch(aErr) + { + case KErrNone: + break; + case KErrCorrupt: + case EAvrcpResponseToUnknownCommand: + case KErrAvrcpAirInvalidCommand: + case KErrAvrcpAirInvalidParameter: + case KErrAvrcpAirParameterNotFound: + case KErrAvrcpAirInternalError: + case KErrAvrcpAirSuccess: + case KErrAvrcpAirUidChanged: + case KErrAvrcpAirReserved: + case KErrAvrcpAirInvalidDirection: + case KErrAvrcpAirNotADirectory: + case KErrAvrcpAirDoesNotExist: + case KErrAvrcpAirInvalidScope: + case KErrAvrcpAirRangeOutOfBounds: + case KErrAvrcpAirUidIsADirectory: + case KErrAvrcpAirMediaInUse: + case KErrAvrcpAirNowPlayingListFull: + case KErrAvrcpAirSearchNotSupported: + case KErrAvrcpAirSearchInProgress: + case KErrAvrcpAirInvalidPlayerId: + case KErrAvrcpAirPlayerNotBrowesable: + case KErrAvrcpAirPlayerNotAddressed: + case KErrAvrcpAirNoValidSearchResults: + case KErrAvrcpAirNoAvailablePlayers: + case KErrAvrcpAirAddressedPlayerChanged: + case KErrAvrcpInvalidScope: + { + // If this fails we can't send the error response - just give up + TRAPD(err, GenerateRejectPayloadL(aErr)); + err = err; // Avoid warning about not using it. + break; + } + } + } + +/** Gets this command's frame. +@return the browse frame for this command +*/ +const TDesC8& CBrowseCommand::Data() const + { + LOG_FUNC + return iFrame; + } + +const TDesC8& CBrowseCommand::CommandData() const + { + LOG_FUNC + return iCommandData; + } + +void CBrowseCommand::GenerateRejectPayloadL(TInt aErr) + { + LOG_FUNC; + + TUint8 pduId = AvrcpBrowsing::BrowsingFrame::PduId(iFrame); + RRemConMediaErrorResponse errResponse; + errResponse.iPduId = pduId; + errResponse.iStatus = RAvrcpIPC::SymbianErrToStatus(aErr); + + RBuf8 frame; + frame.CreateL(KBrowseResponseBaseLength); + CleanupClosePushL(frame); + errResponse.WriteL(frame); + CleanupStack::Pop(&frame); + + iFrame.Close(); + iFrame.Assign(frame); + } + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/browsingframe.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/browsingframe.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +// Copyright (c) 2008-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 "browsingframe.h" + + +/** Verifies the length of a frame is correct. Checking: +1) Header is present +2) Data length indicated is present + +This does not semantically check that the data expected for +the PDU ID is present. + +@param aFrame The frame to verify +@leave KErrCorrupt if the length of the frame is incorrect +*/ +void AvrcpBrowsing::BrowsingFrame::VerifyFrameL(const TDesC8& aFrame) + { + if((aFrame.Length() < AvrcpBrowsing::KHeaderLength) || + (aFrame.Length() < (AvrcpBrowsing::KHeaderLength + ParamLength(aFrame)))) + { + User::Leave(KErrCorrupt); + } + } + + +/** Retreives the PDU ID from this frame. + +@pre The integrity of the frame must have been verified (@see + BrowsingFrame::VerifyFrameL) as the length is not checked + before retrieving the PDU ID. +@param aFrame The frame to retrieve the PDU ID for. +@return The PDU ID of aFrame +*/ +AvrcpBrowsing::TPduId AvrcpBrowsing::BrowsingFrame::PduId(const TDesC8& aFrame) + { + return aFrame[0]; + } + +/** Retreives the parameter length from this frame. + +@pre The integrity of the frame must have been verified (@see + BrowsingFrame::VerifyFrameL) as the length is not checked + before retrieving the parameter length. +@param aFrame The frame to retrieve the parameter length for. +@return The parameter length of aFrame +*/ +TInt AvrcpBrowsing::BrowsingFrame::ParamLength(const TDesC8& aFrame) + { + TInt paramLength = 0; + paramLength += aFrame[2]; + paramLength += ((TUint)aFrame[1]) << 8; + + return paramLength; + } + +/** Retreives the payload from this frame. + +@pre The integrity of the frame must have been verified (@see + BrowsingFrame::VerifyFrameL) as the length is not checked + before retrieving the payload. +@param aFrame The frame to retrieve the payload for. +@param aPayload On return the payload of aFrame +*/ +void AvrcpBrowsing::BrowsingFrame::Payload(const TDesC8& aFrame, TPtrC8& aPayload) + { + aPayload.Set(aFrame.Mid(AvrcpBrowsing::KHeaderLength, AvrcpBrowsing::BrowsingFrame::ParamLength(aFrame))); + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,363 @@ +// Copyright (c) 2008-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include +#include + +#include "avrcpbrowsingcommandhandler.h" +#include "avrcprouter.h" +#include "avrcputils.h" +#include "browsecommand.h" +#include "bulkbearer.h" +#include "playerstatewatcher.h" + +#include "avrcplog.h" + +#ifdef _DEBUG +PANICCATEGORY("avrcpbulk"); +#endif // _DEBUG + +CAvrcpBulkBearer* CAvrcpBulkBearer::NewL(RAvctp& aAvctp, CAvrcpPlayerInfoManager& aPlayerInfoManager) + { + LOG_STATIC_FUNC + CAvrcpBulkBearer* bulkBearer = new(ELeave) CAvrcpBulkBearer(aPlayerInfoManager, aAvctp); + return bulkBearer; + } + +CAvrcpBulkBearer::~CAvrcpBulkBearer() + { + LOG_FUNC + ASSERT_DEBUG(!iRouter); // Should already be stopped... + } + +CAvrcpBulkBearer::CAvrcpBulkBearer(CAvrcpPlayerInfoManager& aPlayerInfoManager, RAvctp& aAvctp) + : iPlayerInfoManager(aPlayerInfoManager) + , iAvctp(aAvctp) + , iReadyBrowseCommands(_FOFF(CAvrcpCommand, iReadyLink)) + { + LOG_FUNC + } + +MIncomingCommandHandler* CAvrcpBulkBearer::IncomingHandler(const TBTDevAddr& aAddr) + { + LOG_FUNC + + MIncomingCommandHandler* handler = NULL; + TInt ix = iBrowseHandlers.Find(aAddr, CAvrcpBulkBearer::CompareBrowsingCommandHandlerByBDAddr); + if(ix >= 0) + { + handler = iBrowseHandlers[ix]; + } + + return handler; + } + +MOutgoingCommandHandler* CAvrcpBulkBearer::OutgoingHandler(const TBTDevAddr& /*aAddr*/) + { + LOG_FUNC + // We've received a response, but we haven't sent a command. Naughty remote, + // just ignore it. + return NULL; + } + +void CAvrcpBulkBearer::DoConnectIndicateL(const TBTDevAddr& aBTDevice) + { + LOG_FUNC + ASSERT_BULK_THREAD; + + ASSERT_DEBUG(Operational()); + + CRcpBrowsingCommandHandler* handler = CRcpBrowsingCommandHandler::NewL(*this, *iRouter, iPlayerInfoManager, aBTDevice); + CleanupStack::PushL(handler); + + iBrowseHandlers.AppendL(handler); + + CleanupStack::Pop(handler); + } + +void CAvrcpBulkBearer::ConnectIndicate(const TBTDevAddr& aBTDevice) + { + LOG_FUNC + // If we failed to allocate a handler for this connection the router will + // not be able to find it when it checks, and will tell AVCTP that we're + // not interested in this connection. + TRAP_IGNORE(DoConnectIndicateL(aBTDevice)); + } + +void CAvrcpBulkBearer::ConnectConfirm(const TBTDevAddr& IF_FLOGGING(aBTDevice), TInt IF_FLOGGING(aError)) + { + LOG_FUNC + LOGBTDEVADDR(aBTDevice); + LOG1(_L("\taError = %d"), aError); + + // Outlandish! We did not ask for this! + __ASSERT_DEBUG(EFalse, AVRCP_PANIC(EAvrcpConnectConfirmOnBrowseChannel)); + } + +void CAvrcpBulkBearer::DisconnectIndicate(const TBTDevAddr& aBTDevice) + { + LOG_FUNC + ASSERT_BULK_THREAD; + + CRcpBrowsingCommandHandler* handler = NULL; + TInt ix = iBrowseHandlers.Find(aBTDevice, CAvrcpBulkBearer::CompareBrowsingCommandHandlerByBDAddr); + if(ix >= 0) + { + handler = iBrowseHandlers[ix]; + delete handler; + iBrowseHandlers.Remove(ix); + } + else + { + ASSERT_DEBUG(EFalse); + } + } + +void CAvrcpBulkBearer::DisconnectConfirm(const TBTDevAddr& IF_FLOGGING(aBTDevice), TInt IF_FLOGGING(aError)) + { + LOG_FUNC + LOGBTDEVADDR(aBTDevice); + LOG1(_L("\taError = %d"), aError); + + // Also outlandish! Connections on browse channel are all passive. + __ASSERT_DEBUG(EFalse, AVRCP_PANIC(EAvrcpDisconnectConfirmOnBrowseChannel)); + } + +void CAvrcpBulkBearer::MrcciNewCommand(CAvrcpCommand& aCommand) + { + LOG_FUNC + + DoNewCommand(aCommand, KNullClientId); + } + +// This overload is used when we want to address a stateless command that may +// be interleaved with commands from other controllers. The only command +// this is currently used for is the internal UidCounterUpdate command. +void CAvrcpBulkBearer::MrcciNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) + { + LOG_FUNC + // Verify that it's an internal command + __ASSERT_DEBUG(aCommand.RemoteAddress() == TBTDevAddr(0), AvrcpUtils::Panic(ESpecificAddressUsedForBrowsingCommand)); + + DoNewCommand(aCommand, aClientId); + } + +void CAvrcpBulkBearer::DoNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) + { + LOG_FUNC + + // Need to put the command on the queue straight + // away in case RemCon collects it synchronously + iReadyBrowseCommands.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + + TInt err = (aClientId == KNullClientId) ? iObserver->NewCommand(remAddr) : iObserver->NewCommand(remAddr, aClientId); + + if(err != KErrNone) + { + TUid interfaceUid; + TUint remconId, operationId; + RBuf8 commandData; + TBTDevAddr btAddr; + + // Calling GetCommandInfo transfers ownership of the command data. + aCommand.GetCommandInfo(interfaceUid, remconId, operationId, commandData, btAddr); + MrcbbiSendReject(interfaceUid, operationId, remconId, remAddr); + commandData.Close(); + + // RemCon is not going to pick this command up + aCommand.iReadyLink.Deque(); + aCommand.DecrementUsers(); + } + } + +TUint CAvrcpBulkBearer::MrcciNewTransactionId() + { + LOG_FUNC + return iObserver->NewTransactionId(); + } + +TInt CAvrcpBulkBearer::MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient) + { + LOG_FUNC + return iObserver->SetAddressedClient(aAddr, aClient); + } + +void CAvrcpBulkBearer::MrcbciRemoveAddressing(const TRemConAddress& aAddr) + { + LOG_FUNC + iObserver->RemoveAddressing(aAddr); + } + +TInt CAvrcpBulkBearer::MrcbbiGetCommand(TUid& aInterfaceUid, + TUint& aTransactionId, + TUint& aOperationId, + RBuf8& aData, + TRemConAddress& aAddr) + { + LOG_FUNC + TInt result = KErrNotFound; + + if(!iReadyBrowseCommands.IsEmpty()) + { + CAvrcpCommand* command = iReadyBrowseCommands.First(); + + // Calling GetCommandInfo transfers the command data to RemCon. This means + // once we have called it we are committed to returning KErrNone. + TBTDevAddr btAddr; + command->GetCommandInfo(aInterfaceUid, aTransactionId, aOperationId, aData, btAddr); + AvrcpUtils::BTToRemConAddr(btAddr, aAddr); + + // Remove command from queue first because calling + // DecrementUsers() may delete command + command->iReadyLink.Deque(); + command->DecrementUsers(); + result = KErrNone; + } + else + { + __DEBUGGER(); + } + + return result; + } + +TInt CAvrcpBulkBearer::MrcbbiSendResponse(TUid aInterfaceUid, + TUint /*aOperationId*/, + TUint aTransactionId, + RBuf8& aData, + const TRemConAddress& aAddr) + { + LOG_FUNC + TBTDevAddr btAddr; + TInt err = KErrNone; + + err = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + __ASSERT_DEBUG(err == KErrNone, AvrcpUtils::Panic(EInvalidBtAddrInResponse)); + + if(btAddr != TBTDevAddr(0)) + { + MIncomingCommandHandler* handler = IncomingHandler(btAddr); + __ASSERT_ALWAYS(handler, AVRCP_PANIC(EAvrcpNotConnected)); + + err = handler->SendRemConResponse(aInterfaceUid, aTransactionId, aData); + } + else + { + err = iInternalHandler->SendRemConResponse(aInterfaceUid, aTransactionId, aData); + } + + return err; + } + +void CAvrcpBulkBearer::MrcbbiSendReject(TUid aInterfaceUid, + TUint /*aOperationId*/, + TUint aTransactionId, + const TRemConAddress& aAddr) + { + LOG_FUNC + + TBTDevAddr btAddr; + TInt err = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + __ASSERT_DEBUG(err == KErrNone, AvrcpUtils::Panic(EInvalidBtAddrInResponse)); + + if(btAddr != TBTDevAddr(0)) + { + IncomingHandler(btAddr)->SendReject(aInterfaceUid, aTransactionId); + } + else + { + iInternalHandler->SendReject(aInterfaceUid, aTransactionId); + } + } + +TInt CAvrcpBulkBearer::MrcbbiStartBulk(MRemConBearerBulkObserver& aObserver) + { + LOG_FUNC + iObserver = &aObserver; + TRAPD(err, DoStartBulkL()); + if(err != KErrNone) + { + MrcbbiStopBulk(); + } + return err; + } + +void CAvrcpBulkBearer::DoStartBulkL() + { + LOG_FUNC + LEAVEIFERRORL(Dll::SetTls(reinterpret_cast(EBulkThread))); + iInternalHandler = iPlayerInfoManager.BulkStartedL(*this); + iRouter = CBulkRouter::NewL(iAvctp, *this); + } + +void CAvrcpBulkBearer::MrcbbiStopBulk() + { + LOG_FUNC + WEAK_ASSERT_BULK_THREAD; + + iPlayerInfoManager.BulkStopped(); + iInternalHandler = NULL; + + delete iRouter; + iRouter = NULL; + + iBrowseHandlers.ResetAndDestroy(); + + iObserver = NULL; // the observer is no longer valid. + + Dll::FreeTls(); + } + +TBool CAvrcpBulkBearer::Operational() const + { + LOG_FUNC + ASSERT_DEBUG(!iRouter == !iObserver); // internal consistency check + return !!iRouter; + } + +void CAvrcpBulkBearer::MrcbbiBulkClientAvailable(const TRemConClientId& aId) + { + LOG_FUNC + iPlayerInfoManager.BulkClientAvailable(aId); + } + +void CAvrcpBulkBearer::MrcbbiBulkClientNotAvailable(const TRemConClientId& aId) + { + LOG_FUNC + iPlayerInfoManager.BulkClientNotAvailable(aId); + } + + +TBool CAvrcpBulkBearer::CompareBrowsingCommandHandlerByBDAddr(const TBTDevAddr* aKey, const CRcpBrowsingCommandHandler& aHandler) + { + LOG_STATIC_FUNC + return aKey && aHandler.BtAddr() == *aKey; + } + + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/controlcommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/controlcommand.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1685 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent + @released +*/ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "controlcommand.h" +#include "avrcpcommandframer.h" +#include "avrcpfragmenter.h" +#include "avrcpinternalinterface.h" +#include "avrcpipc.h" +#include "avrcplog.h" +#include "avrcputils.h" +#include "avrcpincomingcommandhandler.h" +#include "avrcp.h" +#include "mediabrowse.h" +#include "mediainformation.h" +#include "nowplaying.h" +#include "playerinformation.h" +#include "remconbattery.h" +#include "remcongroupnavigation.h" + +//--------------------------------------------------------------------- +// Outgoing command construction +//--------------------------------------------------------------------- + +/** Factory function. + +@param aInterfaceUid The RemCon interface uid of this command. +@param aCommand The operation id of this command within the interface defined + by aInterface Uid. +@param aRemConId The RemCon transaction label. +@param aTransactionLabel The AVCTP transaction label. +@param aCommandData The RemCon command data associated with this command. +@param aIsClick Whether this command is a button click (ie RemCon believes + that this and the other part of the click constitute one + command. +@param aAddr The bluetooth address to send this command to. +@return A fully constructed CControlCommand. +@leave System wide error codes. +*/ +CControlCommand* CControlCommand::NewL(TUid aInterfaceUid, + TUint aCommand, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransactionLabel, + RBuf8& aCommandData, + TBool aIsClick, + const TBTDevAddr& aAddr, + TBool aKnownToBearer) + { + LOG_STATIC_FUNC + CControlCommand* command = new (ELeave) CControlCommand(aInterfaceUid, aCommand, + aRemConId, aTransactionLabel, aCommandData, aIsClick, aAddr, aKnownToBearer); + CleanupStack::PushL(command); + command->ConstructL(); + CleanupStack::Pop(command); + return command; + } + +/** Constructor. + +@param aInterfaceUid The RemCon interface uid of this command. +@param aCommand The operation id of this command within the interface defined + by aInterface Uid. +@param aRemConId The RemCon transaction label. +@param aTransactionLabel The AVCTP transaction label. +@param aCommandData The RemCon command data associated with this command. +@param aIsClick Whether this command is a button click (ie RemCon believes + that this and the other part of the click constitute one + command. +@param aAddr The bluetooth address to send this command to. +@return A constructed CControlCommand. +@leave System wide error codes. +*/ +CControlCommand::CControlCommand(TUid aInterfaceUid, + TUint aCommand, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransactionLabel, + RBuf8& aCommandData, + TBool aIsClick, + const TBTDevAddr& aAddr, + TBool aKnownToBearer) + : CAvrcpCommand(aRemConId, aTransactionLabel, aAddr) + { + LOG_FUNC + + iIsClick = aIsClick; + iInterfaceUid = aInterfaceUid; + iOperationId = aCommand; + iKnownToBearer = aKnownToBearer; + + iCommandData.Assign(aCommandData); + aCommandData.Assign(NULL); + iPlayerInfoManager = NULL; + } + +//--------------------------------------------------------------------- +// Incoming command construction +//--------------------------------------------------------------------- + +/** Factory function. + +@param aMessageInformation A buffer containing AV/C frame this command is to represent. +@param aRemConId The RemCon transaction label. +@param aTransLabel The AVCTP transaction label. +@param aAddr The bluetooth address to send the response to. +@param aClientId The RemCon client that should receive this command +@return A fully constructed CControlCommand. +@leave System wide error codes. +*/ +CControlCommand* CControlCommand::NewL(CAVCFrame* aFrame, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + const TRemConClientId& aClientId, + CAvrcpPlayerInfoManager* aPlayerInfoManager) + { + LOG_STATIC_FUNC + CControlCommand* command = new(ELeave)CControlCommand(aFrame, aRemConId, aTransLabel, aAddr, aClientId, aPlayerInfoManager); + CleanupStack::PushL(command); + command->ConstructL(); + CleanupStack::Pop(command); + return command; + } + +/** Constructor. + +@param aRemConId The RemCon transaction label. +@param aTransLabel The AVCTP transaction label. +@param aAddr The bluetooth address to send the response to. +@param aClientId The RemCon client that should receive this command +@return A partially constructed CControlCommand. +@leave System wide error codes. +*/ +CControlCommand::CControlCommand(CAVCFrame* aFrame, + TUint aRemConId, + SymbianAvctp::TTransactionLabel aTransLabel, + const TBTDevAddr& aAddr, + const TRemConClientId& aClientId, + CAvrcpPlayerInfoManager* aPlayerInfoManager) + : CAvrcpCommand(aRemConId, aTransLabel, aAddr) + , iFrame(aFrame) + , iClientId(aClientId) + { + LOG_FUNC + + iIsClick = ETrue; // Assume click until we know otherwise + iPlayerInfoManager = aPlayerInfoManager; + } + +//--------------------------------------------------------------------- +// Generic construction/destruction +//--------------------------------------------------------------------- + +/** Destructor. +*/ +CControlCommand::~CControlCommand() + { + LOG_FUNC + __ASSERT_DEBUG(iUsers == 0, AvrcpUtils::Panic(EAvrcpCommandStillInUse)); + __ASSERT_ALWAYS(!iHandlingLink.IsQueued(), AvrcpUtils::Panic(EAvrcpCommandStillQueuedForHandling)); + __ASSERT_ALWAYS(!iReadyLink.IsQueued(), AvrcpUtils::Panic(EAvrcpCommandStillQueuedAsReady)); + __ASSERT_ALWAYS(!iSendLink.IsQueued(), AvrcpUtils::Panic(EAvrcpCommandStillQueuedForSending)); + delete iFrame; + iCommandData.Close(); + delete iTimerEntry; + delete iTimerExpiryInfo; + } + +/** Second phase construction. + +@leave System wide error codes. +*/ +void CControlCommand::ConstructL() + { + LOG_FUNC + + // Allocate these now so we know we have the memory. Info is + // irrelevant as we won't add to the timer's queue without + // setting the true info. + TCallBack callback(DummyCallback, NULL); + iTimerEntry = new(ELeave)TDeltaTimerEntry(callback); + iTimerExpiryInfo = new(ELeave)TAvrcpTimerExpiryInfo(NULL, *this); + } + +//------------------------------------------------------------------------------------ +// From MRcpTimerNotify +//------------------------------------------------------------------------------------ + +/** Get the timer entry. + +@return Timer entry. +*/ +TDeltaTimerEntry* CControlCommand::TimerEntry() + { + return iTimerEntry; + } + +/** Get the timer expiry info. + +@return Timer expiry info. +*/ +TAvrcpTimerExpiryInfo* CControlCommand::TimerExpiryInfo() + { + return iTimerExpiryInfo; + } + +/** Remove this command's timer entry from the queue. + +@param aTimer The timer queue to remove this from. +*/ +void CControlCommand::CancelTimer(CDeltaTimer& aTimer) + { + LOG_FUNC + + aTimer.Remove(*iTimerEntry); + } + +//------------------------------------------------------------------------------------ +// Called by bearer +//------------------------------------------------------------------------------------ + +const TRemConClientId& CControlCommand::ClientId() const + { + return iClientId; + } +//------------------------------------------------------------------------------------ +// Called by handlers +//------------------------------------------------------------------------------------ + +/** Creates iFrame. + +This function must be called between creating this command and using it. + +@param aInterfaceUid The RemCon interface this command came from. +@param aCommand The command id within the interface identified by aInterfaceUid. +@param aCommandData Data supplied with this command by RemCon. The format of this + data is defined by RemCon and is dependent on aInterfaceUid and + aCommand. +@leave System wide error code if parsing could not complete. +*/ +void CControlCommand::ProcessOutgoingCommandL(MRemConBearerObserver& aObserver) + { + LOG_FUNC + + switch(iInterfaceUid.iUid) + { + //Process the absolute volume controller api + case KRemConAbsoluteVolumeControllerApiUid: + { + switch (iOperationId) + { + //Registers absolute volume changed + case KRemConAbsoluteVolumeNotification: + { + iFrame = AvrcpCommandFramer::NotifyVolumeChangeCommandL(); + break; + } + //Sets absolute volume. + case KRemConSetAbsoluteVolume: + { + //Gets the absolute volume to be set. + RRemConAbsoluteVolumeRequest setAbsVol; + CleanupClosePushL(setAbsVol); + setAbsVol.ReadL(iCommandData); + + __ASSERT_ALWAYS(setAbsVol.iVolume <= setAbsVol.iMaxVolume, + AvrcpUtils::Panic(EAvrcpVolumeBeyondMaxVolume)); + + TUint8 absVol = KAvrcpMaxAbsoluteVolume * setAbsVol.iVolume / setAbsVol.iMaxVolume; + iFrame = AvrcpCommandFramer::SetAbsoluteVolumeCommandL(absVol); + CleanupStack::PopAndDestroy(&setAbsVol); + break; + } + default: + { + User::Leave(KErrNotSupported); + } + + } + break; + } + case KRemConCoreApiUid: + { + // Default interface - all commands are passthrough + AVCPanel::TOperationId avrcpOp; + + if((RemConToAvrcpOperation(iOperationId, avrcpOp) != KErrNone) || + (iCommandData.Length() < KRemConCoreApiButtonDataLength)) + { + User::Leave(KErrCorrupt); + } + else + { + TInt remConButtonAct; + AvrcpUtils::ReadCommandDataToInt(iCommandData, + KRemConCoreApiCommandDataOffset + KRemConCoreApiButtonDataOffset, + KRemConCoreApiButtonDataLength, remConButtonAct); + + AVCPanel::TButtonAction buttonAct = (remConButtonAct == ERemConCoreApiButtonPress) ? + AVCPanel::EButtonPress : AVCPanel::EButtonRelease; + + iFrame = AvrcpCommandFramer::PassthroughL(avrcpOp, buttonAct); + if(iIsClick) + { + // restore our mangled command data + AvrcpUtils::SetCommandDataFromInt(iCommandData, + KRemConCoreApiCommandDataOffset + KRemConCoreApiButtonDataOffset, + KRemConCoreApiButtonDataLength, ERemConCoreApiButtonClick); + } + } + break; + } + default: + { + RBuf8 buf; + buf.CreateMaxL(KAVCFrameMaxLength); + User::LeaveIfError(aObserver.InterfaceToBearer(TUid::Uid(KRemConBearerAvrcpImplementationUid), + iInterfaceUid, iOperationId, iCommandData, ERemConCommand, buf)); + + CleanupClosePushL(buf); + iFrame = CAVCFrame::NewL(buf, AVC::ECommand); + CleanupStack::PopAndDestroy(&buf); + break; + } + }; + } + +/** Fills in command info from iFrame. + +This must be called by the command handler before handling this +command. + +This functions sets iInterfaceUid, iOperationId and iCommandData +to the correct values according to iFrame. The format of iCommandData +is defined by RemCon and is dependent on iInterfaceUid and iOperationId. + +@return KErrNone If the frame has been parsed successfully. +@return KErrNotSupported This frame represents a command for which a + RemCon converter or client side interface + cannot be found. +@return KErrAvrcpInvalidCType The CType specified in this frame is invalid. +@return KErrAvrcpMetadataInvalidCommand The AVRCP command is invalid. +@return KErrAvrcpMetadataInvalidParameter The AVRCP parameter is invalid. +@return KErrAvrcpMetadataParameterNotFound The AVRCP parameter was not found. +@return KErrAvrcpMetadataInternalError An AVRCP internal error occurred (such as out-of-memory, + or an inter-process communication error) +@return KErrCorrupt If the frame is corrupted(e.g invalid Operation Id). +@return System wide error code. +*/ +TInt CControlCommand::ParseIncomingCommandL(MRemConBearerObserver& aObserver, CAVRCPFragmenter& aFragmenter) + { + LOG_FUNC + TInt err = KErrNotSupported; + + switch(iFrame->Type()) + { + // check it isn't a reponse + case AVC::ENotImplemented: + case AVC::EAccepted: + case AVC::ERejected: + case AVC::EInTransition: + case AVC::EImplemented: + case AVC::EChanged: + case AVC::EInterim: + case 0x0E: // not given a enum for SC reasons; reserved response code in spec + { + // We were told this was a command, can't go using response + // CTypes here matey + err = KErrAvrcpInvalidCType; + break; + } + case AVC::EGeneralEnquiry: + case AVC::ESpecificEnquiry: + { + err = KErrNotSupported; + break; + } + default: + if (iFrame->Opcode() == AVC::EVendorDependent) + { + err = ParseIncomingVendorCommandL(aObserver, aFragmenter); + } + + else + { + // give off to the regular processor + err = ParseIncomingKnownOpcodeL(aObserver); + } + break; + }; + + + return err; + } + +/** Processes an incoming response. + +This function may not fail. We always need to generate something +to RemCon. + +@param aObserver Observer to use for retrieving converter. +@param aFrame The AV/C frame containing the response. +*/ +TInt CControlCommand::ParseIncomingResponse(MRemConBearerObserver& aObserver, const CAVCFrame& aFrame) + { + LOG_FUNC + TInt error = KErrNone; + + // Compare Opcode with that of the sent frame rather than the + // received one because we trust that more. Should be the same + // as this is matched by AVCTP transaction label, but who knows + // what those illicit remote devices could be up to. + if(iFrame->Opcode() == AVC::EPassThrough) + { + switch(aFrame.Type()) + { + case AVC::EAccepted: + { + InsertCoreResult(KErrNone); + break; + } + case AVC::ENotImplemented: + { + InsertCoreResult(KErrNotSupported); + break; + } + default: + { + InsertCoreResult(KErrGeneral); + break; + } + } + } + else if (iFrame->Opcode() == AVC::EVendorDependent) + { + TPtrC8 payloadData; + AVC::TAVCVendorId vID; + //Get the PDU ID with that of the sent frame rather than the received one, + //the reason is the same to above comments. + payloadData.Set(CAVCVendorDependentCommand::GetPayloadAndVID(*iFrame, vID)); + if (vID == KBluetoothSIGVendorId) + { + TMetadataTransferPDUID metadataPDUID = MetadataTransferParser::GetPDUID(payloadData); + switch ( metadataPDUID ) + { + case ESetAbsoluteVolume://Response for setting absolute volume. + { + error = SetSetAbsoluteVolumeResult(aFrame); + break; + } + case ERegisterNotification: + { + //Get notify event ID with the sent frame rather than the received one + //because there is a big possibility that the received one is an error response, e.g. rejected,notimplemented. + //In order to make sure this is an absolute volume response even if the response is an error response, + //we have to use the sent frame, and then we can process absolute volume specifically. + TMetadataTransferNotifyEventID eventID = MetadataTransferParser::GetNotifyEventID(payloadData); + + __ASSERT_ALWAYS(eventID == ERegisterNotificationVolumeChanged, + AvrcpUtils::Panic(EAvrcpInvalidEventId)); + + if (eventID == ERegisterNotificationVolumeChanged) + { + error = SetNotifyVolumeChangeResult(aFrame); + } + break; + } + default: + { + // Should never hit here + AvrcpUtils::Panic(EAvrcpResponseToUnknownCommand); + break; + } + } + } + else + { + ParseIncomingUnknownResponse(aObserver, aFrame); + } + } + else + { + ParseIncomingUnknownResponse(aObserver, aFrame); + } + + return error; + } + +/** Processes an outgoing response. + +This should only be called for vendor dependent commands as +we respond to passthrough commands internally. + +@param aObserver Observer to use for retrieving converter. +@param aFrame The command data for the response. +*/ +TInt CControlCommand::ProcessOutgoingResponse(MRemConBearerObserver& aObserver, +// TRemConMessageType aMessageType, + RBuf8& aResponseData, + CAVRCPFragmenter& aFragmenter) + { + TRAPD(err, DoProcessOutgoingResponseL(aObserver,aResponseData, aFragmenter)); + return err; + } + +void CControlCommand::DoProcessOutgoingResponseL(MRemConBearerObserver& aObserver, + RBuf8& aResponseData, + CAVRCPFragmenter& aFragmenter) + { + LOG_FUNC + + // Payload size may be increased in GenerateMetadataResponsePayload + // if there's a very large response which needs fragmenting + RBuf8 payload; + payload.CreateL(KAVCFrameMaxLength); + CleanupClosePushL(payload); + + if(( iInterfaceUid.iUid == KRemConMediaInformationApiUid ) + || ( iInterfaceUid.iUid == KRemConPlayerInformationUid ) + || ( iInterfaceUid.iUid == KRemConAbsoluteVolumeTargetApiUid ) + || ( iInterfaceUid.iUid == KRemConNowPlayingApiUid ) + || ( iInterfaceUid.iUid == KUidAvrcpInternalInterface)) + { + // metadata + // "this" is the command for which the response lurks in aCommandData + // GenerateMetadataResponsePayload() MUST set PDU id, fragmentation stauts + // and paramlen (4 bytes total) - check this in ASSERT_DEBUG + User::LeaveIfError(GenerateMetadataResponsePayload(aObserver, payload, aResponseData)); + __ASSERT_DEBUG(payload.Length() >= KAVRCPMinVendorDependentResponseLen, AvrcpUtils::Panic(EAvrcpFunnyLengthData)); + aResponseData.Close(); + + if (payload.Length() > KAVCMaxVendorDependentPayload) + { + // Fragment response (in payload) and queue fragments ready + // for sending when CT sends a CONTINUE request. If any other + // request is received (other than pass-through) then throw + // away our fragmented packet, as the CT has aborted. + aFragmenter.AssignPayload(payload); + payload.Assign(NULL); + payload.Close(); + + // Re-allocate this back to a sensible size + // from the much larger size, which has now been + // assigned to fragmenter (avoids copying payload) + payload.CreateL(KAVCFrameMaxLength); + payload.Append(aFragmenter.GetNextFragmentHeader()); + payload.Append(aFragmenter.GetNextFragment()); + } + + CAVCFrame* frame = CAVCVendorDependentResponse::NewL(KBluetoothSIGVendorId); + frame->Append(payload); + frame->SetType(iFrame->Type()); + delete iFrame; + iFrame = frame; + } + else + { + User::LeaveIfError(aObserver.InterfaceToBearer(TUid::Uid(KRemConBearerAvrcpImplementationUid), + iInterfaceUid, iOperationId, + aResponseData, /*ERemConCommand*/ERemConResponse, payload)); + aResponseData.Close(); + CAVCFrame* frame = CAVCFrame::NewL(payload, AVC::EResponse); + delete iFrame; + iFrame = frame; + } + + CleanupStack::PopAndDestroy(&payload); + } + +/** Set the response type in the AV/C frame. + +@param aErr The result of processing the operation. KErrNone if + successful. KErrNotsupported if this operation is not + implemented, eg because no converter was found. +*/ +void CControlCommand::SetResponseType(TInt aErr) + { + LOG_FUNC + AVC::TCType cType = iFrame->Type(); + switch(aErr) + { + case KErrNone: + case KErrCompletion: + if (cType == AVC::EControl) + { + iFrame->SetType(AVC::EAccepted); + } + else if (cType == AVC::ENotify) + { + iFrame->SetType(AVC::EInterim); + } + else if (cType == AVC::EInterim) + { + iFrame->SetType(AVC::EChanged); + } + else if (cType == AVC::EStatus) + { + iFrame->SetType(AVC::EStable); + } + else + { + iFrame->SetType(AVC::EImplemented); + } + break; + case KErrAvrcpMetadataInvalidCommand: + case KErrAvrcpMetadataInvalidParameter: + case KErrAvrcpMetadataParameterNotFound: + case KErrAvrcpMetadataInternalError: + case KErrAvrcpAirInvalidCommand: + case KErrAvrcpAirInvalidParameter: + case KErrAvrcpAirParameterNotFound: + case KErrAvrcpAirInternalError: + case KErrAvrcpAirSuccess: + case KErrAvrcpAirUidChanged: + case KErrAvrcpAirReserved: + case KErrAvrcpAirInvalidDirection: + case KErrAvrcpAirNotADirectory: + case KErrAvrcpAirDoesNotExist: + case KErrAvrcpAirInvalidScope: + case KErrAvrcpAirRangeOutOfBounds: + case KErrAvrcpAirUidIsADirectory: + case KErrAvrcpAirMediaInUse: + case KErrAvrcpAirNowPlayingListFull: + case KErrAvrcpAirSearchNotSupported: + case KErrAvrcpAirSearchInProgress: + case KErrAvrcpAirInvalidPlayerId: + case KErrAvrcpAirPlayerNotBrowesable: + case KErrAvrcpAirPlayerNotAddressed: + case KErrAvrcpAirNoValidSearchResults: + case KErrAvrcpAirNoAvailablePlayers: + case KErrAvrcpAirAddressedPlayerChanged: + { + // If this fails, we're OOM (it only contains a NewL) + // so we can't send the error response - just give up + TRAPD(err, GenerateMetadataRejectPayloadL(aErr)); + err = err; // avoid warning about not using this + break; + } + default: + iFrame->SetType(AVC::ENotImplemented); + } + iFrame->SetFrameType(AVC::EResponse); + } + +/** Gets this command's AV/C frame. +@return the AV/C frame for this command +*/ +const CAVCFrame& CControlCommand::Frame() const + { + LOG_FUNC + return *iFrame; + } + +const TDesC8& CControlCommand::Data() const + { + LOG_FUNC + return iFrame->Data(); + } + +SymbianAvctp::TMessageType CControlCommand::MessageType() const + { + LOG_FUNC + return (iFrame->FrameType() == AVC::ECommand) ? SymbianAvctp::ECommand : SymbianAvctp::EResponse; + } + +/** Gets the button action from this command's AV/C frame. +This is only valid on passthrough commands. + +@return The button action. +*/ +AVCPanel::TButtonAction CControlCommand::ButtonAct() const + { + LOG_FUNC + AVCPanel::TButtonAction act; + iFrame->ButtonAct(act); + return act; + } + +/** Gets whether this command is currently assumed to be a click. + +This is used to support the click facility offered by RemCon, which +is not offered by AVRCP. As such AVRCP internally simulates outgoing +clicks by generating a press and release for one RemCon click. When +responses are received we know that if a command is a click we should +send only one response up to RemCon. + +Incoming passthrough press commands are assumed to be click until +the hold timer expires. When a matching release is received we can +then tell whether we need to send a single click up to RemCon, or +a release to match the press that was sent when the hold timer expired. + +@return ETrue is this is a click. EFalse if not. +*/ +TBool CControlCommand::Click() const + { + LOG_FUNC + return iIsClick; + } + +/** Sets whether this command is currently assumed to be a click +or not. + +@see CRcpcommand::Click() +@param aIsClick ETrue to set this as click. EFalse to set this as + not click. +*/ +void CControlCommand::SetClick(TBool aIsClick) + { + LOG_FUNC + iIsClick = aIsClick; + } + +/** Sets the RemCon data to indicate what button action this +command is. This function is only valid for commands in the +core api. + +@param aButtonAct The RemCon button action for this command. +@param aCommand Whether this is a command. This is needed + because the command data is at a different offset for + commands and responses. +*/ +void CControlCommand::SetCoreButtonAction(TRemConCoreApiButtonAction aButtonAct, TBool aCommand) + { + LOG_FUNC + + TInt offset = aCommand ? KRemConCoreApiButtonDataOffset + KRemConCoreApiCommandDataOffset + : KRemConCoreApiButtonDataOffset + KRemConCoreApiResponseDataOffset; + + AvrcpUtils::SetCommandDataFromInt(iCommandData, offset, + KRemConCoreApiButtonDataLength, aButtonAct); + } +/** ReSets the RemCon data to indicate what button action this +command is. This function is called when we the command is being re-used to generate a +new command to remconServ. + +@param aButtonAct The RemCon button action for this command. +@param aCommand Whether this is a command. This is needed + because the command data is at a different offset for + commands and responses. +*/ +void CControlCommand::ReSetCoreButtonActionL(TRemConCoreApiButtonAction aButtonAct, TBool aCommand) + { + LOG_FUNC + + if (iCommandData.MaxLength() < KRemConCoreApiButtonDataLength) + { + iCommandData.Close(); + iCommandData.CreateMaxL(KRemConCoreApiButtonDataLength); + } + + SetCoreButtonAction(aButtonAct, aCommand); + } + +/** Inserts the results at the beginning of this command's data. +If the data buffer is not large enough it will be ReAlloced to +allow the insertion. + +@return The result to pass to RemCon. KErrNone for an AV/C accepted. + KErrNotSupported for an AV/C not implemented. KErrGeneral + for an AV/C rejected. +*/ +TInt CControlCommand::InsertCoreResult(TInt aResult) + { + LOG_FUNC + TInt err = KErrNone; + TInt requiredLength = KRemConCoreApiResultDataLength + iCommandData.Length(); + + if(iCommandData.Length() >= requiredLength) + { + // Insert data to write result into + iCommandData.Insert(0, KRemConCoreApiResultPad); + } + else + { + // need longer buffer + err = iCommandData.ReAlloc(requiredLength); + if(!err) + { + iCommandData.Insert(0, KRemConCoreApiResultPad); + } + else + { + return err; + } + } + + AvrcpUtils::SetCommandDataFromInt(iCommandData, 0, + KRemConCoreApiResultDataLength, aResult); + return err; + } + +/** +Sets the result of set absolute volume response into this command's data +*/ +TInt CControlCommand::SetSetAbsoluteVolumeResult(const CAVCFrame& aFrame) + { + TInt err = KErrNone; + TRAP(err, DoSetAbsoluteVolumeResultL(aFrame)); + if (err != KErrNone) + { + // Ensure the client can receive an error in case of + // DoSetAbsoluteVolumeResultL leaves out. + iCommandData.Zero(); + TPckgBuf errBuf(err); + iCommandData.Append(errBuf); + iCommandData.SetLength(iCommandData.MaxLength()); + } + return err; + } + +void CControlCommand::DoSetAbsoluteVolumeResultL(const CAVCFrame& aFrame) + { + RRemConAbsoluteVolumeResponse absVol; + absVol.iError = KErrGeneral; + absVol.iMaxVolume = KAvrcpMaxAbsoluteVolume; + + CleanupClosePushL(absVol); + + switch(aFrame.Type()) + { + case AVC::EAccepted: + { + if (aFrame.Data().Length() == KLengthSetAbsoluteVolumeResponse) + { + absVol.iError = KErrNone; + TUint volumeOffset = KLengthSetAbsoluteVolumeResponse - 1; + absVol.iVolume = KAbsoluteVolumeMask & aFrame.Data()[volumeOffset]; + } + break; + } + case AVC::ERejected: // fall through + case AVC::ENotImplemented: + break; + default: + break; + } + + absVol.WriteL(iCommandData); + CleanupStack::PopAndDestroy(&absVol); + } +/** +Sets the result of volume changed notification response into this command's +data. +*/ +TInt CControlCommand::SetNotifyVolumeChangeResult(const CAVCFrame& aFrame) + { + TInt err = KErrNone; + TRAP(err, DoSetNotifyVolumeChangeResultL(aFrame)); + if (err == KErrNone) + { + // Through AVC::TCType the RemCon sever can know whether the response + // is an Interim or Changed or any other responses, so the RemCon + // server can decide to remove the notify command from its + // outgoingsent queue or not. + iFrame->SetType(aFrame.Type()); + } + else + { + // Ensure the client can receive an error in case of + // DoSetNotifyVolumeChangeResultL leaves out. + iCommandData.Zero(); + TPckgBuf errBuf(KErrGeneral); + iCommandData.Append(errBuf); + iCommandData.SetLength(iCommandData.MaxLength()); + + // Setting AVC::TCType to ERejected is intended to let the RemCon + // server to remove the notify command from its outgoingsent queue + // in case of DoSetNotifyVolumeChangeResultL leaves out. + iFrame->SetType(AVC::ERejected); + } + + return err; + } + +void CControlCommand::DoSetNotifyVolumeChangeResultL(const CAVCFrame& aFrame) + { + if (iCommandData.MaxLength() < KAbsoluteVolumeResponseDataSize) + { + iCommandData.Close(); + iCommandData.CreateL(KAbsoluteVolumeResponseDataSize); + } + + RRemConAbsoluteVolumeResponse absVol; + absVol.iError = KErrGeneral; + absVol.iMaxVolume = KAvrcpMaxAbsoluteVolume; + + CleanupClosePushL(absVol); + + switch(aFrame.Type()) + { + case AVC::EInterim: + case AVC::EChanged: + { + if (aFrame.Data().Length() == KLengthNotifyVolumeChangeResponse) + { + absVol.iError = KErrNone; + TUint volumeOffset = KLengthNotifyVolumeChangeResponse - 1; + absVol.iVolume = KAbsoluteVolumeMask & aFrame.Data()[volumeOffset]; + } + break; + } + case AVC::ERejected: // fall through + case AVC::ENotImplemented: + break; + default: + break; + } + absVol.WriteL(iCommandData); + CleanupStack::PopAndDestroy(&absVol); + } +//------------------------------------------------------------------------------------ +// Internal utility functions +//------------------------------------------------------------------------------------ + +/** Fills in command info from an AVC Control. + +This functions sets iInterfaceUid, iOperationId and iCommandData +to the correct values according to iFrame. The format of iCommandData +is defined by RemCon and is dependent on iInterfaceUid and iOperationId. + +@return KErrNone If the frame has been parsed successfully. +@return KErrNotSupported This frame represents a command for which a + RemCon converter or client side interface + cannot be found. +@return System wide error code. +*/ +TInt CControlCommand::ParseIncomingKnownOpcodeL(MRemConBearerObserver& aObserver) + { + LOG_FUNC + TInt err = KErrNotSupported; + + AVC::TCType cType = iFrame->Type(); + + switch(iFrame->Opcode()) + { + case AVC::EPassThrough: + { + if(iFrame->Data().Length() < KAVCPassthroughFrameLength) + { + LEAVEL(KErrCorrupt); + } + if (iFrame->SubunitType() != AVC::EPanel) + { + LEAVEL(KErrNotSupported); + } + + TUint8 avrcpOp; + if (cType != AVC::EGeneralEnquiry && cType == AVC::EControl) + { + iCommandData.CreateMaxL(KRemConCoreApiButtonDataLength); + err = iFrame->OperationId(avrcpOp); + if (err == KErrNone) + { + if (avrcpOp!=AVCPanel::EVendorUnique) + { + err = AvrcpToRemConOperation(avrcpOp, iOperationId, iInterfaceUid); + } + else + { + err = ParseVendorUniquePassthroughCommand(aObserver); + } + } + + if (err!=KErrNone) + { + err = KErrAvrcpInvalidOperationId; + } + } + else + { + iCommandData.Close(); + iCommandData.CreateL(KAVCFrameMaxLength); + TRemConMessageType message = ERemConCommand; + err = aObserver.BearerToInterface(TUid::Uid(KRemConBearerAvrcpImplementationUid), + iFrame->Data(), + iFrame->Data(), + iInterfaceUid, + iOperationId, + message, + iCommandData); + } + break; + } + case AVC::EUnitInfo: + { + if (iFrame->Type() == AVC::EStatus) + { + CAVCFrame* resp = AvrcpCommandFramer::UnitInfoResponseL(); + delete iFrame; + iFrame = resp; + err = KErrCompletion; // since bearer has done its job without client needed + } + else + { + err = KErrAvrcpInvalidCType; + } + break; + } + case AVC::ESubunitInfo: + { + if (iFrame->Type() == AVC::EStatus) + { + CAVCFrame* resp = AvrcpCommandFramer::SubunitInfoResponseL(); + delete iFrame; + iFrame = resp; + err = KErrCompletion; // since bearer has done its job without client needed + } + else + { + err = KErrAvrcpInvalidCType; + } + break; + } + + default: + { + iCommandData.Close(); + iCommandData.CreateL(KAVCFrameMaxLength); + TRemConMessageType message = ERemConCommand; + err = aObserver.BearerToInterface(TUid::Uid(KRemConBearerAvrcpImplementationUid), + iFrame->Data(), + iFrame->Data(), + iInterfaceUid, + iOperationId, + message, + iCommandData); + break; + } + } + + return err; + } + + +/** Fills in command info from an AVC Vendor Dependent message. + +This functions sets iInterfaceUid, iOperationId and iCommandData +to the correct values according to iFrame. The format of iCommandData +is defined by RemCon and is dependent on iInterfaceUid and iOperationId. +The AVC frame's length is checked that it at least contains the vendor id. + +@param aObserver An observer to be used to obtain a converter. +@return KErrNone If the frame has been parsed successfully. +@return KErrNotSupported This frame represents a command for which a + RemCon converter or client side interface + cannot be found. +@return KErrAvrcpInvalidCType The CType specified in this frame is invalid. +@return KErrAvrcpMetadataInvalidCommand The AVRCP command is invalid. +@return KErrAvrcpMetadataInvalidParameter The AVRCP parameter is invalid. +@return KErrAvrcpMetadataParameterNotFound The AVRCP parameter was not found. +@return KErrAvrcpMetadataInternalError An AVRCP internal error occurred (such as out-of-memory, + or an inter-process communication error) +@return System wide error code. +*/ +TInt CControlCommand::ParseIncomingVendorCommandL(MRemConBearerObserver& aObserver, CAVRCPFragmenter& aFragmenter) + { + LOG_FUNC + TInt err = KErrNone; + + SetVendorInfoL(EFalse); // set id and payload; leaves if not enough space available + + if (iVendorId!=KBluetoothSIGVendorId) + { + iCommandData.Close(); + iCommandData.CreateL(KAVCFrameMaxLength); + + TRemConMessageType message = ERemConCommand; + + err = aObserver.BearerToInterface(TUid::Uid(KRemConBearerAvrcpImplementationUid), + iFrame->Data(), + iFrame->Data(), + iInterfaceUid, + iOperationId, + message, + iCommandData); + } + else + { + // process v>1.0 version of AVRCP + // which use vendor dependent frames to extend v1.0 of AVRCP + // the vendor code has the value for the BT SIG + if (iFrame->SubunitType() != AVC::EPanel) + { + // this is for Control not Metadata + return KErrNotSupported; + } + + err = ParseMetadataTransferVendorCommand(aFragmenter); + if (err == KErrNone) + { + // Check that the interface UID is non-zero + __ASSERT_DEBUG(iInterfaceUid != TUid::Uid(0), AvrcpUtils::Panic(EAvrcpInterfaceUidNotSet)); + } + } + return err; + } + + +/** Creates RemCon command information from iFrame. + +This functions sets iInterfaceUid, iOperationId and iCommandData +to the correct values according to iFrame. The format of iCommandData +is defined by the interface, iInterfaceUid and is dependent on +iOperationId. A converter should be able to be found as this response +is a result of an outgoing command on this interface. + +@param aObserver An observer used to get a converter. +@param aFrame The AV/C frame for this command. +*/ +void CControlCommand::ParseIncomingUnknownResponse(MRemConBearerObserver& aObserver, + const CAVCFrame& aFrame) + { + LOG_FUNC + // We need to pass a response up to RemCon even if we can't get a + // converter to generate a decent response so we don't + + iCommandData.Close(); + TInt err = iCommandData.Create(KAVCFrameMaxLength); + if(!err) + { + TRemConMessageType type = ERemConResponse; // output param + err = aObserver.BearerToInterface(TUid::Uid(KRemConBearerAvrcpImplementationUid), + aFrame.Data(), aFrame.Data(), iInterfaceUid, iOperationId, type, iCommandData); + } + } + +/** Translates from an AVC operation id to RemCon's core interface. + +@param aAvrcpOp The AVC passthrough operation id. +@param aRemConOp On return the RemCon operation id within the core interface. +@return KErrNone If the operation has been translated successfully. +@return KErrNotSupported If the operation does not correspond to one + in the RemCon core interface. +*/ +TInt CControlCommand::AvrcpToRemConOperation(TUint aAvrcpOp, TUint& aRemConOp, TUid& aRemConIf) + { + LOG_STATIC_FUNC + TInt err = KErrNone; + + //TBH setting here as most are for the Core API + //some cases will override + aRemConIf = TUid::Uid(KRemConCoreApiUid); + + switch(aAvrcpOp) + { + case AVCPanel::ESelect: + aRemConOp = ERemConCoreApiSelect; + break; + case AVCPanel::EUp: + aRemConOp = ERemConCoreApiUp; + break; + case AVCPanel::EDown: + aRemConOp = ERemConCoreApiDown; + break; + case AVCPanel::ELeft: + aRemConOp = ERemConCoreApiLeft; + break; + case AVCPanel::ERight: + aRemConOp = ERemConCoreApiRight; + break; + case AVCPanel::ERightUp: + aRemConOp = ERemConCoreApiRightUp; + break; + case AVCPanel::ERightDown: + aRemConOp = ERemConCoreApiRightDown; + break; + case AVCPanel::ELeftUp: + aRemConOp = ERemConCoreApiLeftUp; + break; + case AVCPanel::ELeftDown: + aRemConOp = ERemConCoreApiLeftDown; + break; + case AVCPanel::ERootMenu: + aRemConOp = ERemConCoreApiRootMenu; + break; + case AVCPanel::ESetupMenu: + aRemConOp = ERemConCoreApiSetupMenu; + break; + case AVCPanel::EContentsMenu: + aRemConOp = ERemConCoreApiContentsMenu; + break; + case AVCPanel::EFavoriteMenu: + aRemConOp = ERemConCoreApiFavoriteMenu; + break; + case AVCPanel::EExit: + aRemConOp = ERemConCoreApiExit; + break; + case AVCPanel::E0: + aRemConOp = ERemConCoreApi0; + break; + case AVCPanel::E1: + aRemConOp = ERemConCoreApi1; + break; + case AVCPanel::E2: + aRemConOp = ERemConCoreApi2; + break; + case AVCPanel::E3: + aRemConOp = ERemConCoreApi3; + break; + case AVCPanel::E4: + aRemConOp = ERemConCoreApi4; + break; + case AVCPanel::E5: + aRemConOp = ERemConCoreApi5; + break; + case AVCPanel::E6: + aRemConOp = ERemConCoreApi6; + break; + case AVCPanel::E7: + aRemConOp = ERemConCoreApi7; + break; + case AVCPanel::E8: + aRemConOp = ERemConCoreApi8; + break; + case AVCPanel::E9: + aRemConOp = ERemConCoreApi9; + break; + case AVCPanel::EDot: + aRemConOp = ERemConCoreApiDot; + break; + case AVCPanel::EEnter: + aRemConOp = ERemConCoreApiEnter; + break; + case AVCPanel::EClear: + aRemConOp = ERemConCoreApiClear; + break; + case AVCPanel::EChannelUp: + aRemConOp = ERemConCoreApiChannelUp; + break; + case AVCPanel::EChannelDown: + aRemConOp = ERemConCoreApiChannelDown; + break; + case AVCPanel::EPreviousChannel: + aRemConOp = ERemConCoreApiPreviousChannel; + break; + case AVCPanel::ESoundSelect: + aRemConOp = ERemConCoreApiSoundSelect; + break; + case AVCPanel::EInputSelect: + aRemConOp = ERemConCoreApiInputSelect; + break; + case AVCPanel::EDisplayInformation: + aRemConOp = ERemConCoreApiDisplayInformation; + break; + case AVCPanel::EHelp: + aRemConOp = ERemConCoreApiHelp; + break; + case AVCPanel::EPageUp: + aRemConOp = ERemConCoreApiPageUp; + break; + case AVCPanel::EPageDown: + aRemConOp = ERemConCoreApiPageDown; + break; + case AVCPanel::EPower: + aRemConOp = ERemConCoreApiPower; + break; + case AVCPanel::EVolumeUp: + aRemConOp = ERemConCoreApiVolumeUp; + break; + case AVCPanel::EVolumeDown: + aRemConOp = ERemConCoreApiVolumeDown; + break; + case AVCPanel::EMute: + aRemConOp = ERemConCoreApiMute; + break; + case AVCPanel::EPlay: + aRemConOp = ERemConCoreApiPlay; + break; + case AVCPanel::EStop: + aRemConOp = ERemConCoreApiStop; + break; + case AVCPanel::EPause: + aRemConOp = ERemConCoreApiPause; + break; + case AVCPanel::ERecord: + aRemConOp = ERemConCoreApiRecord; + break; + case AVCPanel::ERewind: + aRemConOp = ERemConCoreApiRewind; + break; + case AVCPanel::EFastForward: + aRemConOp = ERemConCoreApiFastForward; + break; + case AVCPanel::EEject: + aRemConOp = ERemConCoreApiEject; + break; + case AVCPanel::EForward: + aRemConOp = ERemConCoreApiForward; + break; + case AVCPanel::EBackward: + aRemConOp = ERemConCoreApiBackward; + break; + case AVCPanel::EAngle: + aRemConOp = ERemConCoreApiAngle; + break; + case AVCPanel::ESubpicture: + aRemConOp = ERemConCoreApiSubpicture; + break; + case AVCPanel::EF1: + aRemConOp = ERemConCoreApiF1; + break; + case AVCPanel::EF2: + aRemConOp = ERemConCoreApiF2; + break; + case AVCPanel::EF3: + aRemConOp = ERemConCoreApiF3; + break; + case AVCPanel::EF4: + aRemConOp = ERemConCoreApiF4; + break; + case AVCPanel::EF5: + aRemConOp = ERemConCoreApiF5; + break; + case AVCPanel::EVendorUnique: + default: + err = KErrNotSupported; + } + + return err; + } + + +TInt CControlCommand::ParseVendorUniquePassthroughCommand(MRemConBearerObserver& aObserver) + { + TInt err = KErrNone; + TRAP(err, SetVendorInfoL(ETrue)); // set id and payload; leaves if not enough space available + + if (err == KErrNone && iVendorId == KBluetoothSIGVendorId) + { + // it's one of the v1.3 (or later!) MT commands + err = ParseMetadataTransferPassthroughCommand(); + } + else + { + iCommandData.Close(); + TRAP(err, iCommandData.CreateL(KAVCFrameMaxLength)); + if(err == KErrNone) + { + TRemConMessageType message = ERemConCommand; + err = aObserver.BearerToInterface(TUid::Uid(KRemConBearerAvrcpImplementationUid), + iFrame->Data(), + iFrame->Data(), + iInterfaceUid, + iOperationId, + message, + iCommandData); + } + } + + return err; + } + +/** Translates from RemCon's core interface to an AVC operation id. + +@param aRemConOp The RemCon operation id within the core interface. +@param aAvrcpOp On return the AVC passthrough operation id. +@return KErrNone If the operation has been translated successfully. +@return KErrNotSupported If the operation does not correspond to one + provided by AVRCP. +*/ +TInt CControlCommand::RemConToAvrcpOperation(TUint aRemConOp, AVCPanel::TOperationId& aAvrcpOp) + { + LOG_STATIC_FUNC + TInt err = KErrNone; + switch(aRemConOp) + { + case ERemConCoreApiSelect: + aAvrcpOp = AVCPanel::ESelect; + break; + case ERemConCoreApiUp: + aAvrcpOp = AVCPanel::EUp; + break; + case ERemConCoreApiDown: + aAvrcpOp = AVCPanel::EDown; + break; + case ERemConCoreApiLeft: + aAvrcpOp = AVCPanel::ELeft; + break; + case ERemConCoreApiRight: + aAvrcpOp = AVCPanel::ERight; + break; + case ERemConCoreApiRightUp: + aAvrcpOp = AVCPanel::ERightUp; + break; + case ERemConCoreApiRightDown: + aAvrcpOp = AVCPanel::ERightDown; + break; + case ERemConCoreApiLeftUp: + aAvrcpOp = AVCPanel::ELeftUp; + break; + case ERemConCoreApiLeftDown: + aAvrcpOp = AVCPanel::ELeftDown; + break; + case ERemConCoreApiRootMenu: + aAvrcpOp = AVCPanel::ERootMenu; + break; + case ERemConCoreApiSetupMenu: + aAvrcpOp = AVCPanel::ESetupMenu; + break; + case ERemConCoreApiContentsMenu: + aAvrcpOp = AVCPanel::EContentsMenu; + break; + case ERemConCoreApiFavoriteMenu: + aAvrcpOp = AVCPanel::EFavoriteMenu; + break; + case ERemConCoreApiExit: + aAvrcpOp = AVCPanel::EExit; + break; + case ERemConCoreApi0: + aAvrcpOp = AVCPanel::E0; + break; + case ERemConCoreApi1: + aAvrcpOp = AVCPanel::E1; + break; + case ERemConCoreApi2: + aAvrcpOp = AVCPanel::E2; + break; + case ERemConCoreApi3: + aAvrcpOp = AVCPanel::E3; + break; + case ERemConCoreApi4: + aAvrcpOp = AVCPanel::E4; + break; + case ERemConCoreApi5: + aAvrcpOp = AVCPanel::E5; + break; + case ERemConCoreApi6: + aAvrcpOp = AVCPanel::E6; + break; + case ERemConCoreApi7: + aAvrcpOp = AVCPanel::E7; + break; + case ERemConCoreApi8: + aAvrcpOp = AVCPanel::E8; + break; + case ERemConCoreApi9: + aAvrcpOp = AVCPanel::E9; + break; + case ERemConCoreApiDot: + aAvrcpOp = AVCPanel::EDot; + break; + case ERemConCoreApiEnter: + aAvrcpOp = AVCPanel::EEnter; + break; + case ERemConCoreApiClear: + aAvrcpOp = AVCPanel::EClear; + break; + case ERemConCoreApiChannelUp: + aAvrcpOp = AVCPanel::EChannelUp; + break; + case ERemConCoreApiChannelDown: + aAvrcpOp = AVCPanel::EChannelDown; + break; + case ERemConCoreApiPreviousChannel: + aAvrcpOp = AVCPanel::EPreviousChannel; + break; + case ERemConCoreApiSoundSelect: + aAvrcpOp = AVCPanel::ESoundSelect; + break; + case ERemConCoreApiInputSelect: + aAvrcpOp = AVCPanel::EInputSelect; + break; + case ERemConCoreApiDisplayInformation: + aAvrcpOp = AVCPanel::EDisplayInformation; + break; + case ERemConCoreApiHelp: + aAvrcpOp = AVCPanel::EHelp; + break; + case ERemConCoreApiPageUp: + aAvrcpOp = AVCPanel::EPageUp; + break; + case ERemConCoreApiPageDown: + aAvrcpOp = AVCPanel::EPageDown; + break; + case ERemConCoreApiPower: + aAvrcpOp = AVCPanel::EPower; + break; + case ERemConCoreApiVolumeUp: + aAvrcpOp = AVCPanel::EVolumeUp; + break; + case ERemConCoreApiVolumeDown: + aAvrcpOp = AVCPanel::EVolumeDown; + break; + case ERemConCoreApiMute: + aAvrcpOp = AVCPanel::EMute; + break; + case ERemConCoreApiPlay: + aAvrcpOp = AVCPanel::EPlay; + break; + case ERemConCoreApiStop: + aAvrcpOp = AVCPanel::EStop; + break; + case ERemConCoreApiPause: + aAvrcpOp = AVCPanel::EPause; + break; + case ERemConCoreApiRecord: + aAvrcpOp = AVCPanel::ERecord; + break; + case ERemConCoreApiRewind: + aAvrcpOp = AVCPanel::ERewind; + break; + case ERemConCoreApiFastForward: + aAvrcpOp = AVCPanel::EFastForward; + break; + case ERemConCoreApiEject: + aAvrcpOp = AVCPanel::EEject; + break; + case ERemConCoreApiForward: + aAvrcpOp = AVCPanel::EForward; + break; + case ERemConCoreApiBackward: + aAvrcpOp = AVCPanel::EBackward; + break; + case ERemConCoreApiAngle: + aAvrcpOp = AVCPanel::EAngle; + break; + case ERemConCoreApiSubpicture: + aAvrcpOp = AVCPanel::ESubpicture; + break; + case ERemConCoreApiF1: + aAvrcpOp = AVCPanel::EF1; + break; + case ERemConCoreApiF2: + aAvrcpOp = AVCPanel::EF2; + break; + case ERemConCoreApiF3: + aAvrcpOp = AVCPanel::EF3; + break; + case ERemConCoreApiF4: + aAvrcpOp = AVCPanel::EF4; + break; + case ERemConCoreApiF5: + aAvrcpOp = AVCPanel::EF5; + break; + default: + err = KErrNotSupported; + } + return err; + } + +TUint16 CControlCommand::Get16(const TPtrC8& aPtr) + { + return (aPtr[0]<<8) | aPtr[1]; + } + +TInt CControlCommand::DummyCallback(TAny*) + { + // Should never be called- should be overwritten by a non-dummy callback + // before it's ever requested let alone called. + AvrcpUtils::Panic(EAvrcpDummyCallbackCalled); + return KErrNone; + } + +void CControlCommand::SetVendorInfoL(TBool aIsPassthrough) + { + if (aIsPassthrough) + { + if (iFrame->DataLength() < KAVCVendorUniquePassthroughHeader) + { + User::Leave(KErrCorrupt); + } + iVendorPayloadData.Set(CAVCVendorUniquePassthroughCommand::GetPayloadAndVID(*iFrame, iVendorId)); + } + else + { + if (iFrame->DataLength() < KAVCVendorIdLength) + { + User::Leave(KErrCorrupt); + } + iVendorPayloadData.Set(CAVCVendorDependentCommand::GetPayloadAndVID(*iFrame, iVendorId)); + } + } + +TBool CControlCommand::IsAvrcpPassthrough() const + { + TBool isAvrcpPassthrough = EFalse; + + if(iInterfaceUid.iUid == KRemConCoreApiUid || iInterfaceUid.iUid == KRemConGroupNavigationApiUid) + { + isAvrcpPassthrough = ETrue; + } + + return isAvrcpPassthrough; + } + +TBool CControlCommand::IsPassthrough() const + { + return ((iFrame->Opcode() == AVC::EPassThrough) && (iFrame->SubunitType() == AVC::EPanel)); + } + +TBool CControlCommand::PlayerSpecificNotify() const + { + TRegisterNotificationEvent eventId = RAvrcpIPC::GetEventIdFromIPCOperationId(iOperationId); + TMetadataTransferPDU pduId = RAvrcpIPC::GetPDUIdFromIPCOperationId(iOperationId); + + if(pduId != ERegisterNotification) + { + return EFalse; + } + + if(iInterfaceUid == TUid::Uid(KRemConPlayerInformationUid)) + { + if((eventId == ERegisterNotificationPlaybackStatusChanged) || + (eventId == ERegisterNotificationTrackChanged) || + (eventId == ERegisterNotificationTrackReachedEnd) || + (eventId == ERegisterNotificationTrackReachedStart) || + (eventId == ERegisterNotificationPlaybackPosChanged) || + (eventId == ERegisterNotificationPlayerApplicationSettingChanged)) + { + return ETrue; + } + } + else if(iInterfaceUid == TUid::Uid(KRemConNowPlayingApiUid)) + { + if (eventId == ERegisterNotificationNowPlayingContentChanged) + { + return ETrue; + } + } + else + { + return EFalse; + } + return EFalse; + } + +TBool CControlCommand::NormalCommand() + { + TBool ret = ETrue; + TRegisterNotificationEvent eventId = RAvrcpIPC::GetEventIdFromIPCOperationId(iOperationId); + TMetadataTransferPDU pduId = RAvrcpIPC::GetPDUIdFromIPCOperationId(iOperationId); + + if((eventId == ERegisterNotificationAvailablePlayersChanged) || + (eventId == ERegisterNotificationAddressedPlayerChanged)) + { + ret = EFalse; + } + return ret; + } +/** +@return Ownership of a CControlCommand representing an interim response to this command + */ +CControlCommand* CControlCommand::InterimResponseL() + { + CAVCFrame* frame = CAVCFrame::NewL(iFrame->Data(), AVC::EResponse); + CleanupStack::PushL(frame); + frame->SetType(AVC::EInterim); + + CControlCommand* finalResponse = CControlCommand::NewL(frame, iRemConId, + iTransactionLabel, iRemoteAddr, iClientId, iPlayerInfoManager); + CleanupStack::Pop(frame); + + finalResponse->iInterfaceUid = iInterfaceUid; + finalResponse->iOperationId = iOperationId; + + return finalResponse; + } + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/internalcommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/internalcommand.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,96 @@ +// Copyright (c) 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 "internalcommand.h" +#include "avrcputils.h" +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_BEARER); +#endif + +/** Factory function. + +@param aFrame The frame this command is to represent. +@param aRemConId The RemCon transaction label. +@param aTransLabel The AVCTP transaction label. +@param aAddr The bluetooth address to send this command to. +@return A fully constructed CBrowseCommand. +@leave System wide error codes. +*/ +CInternalCommand* CInternalCommand::NewL(TUid aInterfaceUid, + TUint aId, + TUint aOperationId, + const TDesC8& aCommandData) + { + CInternalCommand* command = new(ELeave)CInternalCommand(aInterfaceUid, aId, aOperationId); + CleanupStack::PushL(command); + command->ConstructL(aCommandData); + CleanupStack::Pop(command); + return command; + } + +/** Constructor. + +@param aFrame The AV/C frame this command is to represent. +@param aRemConId The RemCon transaction label. +@param aTransLabel The AVCTP transaction label. +@param aAddr The bluetooth address to send this command to. +@return A partially constructed CBrowseCommand. +@leave System wide error codes. +*/ +CInternalCommand::CInternalCommand(TUid aInterfaceUid, + TUint aId, + TUint aOperationId) + : CAvrcpCommand(aId, KDummyTransactionLabel, NULL) + { + LOG_FUNC + iInterfaceUid = aInterfaceUid; + iOperationId = aOperationId; + } + +/** Destructor. +*/ +CInternalCommand::~CInternalCommand() + { + LOG_FUNC + __ASSERT_DEBUG(iUsers == 0, AvrcpUtils::Panic(EAvrcpCommandStillInUse)); + iCommandData.Close(); + } + +void CInternalCommand::ConstructL(const TDesC8& aCommandData) + { + iCommandData.CreateL(aCommandData); + } + +void CInternalCommand::ResetL(TUint& aId, const TDesC8& aCommandData) + { + iCommandData.Close(); + iCommandData.CreateL(aCommandData); + iRemConId = aId; + } + +SymbianAvctp::TMessageType CInternalCommand::MessageType() const + { + // Should never be going out AVCTPwards + __ASSERT_DEBUG(EFalse, AvrcpUtils::Panic(EAvctpMessageTypeRequestedForInternalCommand)); + + return SymbianAvctp::EUndefined; + } + +const TDesC8& CInternalCommand::Data() const + { + return iCommandData; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/passthroughhelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/passthroughhelper.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,443 @@ +// Copyright (c) 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 "avrcplog.h" +#include "avrcprouter.h" +#include "avrcputils.h" +#include "controlcommand.h" +#include "passthroughhelper.h" +#include "controlbearer.h" + + +CPassthroughHelper* CPassthroughHelper::NewL(CRcpRouter& aRouter, CRemConBearerAvrcp& aBearer, CDeltaTimer& aTimer) + { + CPassthroughHelper* helper = new(ELeave)CPassthroughHelper(aRouter, aBearer, aTimer); + CleanupStack::PushL(helper); + helper->ConstructL(); + CleanupStack::Pop(helper); + return helper; + } + +CPassthroughHelper::~CPassthroughHelper() + { + } + +CPassthroughHelper::CPassthroughHelper(CRcpRouter& aRouter, CRemConBearerAvrcp& aBearer, CDeltaTimer& aTimer) + : iRouter(aRouter) + , iBearer(aBearer) + , iTimer(aTimer) + { + } + +void CPassthroughHelper::ConstructL() + { + } + +void CPassthroughHelper::Disconnect() + { + LOG_FUNC + + // We handle the last command as a special case to ensure the presses and + // releases are balanced from a clients' point of view. + if(iPreviousPassthrough) + { + iRouter.RemoveFromSendQueue(*iPreviousPassthrough); + BalanceHandledCommand(*iPreviousPassthrough); + } + } + +/** Sends a response to the remote device. + +Because of the 100ms timeout for responses we send a response to +passthrough commands as soon as we receive them. This means the real +response from RemCon is currently ignored. A real response is +only sent if this is a vendor dependent command. + +@param aCommand The command to respond to. +@param aErr The result of handling the command. KErrNone if successful. + KErrNotSupported if this operation is not supported. +*/ +void CPassthroughHelper::Respond(CControlCommand& aCommand, TInt aErr) + { + LOG_FUNC + aCommand.SetResponseType(aErr); + iRouter.AddToSendQueue(aCommand); + } + +/** To be called on completion of command handling. + +This aggregates the handler's tidying up of a finished +command. + +@param aCommand The command to tidy up. +*/ +void CPassthroughHelper::HandledCommand(CControlCommand& aCommand) + { + LOG_FUNC + + // If this was the previous passthrough reset it to NULL + if(iPreviousPassthrough == &aCommand) + { + iPreviousPassthrough = NULL; + } + + aCommand.CancelTimer(iTimer); + aCommand.DecrementUsers(); + } + +/** Handles incoming passthrough command. + +How the command is handled is dependent on this and the previous command. + +Previous command This command Behaviour +Press_op1 Press_op1 discard +Press_op1 Release_op1 press_op1 hold timer not expired - generate click_op1 + press_op1 release timer not expired - generate release_op1 +Press_op1 Press_op2 generate release_op1, start hold timer for press_op2 +Press_op1 Release_op2 press_op1 hold timer not expired - generate click_op1, discard release_op2 + press_op1 release timer not expired - generate release_op1, discard release_op2 +Release_op1 Press_op1 start hold timer for press_op1 +Release_op1 Release_op1 discard +Release_op1 Press_op2 start hold timer for press_op2 +Release_op1 Release_op2 discard + +@param aCommand The command to handle. +@leave System wide error code. +*/ +void CPassthroughHelper::HandlePassthrough(CControlCommand& aCommand) + { + LOG_FUNC + + // We can't map Vendor Unique passthrough command to clicks as we do + // not know how the button action is conveyed to the API. All we can + // do is try and ensure that we try to generate a release if one is + // missing by asking the convert. We also need to consider them as + // part of the passthrough history for how other passthrough commands + // should be interpreted. + TUint8 thisOpId; + aCommand.Frame().OperationId(thisOpId); + if(!aCommand.IsAvrcpPassthrough()) + { + aCommand.SetClick(EFalse); + } + + // Behaviour depends on previous command + TUint8 prevOpId; + if(iPreviousPassthrough) + { + __ASSERT_ALWAYS(iPreviousPassthrough->ButtonAct() == AVCPanel::EButtonPress, + AvrcpUtils::Panic(EAvrcpPressNotPreviousPassthroughCommand)); + + iPreviousPassthrough->Frame().OperationId(prevOpId); + } + + if(aCommand.ButtonAct() == AVCPanel::EButtonPress) + { + // Respond now so we can decrement users of aCommand at will + Respond(aCommand, KErrNone); + + if(iPreviousPassthrough) + { + // previous is press, current is press + if(prevOpId == thisOpId) + { + // prevCommand is for same opId as this one. Drop this + // command and reset release timer for prevCommand. + aCommand.DecrementUsers(); + + iPreviousPassthrough->CancelTimer(iTimer); + // If still flagged as a click then the user won't have been notified + // of the press yet - so do it now. + if(iPreviousPassthrough->Click()) + { + iPreviousPassthrough->SetClick(EFalse); + iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue); + iBearer.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId()); + } + StartReleaseTimer(*iPreviousPassthrough); + } + else if(iPreviousPassthrough->Click()) + { + // prevCommand is click, Hold timer not expired. Generate click + // to RemCon then start waiting for click. + iPreviousPassthrough->CancelTimer(iTimer); + iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue); + iBearer.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId()); + + HandledCommand(*iPreviousPassthrough); + + // Start waiting for click (core api) or release (vendor unique) + NewPress(aCommand); + } + else + { + // prevCommand is not click, Release timer not expired. Generate + // release to RemCon then start waiting for click. + BalanceHandledCommand(*iPreviousPassthrough); + + // Start waiting for click (core api) or release (vendor unique) + NewPress(aCommand); + } + } + else + { + // No previous command, current is press + + // Start waiting for click (core api) or release (vendor unique) + NewPress(aCommand); + } + } + else if(iPreviousPassthrough) + { + // previous is press, current is release + if(prevOpId == thisOpId) + { + Respond(aCommand, KErrNone); + + if(iPreviousPassthrough->Click()) + { + // Button release for same opId with hold timeout + aCommand.DecrementUsers(); // Drop this command. + + // Cancel hold timer and send the previous command as a click. + iPreviousPassthrough->CancelTimer(iTimer); + iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue); + iBearer.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId()); + + HandledCommand(*iPreviousPassthrough); + } + else + { + // Button release for same opId, hold timeout expired + iPreviousPassthrough->CancelTimer(iTimer); + HandledCommand(*iPreviousPassthrough); + + if(aCommand.IsAvrcpPassthrough()) + { + aCommand.SetCoreButtonAction(ERemConCoreApiButtonRelease, ETrue); + } + iBearer.MrcciNewCommand(aCommand, aCommand.ClientId()); + aCommand.DecrementUsers(); + } + } + else + { + // Drop this release and continue waiting for release to + // prevCommand. + Respond(aCommand, KErrNone); + aCommand.DecrementUsers(); + } + } + else + { + // No prevCommand, this is a release + // To get here either: + // - this is a spurious release + // - we've given up waiting for this + + // Because responses must be made within 100ms we respond before waiting + // to see what RemCon thinks. + Respond(aCommand, KErrNone); + aCommand.DecrementUsers(); + } + } + +void CPassthroughHelper::NewPress(CControlCommand& aCommand) + { + LOG_FUNC + __ASSERT_DEBUG(!iPreviousPassthrough, AVRCP_PANIC(EPreviousPassthroughNonNullReplacing)); + + iPreviousPassthrough = &aCommand; + + if(aCommand.IsAvrcpPassthrough()) + { + StartHoldTimer(aCommand); + } + else + { + iBearer.MrcciNewCommand(aCommand, aCommand.ClientId()); + StartReleaseTimer(aCommand); + } + } + +/** To be called on completion of command handling for an unbalanced press. + +This is a special version of the HandledCommand which which assumes the +command has been notified to the user and so balances the notification +of a press with a generated release command. + +@param aCommand The command to tidy up. +*/ +void CPassthroughHelper::BalanceHandledCommand(CControlCommand& aCommand) + { + LOG_FUNC + // CancelTimer also frees the timer entries, so needs to be called + // here even though there's no pending entry. + aCommand.CancelTimer(iTimer); + + // If this was the previous passthrough reset it to NULL + if(iPreviousPassthrough == &aCommand) + { + iPreviousPassthrough = NULL; + } + + // Here we handle the case that a press has been informed but a release has yet + // to be reported, and if it hasn't we provide the notification. + if(aCommand.ButtonAct() == AVCPanel::EButtonPress && !aCommand.Click()) + { + if(aCommand.IsAvrcpPassthrough()) + { + // FIXME I think we might need a new transaction id here? + TRAPD(err, aCommand.ReSetCoreButtonActionL(ERemConCoreApiButtonRelease, ETrue)); + if (err == KErrNone) + { + iBearer.MrcciNewCommand(aCommand, aCommand.ClientId()); + } + else + { + // just silently drop this command, do not send command to remconserv + } + } + else + { + // Need see if we can get a valid release from the converter. Pass + // it the same AVC Frame as the press, but with the button action + // flipped to release. If we can't do this then there's not a + // lot we can do. + // FIXME + } + } + aCommand.iHandlingLink.Deque(); + aCommand.DecrementUsers(); + } + + +//------------------------------------------------------------------------------------ +// Timer functions +//------------------------------------------------------------------------------------ + +/** Starts the hold timer (only applicable to press commands). + +This is the timer to determine whether a command will be passed to RemCon +as a click. If the timer expires before a matching release is received +the press and release will be sent separately. Otherwise, a click is +sent. + +@param aCommand The command to start the timer for. +*/ +void CPassthroughHelper::StartHoldTimer(CControlCommand& aCommand) + { + LOG_FUNC + + // These cannot fail as we use placement new + TAvrcpTimerExpiryInfo* timerInfo = new(aCommand.TimerExpiryInfo())TAvrcpTimerExpiryInfo(this, aCommand); + + TCallBack callback(HoldExpiry, timerInfo); + TDeltaTimerEntry* timerEntry = new(aCommand.TimerEntry())TDeltaTimerEntry(callback); + + iTimer.Queue(KRcpHoldThreshold, *timerEntry); + } + +/** Callback when hold timer expires. + +This is a static forwarding function. + +@param aExpiryInfo The information used by the real HoldExpiry to + deal with the timer expiry. +*/ +TInt CPassthroughHelper::HoldExpiry(TAny* aExpiryInfo) + { + LOG_STATIC_FUNC + TAvrcpTimerExpiryInfo *timerInfo = reinterpret_cast(aExpiryInfo); + (reinterpret_cast(timerInfo->iHandler))->HoldExpiry(timerInfo->iCommand); + + return KErrNone; + } + +/** Deals with expiry of hold timer. + +1) This is not a click. Set click to false for this command. +2) Inform RemCon of available press command +3) Start release timer. + +@param aCommand The CControlCommand that has expired. +*/ +void CPassthroughHelper::HoldExpiry(CControlCommand& aCommand) + { + LOG_FUNC + __ASSERT_DEBUG((aCommand.ButtonAct() == AVCPanel::EButtonPress), AvrcpUtils::Panic(EAvrcpHoldExpiryForRelease)); + + // We haven't received a release soon enough to treat this as + // a click. Send the press on to RemCon and wait for a release. + // CancelTimer also frees the timer entries, so needs to be called + // here even though there's no pending entry. + aCommand.CancelTimer(iTimer); + aCommand.SetClick(EFalse); + aCommand.SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue); + iBearer.MrcciNewCommand(aCommand, aCommand.ClientId()); + StartReleaseTimer(aCommand); + } + +/** Starts the release timer (only applicable to press commands). + +If a release is not received quickly enough to treat this press as +a click, the release timer is started. 2s after receiving a button +press we should assume the release if we haven't received one. + +@param aCommand The command to start the timer for. +*/ +void CPassthroughHelper::StartReleaseTimer(CControlCommand& aCommand) + { + TAvrcpTimerExpiryInfo* timerInfo = new(aCommand.TimerExpiryInfo())TAvrcpTimerExpiryInfo(this, aCommand); + + TCallBack callback(ReleaseExpiry, timerInfo); + TDeltaTimerEntry* timerEntry = new(aCommand.TimerEntry())TDeltaTimerEntry(callback); + + iTimer.Queue(KRcpIncomingButtonReleaseTimeout, *timerEntry); + } + +/** Callback when release timer expires. + +This is a static forwarding function. + +@param aExpiryInfo The information used by the real ReleaseExpiry to + deal with the timer expiry. +*/ +TInt CPassthroughHelper::ReleaseExpiry(TAny* aExpiryInfo) + { + LOG_STATIC_FUNC + TAvrcpTimerExpiryInfo *timerInfo = reinterpret_cast(aExpiryInfo); + (reinterpret_cast(timerInfo->iHandler))->ReleaseExpiry(timerInfo->iCommand); + + return KErrNone; + } + +/** Deals with expiry of release timer. + +1) Generate release for this command. +2) Inform RemCon of available release command. + +@param aCommand The CControlCommand that has expired. +*/ +void CPassthroughHelper::ReleaseExpiry(CControlCommand& aCommand) + { + LOG_FUNC + __ASSERT_DEBUG((aCommand.ButtonAct() == AVCPanel::EButtonPress), AvrcpUtils::Panic(EAvrcpReleaseExpiryForRelease)); + __ASSERT_DEBUG(!aCommand.Click(), AvrcpUtils::Panic(EAvrcpReleaseExpiryForClick)); + + // We haven't received a release within the allotted time. Assume + // one and generate it to RemCon. + BalanceHandledCommand(aCommand); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerbitmasks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerbitmasks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,337 @@ +// Copyright (c) 2008-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: +// TPlayerFeatureBitmask.cpp +// + +#include +#include "avrcplog.h" +#include "avrcputils.h" +#include "mediabrowse.h" +#include "nowplaying.h" +#include "playerbitmasks.h" +#include "remcongroupnavigation.h" + + +TPlayerFeatureBitmask::TPlayerFeatureBitmask() + { + iFeatureBitmask.FillZ(KFeatureBitmaskLength); + } + +TPlayerFeatureBitmask::TPlayerFeatureBitmask(const TPlayerFeatureBitmask& aFeatureBitmask) + { + iFeatureBitmask.Copy(aFeatureBitmask.FeatureBitmask()); + } + +void TPlayerFeatureBitmask::SetCoreApiFeatures(RArray aOperation) + { + if(aOperation.Count() > 0) + { + for(TInt j = 0; j< aOperation.Count() ; j++) + { + switch(aOperation[j]) + { + case ERemConCoreApiSelect: + iFeatureBitmask[ESelectByteOffset] |= (1< aOperation) + { + if(aOperation.Count()) + { + iFeatureBitmask[EAdvancedControlPlayerByteOffset] |= (1< aOperation) + { + if(aOperation.Count()) + { + iFeatureBitmask[EVendorUniqueByteOffset] |= (1< aOperation) + { + if(aOperation.Count()) + { + iFeatureBitmask[EAdvancedControlPlayerByteOffset] |= (1<= 0) + { + iFeatureBitmask[EAddToNowPlayingByteOffset] |= (1< aOperation) + { + if(aOperation.Count()) + { + iFeatureBitmask[EAdvancedControlPlayerByteOffset] |= (1<= 0) + { + iFeatureBitmask[ESearchByteOffset] |= (1<= 0) + { + iFeatureBitmask[EUidPersistencyByteOffset] |= (1<DecrementUsers(); + } + +void CPlayerWatcherBase::MessageSent(CAvrcpCommand& /*aCommand*/, TInt /*aSendResult*/) + { + LOG_FUNC; + __DEBUG_ONLY(AVRCP_PANIC(ELowerInterfaceUsedOnInternalHandler)); + } + +void CPlayerWatcherBase::MaxPacketSize(TInt /*aMtu*/) + { + LOG_FUNC; + __DEBUG_ONLY(AVRCP_PANIC(ELowerInterfaceUsedOnInternalHandler)); + } + +void CPlayerWatcherBase::ReceiveCommandL(const TDesC8& /*aMessageInformation*/, SymbianAvctp::TTransactionLabel /*aTransLabel*/, const TBTDevAddr& /*aAddr*/) + { + LOG_FUNC; + __DEBUG_ONLY(AVRCP_PANIC(ELowerInterfaceUsedOnInternalHandler)); + } + +CInternalCommand& CPlayerWatcherBase::FindCommand(TUid __DEBUG_ONLY(aInterfaceUid), + TUint aTransactionId, TRemConClientId& aFoundClientId) + { + __ASSERT_DEBUG(aInterfaceUid == TUid::Uid(KRemConPlayerInformationUid) || aInterfaceUid == TUid::Uid(KRemConMediaBrowseApiUid), AVRCP_PANIC(EResponseForWrongInterface)); + THashMapIter commandIter(iCommands); + + CInternalCommand* command = NULL; + while(commandIter.NextValue()) + { + command = *commandIter.CurrentValue(); + if(command->RemConCommandId() == aTransactionId) + { + aFoundClientId = *commandIter.CurrentKey(); + break; + } + } + + // If command is NULL we reached the end of our iter without finding the match + __ASSERT_DEBUG(command, AVRCP_PANIC(EUnmatchedResponseFromRemCon)); + + return *command; + } + +TInt CPlayerWatcherBase::SendRemConResponse(TUid aInterfaceUid, TUint aTransactionId, RBuf8& aData) + { + LOG_FUNC; + + TRemConClientId clientId; + CInternalCommand& command = FindCommand(aInterfaceUid, aTransactionId, clientId); + + ReceiveUpdate(command, clientId, aData); + + return KErrNone; + } + +void CPlayerWatcherBase::SendReject(TUid aInterfaceUid, TUint aTransactionId) + { + TRemConClientId clientId; + (void)FindCommand(aInterfaceUid, aTransactionId, clientId); + + ReceiveReject(clientId); + } + +void CPlayerWatcherBase::Disconnect() + { + LOG_FUNC; + } + +CPlayStatusWatcher* CPlayStatusWatcher::NewL(MPlayStatusObserver& aObserver, MRemConCommandInterface& aCommandInterface) + { + LOG_STATIC_FUNC; + CPlayStatusWatcher* watcher = new(ELeave)CPlayStatusWatcher(aObserver, aCommandInterface); + return watcher; + } + +CPlayStatusWatcher::CPlayStatusWatcher(MPlayStatusObserver& aObserver, + MRemConCommandInterface& aCommandInterface) + : CPlayerWatcherBase(aCommandInterface), iObserver(aObserver) + { + LOG_FUNC; + } + +CPlayStatusWatcher::~CPlayStatusWatcher() + { + LOG_FUNC; + } + +void CPlayStatusWatcher::StartWatchingPlayerL(TRemConClientId aClientId) + { + LOG_FUNC; + __ASSERT_DEBUG(!iCommands.Find(aClientId), AVRCP_PANIC(EAlreadyWatchingPlayer)); + + CInternalCommand* command = CInternalCommand::NewL(TUid::Uid(KRemConPlayerInformationUid), + 0, + EGetPlayStatusUpdate, + KNullDesC8); + + CleanupStack::PushL(command); + iCommands.InsertL(aClientId, command); + CleanupStack::Pop(command); + command->IncrementUsers(); + + // Initially request uid notification relative to stopped + SendPlayStatusUpdateRequest(*command, aClientId, MPlayerEventsObserver::EStopped); + } + +void CPlayStatusWatcher::SendPlayStatusUpdateRequest(CInternalCommand& aCommand, TRemConClientId& aClientId, MPlayerEventsObserver::TPlaybackStatus aPlaybackStatus) + { + LOG_FUNC; + + RRemConPlayerInformationGetPlayStatusUpdateRequest request; + request.iStatus = aPlaybackStatus; + + TBuf8 buf; + TRAPD(err, request.WriteL(buf)); + + // We know how big the request is so this should never fail + __ASSERT_DEBUG(err == KErrNone, AVRCP_PANIC(EUidUpdateRequestWriteFailure)); + + TUint transId = iCommandInterface.MrcciNewTransactionId(); + TRAP(err, aCommand.ResetL(transId, buf)); + + if(err == KErrNone) + { + iCommandInterface.MrcciNewCommand(aCommand, aClientId); + } + else + { + // Doom + iObserver.MpsoError(aClientId); + } + } + +void CPlayStatusWatcher::ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData) + { + LOG_FUNC; + + // Read 4 byte Big-Endian error code before the payload + RAvrcpIPCError errorResponse; + TRAPD(err, errorResponse.ReadL(aData)); + err = err ? err : errorResponse.iError; + + RRemConPlayerInformationGetPlayStatusUpdateResponse response; + if(!err) + { + // Parse the rest of the response (minus error code) + TRAP(err, response.ReadL(aData.RightTPtr(aData.Length() - KLengthErrorResponse))); + } + + aData.Close(); // data has been used now + + if(!err) + { + iObserver.MpsoPlayStatusChanged(aClientId, response.iStatus); + SendPlayStatusUpdateRequest(aCommand, aClientId, response.iStatus); + } + else + { + // Should never get here with a valid player. This client is + // sending us junk. + iObserver.MpsoError(aClientId); + } + } + +void CPlayStatusWatcher::ReceiveReject(TRemConClientId aClientId) + { + LOG_FUNC; + iObserver.MpsoError(aClientId); + } + +CUidWatcher* CUidWatcher::NewL(MUidObserver& aObserver, + MRemConCommandInterface& aCommandInterface) + { + LOG_STATIC_FUNC; + CUidWatcher* watcher = new(ELeave)CUidWatcher(aObserver, aCommandInterface); + return watcher; + } + +CUidWatcher::CUidWatcher(MUidObserver& aObserver, + MRemConCommandInterface& aCommandInterface) + : CPlayerWatcherBase(aCommandInterface), iObserver(aObserver) + { + LOG_FUNC; + } + +CUidWatcher::~CUidWatcher() + { + LOG_FUNC; + } + +void CUidWatcher::StartWatchingPlayerL(TRemConClientId aClientId) + { + LOG_FUNC; + __ASSERT_DEBUG(!iCommands.Find(aClientId), AVRCP_PANIC(EAlreadyWatchingPlayer)); + + CInternalCommand* command = CInternalCommand::NewL(TUid::Uid(KRemConMediaBrowseApiUid), + 0, + EMediaLibraryStateCookieUpdateOperationId, + KNullDesC8); + + CleanupStack::PushL(command); + iCommands.InsertL(aClientId, command); + CleanupStack::Pop(command); + command->IncrementUsers(); + + // Initially request uid notification relative to 0 uid counter + SendUidUpdateRequest(*command, aClientId, 0); + } + +void CUidWatcher::SendUidUpdateRequest(CInternalCommand& aCommand, TRemConClientId& aClientId, TUint16 aUidCounter) + { + LOG_FUNC; + RRemConUidsChangedRequest request; + request.iInitialUidCounter = aUidCounter; + TBuf8 buf; + TRAPD(err, request.WriteL(buf)); + // We know how big the request is so this should never fail + __ASSERT_DEBUG(err == KErrNone, AVRCP_PANIC(EUidUpdateRequestWriteFailure)); + + TUint transId = iCommandInterface.MrcciNewTransactionId(); + TRAP(err, aCommand.ResetL(transId, buf)); + + if(err == KErrNone) + { + iCommandInterface.MrcciNewCommand(aCommand, aClientId); + } + else + { + // Doom + iObserver.MuoError(aClientId); + } + } + +void CUidWatcher::ReceiveUpdate(CInternalCommand& aCommand, TRemConClientId aClientId, RBuf8& aData) + { + LOG_FUNC; + RRemConUidsChangedResponse response; + TRAPD(err, response.ReadL(aData)); + aData.Close(); // data has been used now + + if(!err) + { + iObserver.MuoUidChanged(aClientId, response.iUidCounter); + SendUidUpdateRequest(aCommand, aClientId, response.iUidCounter); + } + else + { + // Should never get here with a valid player. This client is + // sending us junk. + iObserver.MuoError(aClientId); + } + } + +void CUidWatcher::ReceiveReject(TRemConClientId aClientId) + { + LOG_FUNC; + iObserver.MuoError(aClientId); + } + + + diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1155 @@ +// Copyright (c) 2004-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: +// + + + +/** + @file + @internalComponent + @released +*/ + +#include +#include +#include +#include +#include +#include +#include "controlcommand.h" +#include "browsecommand.h" +#include "avrcpbrowsingcommandhandler.h" +#include "avrcpincomingcommandhandler.h" +#include "avrcpoutgoingcommandhandler.h" +#include "avrcpremotedevice.h" +#include "avrcprouter.h" +#include "avrcputils.h" +#include "avrcpplayerinfomanager.h" +#include "bulkbearer.h" +#include "controlbearer.h" +#include "mediabrowse.h" +#include "nowplaying.h" + +#include "avrcplog.h" + + + +/** Allocates and constructs a new CRemConBearerAvrcp object. + +@param aParams Bearer construction params used for base class construction. +@return A new CRemConBearerAvrcp object. +@leave System wide error code +*/ +CRemConBearerAvrcp* CRemConBearerAvrcp::NewL(TBearerParams& aParams) + { + LOG_STATIC_FUNC + CRemConBearerAvrcp* bearer = new(ELeave) CRemConBearerAvrcp(aParams); + CleanupStack::PushL(bearer); + + TRAPD(err, bearer->ConstructL()); + + if(err == KErrNoMemory) + { + User::Leave(err); + } + // else KErrNone or some other error -- swallow it. + + CleanupStack::Pop(bearer); + return bearer; + } + +/** Constructor. + +@param aParams Bearer construction params used for base class construction. +*/ +CRemConBearerAvrcp::CRemConBearerAvrcp(TBearerParams& aParams) : + CRemConBearerPlugin(aParams), iRemotes(_FOFF(CRcpRemoteDevice, iLink)), + iReadyCommands(_FOFF(CAvrcpCommand, iReadyLink)), iReadyResponses(_FOFF(CAvrcpCommand, iReadyLink)), + iReadyNotifyResponses(_FOFF(CControlCommand, iReadyLink)), + iReadyNotifyCommands(_FOFF(CAvrcpCommand, iReadyLink)) + { + LOG_FUNC + } + +/** Second phase construction. + +@leave System wide error code +*/ +void CRemConBearerAvrcp::ConstructL() + { + LOG_FUNC + + // Set-up TLS + LEAVEIFERRORL(Dll::SetTls(reinterpret_cast(EControlThread))); + + // New up a router. This opens and uses the RAvctp. + // On initialisation it should begin listening. + iRouter = CControlRouter::NewL(iAvctp, *this); + iTimer = CDeltaTimer::NewL(CActive::EPriorityStandard); + iPlayerInfoManager = CAvrcpPlayerInfoManager::NewL(Observer(), *this); + iInternalHandler = &iPlayerInfoManager->InternalCommandHandler(); + + // Create the bulk bearer - actual usage occurs in the bulk thread. + iBulkBearer = CAvrcpBulkBearer::NewL(iAvctp, *iPlayerInfoManager); + iConstructionComplete = ETrue; + } + +/** Destructor. +*/ +CRemConBearerAvrcp::~CRemConBearerAvrcp() + { + LOG_FUNC + + while (!iRemotes.IsEmpty()) + { + CRcpRemoteDevice* remote = iRemotes.First(); + remote->iLink.Deque(); + remote->Disconnect(EFalse); + delete remote; + } + + delete iRouter; + + delete iBulkBearer; + + // Delete the timer last as pending events + // are cancelled in remote->Disconnect + + delete iTimer; + + delete iPlayerInfoManager; + + Dll::FreeTls(); + } + +//--------------------------------------------------------------------- +// RemConBearer control functions +//--------------------------------------------------------------------- + +/** Called by RemCon to retrieve a response on a connection. + +This must only be called as a result of a NewResponse upcall. + +@param aInterfaceUid The UID of the outer-layer client API specifying the response. +@param aId The command identifier used as a cookie for command/response matching. +@param aOperationId The ID of the response operation in the outer-layer client API. +@param aData API-specific message data. On success, ownership is returned. +@param aAddr The connection. +*/ +TInt CRemConBearerAvrcp::GetResponse(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr) + { + LOG_FUNC + + // If object only partially constructed, swallow the request + __ASSERT_DEBUG(iConstructionComplete, AVRCP_PANIC(EAvrcpNoResponsesAvailable)); + + + TInt result = KErrNotFound; + + if(!iReadyResponses.IsEmpty()) + { + CAvrcpCommand* command = iReadyResponses.First(); + TBTDevAddr btAddr; + command->GetCommandInfo(aInterfaceUid, aId, aOperationId, aCommandData, btAddr); + AvrcpUtils::BTToRemConAddr(btAddr, aAddr); + + // Remove command from queue first because calling + // DecrementUsers() may delete command + command->iReadyLink.Deque(); + command->DecrementUsers(); + result = KErrNone; + } + else + { + // RemCon is trying to pick up a response we don't think we have + __ASSERT_DEBUG(EFalse, AVRCP_PANIC(EAvrcpNoResponsesAvailable)); + } + + return result; + } + +/** Called by RemCon to retrieve a response on a connection. + +This must only be called as a result of a NewResponse upcall. + +@param aInterfaceUid The UID of the outer-layer client API specifying the response. +@param aId The command identifier used as a cookie for command/response matching. +@param aOperationId The ID of the response operation in the outer-layer client API. +@param aData API-specific message data. On success, ownership is returned. +@param aAddr The connection. +*/ +TInt CRemConBearerAvrcp::GetNotifyResponse(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr, + TRemConMessageSubType& aSubMessageType) + { + LOG_FUNC + + // If object only partially constructed, swallow the request + __ASSERT_DEBUG(iConstructionComplete, AVRCP_PANIC(EAvrcpNoResponsesAvailable)); + + + TInt result = KErrNotFound; + + if(!iReadyNotifyResponses.IsEmpty()) + { + CControlCommand* command = iReadyNotifyResponses.First(); + TBTDevAddr btAddr; + command->GetCommandInfo(aInterfaceUid, aId, aOperationId, aCommandData, btAddr); + AvrcpUtils::BTToRemConAddr(btAddr, aAddr); + + switch ( command->Frame().Type() ) + { + case AVC::EInterim: + aSubMessageType = ERemConNotifyResponseInterim; + break; + case AVC::EChanged: + aSubMessageType = ERemConNotifyResponseChanged; + break; + case AVC::ERejected: // fall into default + case AVC::ENotImplemented:// fall into default + default: + aSubMessageType = ERemConMessageDefault; + break; + } + + // Remove command from queue first because calling + // DecrementUsers() may delete command + command->iReadyLink.Deque(); + command->DecrementUsers(); + result = KErrNone; + } + else + { + // RemCon is trying to pick up a response we don't think we have + __ASSERT_DEBUG(EFalse, AVRCP_PANIC(EAvrcpNoResponsesAvailable)); + } + + return result; + } + +/** Called by RemCon to send a command on a connection. + +@param aInterfaceUid The UID of the outer-layer client API specifying the command. +@param aOperationId The ID of the command operation in the outer-layer client API. +@param aId The command identifier used as a cookie for command/response matching. +@param aData API-specific message data. On success, ownership is passed. +@param aAddr The connection. +@return Error. This request is synchronous. It returns KErrNone when AVRCP has +taken responsibility for sending the message. This involves checking that the message +is well-formed and adding it to the send queue. +*/ +TInt CRemConBearerAvrcp::SendCommand(TUid aInterfaceUid, + TUint aOperationId, + TUint aId, + RBuf8& aData, + const TRemConAddress& aAddr) + { + LOG_FUNC + // RemCon retains ownership of the data in aData until + // this function returns KErrNone. + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return KErrNotSupported; + } + + + TBTDevAddr btAddr; + TInt err = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + + if(err == KErrNone) + { + CRcpRemoteDevice* remote = RemoteDevice(btAddr); + __ASSERT_ALWAYS(remote, AVRCP_PANIC(EAvrcpNotConnected)); + + TRAP(err, remote->OutgoingHandler().SendCommandL(aInterfaceUid, + aOperationId, + aId, + aData, + btAddr)); + } + + return err; + } + + +/** Called by RemCon to retrieve a command on a connection. + +This must only be called as a result of a NewCommand upcall. + +@param aInterfaceUid The UID of the outer-layer client API specifying the command. +@param aId The command identifier used as a cookie for command/response matching. +@param aOperationId The ID of the command operation in the outer-layer client API. +@param aData API-specific message data. On success, ownership is returned. +@param aAddr The connection. +*/ +TInt CRemConBearerAvrcp::GetCommand(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr) + { + TInt result = KErrNotFound; + + if(!iReadyCommands.IsEmpty()) + { + CAvrcpCommand* command = GetFirstCommand(iReadyCommands, aInterfaceUid, aId, aOperationId, aCommandData, aAddr); + if(command) + { + // Remove command from queue first because calling + // DecrementUsers() may delete command + command->iReadyLink.Deque(); + command->DecrementUsers(); + result = KErrNone; + } + } + else + { + __DEBUGGER(); + } + + return result; + } + +/** Called by RemCon to retrieve a notify command on a connection. + +This must only be called as a result of a NewNotifyCommand upcall. + +@param aInterfaceUid The UID of the outer-layer client API specifying the command. +@param aId The command identifier used as a cookie for command/response matching. +@param aOperationId The ID of the command operation in the outer-layer client API. +@param aData API-specific message data. On success, ownership is returned. +@param aAddr The connection. +*/ +TInt CRemConBearerAvrcp::GetNotifyCommand(TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr) + { + TInt result = KErrNotFound; + + CAvrcpCommand* command = GetFirstCommand(iReadyNotifyCommands, aInterfaceUid, aId, aOperationId, aCommandData, aAddr); + if(command) + { + // Remove command from queue first because calling + // DecrementUsers() may delete command + command->iReadyLink.Deque(); + command->DecrementUsers(); + result = KErrNone; + } + + return result; + } + +/** +Internal method, called by GetCommand() and GetNotifyCommand() + +@return The first command from the Queue. NULL if the queue is empty. The command remains + on the queue. +*/ +CAvrcpCommand* CRemConBearerAvrcp::GetFirstCommand(TDblQue& aQue, TUid& aInterfaceUid, + TUint& aId, + TUint& aOperationId, + RBuf8& aCommandData, + TRemConAddress& aAddr) + { + LOG_FUNC + + // If object only partially constructed, swallow the request + __ASSERT_DEBUG(iConstructionComplete, AVRCP_PANIC(EAvrcpNoResponsesAvailable)); + + CAvrcpCommand* command = NULL; + + if(! aQue.IsEmpty()) + { + command = aQue.First(); + + // Calling GetCommandInfo transfers the command data to RemCon. This means + // once we have called it we are committed to returning KErrNone. + TBTDevAddr btAddr; + command->GetCommandInfo(aInterfaceUid, aId, aOperationId, aCommandData, btAddr); + AvrcpUtils::BTToRemConAddr(btAddr, aAddr); + } + else + { + // RemCon is trying to pick up a command we don't think we have + __ASSERT_DEBUG(EFalse, AVRCP_PANIC(EAvrcpNoResponsesAvailable)); + } + + return command; + } +/** Called by RemCon to send a response on a connection. + +@param aInterfaceUid The UID of the outer-layer client API specifying the response. +@param aOperationId The ID of the response operation in the outer-layer client API. +@param aId The command identifier used as a cookie for command/response matching +@param aData API-specific message data. On success, ownership is passed. +@param aAddr The connection. +@return Error. This request is synchronous. It is completed by AVRCP when it has +taken responsibility for sending the message. This involves checking that the message +is well-formed and adding it to the send queue. +*/ +TInt CRemConBearerAvrcp::SendResponse(TUid aInterfaceUid, + TUint /*aOperationId*/, + TUint aId, + RBuf8& aData, + const TRemConAddress& aAddr) + { + LOG_FUNC + // RemCon retains ownership of the data in aData until + // this function returns KErrNone. + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return KErrNotSupported; + } + + + TBTDevAddr btAddr; + TInt err = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + __ASSERT_DEBUG(err == KErrNone, AVRCP_PANIC(EInvalidBtAddrInResponse)); + + if(btAddr != TBTDevAddr(0)) + { + CRcpRemoteDevice* remote = RemoteDevice(btAddr); + __ASSERT_ALWAYS(remote, AVRCP_PANIC(EAvrcpNotConnected)); + + err = remote->IncomingHandler().SendRemConResponse(aInterfaceUid, aId, aData); + } + else + { + err = iInternalHandler->SendRemConResponse(aInterfaceUid, aId, aData); + } + + return err; + } + +/** Called by RemCon when either + a) The TSP does not address a command to any clients + b) The TSP does not permit the response from any commands + c) All the clients disconnect from remcon before the response is sent + to send a null response on a connection. The connection must already + exist + @param aInterfaceUid The UID of the outer-layer client API that the command + was sent to + @param aOperationId The ID of the command operation sent to remcon + @param aId The command identifier used as a cookie for command/response + matching. + @param aAddr The connection. + */ + +void CRemConBearerAvrcp::SendReject(TUid aInterfaceUid, + TUint /* aOperationId */, + TUint aTransactionId, + const TRemConAddress& aAddr) + { + LOG_FUNC + + __ASSERT_DEBUG(iConstructionComplete, AVRCP_PANIC(EAvrcpNotFullyConstructed)); + + TBTDevAddr btAddr; + __DEBUG_ONLY(TInt err = )AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + __ASSERT_DEBUG(err == KErrNone, AVRCP_PANIC(EInvalidBtAddrInResponse)); + + if(btAddr != TBTDevAddr(0)) + { + CRcpRemoteDevice* remote = RemoteDevice(btAddr); + __ASSERT_ALWAYS(remote, AVRCP_PANIC(EAvrcpNotConnected)); + + remote->IncomingHandler().SendReject(aInterfaceUid, aTransactionId); + } + else + { + iInternalHandler->SendReject(aInterfaceUid, aTransactionId); + } + + } + +/** Called by RemCon to establish a bearer-level connection to another party. + +Completion is signalled back in ConnectConfirm. + +@param aAddr The RemCon address to connect to. +*/ +void CRemConBearerAvrcp::ConnectRequest(const TRemConAddress& aAddr) + { + LOG_FUNC + + if (!iConstructionComplete) + { + // Object only partially constructed, error the request + Observer().ConnectConfirm(aAddr, KErrNotSupported); + return; + } + + + // Get a bluetooth address from the TRemConAddr + TBTDevAddr btAddr; + TInt convErr = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + if(convErr != KErrNone) + { + Observer().ConnectConfirm(aAddr, convErr); + return; + } + + // Address for internal commands + if(btAddr == TBTDevAddr(0)) + { + Observer().ConnectConfirm(aAddr, KErrNone); + return; + } + + CRcpRemoteDevice* remote = RemoteDevice(btAddr); + if(remote) + { + // Already have a connection to this address + Observer().ConnectConfirm(aAddr, KErrNone); + return; + } + + TRAPD(devErr, remote = CRcpRemoteDevice::NewL(btAddr, *iRouter, *this, Observer(), *iTimer, *iPlayerInfoManager)); + if(devErr) + { + Observer().ConnectConfirm(aAddr, devErr); + return; + } + + iRemotes.AddLast(*remote); + devErr = iRouter->ConnectRequest(btAddr); + if(devErr != KErrNone) + { + remote->iLink.Deque(); + delete remote; + + // Error with connect, generate errored ConnectConfirm. + Observer().ConnectConfirm(aAddr, devErr); + return; + } + + return; + } + +/** Called by RemCon to destroy a bearer-level connection to another party. + +Completion is signalled back in DisconnectConfirm. + +@param aAddr The RemCon address to disconnect from. +*/ +void CRemConBearerAvrcp::DisconnectRequest(const TRemConAddress& aAddr) + { + LOG_FUNC + + __ASSERT_DEBUG(iConstructionComplete, AVRCP_PANIC(EAvrcpDisconnectRequestWhilePartiallyConstructed)); + + TBTDevAddr btAddr; + TInt err = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + + if(!err) + { + // Address for internal commands + if(btAddr == TBTDevAddr(0)) + { + Observer().DisconnectConfirm(aAddr, KErrNone); + } + else + { + CRcpRemoteDevice *remote = RemoteDevice(btAddr); + if(remote) + { + // calling disconnect gives the remote the opportunity + // to do anything necessary to commands still on its + // queue before we delete it. + remote->Disconnect(ETrue); + remote->iLink.Deque(); + delete remote; + + err = iRouter->DisconnectRequest(btAddr); + // If this failed generate an errored DisconnectConfirm now, + // otherwise we'll be prodded with a DisconnectConfirm from + // the router at a later date. + if(err != KErrNone) + { + Observer().DisconnectConfirm(aAddr, err); + } + } + else + { + __ASSERT_DEBUG(EFalse, AVRCP_PANIC(EAvrcpMismatchedConnectDisconnect)); + Observer().DisconnectConfirm(aAddr, KErrNotFound); + } + } + } + else + { + Observer().DisconnectConfirm(aAddr, err); + } + } + +/** Called by RemCon to get the security policy. + +This is the list of capabilities required to make/destroy connections +over the bearer, and to send and receive messages over the bearer. + +@return The bearer's security policy. +*/ +TSecurityPolicy CRemConBearerAvrcp::SecurityPolicy() const + { + LOG_FUNC + return TSecurityPolicy(ECapabilityLocalServices); + } + +/** Called by RemCon when either (a) the number of controller clients changes +from 0 to 1 or from 1 to 0, or (b) the number of target clients changes +from 0 to 1 or from 1 to 0. + +@param aControllerPresent Whether there are any controller clients connected. +@param aTargetPresent Whether there are any target clients connected. +*/ +void CRemConBearerAvrcp::ClientStatus(TBool aControllerPresent, TBool aTargetPresent) + { + LOG_FUNC + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return; + } + + iPlayerInfoManager->ClientStatus(aControllerPresent, aTargetPresent); + } + +/** +Called by RemCon when a client has become available for addressing. Once this +call has been made the bearer may use the provided TRemConClientId to address +incoming commands and notifys to this client until RemCon calls ClientNotAvailable +with this TRemConClientId. + +@param aId A unique identifier for this client, that can be used when addressing +incoming commands. +@param aClientType The basic type of this client +@param aClientSubType More detailed type information on this client +@param aName The name of this client in UTF-8. +*/ +void CRemConBearerAvrcp::ClientAvailable(TRemConClientId& aId, TPlayerType aClientType, TPlayerSubType aClientSubType, const TDesC8& aName) + { + LOG_FUNC + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return; + } + + iPlayerInfoManager->ClientAvailable(aId, aClientType, aClientSubType, aName); + } + +/** +Called by RemCon when a client is no longer available for addressing. Once this +call has been made the bearer shall not use this client id when addressing incoming +commands and notifys until informed that the client is available again via +ClientAvailable. + +@param aId The client that has ceased to be available. +*/ +void CRemConBearerAvrcp::ClientNotAvailable(TRemConClientId& aId) + { + LOG_FUNC + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return; + } + + iPlayerInfoManager->ClientNotAvailable(aId); + } + +TInt CRemConBearerAvrcp::SetLocalAddressedClient(TRemConClientId& aId) + { + LOG_FUNC + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return KErrNotSupported; + } + + return iPlayerInfoManager->SetLocalAddressedClient(aId); + } + +void CRemConBearerAvrcp::ControllerFeaturesUpdated(RArray& aSupportedInterfaces) + { + LOG_FUNC + + if(!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return; + } + + // This is a best effort attempt at keeping the sdp record accurate. If we + // failed to update it then just live with it. + TRAP_IGNORE(iPlayerInfoManager->ControllerFeaturesUpdatedL(aSupportedInterfaces)); + } + +//--------------------------------------------------------------------- +// Data notifications from the command handlers +//--------------------------------------------------------------------- + +/** Called from incoming handlers to notify that a command +is ready for Remcon. + +@param aCommand The command that is ready. +*/ +void CRemConBearerAvrcp::MrcciNewCommand(CAvrcpCommand& aCommand) + { + LOG_FUNC + + // Need to put the command on the queue straight + // away in case RemCon collects it synchronously + iReadyCommands.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + + // Unaddressed variant + TInt err = Observer().NewCommand(remAddr); + + if(err != KErrNone) + { + HandleUndeliveredCommand(aCommand, remAddr); + } + } + +/** Called from incoming handlers to notify that a command +is ready for Remcon. + +@param aCommand The command that is ready. +*/ +void CRemConBearerAvrcp::MrcciNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) + { + LOG_FUNC + + // Need to put the command on the queue straight + // away in case RemCon collects it synchronously + iReadyCommands.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + + // if this is the null client id then RemCon will address it + TInt err = Observer().NewCommand(remAddr, aClientId); + + if(err != KErrNone) + { + HandleUndeliveredCommand(aCommand, remAddr); + } + } + +/** Called from incoming handlers to notify that a notify command +is ready for Remcon. + +@param aCommand The command that is ready. +*/ +void CRemConBearerAvrcp::MrccciNewNotifyCommand(CAvrcpCommand& aCommand) + { + LOG_FUNC + + // Need to put the command on the queue straight + // away in case RemCon collects it synchronously + iReadyNotifyCommands.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + + // Will be addressed by RemCon + TInt err = Observer().NewNotifyCommand(remAddr); + + if(err != KErrNone) + { + HandleUndeliveredCommand(aCommand, remAddr); + } + } + +/** Called from incoming handlers to notify that a notify command +is ready for Remcon. + +@param aCommand The command that is ready. +*/ +void CRemConBearerAvrcp::MrccciNewNotifyCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) + { + LOG_FUNC + + // Need to put the command on the queue straight + // away in case RemCon collects it synchronously + iReadyNotifyCommands.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + + // if this is the null client id then RemCon will address it + TInt err = Observer().NewNotifyCommand(remAddr, aClientId); + + if(err != KErrNone) + { + HandleUndeliveredCommand(aCommand, remAddr); + } + } + + +/** Called from outgoing handlers to notify that a response +is ready for RemCon. + +@param aCommand The response that is ready. +*/ +void CRemConBearerAvrcp::MrccciNewResponse(CAvrcpCommand& aCommand) + { + LOG_FUNC + + // Need to put the response on the queue straight + // away in case RemCon collects it synchronously + iReadyResponses.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + TInt err = Observer().NewResponse(remAddr); + + if(err != KErrNone) + { + // RemCon is not going to pick this response up + aCommand.iReadyLink.Deque(); + aCommand.DecrementUsers(); + } + } + +/** Get a new transaction id for an incoming command. + +@return The new command id. +*/ +TUint CRemConBearerAvrcp::MrcciNewTransactionId() + { + LOG_FUNC + return Observer().NewTransactionId(); + } + +void CRemConBearerAvrcp::MrccciSetAddressedClient(const TRemConClientId& aClientId) + { + LOG_FUNC + + Observer().SetRemoteAddressedClient(TUid::Uid(KRemConBearerAvrcpImplementationUid), aClientId); + } + +/** Called from outgoing handlers to notify that a response +for a notify command is ready for RemCon. + +@param aCommand The response that is ready. +*/ +void CRemConBearerAvrcp::MrccciNewNotifyResponse(CControlCommand& aCommand) + { + LOG_FUNC + + // Need to put the response on the queue straight + // away in case RemCon collects it synchronously + iReadyNotifyResponses.AddLast(aCommand); + aCommand.IncrementUsers(); + + TRemConAddress remAddr; + AvrcpUtils::BTToRemConAddr(aCommand.RemoteAddress(), remAddr); + TInt err = Observer().NewNotifyResponse(remAddr); + + if(err != KErrNone) + { + // RemCon is not going to pick this response up + aCommand.iReadyLink.Deque(); + aCommand.DecrementUsers(); + } + } + +/** Called by RemCon to send a notify command on a connection. + +@param aInterfaceUid The UID of the outer-layer client API specifying the command. +@param aOperationId The ID of the command operation in the outer-layer client API. +@param aId The command identifier used as a cookie for command/response matching, the transaction ID. +@param aData API-specific message data. On success, ownership is passed. +@param aAddr The connection. +@return Error. This request is synchronous. It returns KErrNone when AVRCP has +taken responsibility for sending the message. This involves checking that the message +is well-formed and adding it to the send queue. +*/ +TInt CRemConBearerAvrcp::SendNotifyCommand(TUid aInterfaceUid, + TUint aOperationId, + TUint aId, + RBuf8& aData, + const TRemConAddress& aAddr) + { + LOG_FUNC + // RemCon retains ownership of the data in aData until + // this function returns KErrNone. + + if (!iConstructionComplete) + { + // Object only partially constructed, swallow the request + return KErrNotSupported; + } + + + TBTDevAddr btAddr; + TInt err = AvrcpUtils::RemConToBTAddr(aAddr, btAddr); + + if(err == KErrNone) + { + CRcpRemoteDevice* remote = RemoteDevice(btAddr); + __ASSERT_ALWAYS(remote, AVRCP_PANIC(EAvrcpNotConnected)); + + TRAP(err, remote->OutgoingHandler().SendNotifyCommandL(aInterfaceUid, + aOperationId, + aId, + aData, + btAddr)); + } + + return err; + } + +//--------------------------------------------------------------------- +// Control notifications from the router +//--------------------------------------------------------------------- + +/** Called when a connection comes in from a remote. + +@param aBTDevice The address of the device initiating the connection. +*/ +void CRemConBearerAvrcp::ConnectIndicate(const TBTDevAddr& aBTDevice) + { + LOG_FUNC + CRcpRemoteDevice *remote = NULL; + // We new up the device here even though we may end up deleting it + // later in the function because we need to know if we've successfully + // got a remote before we can tell RemCon. RemCon may optionally + // drop the connection in which case we delete remote straight away. + TRAPD(devErr, remote = CRcpRemoteDevice::NewL(aBTDevice, *iRouter, *this, Observer(), *iTimer, *iPlayerInfoManager)); + if(!devErr) + { + iRemotes.AddLast(*remote); + + TRemConAddress remoteAddr; + AvrcpUtils::BTToRemConAddr(aBTDevice, remoteAddr); + + TInt err = Observer().ConnectIndicate(remoteAddr); + if(err) + { + // We need to drop this connection. Disconnect and delete + // the remote NOW. When we get the disconnect confirm we + // will then know that we shouldn't tell RemCon. + remote->Disconnect(ETrue); + remote->iLink.Deque(); + delete remote; + + err = iRouter->DisconnectRequest(aBTDevice); + } + } + } + +/** Called to confirm an outgoing connection. + +@param aBTDevice The device the outgoing connection is to. +@param aError The result of the connection attempt. +*/ +void CRemConBearerAvrcp::ConnectConfirm(const TBTDevAddr& aBTDevice, TInt aError) + { + LOG_FUNC + TRemConAddress remoteAddr; + AvrcpUtils::BTToRemConAddr(aBTDevice, remoteAddr); + + if(aError != KErrNone) + { + CRcpRemoteDevice *remote = RemoteDevice(aBTDevice); + if(remote) + { + // calling disconnect gives the remote the opportunity + // to do anything necessary to commands still on its + // queue before we delete it. + remote->Disconnect(ETrue); + remote->iLink.Deque(); + delete remote; + } + } + + Observer().ConnectConfirm(remoteAddr, aError); + } + +/** Called when a remote disconnects. + +@param aBTDevice The address of the remote that has disconnected. +*/ +void CRemConBearerAvrcp::DisconnectIndicate(const TBTDevAddr& aBTDevice) + { + LOG_FUNC + TRemConAddress remoteAddr; + AvrcpUtils::BTToRemConAddr(aBTDevice, remoteAddr); + + CRcpRemoteDevice *remote = RemoteDevice(aBTDevice); + if(remote) + { + // calling disconnect gives the remote the opportunity + // to do anything necessary to commands still on its + // queue before we delete it. + remote->Disconnect(ETrue); + remote->iLink.Deque(); + delete remote; + } + + Observer().DisconnectIndicate(remoteAddr); + } + +/** Called to confirm a locally initiated disconnect. + +@param aBTDevice The address of the disconnected remote. +@param aError The result of the disconnect attempt. +*/ +void CRemConBearerAvrcp::DisconnectConfirm(const TBTDevAddr& aBTDevice, TInt aError) + { + LOG_FUNC + TRemConAddress remoteAddr; + AvrcpUtils::BTToRemConAddr(aBTDevice, remoteAddr); + + Observer().DisconnectConfirm(remoteAddr, aError); + } + +/** Called to get a bearer interface. + +@param aUid The uid of the desired interface. +@return An instance of the desired interface, NULL if + one could not be found. +*/ +TAny* CRemConBearerAvrcp::GetInterface(TUid aUid) + { + LOG_FUNC + + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConBearerInterface1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + else if ( aUid == TUid::Uid(KRemConBearerInterface2) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + else if ( aUid == TUid::Uid(KRemConBearerInterface3) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + else if ( aUid == TUid::Uid(KRemConBearerBulkInterface1) ) + { + ret = reinterpret_cast( + static_cast(iBulkBearer) + ); + } + + return ret; + } + +//--------------------------------------------------------------------- +// Utility functions +//--------------------------------------------------------------------- + +MIncomingCommandHandler* CRemConBearerAvrcp::IncomingHandler(const TBTDevAddr& aAddr) + { + CRcpRemoteDevice* remote = RemoteDevice(aAddr); + if(remote) + { + return &remote->IncomingHandler(); + } + else + { + return NULL; + } + } + +MOutgoingCommandHandler* CRemConBearerAvrcp::OutgoingHandler(const TBTDevAddr& aAddr) + { + CRcpRemoteDevice* remote = RemoteDevice(aAddr); + if(remote) + { + return &remote->OutgoingHandler(); + } + else + { + return NULL; + } + } + +/** Utility function to get the CRcpRemoteDevice that +handles a given BT address. + +@param aAddr The address to get the CRcpRemoteDevice for. +@return A pointer to a remote device, or NULL if not found. +*/ +CRcpRemoteDevice* CRemConBearerAvrcp::RemoteDevice(const TBTDevAddr& aAddr) + { + LOG_FUNC + + CRcpRemoteDevice* remote = NULL; + + TDblQueIter iter(iRemotes); + while (iter) + { + remote = iter++; + if(remote->RemoteAddress() == aAddr) + { + break; + } + remote = NULL; + } + + return remote; + } + +void CRemConBearerAvrcp::HandleUndeliveredCommand(CAvrcpCommand& aCommand, const TRemConAddress& aAddr) + { + TUid interfaceUid; + TUint remconId, operationId; + RBuf8 commandData; + TBTDevAddr btAddr; + + // Calling GetCommandInfo transfers the command data to us. + aCommand.GetCommandInfo(interfaceUid, remconId, operationId, commandData, btAddr); + SendReject(interfaceUid, operationId, remconId, aAddr); + commandData.Close(); + + // RemCon is not going to pick this command up + aCommand.iReadyLink.Deque(); + aCommand.DecrementUsers(); + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusclient/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusclient/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconstatusapi.mmp + +PRJ_EXPORTS +remconstatusapicontroller.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconstatusapicontroller.h) +remconstatusapicontrollerobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(remconstatusapicontrollerobserver.h) + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusclient/remconstatusapi.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusclient/remconstatusapi.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +// Copyright (c) 2004-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: +// remconstatusapi.dll Remote Control status API- an outer-layer client +// side library providing access to AV/C status commands. +// +// + +/** + @file + @internalComponent +*/ + +TARGET remconstatusapi.dll //Recommended unpaged +TARGETPATH /system/libs +// We need all these caps because we don't know anything about the process +// we'll be running in. +CAPABILITY All -Tcb +TARGETTYPE dll +// UID2 = 0x1000008d for static interface DLLs. +// UID3 = unique for RemCon system +UID 0x1000008d 0x10207ea5 +VENDORID 0x70000001 + +SOURCEPATH . +SOURCE statusapicontroller.cpp remconstatusapicontrollerobserver.cpp + +USERINCLUDE ../common +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib +LIBRARY remconinterfacebase.lib + +#include + +// +// End of file + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusclient/remconstatusapicontroller.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusclient/remconstatusapicontroller.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,89 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONSTATUSAPICONTROLLER_H +#define REMCONSTATUSAPICONTROLLER_H + +#include +#include +#include + +_LIT(KStatusApiPanicName, "Status Api Panic"); + +class MRemConStatusApiControllerObserver; +class CRemConInterfaceSelector; + +/** +A controller which sends Status API commands. +@publishedAll +@released +*/ +NONSHARABLE_CLASS(CRemConStatusApiController) : public CRemConInterfaceBase, + public MRemConInterfaceIf + { +private: + enum TStatusApiPanic + { + EStatusApiCommandDataSectionTooLong, + }; + +public: + IMPORT_C static CRemConStatusApiController* NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConStatusApiControllerObserver& aObserver); + IMPORT_C ~CRemConStatusApiController(); + + // Commands + IMPORT_C void UnitInfo(TRequestStatus& aStatus, TUint& aNumRemotes); + IMPORT_C void SubunitInfo(TRequestStatus& aStatus, TUint& aNumRemotes); + +private: + CRemConStatusApiController(CRemConInterfaceSelector& aInterfaceSelector, + MRemConStatusApiControllerObserver& aObserver); + + // from CRemConInterfaceBase + void MrcibNewMessage(TUint aOperationId, const TDesC8& aData); + TAny* GetInterfaceIf(TUid aUid); + + // Utility functions + void SetUnitInfoResponseData(const TDesC8& aCommandData, + TInt& aVendorId, + TInt& aUnit, + TInt& aUnitType, + TInt& aExtendedUnitType); + + void SetSubunitInfoResponseData(const TDesC8& aCommandData, + TInt& aPage, + TInt& aExtension, + TPtrC8& aPageData); + + void ReadCommandDataToInt(const TDesC8& aCommandData, + TInt aOffset, + TInt aLength, + TInt& aValue); + + static void Panic(TStatusApiPanic aPanic); + +private: + MRemConStatusApiControllerObserver& iObserver; + RBuf8 iOutData; // There is no command data for any commands in this API + }; + +#endif // REMCONSTATUSAPICONTROLLER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusclient/remconstatusapicontrollerobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusclient/remconstatusapicontrollerobserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include + +/** +This virtual function allows the M- class to be extended in future in a binary +compatible way by providing a method that clients can override in future to +allow extra callbacks to be made via aObject. +*/ +EXPORT_C void MRemConStatusApiControllerObserver::Mrcsaco_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject) + { + aObject = NULL; + } diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusclient/remconstatusapicontrollerobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusclient/remconstatusapicontrollerobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @publishedAll + @released +*/ + +#ifndef REMCONSTATUSAPICONTROLLEROBSERVER_H +#define REMCONSTATUSAPICONTROLLEROBSERVER_H + +#include + +/** +Interface to observe responses from a Status API controller. +@publishedAll +@released +*/ +class MRemConStatusApiControllerObserver + { +public: + /** A UnitInfo response has been received. + + For details on the meanings on the fields please refer to the + AV/C Digital Interface Command Set General Specification, + section 11.2.1. + + If all values are zero there was an error with the command. + @param aVendorId The VendorId + @param aUnit Unit + @param aUnitType UnitType + @param aExtendedUnitType Extended Unit type. This data is only + valid if Unit type is 0x1e. The second byte is only valid + if the first byte is 0xff. + */ + virtual void MrcsacoUnitInfoResponse(TInt aVendorId, + TInt aUnit, + TInt aUnitType, + TInt aExtendedUnitType) = 0; + + /** A SubunitInfo response has been received. + + For details on the meanings on the fields please + refer to the AV/C Digital Interface Command Set + General Specification, section 11.2.2. + + If all values are zero there was an error with the command. + @param aPage Page + @param aExtension Extension. + @param aPageData Page Data. This data remains valid only for + the duration of this call. If the client wishes to store + the data it must be copied. + */ + virtual void MrcsacoSubunitInfoResponse(TInt aPage, + TInt aExtension, + TDesC8& aPageData) = 0; + + /** + Returns a null aObject if the extension is not implemented, or + a pointer to another interface if it is. + + @param aInterface UID of the interface to return + @param aObject the container for another interface as specified by aInterface + */ + IMPORT_C virtual void Mrcsaco_ExtensionInterfaceL(TUid aInterface, void*& aObject); + }; + +#endif // REMCONSTATUSAPICONTROLLEROBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusclient/statusapicontroller.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusclient/statusapicontroller.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,259 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @publishedAll + @released +*/ + +#include +#include +#include +#include +#include "remconstatusapi.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_AVRCP_STATUS); +#endif + +/** Creates new Status Api Controller. + +@param aInterfaceSelector An interface selector for use with this interface. +@param aObserver An observer to be notified of responses to commands issued + to this interface. +@return A fully constructed CRemConStatusApiController +*/ +EXPORT_C CRemConStatusApiController* CRemConStatusApiController::NewL(CRemConInterfaceSelector& aInterfaceSelector, + MRemConStatusApiControllerObserver& aObserver) + { + LOG_STATIC_FUNC + + CRemConStatusApiController* self = new(ELeave) CRemConStatusApiController(aInterfaceSelector, aObserver); + CleanupStack::PushL(self); + self->BaseConstructL(); + CleanupStack::Pop(self); + return self; + } + +/** Constructs this interface. + +@param aInterfaceSelector An interface selector for use with this interface. +@param aObserver An observer to be notified of responses to commands issued + to this interface. +@internalComponent +@released +*/ +CRemConStatusApiController::CRemConStatusApiController(CRemConInterfaceSelector& aInterfaceSelector, + MRemConStatusApiControllerObserver& aObserver) +: CRemConInterfaceBase(TUid::Uid(KRemConStatusApiUid), + KRemConStatusApiMaxOperationSpecificDataSize, + aInterfaceSelector, + ERemConClientTypeController), + iObserver(aObserver) + { + iOutData.Assign(NULL); + } + +/** Destructor. +*/ +EXPORT_C CRemConStatusApiController::~CRemConStatusApiController() + { + } + +/** Gets a pointer to a specific interface version. + +@return A pointer to the interface, NULL if not supported. +@internalComponent +@released +*/ +TAny* CRemConStatusApiController::GetInterfaceIf(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConInterfaceIf1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +/** New message from RemCon. + +@internalComponent +@released +*/ +void CRemConStatusApiController::MrcibNewMessage(TUint aOperationId, const TDesC8& aData) + { + LOG_FUNC + + switch ( aOperationId ) + { + case ERemConStatusApiUnitInfo: + { + TInt vendorId, unit, unitType, extendedUnitType; + SetUnitInfoResponseData(aData, vendorId, unit, unitType, extendedUnitType); + + iObserver.MrcsacoUnitInfoResponse(vendorId, unit, unitType, extendedUnitType); + break; + } + case ERemConStatusApiSubunitInfo: + { + TInt page, extension; + TPtrC8 pageData; + SetSubunitInfoResponseData(aData, page, extension, pageData); + + iObserver.MrcsacoSubunitInfoResponse(page, extension, pageData); + break; + } + default: + break; + } + } + +/** Parses command data from the buffer. + +@param aCommandData The buffer from which to read the data. +@param aVendorId On return, the vendor id +@param aUnit On return, the unit +@param aUnitType On return, the unit type +@param aExtendedUnitType On return, the extended unit type + +@internalComponent +@released +*/ +void CRemConStatusApiController::SetUnitInfoResponseData(const TDesC8& aCommandData, + TInt& aVendorId, TInt& aUnit, TInt& aUnitType, TInt& aExtendedUnitType) + { + if(aCommandData.Length()) + { + ReadCommandDataToInt(aCommandData, KRemConStatusApiVendorIdOffset, + KRemConStatusApiVendorIdLength, aVendorId); + ReadCommandDataToInt(aCommandData, KRemConStatusApiUnitOffset, + KRemConStatusApiUnitLength, aUnit); + ReadCommandDataToInt(aCommandData, KRemConStatusApiUnitTypeOffset, + KRemConStatusApiUnitTypeLength, aUnitType); + ReadCommandDataToInt(aCommandData, KRemConStatusApiExtendedUnitTypeOffset, + KRemConStatusApiExtendedUnitTypeLength, aExtendedUnitType); + } + else + { + // On error set all fields to 0 + aVendorId = aUnit = aUnitType = aExtendedUnitType = 0; + } + } + +/** Parses command data from the buffer. + +@param aCommandData The buffer from which to read the data. +@param aPage On return, the page +@param aExtension On return, the extension +@param aPageData On return, the page data + +@internalComponent +@released +*/ +void CRemConStatusApiController::SetSubunitInfoResponseData(const TDesC8& aCommandData, + TInt& aPage, TInt& aExtension, TPtrC8& aPageData) + { + if(aCommandData.Length()) + { + ReadCommandDataToInt(aCommandData, KRemConStatusApiPageOffset, + KRemConStatusApiPageLength, aPage); + ReadCommandDataToInt(aCommandData, KRemConStatusApiExtensionOffset, + KRemConStatusApiExtensionLength, aExtension); + + aPageData.Set(aCommandData.Mid(KRemConStatusApiPageDataOffset)); + } + else + { + // On error set all fields to 0 + aPage = aExtension = 0; + aPageData.Set(KNullDesC8()); + } + } + +/** Reads command data from the buffer to an int. + +@param aCommandData The buffer from which to read the data. +@param aOffset The offset within aCommandData read from. +@param aLength The length of data to read. This must not be + more than 4. +@param aValue On return, the value of the specified data section. + +@internalComponent +@released +*/ +void CRemConStatusApiController::ReadCommandDataToInt(const TDesC8& aCommandData, + TInt aOffset, TInt aLength, TInt& aValue) + { + __ASSERT_ALWAYS(aLength <= 4, CRemConStatusApiController::Panic(EStatusApiCommandDataSectionTooLong)); + + aValue = 0; + + for(TInt i = 0 ; i < aLength; i++) + { + aValue |= aCommandData[i+aOffset]<<(8*i); + } + } + +/** Issue UnitInfo command. +Only one command per controller session can be outstanding at any one time. +@param aStatus Status to be completed with the result of issuing this command. +@param aNumRemotes On completion, the number of remotes this command was issued to. +*/ +EXPORT_C void CRemConStatusApiController::UnitInfo(TRequestStatus& aStatus, TUint& aNumRemotes) + { + LOG_FUNC + + InterfaceSelector().Send(aStatus, + TUid::Uid(KRemConStatusApiUid), + (TUint)ERemConStatusApiUnitInfo, + aNumRemotes, + ERemConCommand, + iOutData); + } + +/** Issue SubUnitInfo command. +Only one command per controller session can be outstanding at any one time. +@param aStatus Status to be completed with the result of issuing this command. +@param aNumRemotes On completion, the number of remotes this command was issued to. +*/ +EXPORT_C void CRemConStatusApiController::SubunitInfo(TRequestStatus& aStatus, TUint& aNumRemotes) + { + LOG_FUNC + + InterfaceSelector().Send(aStatus, + TUid::Uid(KRemConStatusApiUid), + (TUint)ERemConStatusApiSubunitInfo, + aNumRemotes, + ERemConCommand); + } + +/** Utility Status Converter panic function. + +@param aPanic The panic number. +@internalComponent +@released +*/ +void CRemConStatusApiController::Panic(TStatusApiPanic aPanic) + { + User::Panic(KStatusApiPanicName, aPanic); + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusconverter/10207ea3.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusconverter/10207ea3.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x10207ea3; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10205C43; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10207ea4; + version_no = 1; + display_name = "RemConAvrcpStatusConverter"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusconverter/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusconverter/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +PRJ_MMPFILES +remconavrcpstatusconverter.mmp + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconverter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconverter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,551 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent + @released +*/ + +#include +#include + +#include "remconstatusapi.h" +#include "remconavrcpstatusconverter.h" + +/** Factory function. + +@return Ownership of a new CRemConAvrcpStatusConverter. +*/ +CRemConAvrcpStatusConverter* CRemConAvrcpStatusConverter::NewL() + { + CRemConAvrcpStatusConverter* self = new(ELeave) CRemConAvrcpStatusConverter; + return self; + } + +/** Destructor. +*/ +CRemConAvrcpStatusConverter::~CRemConAvrcpStatusConverter() + { + } + +/** Constructor. +*/ +CRemConAvrcpStatusConverter::CRemConAvrcpStatusConverter() + { + } + +/** Called to get a converter interface. + +@param aUid The uid of the desired interface. +@return An instance of the desired interface, NULL if + one could not be found. +*/ +TAny* CRemConAvrcpStatusConverter::GetInterface(TUid aUid) + { + TAny* ret = NULL; + if ( aUid == TUid::Uid(KRemConConverterInterface1) ) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + + return ret; + } + +/** Decides whether this converter supports this interface. + +This converter supports only the AVRCP bearer and Status API. +This function checks whether the Uids provided match AVRCP and +Status. + +@param aInterfaceData The Uid of the originating RemCon interface. +@param aBearerUid The Uid of the bearer this data is destined for. +@return Whether this data can be converted. +*/ +TBool CRemConAvrcpStatusConverter::SupportedUids(const TUid& aInterfaceUid, const TUid& aBearerUid) const + { + return (aInterfaceUid == TUid::Uid(KRemConStatusApiUid) && + aBearerUid == TUid::Uid(KRemConBearerAvrcpImplementationUid)); + } + +/** Decides whether this converter supports this interface. + +This converter supports only the AVRCP bearer. That bearer publishes +interface data in the format of an AV/C frame. This function +checks that aBearerUid is that of AVRCP, and if so examines the AV/C +frame in aInterfaceData to see if it is a supported command. + +@param aInterfaceData Data in the format of the bearer identified by + aBearerUid. +@param aBearerUid The Uid of the bearer this data originates from. +@return Whether this data can be converted. +*/ +TBool CRemConAvrcpStatusConverter::SupportedInterface(const TDesC8& aInterfaceData, const TUid& aBearerUid) const + { + TInt supported = EFalse; + if(aBearerUid == TUid::Uid(KRemConBearerAvrcpImplementationUid)) + { + AVC::TOpcode opcode = AVC::EPower; // arbitrary initialisation to avoid compiler warning + TRAPD(err, opcode = CAVCFrame::OpcodeL(aInterfaceData)); + + if ( err == KErrNone + && ( opcode == AVC::EUnitInfo || opcode == AVC::ESubunitInfo ) + ) + { + supported = ETrue; + } + } + + return supported; + } + +/** Convert data from the API's form (as we're given it by RemCon) to +bearer-specific form. + +We only deal with the AVRCP bearer. This requires us to produce a +CAVCFrame. + +The supported commands are Unit Info and Subunit Info. + +@param aInterfaceUid The Uid of the originating RemCon interface. +@param aOperationId The id of the operation within the interface. +@param aData Data in the format defined by the RemCon interface. +@param aMsgType Whether this is a command or response. +@param aBearerData On return, an AV/C frame representing the operation. +*/ +TInt CRemConAvrcpStatusConverter::InterfaceToBearer(TUid aInterfaceUid, + TUint aOperationId, + const TDesC8& /*aData*/, + TRemConMessageType aMsgType, + TDes8& aBearerData) const + { + __ASSERT_ALWAYS(aInterfaceUid.iUid == KRemConStatusApiUid, CRemConAvrcpStatusConverter::Panic(EStatusConverterWrongInterface)); + TInt err = KErrCorrupt; + + switch(aOperationId) + { + case ERemConStatusApiUnitInfo: + { + if(aMsgType == ERemConCommand) + { + CAVCFrame* frame = NULL; + TRAP(err, frame = UnitInfoL()); + if(!err) + { + aBearerData = frame->Data(); + err = KErrNone; + delete frame; + } + } + else if(aMsgType == ERemConResponse) + { + // These should be generated within the bearer + // as it knows the manufacturer id + err = KErrNotSupported; + } + break; + } + case ERemConStatusApiSubunitInfo: + { + if(aMsgType == ERemConCommand) + { + CAVCFrame* frame = NULL; + TRAP(err, frame = SubunitInfoL()); + if(!err) + { + aBearerData = frame->Data(); + err = KErrNone; + delete frame; + } + } + else if(aMsgType == ERemConResponse) + { + // These should be generated within the bearer + // as it knows the manufacturer id + err = KErrNotSupported; + } + break; + } + default: + { + err = KErrNotSupported; + break; + } + } + + return err; + } + +/** Produce a Unit Info AV/C frame. + +@return A new AV/C frame representing unit info. +@leave System wide error. +*/ +CAVCFrame* CRemConAvrcpStatusConverter::UnitInfoL() + { + CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::EStatus, AVC::EUnit, AVC::EIgnore); + frame->Append(TChar(AVC::EUnitInfo)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + return frame; + } + +/** Produce a Subunit Info AV/C frame. + +@return A new AV/C frame representing subunit info. +@leave System wide error. +*/ +CAVCFrame* CRemConAvrcpStatusConverter::SubunitInfoL() + { + CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::EStatus, AVC::EUnit, AVC::EIgnore); + frame->Append(TChar(AVC::ESubunitInfo)); + frame->Append(TChar(0x7)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + frame->Append(TChar(0xff)); + return frame; + } + +/** Convert data from the bearer format to RemCon interface format. + +We only deal with the Status Api. The supported commands are Unit +Info response and Subunit Info response. + +Support of these commands is mandatory in the targets. In the case +where a remote sends us something rubbish, we'll just provide our +client with the default info. + +@param aBearerData An AV/C frame to convert. +@param aInterfaceUid On return, the Uid of the RemCon interface. +@param aOperationId On return, the id of the operation within the + interface. +@param aMsgType Whether this is a command or response. +@param aData On return, Data in the format defined by the RemCon interface. +@return Whether the command was successfully converted. +*/ +TInt CRemConAvrcpStatusConverter::BearerToInterface(const TDesC8& aBearerData, + TUid& aInterfaceUid, + TUint& aOperationId, + TRemConMessageType& aMsgType, + TDes8& aData) const + { + TInt err = KErrCorrupt; + + switch(aOperationId) + { + case ERemConStatusApiUnitInfo: + { + if(aMsgType == ERemConCommand) + { + // These should be generated within the bearer + // as it knows the manufacturer id + err = KErrNotSupported; + } + else if(aMsgType == ERemConResponse) + { + // We try to parse the data, but if what the remote's sent + // us is invalid we'll fill in sensible values later + TRAP(err, SetUnitInfoResponseDataL(aBearerData, aData)); + aInterfaceUid = TUid::Uid(KRemConStatusApiUid); + aOperationId = ERemConStatusApiUnitInfo; + + if(err == KErrCorrupt) + { + // The data is set to the correct length in SetUnitInfoResponseDataL + // Stick some default data in there + SetCommandDataFromInt(aData, KRemConStatusApiUnitOffset, + KRemConStatusApiUnitLength, AVC::EID0); + + SetCommandDataFromInt(aData, KRemConStatusApiUnitTypeOffset, + KRemConStatusApiUnitTypeLength, AVC::EPanel); + + SetCommandDataFromInt(aData, KRemConStatusApiExtendedUnitTypeOffset, + KRemConStatusApiExtendedUnitTypeLength, 0); + + SetCommandDataFromInt(aData, KRemConStatusApiVendorIdOffset, + KRemConStatusApiVendorIdLength, KRemConStatusApiDefaultVendorId); + + err = KErrNone; + } + } + break; + } + case ERemConStatusApiSubunitInfo: + { + if(aMsgType == ERemConCommand) + { + // These should be generated within the bearer + // as it knows the manufacturer id + err = KErrNotSupported; + } + else if(aMsgType == ERemConResponse) + { + // We try to parse the data, but if what the remote's sent + // us is invalid we'll fill in sensible values later + TRAP(err, SetSubunitInfoResponseDataL(aBearerData, aData)); + aInterfaceUid = TUid::Uid(KRemConStatusApiUid); + aOperationId = ERemConStatusApiSubunitInfo; + + if(err == KErrCorrupt) + { + // Subunit response data varies in length, so the length + // set in SetSubunitInfoResponseDataL may be wrong. + aData.FillZ(KRemConStatusApiPageLength + KRemConStatusApiExtensionLength + KRemConStatusApiDefaultPageDataLength); + + // Stick some default data in there + SetCommandDataFromInt(aData, KRemConStatusApiPageOffset, + KRemConStatusApiPageLength, 0); + + SetCommandDataFromInt(aData, KRemConStatusApiExtensionOffset, + KRemConStatusApiExtensionLength, AVC::EIgnore); + + SetCommandDataFromInt(aData, KRemConStatusApiPageDataOffset, + KRemConStatusApiDefaultPageDataLength, KRemConStatusApiDefaultPageData); + + err = KErrNone; + } + } + break; + } + default: + { + err = KErrNotSupported; + break; + } + } + + return err; + } + +/** Parses command data from the buffer. + +@param aCommandData The buffer from which to read the data. +@param aVendorId On return, the vendor id +@param aUnit On return, the unit +@param aUnitType On return, the unit type +@param aExtendedUnitType On return, the extended unit type + +@internalComponent +@released +*/ +void CRemConAvrcpStatusConverter::SetUnitInfoResponseDataL(const TDesC8& aBearerData, + TDes8& aRemConData) + { + // AVRCP should pass us a sensible sized buffer! + __ASSERT_ALWAYS(aRemConData.MaxLength() >= KUnitInfoResponseLength, CRemConAvrcpStatusConverter::Panic(EAvrcpPassedTooSmallABuffer)); + + // Get rid of any junk + aRemConData.FillZ(KRemConStatusApiUnitLength + KRemConStatusApiUnitTypeLength + + KRemConStatusApiExtendedUnitTypeLength + + KRemConStatusApiVendorIdLength); + + // Get unit id if there's enough data for it + if(aBearerData.Length() < KUnitIdOffset + KUnitIdLength) + { + User::Leave(KErrCorrupt); + } + TInt unit; + ReadCommandDataToInt(aBearerData, KUnitIdOffset, KUnitIdLength, unit); + unit &= KAVCSubunitIDMask; + SetCommandDataFromInt(aRemConData, KRemConStatusApiUnitOffset, + KRemConStatusApiUnitLength, unit); + + // Get unit type (maybe extended) if there's enough data + if(aBearerData.Length() < KUnitTypeOffset + KUnitTypeLength) + { + User::Leave(KErrCorrupt); + } + TInt unitType; + ReadCommandDataToInt(aBearerData, KUnitTypeOffset, KUnitTypeLength, unitType); + unitType &= KAVCSubunitTypeMask; + unitType >>= KUnitTypeShift; + SetCommandDataFromInt(aRemConData, KRemConStatusApiUnitTypeOffset, + KRemConStatusApiUnitTypeLength, unitType); + + TInt unitTypeExtend = 0; + TInt vendorIdOffset = KVendorIdBaseOffset; + if(unitType == KUnitTypeExtend) + { + // Extended unit type. VendorId is offset by 1 + vendorIdOffset++; + + // Read the next byte if it's there + if(aBearerData.Length() < KUnitTypeExtendOffset + 1) + { + User::Leave(KErrCorrupt); + } + ReadCommandDataToInt(aBearerData, KUnitTypeExtendOffset, 1, unitTypeExtend); + unitTypeExtend <<= 8; + + // Double extended unit type. + if(unitTypeExtend == KUnitTypeExtendExtend) + { + // VendorId is offset by 1 + vendorIdOffset++; + + // Read the next byte + TInt unitTypeExtendExtend = 0; + if(aBearerData.Length() < KUnitTypeExtendExtendOffset + 1) + { + User::Leave(KErrCorrupt); + } + ReadCommandDataToInt(aBearerData, KUnitTypeExtendExtendOffset, 1, + unitTypeExtendExtend); + unitTypeExtend |= unitTypeExtendExtend; + } + + SetCommandDataFromInt(aRemConData, KRemConStatusApiExtendedUnitTypeOffset, + KRemConStatusApiExtendedUnitTypeLength, unitTypeExtend); + } + + // Get vendor id + if(aBearerData.Length() < vendorIdOffset + KVendorIdLength) + { + User::Leave(KErrCorrupt); + } + TInt vendorId; + ReadCommandDataToInt(aBearerData, vendorIdOffset, KVendorIdLength, vendorId); + SetCommandDataFromInt(aRemConData, KRemConStatusApiVendorIdOffset, + KRemConStatusApiVendorIdLength, vendorId); + } + +/** Parses command data from the buffer. + +@param aCommandData The buffer from which to read the data. +@param aPage On return, the page +@param aExtension On return, the extension +@param aPageData On return, the page data + +@internalComponent +@released +*/ +void CRemConAvrcpStatusConverter::SetSubunitInfoResponseDataL(const TDesC8& aBearerData, + TDes8& aRemConData) + { + // AVRCP should pass us a sensible sized buffer! + __ASSERT_ALWAYS(aRemConData.MaxLength() >= KUnitInfoResponseLength, CRemConAvrcpStatusConverter::Panic(EAvrcpPassedTooSmallABuffer)); + + CAVCFrame* frame = CAVCFrame::NewL(aBearerData, AVC::EResponse); //Qualified + CleanupStack::PushL(frame); + TPtrC8 ptr = frame->Data(); + + // Work out how long a buffer we need for the RemCon data. + // This is KRemConStatusApiPageLength + KRemConStatusApiExtensionLength + // + the length of the page data. + // We can work out the length of the page data from the frame - + // it's the remainder of the frame after KSubunitPageDataOffset. + // This gives us: + TInt remConDataLen = KRemConStatusApiPageLength + + KRemConStatusApiPageLength + + (ptr.Length() - KSubunitPageDataOffset); + + if(aRemConData.MaxLength() < remConDataLen) + { + User::Leave(KErrCorrupt); + } + + // Get rid of any junk + aRemConData.FillZ(remConDataLen); + + // Get page + if(aBearerData.Length() < KSubunitPageOffset + KSubunitPageLength) + { + User::Leave(KErrCorrupt); + } + TInt page; + ReadCommandDataToInt(aBearerData, KSubunitPageOffset, KSubunitPageLength, page); + page &= KSubunitPageMask; + SetCommandDataFromInt(aRemConData, KRemConStatusApiPageOffset, + KRemConStatusApiPageLength, page); + + // Get extension code + if(aBearerData.Length() < KSubunitExtensionOffset + KSubunitExtensionLength) + { + User::Leave(KErrCorrupt); + } + TInt extensionCode; + ReadCommandDataToInt(aBearerData, KSubunitExtensionOffset, KSubunitExtensionLength, + extensionCode); + extensionCode &= KSubunitExtensionMask; + SetCommandDataFromInt(aRemConData, KRemConStatusApiExtensionOffset, + KRemConStatusApiExtensionLength, extensionCode); + + // Get page data + TPtrC8 pageDataPtr = aBearerData.Mid(KSubunitPageDataOffset); + aRemConData.Replace(KRemConStatusApiPageDataOffset, pageDataPtr.Length(), pageDataPtr); + + CleanupStack::PopAndDestroy(frame); + } + +/** Reads command data from the buffer to an int. + +@param aCommandData The buffer from which to read the data. +@param aOffset The offset within aCommandData read from. +@param aLength The length of data to read. This must not be + more than 4. +@param aValue On return, the value of the specified data section. + +@internalComponent +@released +*/ +void CRemConAvrcpStatusConverter::ReadCommandDataToInt(const TDesC8& aCommandData, + TInt aOffset, TInt aLength, TInt& aValue) + { + __ASSERT_DEBUG(aLength <= 4, CRemConAvrcpStatusConverter::Panic(EStatusConverterDataTooShort)); + + aValue = 0; + + for(TInt i = 0 ; i < aLength; i++) + { + aValue |= aCommandData[aOffset+i]<<(8*i); + } + } + +/** Set the command data. This overwrites the current +contents of the data buffer. + +@param aCommandData The buffer in which to set the data. +@param aOffset The offset within aCommandData to set the data. +@param aLength The length of data to replace. +@param aValue The new value for the replaced data. +*/ +void CRemConAvrcpStatusConverter::SetCommandDataFromInt(TDes8& aCommandData, + TInt aOffset, TInt aLength, TInt aValue) + { + __ASSERT_DEBUG(aLength <= 4, CRemConAvrcpStatusConverter::Panic(EStatusConverterDataTooShort)); + + for(TInt i = 0; i < aLength; i++) + { + aCommandData[aOffset+i] = aValue >> (8*i); + } + } + +/** Utility Status Converter panic function. + +@param aPanic The panic number. +*/ +void CRemConAvrcpStatusConverter::Panic(TStatusConverterPanic aPanic) + { + User::Panic(KStatusConverterPanicName, aPanic); + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconverter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconverter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,114 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +#ifndef REMCONAVRCPSTATUSCONVERTER_H +#define REMCONAVRCPSTATUSCONVERTER_H + +#include +#include +#include + +// These values are in bytes +const TUint KUnitIdOffset = 4; +const TUint KUnitIdLength = 1; +const TUint KUnitTypeOffset = 4; +const TUint KUnitTypeLength =1; +const TUint KUnitTypeExtendOffset = 5; +const TUint KUnitTypeExtendExtendOffset = 6; +const TUint KVendorIdBaseOffset = 5; +const TUint KVendorIdLength = 3; +const TUint KUnitInfoResponseLength = 8; +const TUint KRemConStatusApiDefaultPageDataLength = 4; + +const TUint KSubunitPageOffset = 3; +const TUint KSubunitPageLength = 1; +const TUint KSubunitExtensionOffset = 3; +const TUint KSubunitExtensionLength = 1; +const TUint KSubunitPageDataOffset = 4; + +// These values are in bits +const TUint KUnitTypeShift = 3; + +// Defined values for comparison +const TUint KUnitTypeExtend = 0x1e; +const TUint KUnitTypeExtendExtend = 0xff; +const TUint KSubunitPageMask = 0xf8; +const TUint KSubunitExtensionMask = 0x7; + +const TUint KRemConStatusApiDefaultVendorId = 0xffffff; +const TUint KRemConStatusApiDefaultPageData = 0xffffff48; + +_LIT(KStatusConverterPanicName, "Stat Conv Panic"); + +enum TStatusConverterPanic + { + EStatusConverterWrongInterface = 0, + EStatusConverterDataTooShort = 1, + EAvrcpPassedTooSmallABuffer = 2, + }; + +class CAVCFrame; +NONSHARABLE_CLASS(CRemConAvrcpStatusConverter) : public CRemConConverterPlugin, public MRemConConverterInterface + { +public: + static CRemConAvrcpStatusConverter* NewL(); + ~CRemConAvrcpStatusConverter(); + +private: // from CRemConConverterPlugin + TAny* GetInterface(TUid aUid); + + // from MRemConConverterInterface + TInt InterfaceToBearer(TUid aInterfaceUid, + TUint aOperationId, + const TDesC8& aData, + TRemConMessageType aMsgType, + TDes8& aBearerData) const; + + TInt BearerToInterface(const TDesC8& aBearerData, + TUid& aInterfaceUid, + TUint& aOperationId, + TRemConMessageType& aMsgType, + TDes8& aData) const; + + TBool SupportedUids(const TUid& aInterfaceUid, + const TUid& aBearerUid) const; + TBool SupportedInterface(const TDesC8& aInterfaceData, + const TUid& aBearerUid) const; + +private: + CRemConAvrcpStatusConverter(); + + static CAVCFrame* UnitInfoL(); + static CAVCFrame* SubunitInfoL(); + + static void SetUnitInfoResponseDataL(const TDesC8& aBearerData, + TDes8& aRemConData); + static void SetSubunitInfoResponseDataL(const TDesC8& aBearerData, + TDes8& aRemConData); + + static void ReadCommandDataToInt(const TDesC8& aCommandData, + TInt aOffset, TInt aLength, TInt& aValue); + static void SetCommandDataFromInt(TDes8& aCommandData, + TInt aOffset, TInt aLength, TInt aValue); + + static void Panic(TStatusConverterPanic aPanic); + }; + +#endif // REMCONAVRCPSTATUSCONVERTER_H diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconverter.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconverter.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,56 @@ +// Copyright (c) 2004-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: +// remconavrcpstatusconverter.dll Converter between RemCon Avrcp Status API and +// AVRCP bearer. +// +// + +/** + @file + @internalComponent +*/ + +#include + +TARGET remconavrcpstatusconverter.dll //Recommended unpaged +TARGETPATH /system/libs +TARGETTYPE PLUGIN +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +UID 0x10009d8d 0x10207ea3 +VENDORID 0x70000001 + +SOURCEPATH . +SOURCE remconavrcpstatusconverter.cpp +SOURCE remconavrcpstatusconvertermain.cpp + +START RESOURCE 10207ea3.rss +target remconavrcpstatusconverter.rsc +END + +USERINCLUDE . +USERINCLUDE ../common + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib +LIBRARY remconconverterplugin.lib +LIBRARY avc.lib + +NOEXPORTLIBRARY + +// +// End of file + +SMPSAFE diff -r 000000000000 -r f63038272f30 bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconvertermain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothappprofiles/avrcp/statusconverter/remconavrcpstatusconvertermain.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +// Copyright (c) 2004-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: +// + +/** + @file + @internalComponent +*/ + +#include +#include "remconavrcpstatusconverter.h" + +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x10207ea4, CRemConAvrcpStatusConverter::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/data/10208970.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/data/10208970.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2006 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: ECom resource definition Declares +* +*/ + + + +// INCLUDES +#include +#include + +RESOURCE REGISTRY_INFO BTAudioManPluginResource + { + resource_format_version = RESOURCE_FORMAT_VERSION_2; + dll_uid = 0x10208970; + interfaces = + { + INTERFACE_INFO + { + // ASY plugin interface + interface_uid = KACCESSORYPLUGINAPIUID; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020897C; + version_no = 1; + display_name = "0x1020897B"; + default_data = KACCESSORYPLUGINAPIMAINSERVICE; + opaque_data = "Heap=0x1000|Stack=0x1000"; + rom_only = 1; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020897D; + version_no = 1; + display_name = "0x1020897B"; + default_data = KACCESSORYPLUGINAPIHANDLER; + opaque_data = ""; + rom_only = 1; + } + }; + }, + INTERFACE_INFO + { + // BTEng plugin interface + interface_uid = 0x2000277B; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020897B; + version_no = 1; + display_name = "btaudioman"; + default_data = "1108"; + opaque_data = ""; + rom_only = 1; + } + }; + } + }; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/AccessoryTypes_4dos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/AccessoryTypes_4dos.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2002-2004 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: Type definitions for Accessory Framework +* +*/ + + +// This header is copied from A3.1 release and modified to build btaccserver in +// non - Accessory Framework environment. + +#ifndef ACCESSORYTYPES_H +#define ACCESSORYTYPES_H + +// INCLUDES + +enum TAccAudioType + { + EAccMonoAudio, + EAccStereoAudio + }; + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +#endif // ACCESSORYTYPES_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccObserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2005-2006 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: +* Inteface used by Plugins for call-back to Accessory Server +* +*/ + + +#ifndef BTACC_OBSERVER_H +#define BTACC_OBSERVER_H + +#include // TInt +#include + +// FORWARD DECLARATION +class TBTDevAddr; + +// DATA + +// CLASS DECLaRATION +class MBTAccObserver + { +public: + + + /** + Called when an incoming response from a remote is ready to be picked up by + RemCon. + @param aAddr The address the response came from. + @return Error. If KErrNone, RemCon is committing to collecting the message + using GetResponse. If non-KErrNone, the message will be dropped by the + bearer. + */ + virtual void NewAccessory(const TBTDevAddr& aAddr, TProfiles aType) = 0; + + /** + Called when an incoming response from a remote is ready to be picked up by + RemCon. + @param aAddr The address the response came from. + @return Error. If KErrNone, RemCon is committing to collecting the message + using GetResponse. If non-KErrNone, the message will be dropped by the + bearer. + */ + virtual void AccessoryDisconnected(const TBTDevAddr& aAddr, TProfiles aType) = 0; + + /** + Called when an incoming response from a remote is ready to be picked up by + RemCon. + @param aAddr The address the response came from. + @return Error. If KErrNone, RemCon is committing to collecting the message + using GetResponse. If non-KErrNone, the message will be dropped by the + bearer. + */ + virtual void RemoteAudioOpened(const TBTDevAddr& aAddr, TProfiles aType) = 0; + + /** + Called when an incoming response from a remote is ready to be picked up by + RemCon. + @param aAddr The address the response came from. + @return Error. If KErrNone, RemCon is committing to collecting the message + using GetResponse. If non-KErrNone, the message will be dropped by the + bearer. + */ + virtual void RemoteAudioClosed(const TBTDevAddr& aAddr, TProfiles aType) = 0; + + /** + * Requests Accessory Framework or Dos to disable NREC + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual TInt DisableNREC(const TBTDevAddr& aAddr) = 0; + + /** + * Called when a remote should be temporarily taken out of use. + * @param aAddr The address of the remote. + */ + virtual void AccessoryTemporarilyUnavailable(const TBTDevAddr& aAddr, TProfiles aType) = 0; + + + virtual TInt ConnectionStatus(const TBTDevAddr& aAddr) = 0; + + virtual TBool IsAvrcpVolCTSupported() = 0; + virtual TBool IsAbsoluteVolumeSupported(const TBTDevAddr& aAddr) = 0; + + }; + +#endif // BTACC_OBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccParams.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccParams.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2005-2006 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: +* Struct for initialisation parameters for plugins. The derived +* (concrete) plugin will receive an instance of this in its NewL. It should pass +* it to the CBTAccPlugin base class constructor. +* +*/ + + +#ifndef BTACC_PARAMS_H +#define BTACC_PARAMS_H + +// FORWARD DECLARATION +class MBTAccObserver; + + +class TPluginParams + { +public: + /** + Constructor. + @param aImplementationUid The implementation UID of the plugin. + @param aObserver Observer. + */ + TPluginParams(const TUid aImplementationUid, MBTAccObserver& aObserver); + + /** Destructor. */ + ~TPluginParams(); + +public: + /** + Accessor for the implementation UID. + @return Implementation UID. + */ + TUid ImplementationUid() const; + + /** + Accessor for the observer. + @return Observer. + */ + MBTAccObserver& Observer() const; + +private: + const TUid iImplementationUid; + MBTAccObserver& iObserver; + }; + +#include "btaccParams.inl" + +#endif // BEARERPARAMS_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccParams.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccParams.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2005-2006 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: +* Parameter provided to BT Accessory Server Plugins +* +*/ + + +// INCLUDE FILES + + +inline TPluginParams::TPluginParams(const TUid aImplementationUid, MBTAccObserver& aObserver) +: iImplementationUid(aImplementationUid), + iObserver(aObserver) + { + + } + +inline TPluginParams::~TPluginParams() + { + + } + +inline TUid TPluginParams::ImplementationUid() const + { + //TRACE_OPT(KPRINTFTRACE, DebugPrint(_L("[BTAccServer]\t TPluginParams::ImplementationUid() "))); + return iImplementationUid; + } + +inline MBTAccObserver& TPluginParams::Observer() const + { + return iObserver; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccPlugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,175 @@ +/* +* Copyright (c) 2005-2006 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: +* This is the interface declaration and implementation which is +* used by plugins. Contains also virtual methods which are implemented +* by plugins, and hence used by server to call plugins. +* Version : %version: 1.1.3.2.4 % +* +*/ + + +#ifndef BTACC_PLUGIN_H +#define BTACC_PLUGIN_H + +// FORWARD DECLARATION + +#include +#include +#include + + +class CBTAccPlugin : public CBase + { +public: // used by 'Plugin Mananger' to create and destroy plugin instances + + /** + Constructor. + @param aParams Parameters from BT Acc Server, used to initialise the + implementation. + @return Ownership of a new plugin. + */ + static CBTAccPlugin* NewL(TPluginParams& aParams); + + /** Destructor. */ + virtual ~CBTAccPlugin(); + +public: + /** + * Called by BT Acc Sever to connect to mono or stereo accessory + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to cancel connect to mono or stereo accessory + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void CancelConnectToAccessory(const TBTDevAddr& aAddr); + + /** + * Called by BT Acc Sever to disconnect from mono, stereo + * or remote control profile accessory + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void DisconnectAccessory(const TBTDevAddr& aAddr,TRequestStatus& aStatus) = 0; + + /** + * Called by BT Acc Sever to open audio link + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void OpenAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to cancel opening of audio link + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void CancelOpenAudioLink(const TBTDevAddr& aAddr ); + + /** + * Called by BT Acc Sever to close audio link + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void CloseAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to cancel closing of audio link + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + virtual void CancelCloseAudioLink(const TBTDevAddr& aAddr ); + + /** + * Called by BT Acc Sever to inform plugin that accessory is in use (attached to acc fw). + @param None. + @return None. + */ + virtual void AccInUse() = 0; + + /** + * Called by BT Acc Sever to inform plugin that accessory is out of use (detached from acc fw). + @param None. + @return None. + */ + virtual void AccOutOfUse(); + + + /** + * BTAccServer informs 'BTSAC plugin' that it can start streaming + @param None. + @return None. + */ + virtual void StartRecording(); + + /** + * Check whether plugin supports mono audio + @param None. + @return ETrue if plugin supports mono audio, TFalse otherwise. + */ + virtual TProfiles PluginType() = 0; + + virtual void ActivateRemoteVolumeControl(); + + virtual void DeActivateRemoteVolumeControl(); + + virtual TInt GetRemoteSupportedFeature(); + + virtual TInt AudioLinkLatency(); + /** + * Called by BT Acc Server to query the plugin's implementation UID. + @return The plugin's implementation UID. + */ + TUid Uid() const; + + +protected: // called by concrete bearer plugins + /** + * Constructor + @param aParams Parameters from plugin manager, used to initialise the + implementation. + */ + CBTAccPlugin(TPluginParams& aParams); + + /** + Accessor for the observer. + @return The observer. + */ + MBTAccObserver& Observer(); + +private: // unowned + MBTAccObserver& iObserver; + +private: // owned + /** + UID set by ECOM when the instance is created. Used when the instance is + destroyed. + */ + TUid iInstanceId; + + /** + Implementation UID of concrete instance. + */ + const TUid iImplementationUid; + }; + +#include "btaccPlugin.inl" + + +#endif // BTACC_PLUGIN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccPlugin.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccPlugin.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2005-2006 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: +* This is the interface implementation which is +* used by plugins. Server uses this implementation to create +* plugins. +* Version : %version: 1.1.3.2.4 % +* +*/ + + + +// INCLUDE FILES + +#include // declares E-com framework classes +#include // declares TPluginParams + +inline CBTAccPlugin::~CBTAccPlugin() + { + REComSession::DestroyedImplementation(iInstanceId); + } + +inline CBTAccPlugin::CBTAccPlugin(TPluginParams& aParams) +: iObserver(aParams.Observer()), + iImplementationUid(aParams.ImplementationUid()) + { + } + +inline CBTAccPlugin* CBTAccPlugin::NewL(TPluginParams& aParams) + { + //TRACE_OPT(KPRINTFTRACE, DebugPrint(_L("[BTAccServer]\t CBTAccPlugin::NewL()"))); + + CBTAccPlugin* self = reinterpret_cast( + REComSession::CreateImplementationL( + aParams.ImplementationUid(), + _FOFF(CBTAccPlugin, iInstanceId), + (TAny*)&aParams) + ); + + return self; + } + +inline MBTAccObserver& CBTAccPlugin::Observer() + { + return iObserver; + } + +inline TUid CBTAccPlugin::Uid() const + { + return iImplementationUid; + } + +inline void CBTAccPlugin::AccOutOfUse() + { + } + +inline void CBTAccPlugin::StartRecording() + { + + } + +// +inline void CBTAccPlugin::ConnectToAccessory(const TBTDevAddr& /*aAddr*/, TRequestStatus& /*aStatus*/) + { + + } + +// +inline void CBTAccPlugin::CancelConnectToAccessory(const TBTDevAddr& /*aAddr*/) + { + + } + +// +inline void CBTAccPlugin::OpenAudioLink(const TBTDevAddr& /*aAddr*/, TRequestStatus& /*aStatus*/) + { + + } + +// +inline void CBTAccPlugin::CancelOpenAudioLink(const TBTDevAddr& /*aAddr*/ ) + { + + } + +// +inline void CBTAccPlugin::CloseAudioLink(const TBTDevAddr& /*aAddr*/, TRequestStatus& /*aStatus*/) + { + + } + +// +inline void CBTAccPlugin::CancelCloseAudioLink(const TBTDevAddr& /*aAddr*/ ) + { + + } + +inline void CBTAccPlugin::ActivateRemoteVolumeControl() {} + +inline void CBTAccPlugin::DeActivateRemoteVolumeControl() {} + +inline TInt CBTAccPlugin::GetRemoteSupportedFeature() + { + return 0; + } + +inline TInt CBTAccPlugin::AudioLinkLatency() + { + return KErrNotFound; + } +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccPluginUid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccPluginUid.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2005-2006 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: +* This is the interface declaration and implementation which is +* used by plugins. Contains also virtual methods which are implemented +* by plugins, and hence used by server to call plugins. +* +*/ + + +#ifndef BTACC_PLUGIN_UID_H +#define BTACC_PLUGIN_UID_H + +/** +The UID of the Bluetooth Accessory Server plugin's interface. Implementors of new plugins are +implementing this interface. +*/ +#define KBTAccPluginInterfaceUid 0x10208972 + + +#endif // BTACC_PLUGIN_UID_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/expinc/BTAccTypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/expinc/BTAccTypes.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2005-2006 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: +* Type of profiles supported in bluetooth audio accessories +* +*/ + + +#ifndef BTAUDIOPROFILES_H +#define BTAUDIOPROFILES_H + +#include + +enum TProfiles + { + ERemConCT = 0x10, // AVRCP Controller + ERemConTG = 0x08, // AVRCP Target + EStereo = 0x04, // A2DP + EHSP = 0x02, // HFP + EHFP = 0x01, // HSP + EUnknownProfile = 0x00, + EAnyMonoAudioProfiles = EHFP | EHSP, + EAnyAudioProfiles = EStereo | EAnyMonoAudioProfiles, + EAnyRemConProfiles = ERemConTG | ERemConCT, + EAnyAccessoryProfiles = EAnyRemConProfiles | EAnyAudioProfiles, + }; + + +class TProfileStatus + { +public: + TBTDevAddr iAddr; + TInt iProfiles; + TBool iConnected; + }; + +typedef TPckgBuf TProfileStatusPckgBuf; +typedef TPckg TProfileStatusPckg; + + +#endif // BTAUDIOPROFILES_H + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006 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: build file for btaudioman. +* +*/ + + +#include + +PRJ_EXPORTS + +../expinc/BTAccPlugin.h |../../inc/btaccPlugin.h +../expinc/BTAccPlugin.inl |../../inc/btaccPlugin.inl + +../expinc/BTAccParams.h |../../inc/btaccParams.h +../expinc/BTAccParams.inl |../../inc/btaccParams.inl + +../expinc/BTAccObserver.h |../../inc/btaccObserver.h + +../expinc/BTAccTypes.h |../../inc/btaccTypes.h + +../expinc/BTAccPluginUid.h |../../inc/btaccPluginUid.h + +../rom/btaudioman.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btaudioman.iby) + + +PRJ_MMPFILES + +btaudiomanclient.mmp +btaudioman.mmp + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/group/btaudioman.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/group/btaudioman.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2005-2006 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: This is project specification file for the btaudioman. +* Lists information necessary to compile and link the component. +* +*/ + +#include +#include +#include "../inc/prjconfig.h" + +VENDORID VID_DEFAULT + +CAPABILITY CAP_SERVER NetworkControl SurroundingsDD + +TARGET btaudioman.exe +TARGETTYPE exe + +UID 0x1000008d 0x10208971 + +SOURCEPATH ../src +SOURCE basrvmain.cpp +SOURCE BTAccServer.cpp +SOURCE basrvactive.cpp +SOURCE basrvpluginman.cpp +SOURCE basrvacc.cpp +SOURCE basrvaccstate.cpp +SOURCE basrvaccstatequery.cpp +SOURCE basrvaccstateconnect.cpp +SOURCE basrvaccstateattach.cpp +SOURCE basrvaccstateattached.cpp +SOURCE basrvaccstatedisconnect.cpp +SOURCE basrvaccstatedetach.cpp +SOURCE basrvactivenotifier.cpp +SOURCE basrvsdpquery.cpp +SOURCE BTAccInfo.cpp +SOURCE basrvaccman.cpp +SOURCE BTAccSession.cpp +SOURCE basrvpowercontrolagent.cpp +SOURCE basrvrvc.cpp +SOURCE BTAccSession_accfw_var.cpp +SOURCE basrvaccman_accfw_var.cpp +SOURCE basrvaccfwconn.cpp + +USERINCLUDE ../inc +SYSTEMINCLUDE ../../inc ../../../inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY esock.lib +LIBRARY ecom.lib +LIBRARY bluetooth.lib +LIBRARY btdevice.lib +LIBRARY sdpdatabase.lib +LIBRARY btmanclient.lib +LIBRARY btengdevman.lib +LIBRARY centralrepository.lib +LIBRARY AccPolicy.lib + +#ifdef PRJ_USE_STUB +LIBRARY sdpagent_stub.lib +LIBRARY accclient_stub.lib +LIBRARY accbtcontrol_stub.lib +#else +LIBRARY sdpagent.lib +LIBRARY accclient.lib +LIBRARY accbtcontrol.lib +#endif + +#ifdef PRJ_FILE_TRACE +LIBRARY flogger.lib +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/group/btaudiomanclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/group/btaudiomanclient.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2006-2007 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: This is project specification file for the btaudioman client. +* +*/ + + +#include +#include "../inc/prjconfig.h" + +TARGET btaudiomanclient.dll +TARGETTYPE PLUGIN +VENDORID VID_DEFAULT + +CAPABILITY CAP_ECOM_PLUGIN + +UID 0x10009D8D 0x10208970 + +START RESOURCE ../data/10208970.rss +TARGET btaudiomanclient.rsc +END + +SOURCEPATH ../src +SOURCE btaudiomanplugin.cpp +SOURCE BTAccClient.cpp +SOURCE basrvactive.cpp +SOURCE proxy.cpp +SOURCE BTAccInfoCmdHandler.cpp +SOURCE BTAccInfoMainService.cpp +SOURCE BTAccInfoRequester.cpp + +USERINCLUDE ../inc +SYSTEMINCLUDE ../../inc ../../../inc /epoc32/include/ecom +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY bluetooth.lib +LIBRARY ecom.lib + +#ifdef PRJ_USE_STUB +LIBRARY ASYProxy_stub.lib +#else +LIBRARY ASYProxy.lib +#endif + +#ifdef PRJ_FILE_TRACE +LIBRARY flogger.lib +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccClient.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2005 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: +* BT Accessory Server's client API declaration. Starts server +* and creates a session with server if necessary. +* +* +*/ + + +#ifndef BTACCCLIENT_H +#define BTACCCLIENT_H + +#include +#include "BTAccInfo.h" +#include "btaccTypes.h" + + +// CLASS DECLARATION + +/** +* RBTAccClient, the client class. +* An RSessionBase sends messages to the server with the function +* RSessionBase::SendReceive(); specifying an opcode and and array of argument +* pointers. Functions in derived classes, such as RBTAccServer::ManageServices(), +* are wrappers for different calls to SendReceive(). +*/ +class RBTAccClient : public RSessionBase + { +public: + + /** + * Connects to Bluetooth audio accessory + * @param aStatus the request status, KErrNone if the connection is successful, a Symbian + * error code otherwise, specifically: + * KErrNotSupported if the device doesn't support any BT audio profile; + * KErrAlreadyExists if the request is rejected due to other existing connections. + * @param aAddrBuf the package buf of the device address + * @param aDiagnostic will contain the conflict connections if connecting fails due to existing connections. + * Otherwise will contain the connected profile (type TProfiles) + */ + void ConnectToAccessory(TRequestStatus& aStatus, const TBTDevAddrPckgBuf& aAddrBuf, TDes8& aDiagnostic); + + /** + * Cancel Connection attempt to Bluetooth audio accessory + * @param aDevice Bluetooth address of the device + * @return TInt indicating the success of call. + */ + void CancelConnectToAccessory(); + + /** + * Disconnects Bluetooth audio accessory + * @param aStatus the request status, KErrNone if the operation is successful, a Symbian + * error code otherwise + * @param aAddrBuf the package buf of the device address + * @param aDiagnostic will contain the disconnected profile (type TProfiles) + */ + void DisconnectAccessory(TRequestStatus& aStatus, const TBTDevAddrPckgBuf& aAddrBuf, TDes8& aDiagnostic); + + + TInt GetConnections(TDes8& aAddrs, TInt aProfile); + + /** + * Disconnects all connection gracefully. + * This is called internally when BTAudioMan is going to be destroyed. + */ + void DisconnectAllGracefully(TRequestStatus& aStatus); + + void NotifyConnectionStatus(TProfileStatusPckg& aPckg, TRequestStatus& aStatus); + + void CancelNotifyConnectionStatus(); + + /** + * Checks if this is connecting or has been connected to the specified device + * + * @param aAddr the specified BD address + */ + TInt IsConnected(const TBTDevAddr& aAddr) const; + + /** + * + */ + void GetInfoOfConnectedAcc(TPckg& aInfoPckg, TRequestStatus& aStatus ); + + + /** + * Transfer audio to phone + * @param None + * @return TInt indicating the success of call. + */ + TInt AudioToPhone(); + + /** + * Routes the audio paths from the phone to the accessory from which they + * have been earlier on moved to the phone with the audio to phone + * operation. In practice also reconnects to the accessory. + * @param aStatus When the request completes contains the + * success status of the operation. + * @return None. + */ + void AudioToAccessory( TRequestStatus& aStatus ); + + /** + * Cancels the audio to accessory operation. + * Note that if this request is made after the point when it is not + * possible to cancel the actual operation any more, the audio paths + * might still be routed to the accessory again. + * @param TRequestStatus status to be cancelled. + * @return None. + */ + void CancelAudioToAccessory(); + +public: // Functions from base classes + + /** + * From RSessionBase informs current version + * @param None + * @return Version information about the server + */ + TVersion Version() const; + + /** + * From RSessionBase connect to the server + * @param None + * @return Error/success code + */ + TInt Connect(); + +private: // Data + }; + +#endif // BTACCCLIENT_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccClientSrv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccClientSrv.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2005 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: +* BT Acc Server op-codes, panic enumerations and other definitions. +* +*/ + + +#ifndef __BTACCCLIENTSRV_H +#define __BTACCCLIENTSRV_H + +// INCLUDES + +// CONSTANTS + +// Panic definitions +_LIT(KBTAudioManPanic,"BTAudioMan panic"); + +// reasons for server panic +enum TBTAccSrvPanic + { + EBTAccNoPluginsAvailable, + EBTAccPluginImplementationNotAccessable, + EBTAccBadRequest + }; + +// Opcodes used in message passing between client and server +enum TBTAccSrvServRequest + { + EBTAccSrvConnectToAccessory, + EBTAccSrvCancelConnectToAccessory, + EBTAccSrvDisconnectAccessory, + EBTAccSrvGetConnections, + EBTAccSrvDisconnectAllGracefully, + EBTAccSrvNotifyConnectionStatus, + EBTAccSrvCancelNotifyConnectionStatus, + EBTAccSrvConnectionStatus, + EBTAccSrvGetInfoOfConnectedAcc, + EBTAccSrvAudioToPhone, + EBTAccSrvAudioToAccessory, + EBTAccSrvCancelAudioToAccessory, + EBTAccSrvInvalidIpc, + }; + +// server name +_LIT(KBTAudioManName,"btaudioman"); + +// A version must be specifyed when creating a session with the server +const TUint KBTAccServerMajorVersionNumber=1; +const TUint KBTAccServerMinorVersionNumber=0; +const TUint KBTAccServerBuildVersionNumber=1; + +/** +* Utility to panic the client. +*/ +void PanicClient(const RMessage2& aMessage, TInt aPanic); + +/** +* Utility to panic server. +*/ +void PanicServer(TInt aPanic); + +#endif // _BTACCCLIENTSRV_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccFwIf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccFwIf.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2005-2006 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. +* Version : %version: 3.2.3 % +* +* Contributors: +* +* Description: An abstract class implemented by classes which are communicating +* with Accessory Fw or DOS +* +*/ + + +#ifndef BTACC_FW_IF_H +#define BTACC_FW_IF_H + +// INCLUDES +#include // TAccAudioType + +// FORWARD DECLARATION +class TAccInfo; + +// CLASS DECLARATION + +/** +* CBTSession class represent session on server side +* +*/ +NONSHARABLE_CLASS(CBasrvAccfwIf) : public CBase + { + + public: // New Functions + + /** + * Constructor. + */ + static CBasrvAccfwIf* NewL(const TAccInfo* aInfo = NULL); + + /** + * Informs the class that there is a request pending. + * @param aUse True if a request is pending, false otherwise. + * return None. + */ + virtual void CompleteReq(TBool aUse) = 0; + + /** + * Request Accessory Framework to attach accessory + * @param aBDAddr BT Device Address of accessory to be attached + * @param aStatus Success status of the operation. + * return success code of request to attach accessory + */ + virtual void AttachAccessory(const TBTDevAddr& aBDAddr, TRequestStatus& aStatus) = 0; + + /** + * Request Accessory Framework to cancel attach accessory + * @param aBDAddr BT Device Address of accessory to be attached + * return success code of request to attach accessory + */ + virtual void CancelAttachAccessory(const TBTDevAddr& aBDAddr)= 0; + + /** + * Request Accessory Framework to detatch accessory + * @param aBDAddr BT Device Address of accessory to be attached + * @param aStatus Success status of the operation. + * return None. + */ + virtual void DetatchAccessory(const TBTDevAddr& aBDAddr, TRequestStatus& aStatus)= 0; + + /** + * Register for notification when audio link is required to be opened. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void NotifyBTAudioLinkOpenReq(TBTDevAddr& aBDAddress, TRequestStatus& aStatus, TAccAudioType& aType )= 0; + + /** + * Register for notification when audio link is required to be closed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void NotifyBTAudioLinkCloseReq(TBTDevAddr& aBDAdress, TRequestStatus& aStatus, TAccAudioType& aType )= 0; + + /** + * Cancel registeration for notification when audio link is required to be opened. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void CancelNotifyBTAudioLinkOpenReq()= 0; + + /** + * Cancel registeration for notification when audio link is required to be closed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void CancelNotifyBTAudioLinkCloseReq()= 0; + + /** + * Informs that the audio connection open operation has completed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void AudioConnectionOpenCompleteL( const TBTDevAddr& aBDAddress, + TInt aResp, TInt aLatency = 0 )= 0; + + /** + * Informs that the audio connection close operation has completed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void AudioConnectionCloseCompleteL( const TBTDevAddr& aBDAddress, + TInt aResp )= 0; + + /** + * Notifies the DOS that an audio connection to the currently connected + * accessory has been opened. + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual void NotifyAudioLinkOpenL( const TBTDevAddr& aBDAddress, TAccAudioType aType )= 0; + + /** + * Notifies the DOS that the audio connection to the currently connected + * accessory has been closed. + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual void NotifyAudioLinkCloseL( const TBTDevAddr& aBDAddress, TAccAudioType aType )= 0; + + + /** + * Requests Accessory Framework or Dos to disable NREC + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual TInt DisableNREC(const TBTDevAddr& aBDAddress) = 0; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccInfo.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,147 @@ +/* +* Copyright (c) 2005-2006 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: A class that stores audio accessory related information. +* +*/ + + +#ifndef BTACC_INFO_H +#define BTACC_INFO_H + +// INCLUDES +#include // TBTDevAddr + +// DATA TYPES + +// CLASS DECLARATION +class TAccInfo + { + +public: + + enum TSupportedFeaturesIndex + { + ERemConTGIndex = 3, + EStereoIndex = 2, + EHSPIndex = 1, + EHFPIndex = 0 + }; + + enum TAvrcpVersion + { + EAvrcpVersionNo14 = 0x0103, + EAvrcpVersion14 = 0x0104 + }; + +public: + + /** + * Accessor for the + * @return + */ + void SetBDAddress(const TBTDevAddr& aAddr); + + /** + * Accessor for the + * @return + */ + const TBTDevAddr& GetBDAddress(); + + /** + * Accessor for the + * @return + */ + void SetCapturingSupport(TBool aCapturingSupport); + + /** + * Accessor for the + * @return + */ + TBool GetCapturingSupport(); + + /** + * Accessor for the + * @return + */ + void SetSuppportedProfiles(TUint8 aSuppProfiles); + + /** + * Accessor for the + * @return + */ + TUint8 SupportedProfiles() const; + + /** + * Accessor for the + * @return + */ + void SetConnectedProfiles(TUint8 aConnProfiles); + + /** + * Accessor for the + * @return + */ + TUint8 ConnectedProfiles() const; + + /** + * Accessor for the + * @return + */ + void SetDeviceType(TUint8 aDeviceType); + + /** + * Accessor for the + * @return + */ + TUint8 DeviceType() const; + + /** + * Accessor for the + * @return + */ + void SetModel(TUint16 aModel); + + /** + * Accessor for the + * @return + */ + TUint16 Model() const; + + /** + * Accessor for the + * @return + */ + void SetSupportedFeature(TUint16 aSupportedFeature, TInt aPosition); + + /** + * Accessor for the + * @return + */ + TUint16 SupportedFeatureL(TInt aPosition) const; + +public: + TBTDevAddr iAddr; + TBool iCapturingSupport; // If accessory is capable of capturing or recording (DRM feature) + TUint8 iSuppProfiles; // Supported profile in the remote device + TUint8 iConnProfiles; // Connected Profiles from the remote device point of view + TUint8 iAudioOpenedProfiles; // The profiles that currently have audio link. + TUint8 iDeviceType; // 0x1 headset device, 0x2 carkit (@see AccPolGenericid.h) + TUint16 iModel; + TUint16 iAvrcpVersion; // 0x00 AVRCP1.3, 0x01 AVRCP1.4 + TFixedArray iSupportedFeatures; // position of objects matched TSupportedFeaturesIndex + }; + +#endif // BTACC_INFO_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccInfoCmdHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccInfoCmdHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2005-2006 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: Loaded by Accessory Server to retrieve information of an accessory +* +*/ + + +#ifndef BTACCINFOCMDHANDLER_H +#define BTACCINFOCMDHANDLER_H + +// INCLUDES +#include +#include +#include + +#include "BTAccInfoRequester.h" + +// CLASS DECLARATION + +/** +* Implements interface provided by Accessory Server. This interface +* is used to get information about a bluetooth accessory. +* +* @lib BTAccInfo.dll +* @since Series 60 3.1 +*/ +class CBTAccInfoCmdHandler : public CASYCommandHandlerBase, public MBTAccInfoNotifier + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param + * @return The created object. + */ + static CBTAccInfoCmdHandler* NewL(); + + /** + * Destructor. + */ + ~CBTAccInfoCmdHandler(); + + public: // Functions from base classes + + /** + * Processes a command from Acccessory Server + * @since Series 60 3.1 + * @param aCommand Command to process. + * @param aCmdParams Params of command to process. + */ + void ProcessCommandL(const TProcessCmdId aCommand, const TASYCmdParams& aCmdParams); + + /** + * Call-back from BTAccInfoRequester; Provides information of an accessory + * Ownership of TASYBTAccInfo is recieved by this method + * @since Series 60 3.1 + * @param aErr Whether information of an accessory could be retrieved or not. + * @param aAccInfo T-class containing information of an accessory + */ + void GetBTAccInfoCompletedL(TInt aErr, const TASYBTAccInfo& aAccInfo); + + + private: // Functions + + /** + * C++ default constructor. + */ + CBTAccInfoCmdHandler(); + + private: // Data + CBTAccInfoRequester* iRequester; // Owned; Pointer to class which is used to get information of an accessory + + }; + +#endif // BTACCINFOCMDHANDLER_H + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccInfoMainService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccInfoMainService.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2005-2006 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: Loaded by Accessory Server to allow this component to initialize +* +*/ + + +#ifndef BTACCINFOMAINSERVICE_H +#define BTACCINFOMAINSERVICE_H + +// INCLUDES +#include +#include + +// CLASS DECLARATION + +/** +* Creates ASY main service +* +* @lib BTAccInfo.dll +* @since Series 60 3.1 +*/ +class CBTAccInfoMainService : private CASYMainServiceBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTAccInfoMainService* NewL(); + + public: // Functions from base classes + + /** + * Startup function after creating object + * @since Series 60 3.1 + * @return Error code of startup. + * KErrNone if successfully + */ + TInt StartL(); + + private: // Functions + + /** + * By default Symbian 2nd phase constructor is private. + */ + CBTAccInfoMainService(); + + /** + * Destructor. + */ + ~CBTAccInfoMainService(); + + }; + +#endif // BTACCINFOMAINSERVICE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccInfoRequester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccInfoRequester.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2005-2006 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: Retrieves accessory information from Bluetooth Accessory Server +* +*/ + + +#ifndef BTACCINFOREQUESTER_H +#define BTACCINFOREQUESTER_H + +// INCLUDES +#include +#include +#include +#include "BTAccClient.h" +#include "BTAccInfo.h" + +// FORWARD DECLARATIONS +class TAccInfo; + +// CLASS DECLARATION +class MBTAccInfoNotifier + { + public: + virtual void GetBTAccInfoCompletedL(TInt aErr, const TASYBTAccInfo& aAccInfo) = 0; + }; + +/** +* Active object to fetch Acc Info from BTAccClient. +* +* @lib BTAccInfo.dll +* @since Series 60 3.1 +*/ +class CBTAccInfoRequester : public CActive + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aNotifier A reference used for call-back to BTAccInfoCmdHandler class + * @return The created object. + */ + static CBTAccInfoRequester* NewL(MBTAccInfoNotifier& aNotifier); + + /** + * Destructor. + */ + virtual ~CBTAccInfoRequester(); + + public: // New functions + + /** + * Gets the info of a BT audio accessory + * @since Series 60 3.1 + * @param TBTDevAddr bluetooth device of the accessory + * whose information is required + */ + void GetBTAccInfoL(const TBTDevAddr& aAddr); + + protected: // Functions from base classes + + /** + * From CActive Handles an active object's request completion event. + */ + void RunL(); + + void DoCancel(); + + private: + + /** + * C++ default constructor. + * @param aNotifier A reference used for call-back to BTAccInfoCmdHandler class + */ + CBTAccInfoRequester(MBTAccInfoNotifier& aNotifier); + + private: // Data + + MBTAccInfoNotifier& iNotifier; // Store a reference to get a call-back to BTAccInfoCmdHandler class + RBTAccClient iBTAccClient; // Call BT Acc Server component to retrieve information of an accessory + + TAccInfo iAccInfo; + TPckg iAccInfoPckg; + }; + +#endif // BTACCINFOREQUESTER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccSecurityPolicy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccSecurityPolicy.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2005 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: +* BT Accessory Server security policy definition. +* +*/ + + +#ifndef BTACC_SECURITYPOLICY_H +#define BTACC_SECURITYPOLICY_H + +// ---------------------------------------------------------------------------------------- +// BTAccSrv's policy +// ---------------------------------------------------------------------------------------- +// + +//Total number of ranges + + +//Definition of the ranges of IPC numbers +const TInt KBTAccSrvRanges[] = + { + 0, //EBTAccSrvConnectToAccessory, + //EBTAccSrvCancelConnectToAccessory, + //EBTAccSrvDisconnectAccessory, + //EBTAccSrvDisconnectAllGracefully, + //EBTAccSrvIsConnected, + //EBTAccSrvGetInfoOfConnectedAcc, + //EBTAccSrvAudioToPhone, + //EBTAccSrvAudioToAccessory, + //EBTAccSrvCancelAudioToAccessory, + EBTAccSrvInvalidIpc // Range 3: Invalid IPC opcode, return ENotSupported + }; + +const TUint KBTAccSrvRangeCount = sizeof(KBTAccSrvRanges) / sizeof(TInt); + +//Policy to implement for each of the above ranges +const TUint8 KBTAccSrvElementsIndex[KBTAccSrvRangeCount] = + { + 0, //policy 0 applies to 0th range + CPolicyServer::ENotSupported //applies to 7th range(out of range IPC) + }; + +//Specific capability checks +const CPolicyServer::TPolicyElement KBTAccSrvElements[] = + { + {_INIT_SECURITY_POLICY_C1(ECapabilityLocalServices), + CPolicyServer::EFailClient + } + }; + +//Package all the above together into a policy +const CPolicyServer::TPolicy KBTAccSrvPolicy = + { + CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass + KBTAccSrvRangeCount, //number of ranges + KBTAccSrvRanges, //ranges array + KBTAccSrvElementsIndex, //elements<->ranges index + KBTAccSrvElements //array of elements + }; + +#endif // BTACC_SECURITYPOLICY_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccServer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2005 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: +* Server class is responsible for creating sessions and then handle +* messages from the session class. +* +*/ + + +#ifndef BTACC_SERVER_H +#define BTACC_SERVER_H + +// INCLUDES +#include + +// CONSTANTS + +// FORWARD DECLARATION +class CBasrvAccMan; +class TAccInfo; +class CBTAccSession; + +/** +* CBTAccServer server core class +*/ +NONSHARABLE_CLASS(CBTAccServer) : public CPolicyServer + { +public: // Constructors and destructor + /** + * Two-phased constructor. + */ + static CBTAccServer* NewLC(); + + /** + * Destructor. + */ + ~CBTAccServer(); + + void StartShutdownTimerIfNoSessions(); + + void ClientOpened(CBTAccSession& aSession); + + void ClientClosed(CBTAccSession& aSession); + +private: // Functions from base classes + /** + * Creates a new session to client + * @param aVersion the version + * @param aMessage not used + * return the new created session + */ + CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; + + /** + * Constructor + * @param aPriority This AO's priority + */ + CBTAccServer(TInt aPriority); + + /** + * Two-Phase constructor + */ + void ConstructL(); + + void CancelShutdownTimer(); + + static TInt TimerFired(TAny* aThis); + +private: // Data + CBasrvAccMan* iAccMan; + + CPeriodic* iTimer; + + RPointerArray iSessions; + }; + +#endif // BTACC_SERVER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/BTAccSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/BTAccSession.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2005-2006 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: +* Server class creates the session. This class then recieves the messages from +* client and forward them to server class to be handled. Messages are completed +* with return values recieved from server. +* +*/ + + +#ifndef BTACCSESSION_H +#define BTACCSESSION_H + +// INCLUDES +#include // access CSession2 declaration +#include +#include "btaccTypes.h" + +// CLASS DECLARATION +class CBTAccServer; +class CBasrvAccMan; +class TAccInfo; +class CBasrvAudio4Dos; + +/** +* CBTSession class represent session on server side +* +*/ +NONSHARABLE_CLASS(CBTAccSession) : public CSession2 + { +public: // Constructors and destructor + /** + * Constructor. + */ + static CBTAccSession* NewL(CBasrvAccMan& aAccMan); + + /** + * Destructor. + */ + ~CBTAccSession(); + + void ConnectCompleted(TInt aErr, TInt aProfile, const RArray* aConflicts); + + void DisconnectCompleted(TInt aProfile, TInt aErr); + + void DisconnectAllCompleted(TInt aErr); + + void NotifyClientNewProfile(TInt aProfile, const TBTDevAddr& aAddr); + void NotifyClientNoProfile(TInt aProfile, const TBTDevAddr& aAddr); + + // For DosServer version only + void AudioToPhone(const RMessage2& aMessage); + void AudioToAccessory(const RMessage2& aMessage); + void CancelAudioToAccessory(); + void AudioToPhoneComplete(); + void AudioToAccessoryComplete(TInt aErr); + +private: + /** + * connect an accessory + * @param aMessage Message from client containing BT Device address + * @return KErrNone if successful otherwise one of the system wide error cdes + */ + void ConnectToAccessory(const RMessage2& aMessage); + + /** + * cancel connecting + */ + void CancelConnectToAccessory(); + + /** + * disconnect an accessory + * @param aMessage Message from client containing BT Device address + * @return KErrNone if successful otherwise one of the system wide error cdes + */ + void DisconnectAccessory(const RMessage2& aMessage); + + void GetConnections(const RMessage2& aMessage); + + void DisconnectAllGracefully(const RMessage2& aMessage); + + void NotifyProfileStatus(const RMessage2& aMessage); + + /** + * + * @param + * @return + */ + void GetInfoOfConnectedAcc(const RMessage2& aMessage); + + void IsConnected(const RMessage2& aMessage); + +private: // Functions from base classes + void ServiceL(const RMessage2 &aMessage); + + CBTAccServer& Server(); + + void CreateL(); + +private: + /** + * C++ default constructor. + */ + CBTAccSession(CBasrvAccMan& aAccMan); + + void HandleAudio4DosRequest(const RMessage2 &aMessage); + + void DestructVariant(); + + void UpdateProfileStatusCache(const TProfileStatus& aStatus); + +private: // Data + CBasrvAccMan& iAccMan; // not own + + TBTDevAddr iConnectingAddr; + RMessagePtr2 iConnectMsg; + RMessagePtr2 iDisconnectMsg; + RMessagePtr2 iDisconnectAllMsg; + + RArray iProfileStatusCache; + RMessagePtr2 iNotifyProfileMsg; + + CBasrvAudio4Dos* iAudio4Dos; + }; + +#endif // BTACCSESSION_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvacc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvacc.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2005-2006 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: +* +*/ + + +#ifndef C_BTASRVACC_H +#define C_BTASRVACC_H + +#include +#include +#include +#include +#include "BTAccInfo.h" +#include "btaccTypes.h" + +class CBasrvAccState; +class TAccInfo; +class CBasrvAccMan; +class CBasrvPowerControlAgent; +class CBasrvRvc; + +class CBasrvAcc : public CBase + { +public: + static CBasrvAcc* NewL(CBasrvAccMan& aAccMan); + + static CBasrvAcc* NewLC(CBasrvAccMan& aAccMan); + + ~CBasrvAcc(); + + const TBTDevAddr& Remote(); + + void ConnectL(const TBTDevAddr& aAddr); + + void CancelConnect(); + + void DisconnectL(); + + void AccessoryConnectedL(const TBTDevAddr& aAddr, TProfiles aProfile); + + void AccOpenedAudio(TProfiles aProfile); + + void AccClosedAudio(TProfiles aProfile); + + void AccessoryDisconnectedL(TProfiles aProfile); + + const TAccInfo* AccInfo(const TBTDevAddr& aAddr); + + TAccInfo& AccInfo(); + + /** + * Called when an audio open request comes from Acc FW. + */ + void OpenAudioL(TAccAudioType aType); + + /** + * Called when an audio close request comes from Acc FW. + */ + void CloseAudioL(TAccAudioType aType); + + void ChangeStateL(CBasrvAccState* aNewState); + + CBasrvAccMan& AccMan(); + + TBTEngConnectionStatus ConnectionStatus() const; + + void RequestSniffMode(); + + void RequestActiveMode(); + + void CancelPowerModeControl(); + + void NotifyLinkChange2Rvc(); + + void PreventLowPowerMode(); + + void AllowLowPowerMode(); + +protected: + + /** + * Default constructor + */ + CBasrvAcc(CBasrvAccMan& aAccMan); + + void ConstructL(); + +protected: + CBasrvAccMan& iAccMan; + + CBasrvAccState* iState; + + TAccInfo iAccInfo; + + CBasrvPowerControlAgent* iPowerController; + CBasrvRvc* iRvc; + }; + +#endif // C_BTASRVACC_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccfwconn.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccfwconn.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2005-2006 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: +* This class communicates with Nokia "Accessory Framework" +* to, e.g. get permission to attach/detach a remote bluetooth +* device and also recieves requests to open/close audio connections. +* Version : %version: 1.2.4 % +* +*/ + + +#ifndef BTACC_FW_CONNECTION_H +#define BTACC_FW_CONNECTION_H + +// INCLUDES +#include // Declaration of CActive +#include +#include +#include "BTAccFwIf.h" + +/** +* CBTSession class represent session on server side +* +*/ +NONSHARABLE_CLASS(CBasrvAccfwConn) : public CBasrvAccfwIf + +{ +public: // Constructors and destructor + + /** + * Constructor. + */ + static CBasrvAccfwIf* NewL(); + + /** + * Destructor. + */ + ~CBasrvAccfwConn(); + +public: // from BTAccFwIf + + /** + * + * @param + * return + */ + virtual void CompleteReq(TBool aUse); + + /** + * Request Accessory Framework to attach accessory + * @param aBDAddr BT Device Address of accessory to be attached + * @param aStatus Success status of the operation. + * return success code of request to attach accessory + */ + virtual void AttachAccessory(const TBTDevAddr& aBDAddr, TRequestStatus& aStatus); + + + /** + * Request Accessory Framework to cancel attach accessory + * @param aBDAddr BT Device Address of accessory to be attached + * return success code of request to attach accessory + */ + virtual void CancelAttachAccessory(const TBTDevAddr& aBDAddr); + + /** + * Request Accessory Framework to detatch accessory + * @param aBDAddr BT Device Address of accessory to be attached + * @param aStatus Success status of the operation. + * return None. + */ + virtual void DetatchAccessory(const TBTDevAddr& aBDAddr, TRequestStatus& aStatus); + + /** + * Register for notification when audio link is required to be opened. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void NotifyBTAudioLinkOpenReq(TBTDevAddr& aBDAddress, TRequestStatus& aStatus, TAccAudioType& aType ); + + /** + * Register for notification when audio link is required to be closed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void NotifyBTAudioLinkCloseReq(TBTDevAddr& aBDAdress, TRequestStatus& aStatus, TAccAudioType& aType ); + + /** + * Cancel registeration for notification when audio link is required to be opened. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void CancelNotifyBTAudioLinkOpenReq(); + + /** + * Cancel registeration for notification when audio link is required to be closed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void CancelNotifyBTAudioLinkCloseReq(); + + /** + * Informs that the audio connection open operation has completed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void AudioConnectionOpenCompleteL( const TBTDevAddr& aBDAddress, + TInt aResp, TInt aLatency = 0 ); + + /** + * Informs that the audio connection close operation has completed. + * @param aStatus Success status of the operation. + * @return None. + */ + virtual void AudioConnectionCloseCompleteL( const TBTDevAddr& aBDAddress, + TInt aResp ); + + /** + * Notifies the DOS that an audio connection to the currently connected + * accessory has been opened. + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual void NotifyAudioLinkOpenL( const TBTDevAddr& aBDAddress, TAccAudioType aType ); + + /** + * Notifies the DOS that the audio connection to the currently connected + * accessory has been closed. + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual void NotifyAudioLinkCloseL( const TBTDevAddr& aBDAddress, TAccAudioType aType ); + + /** + * Requests Accessory Framework to disable NREC + * @param aBDAddress BT hardware address of the accessory. + * @return None. + */ + virtual TInt DisableNREC(const TBTDevAddr& aBDAddress); + +private: // New Functions + + /** + * C++ default constructor. + */ + CBasrvAccfwConn(); + + /** + * 2nd Phase Construction + */ + void ConstructL(); + + +private: // Data + + RAccessoryServer iAccessoryServerSession; + RAccessoryBTControl iAccessoryBTControlSession; + +}; + +#endif // BTACC_FW_CONNECTION_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2005-2006 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: +* ============================================================================ +* Name : basrvaccman.h +* Part of : BTEng / Bluetooth Accessory Server +* Description : +* Version : %version: 3.1.4.1.2.2.10 % +* +*/ + + +#ifndef C_BTASRVACCMAN_H +#define C_BTASRVACCMAN_H + +#include +#include +#include +#include +#include "basrvactive.h" +#include "btaccObserver.h" +#include "BTAccFwIf.h" +#include "basrvactivenotifier.h" + +class CBasrvAcc; +class CBTAccSession; +class TAccInfo; +class CBasrvPluginMan; +class CBasrvAudio4Dos; + +class CBasrvAccMan : + public CBase, + public MBTAccObserver, + public MBasrvActiveObserver + { +public: + static CBasrvAccMan* NewL(); + + ~CBasrvAccMan(); + + void LoadServicesL(); + + void ConnectL(CBTAccSession& aSession, const TBTDevAddr& aAddr); + + void CancelConnect(const TBTDevAddr& aAddr); + + void DisconnectL(CBTAccSession& aSession, const TBTDevAddr& aAddr); + + void DisconnectAllL(CBTAccSession& aSession); + + void SetProfileNotifySession(CBTAccSession& aSession); + + void ClearProfileNotifySession(CBTAccSession& aSession); + + const TAccInfo* AccInfo(const TBTDevAddr& aAddr); + + CBasrvPluginMan& PluginMan(); + + void ConnectCompletedL(const TBTDevAddr& aAddr, TInt aErr, TInt aProfile, const RArray* aConflicts = NULL); + + void DisconnectCompletedL(const TBTDevAddr& aAddr, TInt aProfile, TInt aErr); + + TInt OpenAudioCompleted(const TBTDevAddr& aAddr, TAccAudioType aType, TInt aErr); + + TInt CloseAudioCompleted(const TBTDevAddr& aAddr, TAccAudioType aType, TInt aErr); + + void AccObsoleted(CBasrvAcc* aAcc, const TBTDevAddr& aAddr); + + CBasrvAccfwIf* AccfwConnectionL(const TAccInfo* aInfo = NULL); + + CBasrvAccfwIf* NewAccfwConnectionInstanceL(); + + void ListenAudioRequestL(); + + void CancelAudioRequestListen(); + + void RemoveAudioRequest(const TBTDevAddr& aAddr); + + void ShowNote(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr); + + void FilterProfileSupport(TAccInfo& aInfo); + + TInt NotifyAccFwAudioOpened(const TBTDevAddr& aAddr, TAccAudioType aType, TInt aLatency); + + TInt AccInfos(RPointerArray& aInfos); + + void NotifyClientNewProfile(TInt aProfile, const TBTDevAddr& aAddr); + void NotifyClientNoProfile(TInt aProfile, const TBTDevAddr& aAddr); + + TBTEngConnectionStatus ConnectionStatus4Client(const TBTDevAddr& aAddr) const; + + // For DosServer version only + void AudioToPhone(CBasrvAudio4Dos& aAudio4Dos); + void AudioToAccessory(CBasrvAudio4Dos& aAudio4Dos); + + TBool IsAvrcpVolCTSupported(); + TBool IsAbsoluteVolumeSupported(const TBTDevAddr& aAddr); + TBool DisconnectIfAudioOpenFails(); + +private: // From MBTAccObserver + void NewAccessory(const TBTDevAddr& aAddr, TProfiles aProfile); + + void AccessoryDisconnected(const TBTDevAddr& aAddr, TProfiles aProfile); + + void RemoteAudioOpened(const TBTDevAddr& aAddr, TProfiles aProfile); + + void RemoteAudioClosed(const TBTDevAddr& aAddr, TProfiles aProfile); + + TInt DisableNREC(const TBTDevAddr& aAddr); + + void AccessoryTemporarilyUnavailable(const TBTDevAddr& aAddr, TProfiles aType); + + TInt ConnectionStatus(const TBTDevAddr& aAddr); + + //TCleanupOperation callback function for TCleanupItem + static void CleanupLastItemFromClientRequestsArray(TAny* aPtr); + +private: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void CancelRequest(CBasrvActive& aActive); + +protected: + /** + * Default constructor + */ + CBasrvAccMan(); + + void ConstructL(); + + void HandleNewAudioRequestL(); + + void DoAudioRequestL(); + + void DestructVariant(); + + TInt FindAcc(const TBTDevAddr& aRemote); + + TInt AudioLinkStatus(); + + void RejectAudioLink(const TBTDevAddr& aAddr, TAccAudioType aType); + +private: + enum TRequestType + { + ECloseReqFromAudioPolicy, + EOpenReqFromAudioPolicy, + ERejectAudioOpenedByAcc, + }; + + class TAudioRequest + { + public: + TBTDevAddr iAddr; + TAccAudioType iAudioType; + TRequestType iReqType; + TBool iOngoing; + }; + + class TClientRequestCache + { + public: + CBTAccSession* iSession; + TInt iRequest; + TBTDevAddr iAddr; + }; + +protected: + RArray iClientRequests; + CBTAccSession* iSessionOfDisconnectAll; // not own + CBTAccSession* iProfileNotifySession; // not own + + CBasrvAudio4Dos* iAudio4Dos; // not own + + RPointerArray iAccs; + + CBasrvPluginMan* iPluginMan; + CBasrvAccfwIf* iAccfw; + + CBasrvActive* iOpenListener; + CBasrvActive* iCloseListener; + TAccAudioType iOpenType; + TAccAudioType iCloseType; + TBTDevAddr iOpenAddr; + TBTDevAddr iCloseAddr; + RArray iAudioRequests; + + RPointerArray iNotifierArray; + TBuf8 iNoResult; + + TBool iDisconnectAllPending; + + CBasrvActive* iAsyncHandlingActive; + + TBool iAvrcpVolCTSupported; + TBool iDisconnectIfAudioOpenFails; + }; + +#endif // C_BTASRVACCMAN_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstate.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 2005-2006 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: The base accessory state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATE_H +#define C_BTASRVACCSTATE_H + +#include +#include +#include +#include "basrvactive.h" +#include "basrvacc.h" +#include "basrvaccman.h" +#include "basrvpluginman.h" +#include "btaccPlugin.h" +#include "btaccTypes.h" +#include "BTAccInfo.h" +#include "BTAccFwIf.h" + +class CBasrvAccState : public CBase, public MBasrvActiveObserver + { +public: + + virtual ~CBasrvAccState(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + virtual void EnterL() = 0; + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + virtual CBasrvAccState* ErrorOnEntry(TInt aReason); + + virtual TBTEngConnectionStatus ConnectionStatus() const = 0; + + /** + * Connect to an accessory. Default inplementation returns KErrInUse. + * @param aAddr BD address of the accessory to be connected + * @return an error + */ + virtual void ConnectL(const TBTDevAddr& aAddr); + + /** + * Cancel connecting to accessory + */ + virtual void CancelConnect(); + + /** + * Disconnect accessory. Default implementation returns KErrNotFound. + * @param aAddr BD address of the accessory to be connected + * @return an error + */ + virtual void DisconnectL(); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + virtual void AccessoryConnected(TProfiles aProfile); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + virtual void AccOpenedAudio(TProfiles aProfile); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + virtual void AccClosedAudio(TProfiles aProfile); + + /** + * Called when the connection is disconnected from remote side or there + * is error on reading/writing data packet. + * @param aErr the error code of event + */ + virtual void AccessoryDisconnectedL(TProfiles aProfile); + + /** + * Called when an audio open request comes from Acc FW. + */ + virtual void OpenAudioL(TAccAudioType aType); + + /** + * Called when an audio close request comes from Acc FW. + */ + virtual void CloseAudioL(TAccAudioType aType); + +protected: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive); + +protected: + + /** + * Default constructor + */ + CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest); + + /** + * Gets the owner of the state machine + * + * @since S60 v3.1 + * @return the state machine owner + */ + CBasrvAcc& Parent(); + + /** + * Completes the pending request in this state with specified error code + * and then zero the pointer. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void CompleteStateRequest(TInt aErr); + + /** + * Completes the give pending request with specified error code.. + * + * @since S60 v3.1 + * @param aRequest the request to be completed + * @param aErr the completion error code + */ + void CompleteRequest(TRequestStatus* aRequest, TInt aErr); + + void StatePrint(const TDesC& aStateName); + + TAccInfo& AccInfo(); + + void NewProfileConnection(TProfiles aProfile); + + void ProfileDisconnected(TProfiles aProfile); + + TBool IsAvrcpTGCat2SupportedByRemote(); + +protected: + + CBasrvAcc& iParent; + + /** + * Possible to be NULL. + * The async request performed in this state if it is not NULL. + */ + TRequestStatus* iRequest; + }; + +#endif // C_BTASRVACCSTATE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstateattach.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstateattach.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2005-2006 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: The Query state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATEATTACH_H +#define C_BTASRVACCSTATEATTACH_H + +#include "basrvaccstate.h" + +class CBasrvAccStateAttach : public CBasrvAccState + { +public: + + static CBasrvAccStateAttach* NewL(CBasrvAcc& aParent, TBool aConnecting); + + virtual ~CBasrvAccStateAttach(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBasrvAccState* ErrorOnEntry(TInt aReason); + + TBTEngConnectionStatus ConnectionStatus() const; + + /** + * Cancel connecting to accessory + */ + void CancelConnect(); + + void DisconnectL(); + + + /** + * Called when the connection is disconnected from remote side or there + * is error on reading/writing data packet. + * @param aErr the error code of event + */ + void AccessoryDisconnectedL(TProfiles aProfile); + +protected: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive); + +protected: + + /** + * Default constructor + */ + CBasrvAccStateAttach(CBasrvAcc& aParent, TBool aConnecting); + + void ConstructL(); + +protected: + CBasrvActive* iActive; + TBool iConnecting; + }; + +#endif // C_BTASRVACCSTATEATTACH_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstateattached.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstateattached.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2005-2006 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: The Connected state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATECONNECTED_H +#define C_BTASRVACCSTATECONNECTED_H + +#include "basrvaccstate.h" +#include "btengprivatepskeys.h" + +class CBasrvAccStateAttached : public CBasrvAccState + { +public: + + static CBasrvAccStateAttached* NewL(CBasrvAcc& aParent, TBool aShowNote = EFalse); + + virtual ~CBasrvAccStateAttached(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBasrvAccState* ErrorOnEntry(TInt aReason); + + TBTEngConnectionStatus ConnectionStatus() const; + + void ConnectL(const TBTDevAddr& aAddr); + + /** + * Disconnect accessory. + */ + void DisconnectL(); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + void AccessoryConnected(TProfiles aProfile); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + void AccOpenedAudio(TProfiles aProfile); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + void AccClosedAudio(TProfiles aProfile); + + /** + * Called when the connection is disconnected from remote side. + * @param aErr the error code of event + */ + void AccessoryDisconnectedL(TProfiles aProfile); + + /** + * Called when an audio open request comes from Acc FW. + */ + void OpenAudioL(TAccAudioType aType); + + /** + * Called when an audio close request comes from Acc FW. + */ + void CloseAudioL(TAccAudioType aType); + +protected: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive); + +protected: + + /** + * Default constructor + */ + CBasrvAccStateAttached(CBasrvAcc& aParent, TBool aShowNote); + + void HandleAccOpenedAudio(TProfiles aProfile); + + void DoCloseAudioL(TAccAudioType aType); + + void DoConnectRemConCtIfNeededL(); + +private: + + void UpdateAudioState(TBTAudioLinkState aState, TAccAudioType aType); + + RPointerArray iActives; + CBasrvActive* iAudioOpener; + CBasrvActive* iAudioCloser; + + RTimer iTimer; + CBasrvActive* iTimerActive; + TProfiles iCloseAudioProfile; + + TBool iShowNote; + + CBasrvActive* iRemConTGConnector; + }; + +#endif // C_BTASRVACCSTATECONNECTED_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstateconnect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstateconnect.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2005-2006 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: The Connect state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATECONNECT_H +#define C_BTASRVACCSTATECONNECT_H + +#include "basrvaccstate.h" + +class CBasrvAccStateConnect : public CBasrvAccState + { +public: + + static CBasrvAccStateConnect* NewL(CBasrvAcc& aParent); + + virtual ~CBasrvAccStateConnect(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBasrvAccState* ErrorOnEntry(TInt aReason); + + TBTEngConnectionStatus ConnectionStatus() const; + + /** + * Cancel connecting to accessory + */ + void CancelConnect(); + +protected: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive); + +protected: + + /** + * Default constructor + */ + CBasrvAccStateConnect(CBasrvAcc& aParent); + void ConstructL(); + +private: + CBasrvActive* iActive; + TProfiles iConnectingProfile; + }; + +#endif // C_BTASRVACCSTATECONNECT_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstatedetach.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstatedetach.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2005-2006 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: The Query state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATEDETACH_H +#define C_BTASRVACCSTATEDETACH_H + +#include "basrvaccstate.h" +class CBasrvAccfwIf; + +class CBasrvAccStateDetach : public CBasrvAccState + { +public: + + static CBasrvAccStateDetach* NewL(CBasrvAcc& aParent); + + virtual ~CBasrvAccStateDetach(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBasrvAccState* ErrorOnEntry(TInt aReason); + + TBTEngConnectionStatus ConnectionStatus() const; + + /** + * Called when the connection is disconnected from remote side or there + * is error on reading/writing data packet. + * @param aErr the error code of event + */ + void AccessoryDisconnectedL(TProfiles aProfile); + + /** + * Called when an audio open request comes from Acc FW. + */ + void OpenAudioL(TAccAudioType aType); + + /** + * Called when an audio close request comes from Acc FW. + */ + void CloseAudioL(TAccAudioType aType); + +protected: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive); + +protected: + + /** + * Default constructor + */ + CBasrvAccStateDetach(CBasrvAcc& aParent); + +protected: + CBasrvActive* iActive; + CBasrvAccfwIf* iAccfw; + }; + +#endif // C_BTASRVACCSTATEDETACH_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstatedisconnect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstatedisconnect.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2005-2006 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: The Disconnect state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATEDISCONNECT_H +#define C_BTASRVACCSTATEDISCONNECT_H + +#include "basrvaccstate.h" + +class CBasrvAccStateDisconnect : public CBasrvAccState + { +public: + + static CBasrvAccStateDisconnect* NewL(CBasrvAcc& aParent, TInt aConnErr = KErrNone); + + virtual ~CBasrvAccStateDisconnect(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBasrvAccState* ErrorOnEntry(TInt aReason); + + TBTEngConnectionStatus ConnectionStatus() const; + +protected: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive); + +protected: + + /** + * Default constructor + */ + CBasrvAccStateDisconnect(CBasrvAcc& aParent, TInt aConnErr); + + void DoDisconnectL(); + +protected: + CBasrvActive* iActive; + TInt iDiscErr; + TInt iConnErr; + TInt iProfiles; + }; + +#endif // C_BTASRVACCSTATEDISCONNECT_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvaccstatequery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvaccstatequery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2005-2006 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: The Query state declaration +* +*/ + + +#ifndef C_BTASRVACCSTATEQUERY_H +#define C_BTASRVACCSTATEQUERY_H + +#include "basrvaccstate.h" +#include "basrvsdpquery.h" + +class CBasrvAccStateQuery : public CBasrvAccState, public MBasrvSdpQuerier + { +public: + + static CBasrvAccStateQuery* NewL(CBasrvAcc& aParent, TBool aConnectingRequest); + + virtual ~CBasrvAccStateQuery(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBasrvAccState* ErrorOnEntry(TInt aReason); + + TBTEngConnectionStatus ConnectionStatus() const; + + /** + * Cancel connecting to accessory + */ + void CancelConnect(); + + void DisconnectL(); + + /** + * Called when the connection is disconnected from remote side or there + * is error on reading/writing data packet. + * @param aErr the error code of event + */ + void AccessoryDisconnectedL(TProfiles aProfile); + +private: + // From MBasrvSdpQuerier + + void GetAccInfoCompletedL(TInt aErr, const TAccInfo* aAcc, const TBTDeviceClass* aCod); + +private: + + CBasrvAccStateQuery(CBasrvAcc& aParent, TBool aConnectingRequest); + + void ConstructL(); + + void ResolveConflicts(RArray& aConflicts); + +private: + CBasrvSdpQuery* iQuery; + TBool iConnecting; + }; + +#endif // C_BTASRVACCSTATEQUERY_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2005-2006 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: The base active object declaration +* +*/ + + +#ifndef C_BASRVACTIVE_H +#define C_BASRVACTIVE_H + +// INCLUDES +#include + +class CBasrvActive; + +/** + * The observer of CBasrvActive's request events + * + * This class defines the interface to handle a async request events from CBasrvActive. + * + * @since S60 v3.1 + */ +class MBasrvActiveObserver + { + +public: + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBasrvActive& aActive) = 0; + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBasrvActive& aActive) = 0; + + }; + +/** + * A base class for abstract Active Objects. + * + * This class provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CBasrvActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CBasrvActive : public CActive + { + +public: + + static CBasrvActive* New(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + + static CBasrvActive* NewL(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + static CBasrvActive* NewLC(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + virtual ~CBasrvActive(); + +public: + + /** + * Calls SetActive(). + * + * @since S60 v3.1 + */ + virtual void GoActive(); + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @return the request identifier + */ + TInt RequestId() const; + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @param the request identifier + */ + void SetRequestId(TInt aRequestId); + +protected: + + /** + * From CActive. + * cancels the outstanding request. + * + * @since S60 v3.1 + */ + virtual void DoCancel(); + + /** + * From CActive. + * Handles the request completion event. + * + * @since S60 v3.1 + */ + virtual void RunL(); + + /** + * From CActive. + * Handles the leave from RunL(). + * + * @since S60 v3.1 + * @param aError the leave code in RunL() + * @return the error code to Active Scheduler + */ + virtual TInt RunError(TInt aError); + +protected: + + CBasrvActive(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + MBasrvActiveObserver& Observer(); + +private: + + /** + * The observer which is interested in the request handling events. + * Not own. + */ + MBasrvActiveObserver& iObserver; + + /** + * The request identifier assigned to this active object. + */ + TInt iRequestId; + + }; + +#endif // C_BASRVACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvactivenotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvactivenotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2005-2006 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: The base active object declaration +* +*/ + + +#ifndef C_BASRVACTIVENOTIFIER_H +#define C_BASRVACTIVENOTIFIER_H + +// INCLUDES +#include +#include +#include "basrvactive.h" + +class TBTDevAddr; + +/** + * An abstract Active Object. + * + * This class provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CBasrvActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CBasrvActiveNotifier : public CBasrvActive + { +public: + static CBasrvActiveNotifier* NewL(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId, const TBTDevAddr& aAddr, TBTGenericInfoNoteType aNote); + + virtual ~CBasrvActiveNotifier(); + +private: + void GoActive(); + +private: + void ConstructL(); + + void DoCancel(); + +protected: + CBasrvActiveNotifier(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId, const TBTDevAddr& iAddr, TBTGenericInfoNoteType aNote); + + MBasrvActiveObserver& Observer(); + +private: + RNotifier iNotifier; + TBTGenericInfoNotiferParamsPckg iPckg; + TBuf8 iNoResult; + }; + +#endif // C_BASRVACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvpluginman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvpluginman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2005-2006 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. +* Version : %version: 1.1.1.2.5 % +* +* Contributors: +* +* Description: +* Loads/unloads plugins and handles messaging between plugins and server class. +* +*/ + + +#ifndef BTACCMANAGER_H +#define BTACCMANAGER_H + +// INCLUDES +#include // RImplInfoPtrArray + +#include "BTAccClientSrv.h" // TBTAccCmd +#include "btaccTypes.h" // BT Acc Server defines type of audio accessories + + +// CLASS DECLARATION +class CBTAccPlugin; +class MBTAccObserver; + +/** +* CBTSession class represent session on server side +* +*/ +NONSHARABLE_CLASS(CBasrvPluginMan) : public CBase + + { +public: // Constructors and destructor + + /** + * Constructor. + */ + static CBasrvPluginMan* NewL(); + + /** + * Destructor. + */ + ~CBasrvPluginMan(); + + void AccInUse(); + + TInt AudioLinkLatency(); + void AccOutOfUse(); + + TInt AvailablePlugins(); + +public: + + /** + * + * + * + * @param + * @return None + */ + void LoadPluginsL(MBTAccObserver& aObserver); + + /** + * + * + * + * @param + * @return None + */ + void UnloadPlugins(); + + CBTAccPlugin* Plugin(TProfiles aProfile); + +private: // New Functions + CBasrvPluginMan(); + +private: // Data + RPointerArray iPlugins; + }; + +#endif // BTACCMANAGER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvpowercontrolagent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvpowercontrolagent.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2007 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: Baseband power mode control agent for plugins +* +*/ + + +#ifndef C_BASRVPOWERCONTROLAGENT_H +#define C_BASRVPOWERCONTROLAGENT_H + +#include +#include // RBTPhysicalLinkAdapter +#include "basrvactive.h" + +NONSHARABLE_CLASS(CBasrvPowerControlAgent) : public CBase, public MBasrvActiveObserver + { +public: + static CBasrvPowerControlAgent* NewL(const TBTDevAddr& aAddr); + + ~CBasrvPowerControlAgent(); + + void RequestSniffMode(); + + void RequestActiveMode(); + + void CancelPowerModeControl(); + + void PreventLowPowerMode(); + + void AllowLowPowerMode(); + +private: + // From MBasrvActiveObserver + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBasrvActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void CancelRequest(CBasrvActive& aActive); + + +private: + CBasrvPowerControlAgent(const TBTDevAddr& aAddr); + + void ConstructL(); + + void DoPowerControl(); + + void DosniffRequest(); + +private: + enum TPowerControlState + { + EPowerModeDefault, + ESniffModeTiming, + ESniffModeRequested, + EActiveModeRequested, + }; +private: + RSocketServ iSockServ; + TBTDevAddr iAddr; + TPowerControlState iState; + RBTPhysicalLinkAdapter iPlAda; + TBTBasebandEvent iBbEvent; + RTimer iTimer; + CBasrvActive* iSniffDelayTimer; + CBasrvActive* iBbEventer; + }; + +#endif // C_BASRVPOWERCONTROLAGENT_H \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvrvc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvrvc.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2005-2007 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: Remote Volume Control +* +*/ + + +#ifndef C_BTASRVRVC_H +#define C_BTASRVRVC_H + +#include +#include "btaccTypes.h" + +class CBasrvAcc; + +/** +* This class is responsible for deciding which profile should take care of remote volume control +* based on the supported profiles in the remote side and the current audio path situation. +*/ +class CBasrvRvc : public CBase + { +public: + static CBasrvRvc* New(CBasrvAcc& aAcc); + + ~CBasrvRvc(); + + void Update(TInt aConnectedProfiles, TInt aProfileCarryingAudio); + +private: + + /** + * Default constructor + */ + CBasrvRvc(CBasrvAcc& aAcc); + + void DoUpdateRvcMaster(); + +private: + CBasrvAcc& iAcc; + + TInt iConnectedProfiles; + + TProfiles iRvcMaster; // the current profile which is mastering RVC + TInt iProfileCarryingAudio; // The latest (last if no BT audio is opne) profile that carries BT audio + + }; + +#endif // C_BTASRVRVC_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/basrvsdpquery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/basrvsdpquery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2006 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: +* Implementations of SDP queries +* +*/ + + +#ifndef BASRVSDPQUERY_H +#define BASRVSDPQUERY_H + +#include +#include +#include +#include +#include "BTAccInfo.h" +#include "basrvactive.h" + +class TBTDevAddr; +class CSdpSearchPattern; + + +class TBTSdpAttrInt + { +public: + TUUID iUUID; // The UUID of the service. Must be specified by caller. + TUint16 iAttrID; // The Attribute ID. Must be specified by the caller. + TUint iAttrValue; // The value of the attribute if this is found in the device. + }; + +class MBasrvSdpQuerier + { +public: + + /** + * Indicates GetAccInfo completed. + * @param aAcc the accinfo if the operation succeeded. + * @param aErr the completion status + */ + virtual void GetAccInfoCompletedL(TInt aErr, const TAccInfo* aAcc, const TBTDeviceClass* aCod) = 0; + + }; + +/** +* The base class for various SDP query strategies +*/ +class CBasrvSdpQuery : public CBase, public MSdpAgentNotifier, public MBasrvActiveObserver, + public MSdpAttributeValueVisitor + { +public: + + static CBasrvSdpQuery* NewL(MBasrvSdpQuerier& aQuerier); + + ~CBasrvSdpQuery(); + + void QueryAccInfoL(const TBTDevAddr& aDevAddr, TBool aTolerateSdpError); + +private: // From MSdpAgentNotifier + + /** + * Called when an service record request operation completes. + * + * @param aError KErrNone if successful; + * KErrEof if there are no more SDP records left to be read; or an SDP error. + * @param aHandle Service record for which the query was made + * @param aTotalRecordsCount Total number of matching records + */ + void NextRecordRequestComplete( + TInt aError, + TSdpServRecordHandle aHandle, + TInt aTotalRecordsCount); + + /** + * Called when an attribute request (CSdpAgent::AttributeRequestL()) wants to + * pass up a result. + * + * @param aHandle Service record for which the query was made + * @param aAttrID ID of the attribute obtained + * @param aAttrValue Attribute value obtained + */ + void AttributeRequestResult( + TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, + CSdpAttrValue* aAttrValue); + + /** + * Called when an attribute request (CSdpAgent::AttributeRequestL()) wants to + * signal the completion of a attribute request. + * + * @param aHandle Service record for which the query was made + * @param aError an error + */ + void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError); + // from base class MSdpAttributeValueVisitor + + /** + * From MSdpAttributeValueVisitor. + * Called to pass an attribute value. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void VisitAttributeValueL( CSdpAttrValue &aValue, TSdpElementType aType ); + + /** + * From MSdpAttributeValueVisitor. + * Called to indicate the start of a list of attribute values. + * This call is followed by a call to VisitAttributeValueL() + * for each attribute value in the list, and concluded by + * a call to EndList(). + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void StartListL( CSdpAttrValueList &aList ); + + /** + * From MSdpAttributeValueVisitor. + * Called to indicate the end of a list of attribute values. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void EndListL(); + +private: + // From MBasrvActiveObserver + + void RequestCompletedL(CBasrvActive& aActive); + + void CancelRequest(CBasrvActive& aActive); + + +private: + + void ConstructL(); + + CBasrvSdpQuery(MBasrvSdpQuerier& aQuerier); + + void QueryCompleteL(TInt aStatus); + + void DoNextServiceRecordRequestL(); + + void NextRecordRequestCompleteL( + TInt aError, + TSdpServRecordHandle aHandle, + TInt aTotalRecordsCount); + + void AttributeRequestResultL( + TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, + CSdpAttrValue* aAttrValue); + + void AttributeRequestCompleteL(TSdpServRecordHandle aHandle, TInt aError); + + void MakeAccInfo(TAccInfo& aInfo); + +private: + + MBasrvSdpQuerier& iQuerier; // not own + + CSdpAgent* iSdpAgent; + CSdpSearchPattern* iSdpSearchPattern; + RArray iServiceAttrs; + + TInt iCursor; + TBTDevAddr iAddr; + + CBasrvActive* iActive; + RBTRegServ iRegServ; + RBTRegistry iReg; + CBTRegistryResponse* iResponse; + TBool iTolerateSdpError; + }; +#endif // BASRVSDPQUERY_H + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/btaudiomanplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/btaudiomanplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,193 @@ +/* +* Copyright (c) 2006 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: Bluetooth Audio Manager ECom plug-in class declaration. +* +*/ + + +#ifndef BTAUDIOMANPLUGIN_H +#define BTAUDIOMANPLUGIN_H + +#include +#include +#include +#include "BTAccClient.h" +#include "basrvactive.h" +#include "BTAccClientSrv.h" + +/** + * BTEng plug-in base class. + * + * + * @lib btaudiomanclient.lib + * @since S60 v3.2 + */ +class CBtAudioManPlugin: public CBTEngPlugin, public MBasrvActiveObserver + { + +public: + + /** + * Constructor; loads the plug-in through the ECom framework. + * + * @since S60 v3.2 + * @param aImplementationUid The UID of the interface implementation + * to be loaded. + * @return Pointer to the constructed CBtAudioManPlugin object. + */ + static CBtAudioManPlugin* NewL(); + + /** + * Destructor; destroys the plug-in through the ECom framework. + */ + virtual ~CBtAudioManPlugin(); + + /** + * Sets the observer for receiving connection events through the + * MBTEngPluginObserver interface. This method MUST be called + * before any command is given to the plug-in + * + * @since S60 v3.2 + * @param aObserver The observer of connection events. + */ + void SetObserver( MBTEngPluginObserver* aObserver ); + + /** + * Gets the list of profiles implemented by this plug-in. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v3.2 + * @param aProfiles Array of integers identifying the BT profiles + * implemented by this plug-in. + */ + void GetSupportedProfiles( RProfileArray& aProfiles ); + + /** + * Indicates if this plug-in implements the specified profiles. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v3.2 + * @param aProfile Integer identifying the BT profile. + * @return ETrue if the plug-in implements the requested profile, + * otherwise EFalse. + */ + TBool IsProfileSupported( const TBTProfile aProfile ) const; + + /** + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::ConnectComplete with + * the appropriate error code. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * @return KErrNone on success, otherwise an appropriate error code. + */ + TInt Connect( const TBTDevAddr& aAddr ); + + /** + * Instructs the plug-in to cancel the creation a service-level + * connection with the specified Bluetooth address. + * + * In addition, as this is part of an asynchronous operation, the plug-in + * completes the outstanding asyncronous request status with KErrCancel. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + */ + void CancelConnect( const TBTDevAddr& aAddr ); + + /** + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::DisconnectComplete with + * the appropriate error code. + * + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * In case the address is the NULL address, the plug-in is + * expected to disconnect all its connections. + * @param aDiscType The type of disconnection; + * EGraceful for graceful (normal) disconnection, + * EImmediate for immediate (forced) disconnection. + * @return KErrNone on success, otherwise an appropriate error code. + */ + TInt Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType); + + /** + * Gets the addresses of the connected devices for the specified profile. + * + * @since S60 v3.2 + * @param aAddrArray On return, holds the Bluetooth device addresses + * of the connected Bluetooth devices for the + * requested profile. + * @param aConnectedProfile The profile for which the existing + * connections are requested. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + void GetConnections( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ); + + /** + * Indicates if this plug-in has a service-level connection + * with the specified Bluetooth address. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * @return The status of the connection according to the TConnectionStatus + * enumeration. EConnecting is interpreted that at least one + * incoming connection request has been completed, but that not + * all service-level connections have been fully established. + */ + TBTEngConnectionStatus IsConnected( const TBTDevAddr& aAddr ); + +private: + void RequestCompletedL(CBasrvActive& aActive); + + void CancelRequest(CBasrvActive& aActive); + +private: + + CBtAudioManPlugin(); + + void ConstructL(); + + TInt HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId); + + void ReportProfileConnectionEvents(const TBTDevAddr& aAddr, const TInt aProfiles, TBool aConnected); + +private: // data + + MBTEngPluginObserver* iObserver; // not own + + RBTAccClient iClient; + CBasrvActive* iActive4ClientReq; + TBTDevAddrPckgBuf iBTDevAddrPckgBuf; + TBuf8 iDiagnostic; + + CBasrvActive* iActive4ProfileStatus; + TProfileStatus iProfileStatus; + TProfileStatusPckg iProfileStatusPckg; + }; + + +#endif // BTAUDIOMANPLUGIN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,182 @@ +/* +* Copyright (c) 2006 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: Logging definition +* +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + RBuf16 theFinalString; + theFinalString.Create(KMaxLogLineLength); + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + theFinalString.Close(); +#endif + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TOverflowTruncate8 overflow; + RBuf8 buf8; + buf8.Create(KMaxLogLineLength); + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + + RBuf16 buf16; + buf16.Create(KMaxLogLineLength); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + buf8.Close(); + buf16.Close(); +#endif + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + RBuf8 buf; + buf.Create(KMaxLogLineLength); + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + buf.Close(); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + RBuf8 buf; + buf.Create(KMaxLogLineLength); + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + buf.Close(); + User::Leave(aReason); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, KErrGeneral);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE_IF_NULL(PTR) {static_cast(User::LeaveIfNull(PTR));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_STATIC_FUNC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 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: logging configure file. +* +*/ + + +#ifndef LOCOD_DEBUGCONFIG_H +#define LOCOD_DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"basrv.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BASRV] "); +_LIT8(KTracePrefix8, "[BASRV] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTAccServer"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // LOCOD_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef LOCOD_PRJCONFIG_H +#define LOCOD_PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // LOCOD_PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/inc/utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/utils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2006 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: Defines utility functions. +* +*/ + + +#ifndef BASRVUTILS_H +#define BASRVUTILS_H + +#include + +template +class CleanupResetDestroyClose + { +public: + inline static void PushL(T& aRef) + { + CleanupStack::PushL(TCleanupItem(&ResetDestroyClose,&aRef)); + } +private: + static void ResetDestroyClose(TAny *aPtr) + { + static_cast(aPtr)->ResetAndDestroy(); + static_cast(aPtr)->Close(); + } + }; + +/** + * Pushes an object into CleanupStack and specifies the cleanup + * function as ResetAndDestroy() and Close(). +*/ +template +inline void CleanupResetDestroyClosePushL(T& aRef) + {CleanupResetDestroyClose::PushL(aRef);} + +template +static TBool OperatorEqual(const T& aT1, const T& aT2) + { + return aT1 == aT2; + } + +#endif // BASRVUTILS_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/rom/btaudioman.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/rom/btaudioman.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef __BTAUDIOMAN_IBY__ +#define __BTAUDIOMAN_IBY__ + +#if defined(__BT) && defined(__BT_AUDIO) + +ECOM_PLUGIN(btaudiomanclient.dll, btaudiomanclient.rsc) +file=ABI_DIR\BUILD_DIR\btaudioman.exe PROGRAMS_DIR\btaudioman.exe +#endif + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/BTAccClient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/BTAccClient.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,195 @@ +/* +* Copyright (c) 2005 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: +* BT Accessory Server's client API Implementation. Starts server +* and creates a session with server if necessary. +* +* +*/ + + +// INCLUDE FILES +#include "BTAccClient.h" +#include "BTAccClientSrv.h" +#include "debug.h" + +// CONSTANTS + +_LIT(KBTAudioManImg, "btaudioman.exe"); + +const TUid KBTAudioManUid3={0x10208971}; + +static TInt StartServer() + { + const TUidType serverUid(KNullUid,KNullUid,KBTAudioManUid3); + + RProcess server; + TInt r = server.Create(KBTAudioManImg, KNullDesC, serverUid); + server.SetPriority(EPriorityHigh); + if (r!=KErrNone) + return r; + TRequestStatus stat; + server.Rendezvous(stat); + if (stat!=KRequestPending) + { + server.Kill(0); // abort startup + } + else + { + server.Resume(); // logon OK - start the server + } + + User::WaitForRequest(stat); // wait for start or death + TRACE_INFO((_L("Server started, code %d"), stat.Int())) + r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); + server.Close(); + return r; + } + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// Connect +// Handles connection to server(creates session) +// --------------------------------------------------------- +// +TInt RBTAccClient::Connect() + { + TRACE_FUNC + TInt retVal = CreateSession(KBTAudioManName, Version()); + if (retVal != KErrNone && retVal != KErrAlreadyExists) + { + retVal = StartServer(); + if (retVal == KErrNone || retVal == KErrAlreadyExists) + { + retVal = CreateSession(KBTAudioManName, Version()); + } + } + TRACE_INFO((_L("ret %d "), retVal)) + return retVal; + } + +// --------------------------------------------------------- +// Version +// Defines server version number +// --------------------------------------------------------- +// +TVersion RBTAccClient::Version() const + { + return(TVersion(KBTAccServerMajorVersionNumber, + KBTAccServerMinorVersionNumber, + KBTAccServerBuildVersionNumber)); + } + +// --------------------------------------------------------- +// ConnectToAccessory +// Establishes a Bluetooth Handsfree connection +// --------------------------------------------------------- +// +void RBTAccClient::ConnectToAccessory(TRequestStatus& aStatus, + const TBTDevAddrPckgBuf& aAddrBuf, TDes8& aDiagnostic) + { + SendReceive(EBTAccSrvConnectToAccessory, TIpcArgs(&aAddrBuf, &aDiagnostic), aStatus); + } + +// --------------------------------------------------------- +// CancelConnectToAccessory +// Cancel Connection attempt +// --------------------------------------------------------- +// +void RBTAccClient::CancelConnectToAccessory() + { + TRACE_FUNC + SendReceive(EBTAccSrvCancelConnectToAccessory); + } + +// --------------------------------------------------------- +// DisconnectAccessory +// Disconnect Bluetooth Handfree device +// --------------------------------------------------------- +// +void RBTAccClient::DisconnectAccessory(TRequestStatus& aStatus, const TBTDevAddrPckgBuf& aAddrBuf, TDes8& aDiagnostic) + { + TRACE_FUNC + SendReceive(EBTAccSrvDisconnectAccessory, TIpcArgs(&aAddrBuf, &aDiagnostic), aStatus); + } + +TInt RBTAccClient::GetConnections(TDes8& aAddrs, TInt aProfile) + { + TRACE_FUNC + return SendReceive(EBTAccSrvGetConnections, TIpcArgs(&aAddrs, aProfile)); + } + +void RBTAccClient::DisconnectAllGracefully(TRequestStatus& aStatus) + { + TRACE_FUNC + SendReceive(EBTAccSrvDisconnectAllGracefully, aStatus); + } + +void RBTAccClient::NotifyConnectionStatus(TProfileStatusPckg& aPckg, TRequestStatus& aStatus) + { + SendReceive(EBTAccSrvNotifyConnectionStatus, TIpcArgs(&aPckg), aStatus); + } + +void RBTAccClient::CancelNotifyConnectionStatus() + { + SendReceive(EBTAccSrvCancelNotifyConnectionStatus); + } + +TInt RBTAccClient::IsConnected(const TBTDevAddr& aAddr) const + { + TRACE_FUNC + TBTDevAddrPckgBuf pckg(aAddr); + return SendReceive(EBTAccSrvConnectionStatus, TIpcArgs(&pckg)); + } + +// --------------------------------------------------------- +// GetBTAccInfo +// --------------------------------------------------------- +// +void RBTAccClient::GetInfoOfConnectedAcc(TPckg& aInfoPckg, TRequestStatus& aStatus ) + { + TRACE_FUNC + SendReceive(EBTAccSrvGetInfoOfConnectedAcc, TIpcArgs(&aInfoPckg), aStatus); + } + +// --------------------------------------------------------- +// AudioToPhone +// Dos Related functionality only. +// --------------------------------------------------------- +// +TInt RBTAccClient::AudioToPhone() + { + TRACE_FUNC + return SendReceive(EBTAccSrvAudioToPhone); + } + +// --------------------------------------------------------- +// AudioToAccessory +// Dos Related functionality only. +// --------------------------------------------------------- +// +void RBTAccClient::AudioToAccessory( TRequestStatus& aStatus ) + { + TRACE_FUNC + SendReceive(EBTAccSrvAudioToAccessory, aStatus); + } + +void RBTAccClient::CancelAudioToAccessory() + { + SendReceive(EBTAccSrvCancelAudioToAccessory); + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/BTAccInfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/BTAccInfo.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2005-2006 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 FILES +#include "BTAccInfo.h" + +/////////////////////////////// TAccInfo implementation ///////////////////////// +// ----------------------------------------------------------------------------- +// TAccInfo::TAccInfo +// ----------------------------------------------------------------------------- +// +void TAccInfo::SetBDAddress(const TBTDevAddr& aAddr) + { + iAddr = aAddr; + iSuppProfiles = 0x00; + iConnProfiles = 0x00; + iAudioOpenedProfiles = 0x00; + iModel = 0x00; + iCapturingSupport = EFalse; + for (TInt x=0; x + +#include "BTAccInfoCmdHandler.h" +#include "debug.h" + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBTAccInfoCmdHandler::CBTAccInfoCmdHandler +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBTAccInfoCmdHandler::CBTAccInfoCmdHandler() + { + + } + +// ----------------------------------------------------------------------------- +// CBTAccInfoCmdHandler::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTAccInfoCmdHandler* CBTAccInfoCmdHandler::NewL() + { + return new (ELeave) CBTAccInfoCmdHandler(); + } + +// Destructor +CBTAccInfoCmdHandler::~CBTAccInfoCmdHandler() + { + TRACE_FUNC_ENTRY + delete iRequester; + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTAccInfoCmdHandler::ProcessCommandL +// ----------------------------------------------------------------------------- +// +void CBTAccInfoCmdHandler::ProcessCommandL( + const TProcessCmdId aCommand, + const TASYCmdParams& aCmdParams) + { + TRACE_FUNC; + TRACE_INFO((_L(" aCommand %d"), aCommand)); + switch (aCommand) + { + case ECmdProcessCommandInit: + { + TAccValueTypeTBool boolInitResponse; + boolInitResponse.iValue = ETrue; + ProcessResponseL( boolInitResponse ); + break; + } + case ECmdGetSupportedBTProfiles : + { + if (iRequester) + { + TASYBTAccInfo info; + TASYBTAccInfoPckgC btInfoPckg(info); + ProcessResponseL(btInfoPckg, KErrInUse); + break; + } + iRequester = CBTAccInfoRequester::NewL(*this); + TBTDevAddr addr(aCmdParams().iCmdValue); + TRACE_INFO_SEG( + {TBuf<12> buf; addr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);} + ); + iRequester->GetBTAccInfoL(addr); + break; + } + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CBTAccInfoCmdHandler::GetBTAccInfoCompleted +// ----------------------------------------------------------------------------- +// +void CBTAccInfoCmdHandler::GetBTAccInfoCompletedL(TInt aErr, const TASYBTAccInfo& aAccInfo) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L(" aErr %d"), aErr)); + TASYBTAccInfoPckgC btInfoPckg(aAccInfo); + ProcessResponseL(btInfoPckg, aErr); + delete iRequester; + iRequester = NULL; + TRACE_FUNC_EXIT + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/BTAccInfoMainService.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/BTAccInfoMainService.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2005-2006 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: Loaded by Accessory Server to allow this component to initialize +* +*/ + + +// INCLUDE FILES +#include "BTAccInfoMainService.h" +#include "debug.h" + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBTAccInfoMainService::CBTAccInfoMainService +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBTAccInfoMainService::CBTAccInfoMainService() + { + TRACE_FUNC; + } + +// ----------------------------------------------------------------------------- +// CBTAccInfoMainService::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTAccInfoMainService* CBTAccInfoMainService::NewL() + { + return new (ELeave) CBTAccInfoMainService(); + } + +// Destructor +CBTAccInfoMainService::~CBTAccInfoMainService() + { + TRACE_FUNC; + } + +// ----------------------------------------------------------------------------- +// CBTAccInfoMainService::StartL +// ----------------------------------------------------------------------------- +// +TInt CBTAccInfoMainService::StartL() + { + TRACE_FUNC; + // Synchronous ASY : Signal + Signal(); + return KErrNone; + } + +// End of File + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/BTAccInfoRequester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/BTAccInfoRequester.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,175 @@ +/* +* Copyright (c) 2005-2006 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: Retrieves accessory information from Bluetooth Accessory Server +* +*/ + + +// INCLUDE FILES +#include +#include "BTAccInfoRequester.h" +#include "debug.h" + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBTAccInfoRequester::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTAccInfoRequester* CBTAccInfoRequester::NewL(MBTAccInfoNotifier& aNotifier) + { + CBTAccInfoRequester* self = new (ELeave) CBTAccInfoRequester(aNotifier); + return self; + } + +// Destructor +CBTAccInfoRequester::~CBTAccInfoRequester() + { + TRACE_FUNC_ENTRY + Cancel(); + iBTAccClient.Close(); + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTAccInfoRequester::GetBTAccInfo +// ----------------------------------------------------------------------------- +// +void CBTAccInfoRequester::GetBTAccInfoL(const TBTDevAddr& aAddr) + { + TRACE_FUNC; + if (IsActive()) + { + LEAVE(KErrInUse); + } + + TInt err = iBTAccClient.Connect(); + if (err != KErrNone && err != KErrAlreadyExists) + { + LEAVE(err); + } + + iAccInfo.iAddr = aAddr; + iAccInfo.iSuppProfiles = 0x00; + iAccInfo.iConnProfiles = 0x00; + iAccInfo.iModel = 0x00; + iAccInfo.iCapturingSupport = EFalse; + for (TInt x=0; x +#include + +#include "BTAccServer.h" +#include "BTAccClientSrv.h" // server name, panic code +#include "BTAccSecurityPolicy.h" +#include "BTAccSession.h" // create server's session +#include "debug.h" +#include "btmanclient.h" // TBTDevAddrPckgBug +#include "basrvaccman.h" +#include "BTAccInfo.h" + +/** PubSub key read and write policies */ +_LIT_SECURITY_POLICY_C1( KBTEngPSKeyReadPolicy, + ECapabilityLocalServices); +_LIT_SECURITY_POLICY_C1( KBTEngPSKeyWritePolicy, + ECapabilityLocalServices); + +// CONSTANTS +const TInt KShutdownDelay = 5000000; + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTAccServer::CBTAccServer +// C++ default constructor can NOT contain any code that +// might leave. +// ----------------------------------------------------------------------------- +// +CBTAccServer::CBTAccServer(TInt aPriority) : CPolicyServer(aPriority, KBTAccSrvPolicy) + { + } + +// Destructor +CBTAccServer::~CBTAccServer() + { + delete iAccMan; + delete iTimer; + iSessions.Close(); + + RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTATCodec ); + + TRACE_FUNC + } + +// --------------------------------------------------------- +// NewL +// --------------------------------------------------------- +// +CBTAccServer* CBTAccServer::NewLC() + { + CBTAccServer* self=new(ELeave) CBTAccServer(EPriorityStandard); + CleanupStack::PushL(self); + self->ConstructL(); + self->StartL(KBTAudioManName); + RThread().SetPriority(EPriorityRealTime); + return self; + } + +void CBTAccServer::StartShutdownTimerIfNoSessions() + { + if (iSessions.Count() == 0 && (!iTimer || !iTimer->IsActive())) + { + if (!iTimer) + { + TRAP_IGNORE(iTimer = CPeriodic::NewL(CActive::EPriorityStandard)); + } + + if (iTimer) + { + iTimer->Start(KShutdownDelay, 0, TCallBack(CBTAccServer::TimerFired, this)); + } + + TRACE_FUNC + } + } + +void CBTAccServer::ClientOpened(CBTAccSession& aSession) + { + TRACE_FUNC + + //cancel the timer to prevent the server from shutting down + CancelShutdownTimer(); + + //add the session to the array of sessions + (void)iSessions.Append(&aSession); + } + +void CBTAccServer::ClientClosed(CBTAccSession& aSession) + { + TRACE_FUNC_ENTRY + + //find and remove the given session from the array + for (TUint i = 0; i < iSessions.Count(); ++i) + { + if (iSessions[i] == &aSession) + { + iSessions.Remove(i); + break; + } + } + + StartShutdownTimerIfNoSessions(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// NewSessionL +// Create session(s) to client(s) +// --------------------------------------------------------- +// +CSession2* CBTAccServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const + { + // check we're the right version + TVersion srvVersion(KBTAccServerMajorVersionNumber, + KBTAccServerMinorVersionNumber, + KBTAccServerBuildVersionNumber); + + if (!User::QueryVersionSupported(srvVersion, aVersion)) + { + User::Leave(KErrNotSupported); + } + + CBTAccSession* session = CBTAccSession::NewL(*iAccMan); + return session; + } + +void CBTAccServer::ConstructL() + { + iAccMan = CBasrvAccMan::NewL(); + iAccMan->LoadServicesL(); + + User::LeaveIfError(RProperty::Define(KPSUidBluetoothEnginePrivateCategory, + KBTATCodec, RProperty::EByteArray, + KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy)); + } + +void CBTAccServer::CancelShutdownTimer() + { + delete iTimer; + iTimer = NULL; + } + +TInt CBTAccServer::TimerFired(TAny* /*aThis*/) + { + CActiveScheduler::Stop(); + return KErrNone; + } + +// --------------------------------------------------------- +// PanicClient +// RMessage::Panic() also completes the message. +// --------------------------------------------------------- +void PanicClient(const RMessage2& aMessage,TInt aPanic) + { + TRACE_ERROR((_L("[BTAccServer]\t PanicClient: Reason: %d"), aPanic)) + aMessage.Panic(KBTAudioManPanic,aPanic); + } + +// --------------------------------------------------------- +// PanicServer +// Panic our own thread +// --------------------------------------------------------- +void PanicServer(TInt aPanic) + { + TRACE_ERROR((_L("[BTAccServer]\t PanicServer: Reason: %d"), aPanic)) + User::Panic(KBTAudioManPanic, aPanic); + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/BTAccSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/BTAccSession.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,485 @@ +/* +* Copyright (c) 2005-2006 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: +* Server class creates the session. This class then recieves the messages from +* client and forward them to server class to be handled. Messages are completed +* with return values recieved from server. +* +*/ + + +// INCLUDE FILES +#include +#include "BTAccSession.h" +#include "BTAccClientSrv.h" +#include "debug.h" +#include "BTAccServer.h" +#include "basrvaccman.h" +#include "BTAccInfo.h" + +typedef TPckgBuf TBTDevAddrPckgBuf; + +// ================= MEMBER FUNCTIONS ======================= +CBTAccSession* CBTAccSession::NewL(CBasrvAccMan& aAccMan) + { + return new (ELeave) CBTAccSession(aAccMan); + } + +CBTAccSession::CBTAccSession(CBasrvAccMan& aAccMan) + : iAccMan(aAccMan) + { + TRACE_FUNC + } + +// destructor +CBTAccSession::~CBTAccSession() + { + TRACE_FUNC + if (iConnectMsg.Handle()) + { + iAccMan.CancelConnect(iConnectingAddr); + iConnectMsg.Complete(KErrAbort); + } + if (iDisconnectMsg.Handle()) + { + iDisconnectMsg.Complete(KErrAbort); + } + if (iDisconnectAllMsg.Handle()) + { + iDisconnectAllMsg.Complete(KErrAbort); + } + if (iNotifyProfileMsg.Handle()) + { + iNotifyProfileMsg.Complete(KErrAbort); + } + iProfileStatusCache.Close(); + DestructVariant(); + + //clear the accessory managers pointer to this session if it has one + iAccMan.ClearProfileNotifySession(*this); + + //clear the servers reference to this session + Server().ClientClosed(*this); + } + +void CBTAccSession::CreateL() + { + TRACE_FUNC + //use CreateL instead of NewSessionL when using Server() to ensure the + //session has been created correctly and Server() returns a valid pointer + Server().ClientOpened(*this); + } + +void CBTAccSession::ConnectCompleted(TInt aErr, TInt aProfile, const RArray* aConflicts) + { + TRACE_FUNC + if (iConnectMsg.Handle()) + { + TRACE_INFO((_L("CBTAccSession::ConnectCompleted err %d"), aErr)) + if (aConflicts) + { + TBuf8 buf; + TInt count = aConflicts->Count(); + for (TInt i = 0; i < count; i++) + { + buf.Append((*aConflicts)[i].Des()); + } + + if (buf.Length()) + { + iConnectMsg.Write(1, buf); + } + } + else if (!aErr) + { + TPckgBuf buf(aProfile); + iConnectMsg.Write(1, buf); + } + iConnectMsg.Complete(aErr); + } + } + +void CBTAccSession::DisconnectCompleted(TInt aProfile, TInt aErr) + { + TRACE_FUNC + if (iDisconnectMsg.Handle()) + { + TRACE_FUNC + if (!aErr) + { + TPckgBuf buf(aProfile); + iDisconnectMsg.Write(1, buf); + } + iDisconnectMsg.Complete(aErr); + } + } + +void CBTAccSession::DisconnectAllCompleted(TInt aErr) + { + TRACE_FUNC + if (iDisconnectAllMsg.Handle()) + { + TRACE_FUNC + TRACE_INFO((_L("ERR %d"), aErr)) + iDisconnectAllMsg.Complete(aErr); + } + } + +// --------------------------------------------------------- +// CBTAccSession::ConnectToAccessory +// --------------------------------------------------------- +void CBTAccSession::ConnectToAccessory(const RMessage2& aMessage) + { + TRACE_FUNC + if (iConnectMsg.Handle()) + { + aMessage.Complete(KErrServerBusy); + } + else + { + TInt err; + TBTDevAddrPckgBuf pckg; + iConnectMsg = aMessage; + err = aMessage.Read(0, pckg); + if (!err) + { + iConnectingAddr = pckg(); + TRAP(err, iAccMan.ConnectL(*this, pckg())); + } + if (err) + { + iConnectMsg.Complete(err); + } + } + } + +// --------------------------------------------------------- +// CBTAccSession::ConnectToAccessory +// --------------------------------------------------------- +void CBTAccSession::CancelConnectToAccessory() + { + TRACE_FUNC + if (iConnectMsg.Handle()) + { + iAccMan.CancelConnect(iConnectingAddr); + iConnectMsg.Complete(KErrCancel); + } + } + +// --------------------------------------------------------- +// CBTAccSession::DisconnectAccessory +// --------------------------------------------------------- +void CBTAccSession::DisconnectAccessory(const RMessage2& aMessage) + { + TRACE_FUNC + if (iDisconnectMsg.Handle() || iDisconnectAllMsg.Handle()) + { + aMessage.Complete(KErrServerBusy); + } + else + { + iDisconnectMsg = aMessage; + TBTDevAddrPckgBuf pckg; + TInt err = aMessage.Read(0, pckg); + if (!err) + { + TRAP(err, iAccMan.DisconnectL(*this, pckg())); + } + if (err) + { + iDisconnectMsg.Complete(err); + } + } + } + +void CBTAccSession::GetConnections(const RMessage2& aMessage) + { + TRACE_FUNC + TProfiles profile = static_cast(aMessage.Int1()); + RPointerArray infos; + TInt ret = iAccMan.AccInfos(infos); + + if (ret == KErrNone) + { + RBuf8 buf; + + //get the number of connected accessories + TInt accessoryCount = infos.Count(); + + //create a buffer the size of either the client side buffer or the + //maximum amount of addresses (number of connected accessories) + TInt min = Min(aMessage.GetDesMaxLength(0) / KBTDevAddrSize, accessoryCount); + ret = buf.Create(min * KBTDevAddrSize); + + //if the buffer was created successfully + if (ret == KErrNone) + { + //iterate through the accessory info array and append the device + //addresses to the buffer + for (TInt i = 0; i < min; i++) + { + if (infos[i]->iConnProfiles & profile) + { + buf.Append(infos[i]->iAddr.Des()); + } + } + } + + //finished with the accessory info array + infos.Close(); + + //if there is no error and the buffer has something in, + //write the buffer to the message + if (ret == KErrNone) + { + ret = aMessage.Write(0, buf); + + if (ret == KErrNone) + { + ret = accessoryCount; + } + } + } + + //complete the message with either the number of addresses (num of + //connected accessories) or a system-wide error code + aMessage.Complete(ret); + } + +void CBTAccSession::DisconnectAllGracefully(const RMessage2& aMessage) + { + TRACE_FUNC + if (iDisconnectMsg.Handle() || iDisconnectAllMsg.Handle()) + { + aMessage.Complete(KErrServerBusy); + } + else + { + iDisconnectAllMsg = aMessage; + TRAPD(err, iAccMan.DisconnectAllL(*this)); + if (err) + { + iDisconnectAllMsg.Complete(err); + } + } + } + +void CBTAccSession::NotifyProfileStatus(const RMessage2& aMessage) + { + TRACE_FUNC + iAccMan.SetProfileNotifySession(*this); + if (iNotifyProfileMsg.Handle()) + { + aMessage.Complete(KErrInUse); + } + else + { + if (iProfileStatusCache.Count()) + { + TProfileStatusPckgBuf buf(iProfileStatusCache[0]); + TInt err = aMessage.Write(0, buf); + aMessage.Complete(err); + iProfileStatusCache.Remove(0); + } + else + { + iNotifyProfileMsg = aMessage; + } + } + } + +// --------------------------------------------------------- +// CBTAccSession::GetBTAccInfo +// --------------------------------------------------------- +void CBTAccSession::GetInfoOfConnectedAcc( const RMessage2& aMessage ) + { + TRACE_FUNC + TAccInfo info; + TPckg infoPckg(info); + TInt err = aMessage.Read(0, infoPckg); + if (!err) + { + const TAccInfo* infoptr = iAccMan.AccInfo(info.GetBDAddress()); + if (infoptr) + { + TPtr8 ptr((TUint8*)infoptr, sizeof(TAccInfo), sizeof(TAccInfo)); + err = aMessage.Write(0, ptr); + } + else + { + err = KErrNotFound; + } + } + aMessage.Complete(err); + } + +void CBTAccSession::IsConnected(const RMessage2& aMessage) + { + TRACE_FUNC + TBTDevAddrPckgBuf pckg; + TInt err = aMessage.Read(0, pckg); + + if (err == KErrNone) + { + aMessage.Complete(iAccMan.ConnectionStatus4Client(pckg())); + } + else + { + aMessage.Complete(err); + } + } + +void CBTAccSession::NotifyClientNewProfile(TInt aProfile, const TBTDevAddr& aAddr) + { + TRACE_FUNC + TProfileStatus newp; + newp.iAddr = aAddr; + newp.iConnected = ETrue; + newp.iProfiles = aProfile; + if (iNotifyProfileMsg.Handle()) + { + TProfileStatusPckgBuf buf(newp); + TInt err = iNotifyProfileMsg.Write(0, buf); + iNotifyProfileMsg.Complete(err); + } + else + { + UpdateProfileStatusCache(newp); + } + } + +void CBTAccSession::NotifyClientNoProfile(TInt aProfile, const TBTDevAddr& aAddr) + { + TRACE_FUNC + TProfileStatus newp; + newp.iAddr = aAddr; + newp.iConnected = EFalse; + newp.iProfiles = aProfile; + if (iNotifyProfileMsg.Handle()) + { + TProfileStatusPckgBuf buf(newp); + TInt err = iNotifyProfileMsg.Write(0, buf); + iNotifyProfileMsg.Complete(err); + } + else + { + UpdateProfileStatusCache(newp); + } + } + +// --------------------------------------------------------- +// Server +// Return a reference to CBTServer +// --------------------------------------------------------- +// +CBTAccServer& CBTAccSession::Server() + { + return *static_cast(const_cast(CSession2::Server())); + } + +// --------------------------------------------------------- +// ServiceL +// service a client request; test the opcode and then do +// appropriate servicing +// --------------------------------------------------------- +// +void CBTAccSession::ServiceL(const RMessage2& aMessage) + { + TRACE_FUNC + TRACE_INFO((_L("CBTAccSession::DispatchMessageL func %d"), aMessage.Function())) + switch (aMessage.Function()) + { + case EBTAccSrvConnectToAccessory: + { + ConnectToAccessory(aMessage); + break; + } + case EBTAccSrvCancelConnectToAccessory: + { + CancelConnectToAccessory(); + aMessage.Complete(KErrNone); + break; + } + + case EBTAccSrvDisconnectAccessory: + { + DisconnectAccessory(aMessage); + break; + } + case EBTAccSrvGetConnections: + { + GetConnections(aMessage); + break; + } + case EBTAccSrvDisconnectAllGracefully: + { + DisconnectAllGracefully(aMessage); + break; + } + case EBTAccSrvNotifyConnectionStatus: + { + NotifyProfileStatus(aMessage); + break; + } + case EBTAccSrvCancelNotifyConnectionStatus: + { + if (iNotifyProfileMsg.Handle()) + { + iNotifyProfileMsg.Complete(KErrCancel); + } + aMessage.Complete(KErrNone); + break; + } + case EBTAccSrvConnectionStatus: + { + IsConnected(aMessage); + break; + } + case EBTAccSrvGetInfoOfConnectedAcc: + { + GetInfoOfConnectedAcc(aMessage); + break; + } + case EBTAccSrvAudioToPhone: + case EBTAccSrvAudioToAccessory: + case EBTAccSrvCancelAudioToAccessory: + { + HandleAudio4DosRequest(aMessage); + break; + } + default: + { + PanicClient(aMessage, EBTAccBadRequest); + break; + } + } + } + +void CBTAccSession::UpdateProfileStatusCache(const TProfileStatus& aStatus) + { + TRACE_FUNC + TInt count = iProfileStatusCache.Count(); + for (TInt i = 0; i < count; i++) + { + if (iProfileStatusCache[i].iAddr == aStatus.iAddr && + iProfileStatusCache[i].iProfiles == aStatus.iProfiles) + { + iProfileStatusCache[i].iConnected = aStatus.iConnected; + return; + } + } + iProfileStatusCache.Append(aStatus); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/BTAccSession_accfw_var.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/BTAccSession_accfw_var.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006-2007 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: Variants for Dos Server version +* +* +*/ + + +// INCLUDE FILES +#include "BTAccSession.h" +#include "debug.h" + +void CBTAccSession::HandleAudio4DosRequest(const RMessage2 &aMessage) + { + aMessage.Complete(KErrNotSupported); + } + +void CBTAccSession::DestructVariant() + { + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvacc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvacc.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,275 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of an accessory management. +* +*/ + + +// INCLUDE FILES +#include "basrvacc.h" +#include "basrvaccman.h" +#include "basrvrvc.h" +#include "basrvaccstatequery.h" +#include "basrvpowercontrolagent.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAcc* CBasrvAcc::NewL(CBasrvAccMan& aAccMan) + { + CBasrvAcc* self = CBasrvAcc::NewLC(aAccMan); + CleanupStack::Pop(); + return self; + } + +CBasrvAcc* CBasrvAcc::NewLC(CBasrvAccMan& aAccMan) + { + CBasrvAcc* self = new(ELeave) CBasrvAcc(aAccMan); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CBasrvAcc::~CBasrvAcc() + { + delete iState; + delete iRvc; + delete iPowerController; + TRACE_FUNC + } + +const TBTDevAddr& CBasrvAcc::Remote() + { + return iAccInfo.iAddr; + } + +void CBasrvAcc::ConnectL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (!iState) + { + iAccInfo.SetBDAddress(aAddr); + iState = CBasrvAccStateQuery::NewL(*this, ETrue); + iState->EnterL(); + } + else + { + iState->ConnectL(aAddr); + } + } + +void CBasrvAcc::CancelConnect() + { + TRACE_FUNC + if (iState) + { + iState->CancelConnect(); + } + } + +void CBasrvAcc::DisconnectL() + { + TRACE_FUNC + if (iState) + { + iState->DisconnectL(); + } + } + +void CBasrvAcc::AccessoryConnectedL(const TBTDevAddr& aAddr, TProfiles aProfile) + { + TRACE_FUNC + if (!iState) + { + iAccInfo.SetBDAddress(aAddr); + iAccInfo.iConnProfiles = aProfile; + iAccInfo.iSuppProfiles = aProfile; + iState = CBasrvAccStateQuery::NewL(*this, EFalse); + iState->EnterL(); + } + else if (aAddr == iAccInfo.iAddr) + { + iState->AccessoryConnected(aProfile); + } + } + +void CBasrvAcc::AccOpenedAudio(TProfiles aProfile) + { + TRACE_FUNC + iState->AccOpenedAudio(aProfile); + } + +void CBasrvAcc::AccClosedAudio(TProfiles aProfile) + { + TRACE_FUNC + iState->AccClosedAudio(aProfile); + } + +void CBasrvAcc::AccessoryDisconnectedL(TProfiles aProfile) + { + TRACE_FUNC + iState->AccessoryDisconnectedL(aProfile); + } + +void CBasrvAcc::OpenAudioL(TAccAudioType aType) + { + TRACE_FUNC + iState->OpenAudioL(aType); + } + +void CBasrvAcc::CloseAudioL(TAccAudioType aType) + { + TRACE_FUNC + iState->CloseAudioL(aType); + } + +const TAccInfo* CBasrvAcc::AccInfo(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (iAccInfo.iAddr == aAddr) + { + return &iAccInfo; + } + return NULL; + } + +void CBasrvAcc::ChangeStateL(CBasrvAccState* aNewState) + { + TRACE_FUNC_ENTRY + delete iState; + iState = aNewState; + if (iState) + { + TInt err = KErrNone; + TRAP(err, iState->EnterL()); + if (err) + { + ChangeStateL(iState->ErrorOnEntry(err)); + } + } + if (!iState) + { + iAccMan.AccObsoleted(this, iAccInfo.iAddr); + } + TRACE_FUNC_EXIT + } + +CBasrvAccMan& CBasrvAcc::AccMan() + { + return iAccMan; + } + + +TAccInfo& CBasrvAcc::AccInfo() + { + return iAccInfo; + } + +TBTEngConnectionStatus CBasrvAcc::ConnectionStatus() const + { + if (iState) + { + return iState->ConnectionStatus(); + } + + return EBTEngNotConnected; + } + +void CBasrvAcc::RequestSniffMode() + { + if (!(AccInfo().iSuppProfiles & EHFP) && !(AccInfo().iSuppProfiles & EStereo)) + { + return; // No power mode handling with HSP + } + + if (!iPowerController) + { + TRAP_IGNORE(iPowerController = CBasrvPowerControlAgent::NewL(iAccInfo.iAddr)); + } + + if (iPowerController) + { + iPowerController->RequestSniffMode(); + } + } + +void CBasrvAcc::RequestActiveMode() + { + if (!(AccInfo().iSuppProfiles & EHFP) && !(AccInfo().iSuppProfiles & EStereo)) + { + return; // No power mode handling with HSP + } + if (!iPowerController) + { + TRAP_IGNORE(iPowerController = CBasrvPowerControlAgent::NewL(iAccInfo.iAddr)); + } + if (iPowerController) + { + iPowerController->RequestActiveMode(); + } + } + +void CBasrvAcc::CancelPowerModeControl() + { + if (iPowerController) + { + iPowerController->CancelPowerModeControl(); + } + } + +void CBasrvAcc::NotifyLinkChange2Rvc() + { + if (!iRvc) + iRvc = CBasrvRvc::New(*this); + if (iRvc) + { + iRvc->Update(iAccInfo.iConnProfiles, iAccInfo.iAudioOpenedProfiles); + } + } + +void CBasrvAcc::PreventLowPowerMode() + { + TRACE_FUNC + if (!iPowerController) + { + TRAP_IGNORE(iPowerController = CBasrvPowerControlAgent::NewL(iAccInfo.iAddr)); + } + if (iPowerController) + { + iPowerController->PreventLowPowerMode(); + } + } + +void CBasrvAcc::AllowLowPowerMode() + { + TRACE_FUNC + if (iPowerController) + { + iPowerController->AllowLowPowerMode(); + } + } + + +CBasrvAcc::CBasrvAcc(CBasrvAccMan& aAccMan) + : iAccMan(aAccMan) + { + TRACE_FUNC + iAccInfo.SetBDAddress(TBTDevAddr()); + } + +void CBasrvAcc::ConstructL() + { + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccfwconn.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccfwconn.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,296 @@ +/* +* Copyright (c) 2005-2006 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: +* This class communicates with Nokia "Accessory Framework" +* to for e.g., get permission to attach/detach a remote bluetooth +* device and also recieves requests to open/close audio connections. +* Version : %version: 2.2.3 % +* +*/ + + +// INCLUDE FILES +#include "BTAccInfo.h" +#include "basrvaccfwconn.h" +#include "debug.h" + +#include + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::CBasrvAccfwConn +// C++ default constructor can NOT contain any code that +// might leave. +// ----------------------------------------------------------------------------- +// +CBasrvAccfwConn::CBasrvAccfwConn() + { + } + +// --------------------------------------------------------- +// Destructor +// --------------------------------------------------------- +// +CBasrvAccfwConn::~CBasrvAccfwConn() + { + iAccessoryBTControlSession.CloseSubSession(); + iAccessoryServerSession.Close(); + TRACE_FUNC + } + +// --------------------------------------------------------- +// CBasrvAccfwIf::NewL +// --------------------------------------------------------- +// +CBasrvAccfwIf* CBasrvAccfwIf::NewL(const TAccInfo* /*aInfo*/) +{ + return CBasrvAccfwConn::NewL(); +} + +// --------------------------------------------------------- +// CBasrvAccfwConn::NewL +// --------------------------------------------------------- +// +CBasrvAccfwIf* CBasrvAccfwConn::NewL() + { + CBasrvAccfwConn* self = new(ELeave) CBasrvAccfwConn(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + + +// --------------------------------------------------------- +// ConstructL +// --------------------------------------------------------- +// +void CBasrvAccfwConn::ConstructL() + { + User::LeaveIfError( iAccessoryServerSession.Connect() ); + User::LeaveIfError( iAccessoryBTControlSession.CreateSubSession( iAccessoryServerSession ) ); + TRACE_FUNC + } + +// --------------------------------------------------------- +// CBasrvAccfwConn::CompleteReq +// --------------------------------------------------------- +// +void CBasrvAccfwConn::CompleteReq(TBool /*aUse*/) + { + // Dos related implementation + } + +// --------------------------------------------------------- +// CBasrvAccfwConn::AttachAccessory +// --------------------------------------------------------- +// +void CBasrvAccfwConn::AttachAccessory(const TBTDevAddr& aBDAddr, TRequestStatus &aStatus) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddr.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::AttachAccessory, BTAddr: %S"), &buf)) + }); + iAccessoryBTControlSession.ConnectAccessory( aStatus, aBDAddr ); + } + +// --------------------------------------------------------- +// CBasrvAccfwConn::CancelAttachAccessory +// --------------------------------------------------------- +// +void CBasrvAccfwConn::CancelAttachAccessory(const TBTDevAddr& /*aBDAddr*/) + { + iAccessoryBTControlSession.CancelConnectAccessory(); + TRACE_FUNC + } + +// --------------------------------------------------------- +// CBasrvAccfwConn::DetatchAccessory +// --------------------------------------------------------- +// +void CBasrvAccfwConn::DetatchAccessory( const TBTDevAddr& aBDAddr, TRequestStatus &aStatus ) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddr.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::DetatchAccessory, BTAddr: %S"), &buf)) + }); + iAccessoryBTControlSession.DisconnectAccessory( aStatus, aBDAddr ); + } + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::NotifyBTAudioLinkOpenReq +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::NotifyBTAudioLinkOpenReq(TBTDevAddr& aBDAddress, + TRequestStatus& aStatus, TAccAudioType& aType ) + { + TRACE_FUNC + iAccessoryBTControlSession.NotifyBluetoothAudioLinkOpenReq( aStatus, aBDAddress, aType ); + } + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::NotifyBTAudioLinkCloseReq +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::NotifyBTAudioLinkCloseReq(TBTDevAddr& aBDAddress, + TRequestStatus& aStatus, TAccAudioType& aType ) + { + TRACE_FUNC + iAccessoryBTControlSession.NotifyBluetoothAudioLinkCloseReq( aStatus, aBDAddress, aType ); + } + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::CancelNotifyBTAudioLinkOpenReq +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::CancelNotifyBTAudioLinkOpenReq() + { + iAccessoryBTControlSession.CancelNotifyBluetoothAudioLinkOpenReq(); + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::CancelNotifyBTAudioLinkCloseReq +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::CancelNotifyBTAudioLinkCloseReq() + { + iAccessoryBTControlSession.CancelNotifyBluetoothAudioLinkCloseReq(); + TRACE_FUNC + } + + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::AudioConnectionOpenComplete +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::AudioConnectionOpenCompleteL( const TBTDevAddr& aBDAddress, + TInt aResp, TInt aLatency ) + { + + TAccValueTypeTInt value; + value.iValue = aLatency; + + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddress.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::AudioConnectionOpenCompleteL, BTAddr: %S LATENCY: %d"), &buf, value.iValue)) + }); + iAccessoryBTControlSession.BluetoothAudioLinkOpenRespL( aBDAddress, aResp ) ; + TAccPolNameRecord nameRecord; + TRAPD(ret, nameRecord.SetNameL(KAccAudioLatency)); + if ( !ret ) + { + TRAP_IGNORE(iAccessoryBTControlSession.AccessoryValueChangedNotifyL(aBDAddress, nameRecord, value)); + } + } + + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::AudioConnectionCloseComplete +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::AudioConnectionCloseCompleteL( const TBTDevAddr& aBDAddress, + TInt aResp ) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddress.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::AudioConnectionCloseCompleteL, BTAddr: %S"), &buf)) + }); + iAccessoryBTControlSession.BluetoothAudioLinkCloseRespL( aBDAddress, aResp ) ; + + } + + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::NotifyAudioLinkOpen +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::NotifyAudioLinkOpenL( const TBTDevAddr& aBDAddress, TAccAudioType aType ) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddress.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::NotifyAudioLinkOpenL, BTAddr: %S"), &buf)) + }); + iAccessoryBTControlSession.BluetoothAudioLinkOpenedNotifyL( aBDAddress, aType ) ; + } + + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::NotifyAudioLinkClose +// ----------------------------------------------------------------------------- +// +void CBasrvAccfwConn::NotifyAudioLinkCloseL( const TBTDevAddr& aBDAddress, TAccAudioType aType ) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddress.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::NotifyAudioLinkCloseL, BTAddr: %S"), &buf)) + }); + iAccessoryBTControlSession.BluetoothAudioLinkClosedNotifyL( aBDAddress, aType ) ; + } + +// ----------------------------------------------------------------------------- +// CBasrvAccfwConn::DisableNREC +// ----------------------------------------------------------------------------- +// +TInt CBasrvAccfwConn::DisableNREC(const TBTDevAddr& aBDAddress) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aBDAddress.GetReadable(buf); + TRACE_INFO((_L("CBasrvAccfwConn::DisableNREC, BTAddr: %S"), &buf)) + }); + + TAccValueTypeTBool value; + value.iValue = ETrue; + TAccPolNameRecord nameRecord; + + // Echo cancellation + TRAPD(ret, nameRecord.SetNameL(KAccAcousticEchoControl)); + if (!ret) + { + TRAP(ret, iAccessoryBTControlSession.AccessoryValueChangedNotifyL( aBDAddress, + nameRecord, + value )); + } + if (!ret) + { + // Noise Reduction + TRAP(ret, nameRecord.SetNameL(KAccNoiseReduction)); + if (!ret) + { + TRAP(ret, iAccessoryBTControlSession.AccessoryValueChangedNotifyL( aBDAddress, + nameRecord, + value )); + } + } + return ret; + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,848 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of an accessory management. +* Version : %version: 14.1.7 % +* +*/ + + +// INCLUDE FILES +#include +#include "basrvaccman.h" +#include "BTAccSession.h" +#include "BTAccClientSrv.h" +#include "basrvacc.h" +#include "BTAccInfo.h" +#include "basrvpluginman.h" +#include "BTAccFwIf.h" +#include "debug.h" + +const TInt KOpenAudioListenerId = 20; +const TInt KCloseAudioListenerId = 21; +const TInt KShowNoteRequest = 22; +const TInt KAsyncHandlingRequest = 23; + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccMan* CBasrvAccMan::NewL() + { + CBasrvAccMan* self = new (ELeave) CBasrvAccMan(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBasrvAccMan::~CBasrvAccMan() + { + delete iOpenListener; + delete iCloseListener; + delete iAsyncHandlingActive; + + // Response to any buffered audio request from Audio Policy. + if (iAccfw) + { + TInt count = iAudioRequests.Count(); + for (TInt i = 0; i < count; i++) + { + if (iAudioRequests[i].iReqType == EOpenReqFromAudioPolicy) + { + TRAP_IGNORE(iAccfw->AudioConnectionOpenCompleteL( + iAudioRequests[i].iAddr, KErrDisconnected)); + } + else if (iAudioRequests[i].iReqType == ECloseReqFromAudioPolicy) + { + TRAP_IGNORE(iAccfw->AudioConnectionCloseCompleteL( + iAudioRequests[i].iAddr, KErrDisconnected)); + } + } + } + + iAudioRequests.Close(); + iAccs.ResetAndDestroy(); + iAccs.Close(); + delete iAccfw; + delete iPluginMan; + iNotifierArray.ResetAndDestroy(); + iNotifierArray.Close(); + iClientRequests.Close(); + DestructVariant(); + TRACE_FUNC + } + +void CBasrvAccMan::LoadServicesL() + { + TRACE_FUNC + if (!iPluginMan) + { + iPluginMan = CBasrvPluginMan::NewL(); + } + iPluginMan->LoadPluginsL(*this); + } + +void CBasrvAccMan::ConnectL(CBTAccSession& aSession, const TBTDevAddr& aAddr) + { + TRACE_FUNC + TClientRequestCache request; + request.iSession = &aSession; + request.iRequest = EBTAccSrvConnectToAccessory; + request.iAddr = aAddr; + iClientRequests.AppendL(request); + + //remove the last item from the RArray if a leave occurs later + TCleanupItem cleanupItem(CleanupLastItemFromClientRequestsArray, &iClientRequests); + CleanupStack::PushL(cleanupItem); + + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + iAccs[idx]->ConnectL(aAddr); + } + else + { + CBasrvAcc* acc = CBasrvAcc::NewLC(*this); + iAccs.AppendL(acc); + CleanupStack::Pop(acc); + acc->ConnectL(aAddr); + } + + CleanupStack::Pop(&iClientRequests); + } + +void CBasrvAccMan::CancelConnect(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + TInt count = iClientRequests.Count(); + for (TInt i = 0; i < count; i++) + { + if (iClientRequests[i].iAddr == aAddr && + iClientRequests[i].iRequest == EBTAccSrvConnectToAccessory) + { + iClientRequests.Remove(i); + break; + } + } + iAccs[idx]->CancelConnect(); + } + } + +void CBasrvAccMan::DisconnectL(CBTAccSession& aSession, const TBTDevAddr& aAddr) + { + TRACE_FUNC + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + RemoveAudioRequest(aAddr); + TClientRequestCache request; + request.iSession = &aSession; + request.iRequest = EBTAccSrvDisconnectAccessory; + request.iAddr = aAddr; + iClientRequests.AppendL(request); + iAccs[idx]->DisconnectL(); + } + else + { + aSession.DisconnectCompleted(EAnyMonoAudioProfiles, KErrNotFound); + } + } + +void CBasrvAccMan::DisconnectAllL(CBTAccSession& aSession) + { + TRACE_FUNC + if (!iDisconnectAllPending) + { + TInt count = iAccs.Count(); + if (!count) + { + aSession.DisconnectAllCompleted(KErrNone); + } + else + { + iSessionOfDisconnectAll = &aSession; + for (TInt i = 0; i < count; i++) + { + RemoveAudioRequest(iAccs[i]->Remote()); + iAccs[i]->DisconnectL(); + } + iDisconnectAllPending = ETrue; + } + } + } + +void CBasrvAccMan::SetProfileNotifySession(CBTAccSession& aSession) + { + iProfileNotifySession = &aSession; + } + +void CBasrvAccMan::ClearProfileNotifySession(CBTAccSession& aSession) + { + //if the session passed in is equal to what we have stored + if (&aSession == iProfileNotifySession) + { + //invalidate the pointer to the session + iProfileNotifySession = NULL; + } + } + +const TAccInfo* CBasrvAccMan::AccInfo(const TBTDevAddr& aAddr) + { + TInt count = iAccs.Count(); + const TAccInfo* info = NULL; + for (TInt i = 0; i < count; i++) + { + info = iAccs[i]->AccInfo(aAddr); + if (info) + { + return info; + } + } + return NULL; + } + +CBasrvPluginMan& CBasrvAccMan::PluginMan() + { + return *iPluginMan; + } + +void CBasrvAccMan::ConnectCompletedL(const TBTDevAddr& aAddr, TInt aErr, + TInt aProfile, const RArray* aConflicts) + { + TRACE_FUNC + TInt count = iClientRequests.Count(); + for (TInt i = 0; i < count; i++) + { + if (iClientRequests[i].iAddr == aAddr && + iClientRequests[i].iRequest == EBTAccSrvConnectToAccessory) + { + iClientRequests[i].iSession->ConnectCompleted(aErr, aProfile, aConflicts); + iClientRequests.Remove(i); + break; + } + } + } + +void CBasrvAccMan::DisconnectCompletedL(const TBTDevAddr& aAddr, TInt aProfile, TInt aErr) + { + TRACE_FUNC + TInt count = iClientRequests.Count(); + for (TInt i = 0; i < count; i++) + { + if (iClientRequests[i].iAddr == aAddr && + iClientRequests[i].iRequest == EBTAccSrvDisconnectAccessory) + { + iClientRequests[i].iSession->DisconnectCompleted(aProfile, aErr); + iClientRequests.Remove(i); + break; + } + } + } + +#define TRACE_AUDIO_REQUEST_COMPLETE \ + TRACE_INFO_SEG(\ + {\ + TBuf<12> buf;\ + aAddr.GetReadable(buf);\ + Trace(_L("[Audio Request Complete] %d %d at '%S', err %d"), \ + iAudioRequests[0].iReqType, aType, &buf, aErr);\ + }); + +TInt CBasrvAccMan::OpenAudioCompleted(const TBTDevAddr& aAddr, TAccAudioType aType, TInt aErr) + { + TInt err = KErrNone; + if (iAudioRequests.Count()) + { + TRACE_AUDIO_REQUEST_COMPLETE + TRequestType reqType = iAudioRequests[0].iReqType; + iAudioRequests.Remove(0); + TInt latency = iPluginMan->AudioLinkLatency(); + if (reqType == EOpenReqFromAudioPolicy) + { + + TRAP(err, AccfwConnectionL()->AudioConnectionOpenCompleteL(aAddr, aErr, latency)) + TRACE_INFO((_L("AccfwConnectionL()->AudioConnectionOpenCompleteL trap %d"), err)) + if (!err && !aErr) + { + err = NotifyAccFwAudioOpened(aAddr, aType, latency); + } + else if (err == KErrAlreadyExists && !aErr) + { + RejectAudioLink(aAddr, aType); + } + } + } + if (!err) // if err, a rejecting audio link has been scheduled. + { + TRAP_IGNORE(DoAudioRequestL()); + } + return err; + } + +TInt CBasrvAccMan::CloseAudioCompleted(const TBTDevAddr& aAddr, TAccAudioType aType, TInt aErr) + { + TInt err = KErrNone; + if (iAudioRequests.Count()) + { + TRACE_AUDIO_REQUEST_COMPLETE + if (iAudioRequests[0].iReqType == ECloseReqFromAudioPolicy) + { + TRAP(err, AccfwConnectionL()->NotifyAudioLinkCloseL(aAddr, aType)); + TRACE_INFO((_L("AccfwConnectionL()->NotifyAudioLinkCloseL trap %d"), err)) + TRAP(err, AccfwConnectionL()->AudioConnectionCloseCompleteL(aAddr, aErr)); + TRACE_INFO((_L("AccfwConnectionL()->AudioConnectionCloseCompleteL trap %d"), err)) + } + iAudioRequests.Remove(0); + } + if (iAudioRequests.Count()) + { + TRAP_IGNORE(DoAudioRequestL()); + } + return err; + } + +void CBasrvAccMan::AccObsoleted(CBasrvAcc* aAcc, const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + TInt idx = iAccs.Find(aAcc); + if (idx >= 0) + { + RemoveAudioRequest(iAccs[idx]->Remote()); + delete aAcc; + iAccs.Remove(idx); + } + if (!iAccs.Count()) + { + delete iOpenListener; + iOpenListener = NULL; + delete iCloseListener; + iCloseListener = NULL; + delete iAccfw; + iAccfw = NULL; + iAudioRequests.Reset(); + if (iDisconnectAllPending) + { + iDisconnectAllPending = EFalse; + if (iSessionOfDisconnectAll) + iSessionOfDisconnectAll->DisconnectAllCompleted(KErrNone); + } + } + } + +CBasrvAccfwIf* CBasrvAccMan::AccfwConnectionL(const TAccInfo* aInfo) + { + if (!iAccfw) + { + iAccfw = CBasrvAccfwIf::NewL(aInfo); + } + return iAccfw; + } + +CBasrvAccfwIf* CBasrvAccMan::NewAccfwConnectionInstanceL() + { + TRACE_FUNC + return CBasrvAccfwIf::NewL(NULL); + } + +void CBasrvAccMan::ListenAudioRequestL() + { + TRACE_FUNC + if (!iOpenListener) + { + iCloseListener = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KCloseAudioListenerId); + iOpenListener = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KOpenAudioListenerId); + AccfwConnectionL()->NotifyBTAudioLinkOpenReq(iOpenAddr,iOpenListener->iStatus, iOpenType); + iOpenListener->GoActive(); + AccfwConnectionL()->NotifyBTAudioLinkCloseReq(iCloseAddr,iCloseListener->iStatus, iCloseType); + iCloseListener->GoActive(); + } + } + +void CBasrvAccMan::CancelAudioRequestListen() + { + delete iOpenListener; + iOpenListener = NULL; + delete iCloseListener; + iCloseListener = NULL; + TRACE_FUNC + } + +void CBasrvAccMan::RemoveAudioRequest(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TInt count = iAudioRequests.Count(); + TInt i = 0; + while(count && i < count) + { + if (iAudioRequests[i].iAddr == aAddr) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aAddr.GetReadable(buf); + Trace(_L("[Audio Request Aborted] %d %d at '%S'"), + iAudioRequests[i].iReqType, iAudioRequests[i].iAudioType, &buf); + }); + if (iAudioRequests[i].iReqType == EOpenReqFromAudioPolicy) + { + TRAP_IGNORE(AccfwConnectionL()->AudioConnectionOpenCompleteL(aAddr, KErrDisconnected)); + } + else if (iAudioRequests[i].iReqType == ECloseReqFromAudioPolicy) + { + TRAP_IGNORE(AccfwConnectionL()->AudioConnectionCloseCompleteL(aAddr, KErrDisconnected)); + } + iAudioRequests.Remove(i); + count--; + } + else + { + i++; + } + } + } + +void CBasrvAccMan::ShowNote(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr) + { + TRACE_INFO((_L("CBasrvAccMan::ShowNote %d"), aNote)) + TRAPD(err, iNotifierArray.Append(CBasrvActiveNotifier::NewL(*this, CActive::EPriorityStandard, KShowNoteRequest, aAddr, aNote))); + if (err) + { + TRACE_ERROR((_L("could not construct active notifer object"))) + return; + } + } + +void CBasrvAccMan::FilterProfileSupport(TAccInfo& aInfo) + { + TInt pluginbit = iPluginMan->AvailablePlugins(); + aInfo.iSuppProfiles &= pluginbit; + } + +TInt CBasrvAccMan::NotifyAccFwAudioOpened(const TBTDevAddr& aAddr, TAccAudioType aType, TInt /*aLatency*/) + { + TRAPD(err, AccfwConnectionL()->NotifyAudioLinkOpenL(aAddr, aType)); + TRACE_INFO((_L("AccfwConnectionL()->NotifyAudioLinkOpenL type %d trap %d"), aType, err)) + if (err) + { + RejectAudioLink(aAddr, aType); + } + return err; + } + +TInt CBasrvAccMan::AccInfos(RPointerArray& aInfos) + { + TInt count = iAccs.Count(); + TInt err = KErrNone; + + for (TInt i = 0; i < count; i++) + { + err = aInfos.Append(&(iAccs[i]->AccInfo())); + + if (err != KErrNone) + { + //an error occured so cleanup + aInfos.Close(); + break; + } + } + + return err; + } + +void CBasrvAccMan::NotifyClientNewProfile(TInt aProfile, const TBTDevAddr& aAddr) + { + if (iProfileNotifySession) + { + iProfileNotifySession->NotifyClientNewProfile(aProfile, aAddr); + } + } + +void CBasrvAccMan::NotifyClientNoProfile(TInt aProfile, const TBTDevAddr& aAddr) + { + if (iProfileNotifySession) + { + iProfileNotifySession->NotifyClientNoProfile(aProfile, aAddr); + } + } + +TBTEngConnectionStatus CBasrvAccMan::ConnectionStatus4Client(const TBTDevAddr& aAddr) const + { + TInt count = iAccs.Count(); + for (TInt i = 0; i < count; i++) + { + if (iAccs[i]->Remote() == aAddr) + { + return iAccs[i]->ConnectionStatus(); + } + } + return EBTEngNotConnected; + } + +TBool CBasrvAccMan::IsAvrcpVolCTSupported() + { + return iAvrcpVolCTSupported; + } + +TBool CBasrvAccMan::IsAbsoluteVolumeSupported(const TBTDevAddr& aAddr) + { + TInt count = iAccs.Count(); + for (TInt i = 0; i < count; i++) + { + if (iAccs[i]->Remote() == aAddr) + { + TBool ret = iAccs[i]->AccInfo().iAvrcpVersion == TAccInfo::EAvrcpVersion14 ? ETrue : EFalse; + return ret; + } + } + return EFalse; + } + +TBool CBasrvAccMan::DisconnectIfAudioOpenFails() + { + return iDisconnectIfAudioOpenFails; + } + +void CBasrvAccMan::NewAccessory( const TBTDevAddr& aAddr, TProfiles aProfile ) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aAddr.GetReadable(buf); + Trace(_L("[profile remote connect] profile %d, BTAddr '%S' "), aProfile, &buf ); + }); + + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + TRAP_IGNORE(iAccs[idx]->AccessoryConnectedL(aAddr, aProfile)); + } + else + { + CBasrvAcc* acc = NULL; + TRAP_IGNORE(acc = CBasrvAcc::NewL(*this)); + if (acc) + { + TInt err = iAccs.Append(acc); + if (err) + delete acc; + else + { + TRAP_IGNORE(acc->AccessoryConnectedL(aAddr, aProfile)); + } + } + } + } + +void CBasrvAccMan::AccessoryDisconnected(const TBTDevAddr& aAddr, TProfiles aProfile) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aAddr.GetReadable(buf); + Trace(_L("[profile remote disconnect] profile %d, BTAddr '%S' "), aProfile, &buf ); + }); + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + TRAP_IGNORE(iAccs[idx]->AccessoryDisconnectedL(aProfile)); + } + } + +void CBasrvAccMan::RemoteAudioOpened(const TBTDevAddr& aAddr, TProfiles aProfile) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aAddr.GetReadable(buf); + Trace(_L("[Audio remote open] profile %d, BTAddr '%S' "), aProfile, &buf ); + }); + + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + // Check if another audio link opened already + TInt audiolinks = AudioLinkStatus(); + + if ( ( audiolinks && audiolinks != aProfile) || + ( iAudioRequests.Count() && + iAudioRequests[0].iOngoing && + iAudioRequests[0].iAddr == aAddr) ) + { + // another audio type is opened while we have an audio link or pending audio request. + if (iAudioRequests.Count()) + { + TRACE_INFO((_L(" [audio link check] existing audio link %x, audio request pending ? %d. Audio should be rejected!"), + audiolinks, iAudioRequests[0].iOngoing)) + } + else + { + TRACE_INFO((_L(" [audio link check] existing audio link %x. Audio should be rejected!"), + audiolinks)) + } + RejectAudioLink(aAddr, (aProfile == EStereo) ? EAccStereoAudio : EAccMonoAudio); + } + else + { + iAccs[idx]->AccOpenedAudio(aProfile); + } + } + } + +void CBasrvAccMan::RemoteAudioClosed(const TBTDevAddr& aAddr, TProfiles aProfile) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + aAddr.GetReadable(buf); + Trace(_L("[Audio remote close] profile %d, BTAddr '%S' "), aProfile, &buf ); + }); + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + iAccs[idx]->AccClosedAudio(aProfile); + } + } + +TInt CBasrvAccMan::DisableNREC(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TInt idx = FindAcc(aAddr); + if (idx >= 0) + { + TInt err = KErrNone; + TRAPD(trap, err = AccfwConnectionL()->DisableNREC(aAddr)); + if (trap) + return trap; + return err; + } + return KErrNotFound; + } + +void CBasrvAccMan::AccessoryTemporarilyUnavailable(const TBTDevAddr& /*aAddr*/, TProfiles /*aType*/) + { + TRACE_INFO((_L("AccessoryTemporarilyUnavailable Deprecated !!!"))) + } + +TInt CBasrvAccMan::ConnectionStatus(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TInt count = iAccs.Count(); + const TAccInfo* info = NULL; + for (TInt i = 0; i < count; i++) + { + info = iAccs[i]->AccInfo(aAddr); + if (info) + { + return info->iConnProfiles; + } + } + return 0; + } + +void CBasrvAccMan::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_FUNC + switch (aActive.RequestId()) + { + case KOpenAudioListenerId: + { + if (aActive.iStatus == KErrNone) + { + TAudioRequest req; + req.iAddr = iOpenAddr; + req.iAudioType = iOpenType; + req.iReqType = EOpenReqFromAudioPolicy; + req.iOngoing = EFalse; + + TRACE_INFO_SEG( + { + TBuf<12> buf; + iOpenAddr.GetReadable(buf); + Trace(_L("[Audio Request Buf] 1(Open) %d at '%S'"), iOpenType, &buf); + }); + + AccfwConnectionL()->NotifyBTAudioLinkOpenReq(iOpenAddr, aActive.iStatus, iOpenType); + aActive.GoActive(); + iAudioRequests.AppendL(req); + DoAudioRequestL(); + } + break; + } + case KCloseAudioListenerId: + if (aActive.iStatus == KErrNone) + { + TAudioRequest req; + req.iAddr = iCloseAddr; + req.iAudioType = iCloseType; + req.iReqType = ECloseReqFromAudioPolicy; + req.iOngoing = EFalse; + TRACE_INFO_SEG( + { + TBuf<12> buf; + iCloseAddr.GetReadable(buf); + Trace(_L("[Audio Request Buf] 0(Close) %d at '%S'"), iCloseType, &buf); + }); + AccfwConnectionL()->NotifyBTAudioLinkCloseReq(iCloseAddr, aActive.iStatus, iCloseType); + aActive.GoActive(); + iAudioRequests.AppendL(req); + DoAudioRequestL(); + } + break; + case KShowNoteRequest: + { + TInt index = iNotifierArray.Find(&aActive); + if(index>=0) + { + delete iNotifierArray[index]; + iNotifierArray.Remove(index); + } + break; + } + case KAsyncHandlingRequest: + { + DoAudioRequestL(); + delete iAsyncHandlingActive; + iAsyncHandlingActive = NULL; + break; + } + default: + { + + } + } + } + +void CBasrvAccMan::CancelRequest(CBasrvActive& aActive) + { + TRACE_FUNC + if (aActive.RequestId() == KOpenAudioListenerId) + { + TRAP_IGNORE(AccfwConnectionL()->CancelNotifyBTAudioLinkOpenReq()); + } + else if (aActive.RequestId() == KCloseAudioListenerId) + { + TRAP_IGNORE(AccfwConnectionL()->CancelNotifyBTAudioLinkCloseReq()); + } + } + +CBasrvAccMan::CBasrvAccMan() + { + } + +void CBasrvAccMan::DoAudioRequestL() + { + TRACE_FUNC + if (iAudioRequests.Count() && !iAudioRequests[0].iOngoing && (!iAsyncHandlingActive || !iAsyncHandlingActive->IsActive())) + { + iAudioRequests[0].iOngoing = ETrue; + TInt err = KErrNotFound; + TInt idx = FindAcc(iAudioRequests[0].iAddr); + if (idx >= 0) + { + if (iAudioRequests[0].iReqType == EOpenReqFromAudioPolicy) + { + TRAP(err, iAccs[idx]->OpenAudioL(iAudioRequests[0].iAudioType)); + } + else + { + TRAP(err, iAccs[idx]->CloseAudioL(iAudioRequests[0].iAudioType)); + } + TRACE_INFO_SEG({ + if ( iAudioRequests.Count() ) + { + TBuf<12> buf; + iAudioRequests[0].iAddr.GetReadable(buf); + Trace(_L("[Audio Request Start] %d %d at '%S', trap %d"), + iAudioRequests[0].iReqType, iAudioRequests[0].iAudioType, &buf, err); + } + }); + } + if (err) + { + if (iAudioRequests[0].iReqType == EOpenReqFromAudioPolicy) + OpenAudioCompleted(iAudioRequests[0].iAddr, iAudioRequests[0].iAudioType, err); + else if(iAudioRequests[0].iReqType == ECloseReqFromAudioPolicy) + CloseAudioCompleted(iAudioRequests[0].iAddr, iAudioRequests[0].iAudioType, err); + } + } + } + +TInt CBasrvAccMan::FindAcc(const TBTDevAddr& aRemote) + { + TInt count = iAccs.Count(); + for (TInt i = 0; i < count; i++) + { + if (iAccs[i]->Remote() == aRemote) + { + return i; + } + } + return KErrNotFound; + } + +TInt CBasrvAccMan::AudioLinkStatus() + { + TInt profiles = 0; + TInt count = iAccs.Count(); + for (TInt i = 0; i < count; i++) + { + profiles |= iAccs[i]->AccInfo().iAudioOpenedProfiles; + } + return profiles; + } + +void CBasrvAccMan::RejectAudioLink(const TBTDevAddr& aAddr, TAccAudioType aType) + { + TAudioRequest req; + req.iAddr = aAddr; + req.iAudioType = aType; + req.iReqType = ERejectAudioOpenedByAcc; + req.iOngoing = EFalse; + TInt idx = 0; + if (iAudioRequests.Count() && iAudioRequests[0].iOngoing) + { + idx = 1; + } + TInt err = iAudioRequests.Insert(req, idx); + TRACE_INFO_SEG( + { + TBuf<12> buf; + iCloseAddr.GetReadable(buf); + Trace(_L("[Audio Request buf] 2(Reject) %d at '%S', to index %d"), iCloseType, &buf, idx); + }); + + if (!err && !iAsyncHandlingActive && !iAudioRequests[0].iOngoing) + { + // Start rejection asynchronously + iAsyncHandlingActive = + CBasrvActive::New(*this, CActive::EPriorityStandard, KAsyncHandlingRequest); + if (iAsyncHandlingActive) + { + iAsyncHandlingActive->iStatus = KRequestPending; + TRequestStatus* sta = &(iAsyncHandlingActive->iStatus); + User::RequestComplete(sta, KErrNone); + iAsyncHandlingActive->GoActive(); + } + } + } + +void CBasrvAccMan::CleanupLastItemFromClientRequestsArray(TAny* aPtr) + { + //cast the pointer passed in to the correct RArray type + RArray& clientRequests = *static_cast*>(aPtr); + + //remove the last item from the array + clientRequests.Remove(clientRequests.Count() - 1); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccman_accfw_var.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccman_accfw_var.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of an accessory management. +* +*/ + + +// INCLUDE FILES +#include +#include + +#include "basrvaccman.h" +#include "debug.h" + +void CBasrvAccMan::AudioToPhone(CBasrvAudio4Dos& /*aAudio4Dos*/) + { + } + +void CBasrvAccMan::AudioToAccessory(CBasrvAudio4Dos& /*aAudio4Dos*/) + { + } + +void CBasrvAccMan::ConstructL() + { + CRepository* cenrep = NULL; + TRAP_IGNORE(cenrep = CRepository::NewL(KCRUidBluetoothEngine)); + TInt avrcpVol = EBTAvrcpVolCTNotSupported; + TInt autoDisconnect = EBTDisconnectIfAudioOpenFails; + if (cenrep) + { + cenrep->Get(KBTAvrcpVolCTLV, avrcpVol); + cenrep->Get(KBTDisconnectIfAudioOpenFailsLV, autoDisconnect); + delete cenrep; + } + iAvrcpVolCTSupported = (avrcpVol == EBTAvrcpVolCTSupported) ? ETrue : EFalse; + iDisconnectIfAudioOpenFails = (autoDisconnect == EBTDisconnectIfAudioOpenFails) ? ETrue : EFalse; + TRACE_INFO((_L("[AVRCP_Vol_CT] %d [DisconnectIfAudioOpenFails] %d"), + iAvrcpVolCTSupported, iDisconnectIfAudioOpenFails)) + } + +void CBasrvAccMan::DestructVariant() + { + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstate.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of BT Acc Server accessory base state. +* +*/ + + +// INCLUDE FILES +#include "basrvaccstate.h" +#include "debug.h" + +const TInt KBitAvrcpSupportedFeatureCategory2 = 0x2; + + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccState::~CBasrvAccState() + { + CompleteStateRequest(KErrAbort); + } + +CBasrvAccState* CBasrvAccState::ErrorOnEntry(TInt /*aReason*/) + { + TRACE_FUNC + return NULL; + } + +void CBasrvAccState::ConnectL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + LEAVE(KErrAlreadyExists); + } + +void CBasrvAccState::CancelConnect() + { + TRACE_FUNC + } + +void CBasrvAccState::DisconnectL() + { + TRACE_FUNC + LEAVE(KErrDisconnected); + } + +void CBasrvAccState::AccessoryConnected(TProfiles aProfile) + { + TRACE_FUNC + NewProfileConnection(aProfile); + StatePrint(_L("StateXXX")); + } + +void CBasrvAccState::AccOpenedAudio(TProfiles aProfile) + { + TRACE_FUNC + AccInfo().iAudioOpenedProfiles |= aProfile; + StatePrint(_L("StateXXX")); + } + +void CBasrvAccState::AccClosedAudio(TProfiles aProfile) + { + TRACE_FUNC + if (aProfile & EAnyMonoAudioProfiles) + AccInfo().iAudioOpenedProfiles &= ~EAnyMonoAudioProfiles; + else + AccInfo().iAudioOpenedProfiles &= ~aProfile; + StatePrint(_L("StateXXX")); + } + +void CBasrvAccState::AccessoryDisconnectedL(TProfiles /*aProfile*/) + { + TRACE_FUNC + } + +void CBasrvAccState::OpenAudioL(TAccAudioType /*aType*/) + { + TRACE_FUNC + } + +void CBasrvAccState::CloseAudioL(TAccAudioType /*aType*/) + { + TRACE_FUNC + } + +void CBasrvAccState::RequestCompletedL(CBasrvActive& /*aActive*/) + { + TRACE_FUNC + } + +void CBasrvAccState::CancelRequest(CBasrvActive& /*aActive*/) + { + TRACE_FUNC + } + +CBasrvAccState::CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest) + : iParent(aParent), iRequest(aRequest) + { + } + +CBasrvAcc& CBasrvAccState::Parent() + { + return iParent; + } + +void CBasrvAccState::CompleteStateRequest(TInt aErr) + { + if (iRequest) + { + User::RequestComplete(iRequest, aErr); + TRACE_INFO((_L("Request 0x%08X completed with %d"), iRequest, aErr)) + iRequest = NULL; + } + } + +void CBasrvAccState::CompleteRequest(TRequestStatus* aStatus, TInt aErr) + { + if (aStatus) + { + User::RequestComplete(aStatus, aErr); + TRACE_INFO((_L("Request 0x%08X completed with %d"), aStatus, aErr)) + } + } + +void CBasrvAccState::StatePrint(const TDesC& aStateName) + { + TRACE_INFO_SEG( + { + TBuf<12> buf; + AccInfo().iAddr.GetReadable(buf); + Trace(_L("[%S State %S] Profiles %04X, Connected %04X, withAudio %04X"), + &aStateName, &buf, AccInfo().iSuppProfiles, AccInfo().iConnProfiles, AccInfo().iAudioOpenedProfiles); + }); (void) aStateName; + } + +TAccInfo& CBasrvAccState::AccInfo() + { + return Parent().AccInfo(); + } + +void CBasrvAccState::NewProfileConnection(TProfiles aProfile) + { + AccInfo().iConnProfiles |= aProfile; + AccInfo().iSuppProfiles |= aProfile; + if (aProfile == ERemConCT && + Parent().AccMan().IsAvrcpVolCTSupported()&& + IsAvrcpTGCat2SupportedByRemote()) + { + AccInfo().iConnProfiles |= ERemConTG; + } + TRACE_INFO((_L("Profiles %04X, Connected %04X"), AccInfo().iSuppProfiles, AccInfo().iConnProfiles)) + } + +void CBasrvAccState::ProfileDisconnected(TProfiles aProfile) + { + if (aProfile & EAnyRemConProfiles) + { + AccInfo().iConnProfiles &= ~EAnyRemConProfiles; + } + else if (aProfile & EAnyMonoAudioProfiles) + { + AccInfo().iConnProfiles &= ~EAnyMonoAudioProfiles; + } + else + { + AccInfo().iConnProfiles &= ~aProfile; + } + } + +TBool CBasrvAccState::IsAvrcpTGCat2SupportedByRemote() + { + return (AccInfo().iSuppProfiles & ERemConTG) && + (AccInfo().iSupportedFeatures[TAccInfo::ERemConTGIndex] & KBitAvrcpSupportedFeatureCategory2); + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstateattach.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of Attach state. +* +*/ + + +// INCLUDE FILES +#include "basrvaccstateattach.h" +#include "basrvaccstatedisconnect.h" +#include "basrvaccstateattached.h" +#include "debug.h" + +const TInt KAttachRequestId = 10; + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccStateAttach* CBasrvAccStateAttach::NewL(CBasrvAcc& aParent, TBool aConnecting) + { + CBasrvAccStateAttach* self=new(ELeave) CBasrvAccStateAttach(aParent, aConnecting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBasrvAccStateAttach::~CBasrvAccStateAttach() + { + delete iActive; + TRACE_FUNC + } + +void CBasrvAccStateAttach::EnterL() + { + StatePrint(_L("Attach")); + Parent().AccMan().AccfwConnectionL(&(AccInfo()))->AttachAccessory(AccInfo().iAddr, iActive->iStatus); + iActive->GoActive(); + } + +CBasrvAccState* CBasrvAccStateAttach::ErrorOnEntry(TInt aReason) + { + TRACE_FUNC + TRAP_IGNORE(Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aReason, AccInfo().iSuppProfiles)); + CBasrvAccState* next = NULL; + TRAP_IGNORE(next = CBasrvAccStateDisconnect::NewL(Parent())); + return next; + } + +TBTEngConnectionStatus CBasrvAccStateAttach::ConnectionStatus() const + { + return EBTEngConnecting; + } + +void CBasrvAccStateAttach::CancelConnect() + { + TRACE_FUNC + iActive->Cancel(); + CBasrvAccState* next = NULL; + TRAP_IGNORE(next = CBasrvAccStateDisconnect::NewL(Parent())); + TRAP_IGNORE(Parent().ChangeStateL(next)); + } + + +void CBasrvAccStateAttach::DisconnectL() + { + TRACE_FUNC + iActive->Cancel(); + Parent().ChangeStateL(CBasrvAccStateDisconnect::NewL(Parent())); + } + +void CBasrvAccStateAttach::AccessoryDisconnectedL(TProfiles aProfile) + { + TRACE_FUNC + ProfileDisconnected(aProfile); + AccClosedAudio(aProfile); + StatePrint(_L("Attach")); + if (!AccInfo().iConnProfiles) + { + if (iConnecting) + { + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, KErrDisconnected, AccInfo().iSuppProfiles); + } + iActive->Cancel(); + Parent().ChangeStateL(NULL); + } + } + +void CBasrvAccStateAttach::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_FUNC + if (iConnecting && aActive.iStatus == KErrNone) + { + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aActive.iStatus.Int(), AccInfo().iConnProfiles); + } + + if (aActive.iStatus == KErrNone) + { + Parent().AccMan().ListenAudioRequestL(); + Parent().AccMan().PluginMan().AccInUse(); + Parent().ChangeStateL(CBasrvAccStateAttached::NewL(Parent(), !iConnecting)); + } + else + { + Parent().ChangeStateL(CBasrvAccStateDisconnect::NewL(Parent(), aActive.iStatus.Int())); + } + } + +void CBasrvAccStateAttach::CancelRequest(CBasrvActive& /*aActive*/) + { + TRACE_FUNC + CBasrvAccfwIf* accif = NULL; + TRAP_IGNORE(accif = Parent().AccMan().AccfwConnectionL()); + if (accif) + accif->CancelAttachAccessory(AccInfo().iAddr); + } + +CBasrvAccStateAttach::CBasrvAccStateAttach(CBasrvAcc& aParent, TBool aConnecting) + : CBasrvAccState(aParent, NULL), iConnecting(aConnecting) + { + } + +void CBasrvAccStateAttach::ConstructL() + { + iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KAttachRequestId); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstateattached.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstateattached.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,478 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of Connected state. +* Version : %version: 20 % +* +*/ + + +// INCLUDE FILES +#include +#include +#include "basrvaccstateattached.h" +#include "basrvaccstateattach.h" +#include "basrvaccstatedetach.h" +#include "basrvaccstatedisconnect.h" +#include "BTAccInfo.h" +#include "debug.h" + +const TInt KRequestIdOpenMonoAudio = 40; +const TInt KRequestIdOpenStereoAudio = 41; +const TInt KRequestIdCloseMonoAudio = 42; +const TInt KRequestIdCloseStereoAudio = 43; +const TInt KRequestIdTimer = 44; +const TInt KRequestIdMonoActiveModeRequest = 45; +const TInt KRequestIdStereoActiveModeRequest = 46; +const TInt KRequestIdConnectRemConTG = 47; + +const TInt KAudioCloseResponseDelay = 1200000; // 1.2 sec + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccStateAttached* CBasrvAccStateAttached::NewL(CBasrvAcc& aParent, TBool aShowNote) + { + CBasrvAccStateAttached* self=new(ELeave) CBasrvAccStateAttached(aParent, aShowNote); + return self; + } + +CBasrvAccStateAttached::~CBasrvAccStateAttached() + { + delete iRemConTGConnector; + delete iAudioOpener; + delete iAudioCloser; + delete iTimerActive; + iTimer.Close(); + TRACE_FUNC + } + +void CBasrvAccStateAttached::EnterL() + { + StatePrint(_L("Attached")); + iTimer.CreateLocal(); + if (AccInfo().iAudioOpenedProfiles) + { + if (AccInfo().iAudioOpenedProfiles & EStereo) + HandleAccOpenedAudio(EStereo); + if (AccInfo().iAudioOpenedProfiles & EHFP) + HandleAccOpenedAudio(EHFP); + if (AccInfo().iAudioOpenedProfiles & EHSP) + HandleAccOpenedAudio(EHSP); + } + else + { + Parent().RequestSniffMode(); + } + if (iShowNote) + { + Parent().AccMan().NotifyClientNewProfile(AccInfo().iConnProfiles, AccInfo().iAddr); + TInt callState; + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); + if(!err && (callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized)) + { + Parent().AccMan().ShowNote(EBTConnected, AccInfo().iAddr); + } + } + } + +CBasrvAccState* CBasrvAccStateAttached::ErrorOnEntry(TInt /*aReason*/) + { + TRACE_FUNC + CBasrvAccState* next = NULL; + TRAP_IGNORE(next = CBasrvAccStateDetach::NewL(Parent())); + return next; + } + +TBTEngConnectionStatus CBasrvAccStateAttached::ConnectionStatus() const + { + return EBTEngConnected; + } + +void CBasrvAccStateAttached::ConnectL(const TBTDevAddr& aAddr) + { + if (aAddr == AccInfo().iAddr) + { + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, KErrNone, AccInfo().iConnProfiles); + } + else + { + CBasrvAccState::ConnectL(aAddr); + } + } + +void CBasrvAccStateAttached::DisconnectL() + { + TRACE_FUNC + Parent().AccMan().RemoveAudioRequest(AccInfo().iAddr); + + if (AccInfo().iAudioOpenedProfiles) + { + TAccAudioType type = (AccInfo().iAudioOpenedProfiles & EAnyMonoAudioProfiles) + ? EAccMonoAudio : EAccStereoAudio; + Parent().AccMan().AccfwConnectionL()->NotifyAudioLinkCloseL(AccInfo().iAddr, type); + AccInfo().iAudioOpenedProfiles = EUnknownProfile; + } + + Parent().ChangeStateL(CBasrvAccStateDetach::NewL(Parent())); + } + +void CBasrvAccStateAttached::AccessoryConnected(TProfiles aProfile) + { + TRACE_FUNC + CBasrvAccState::AccessoryConnected(aProfile); + Parent().NotifyLinkChange2Rvc(); + Parent().AccMan().NotifyClientNewProfile(aProfile, AccInfo().iAddr); + } + +void CBasrvAccStateAttached::AccOpenedAudio(TProfiles aProfile) + { + TRACE_FUNC + delete iTimerActive; + iTimerActive = NULL; + HandleAccOpenedAudio(aProfile); + } + +void CBasrvAccStateAttached::AccClosedAudio(TProfiles aProfile) + { + TRACE_FUNC + UpdateAudioState(EAudioLinkClosed, (aProfile == EStereo) ? EAccStereoAudio : EAccMonoAudio); + CBasrvAccState::AccClosedAudio(aProfile); + Parent().NotifyLinkChange2Rvc(); + iCloseAudioProfile = aProfile; + if (!iTimerActive) + { + iTimerActive = CBasrvActive::New(*this, CActive::EPriorityStandard, KRequestIdTimer); + } + if (iTimerActive) + { + iTimerActive->Cancel(); + iTimer.After(iTimerActive->iStatus, KAudioCloseResponseDelay); + iTimerActive->GoActive(); + } + Parent().RequestSniffMode(); + StatePrint(_L("Attached")); + } + +void CBasrvAccStateAttached::AccessoryDisconnectedL(TProfiles aProfile) + { + TRACE_FUNC + delete iTimerActive; + iTimerActive = NULL; + TInt audiolinkcache = AccInfo().iAudioOpenedProfiles; + if ((AccInfo().iAudioOpenedProfiles & EStereo) && (aProfile & EStereo)) + { + Parent().RequestSniffMode(); + } + ProfileDisconnected(aProfile); + CBasrvAccState::AccClosedAudio(aProfile); + Parent().NotifyLinkChange2Rvc(); + Parent().AccMan().NotifyClientNoProfile(aProfile, AccInfo().iAddr); + StatePrint(_L("Attached")); + + // AudioPolicy wants to get a notification about audio link closes before + // detaches as well so here we go + if (audiolinkcache & aProfile || + iCloseAudioProfile & aProfile ) + { + TAccAudioType type = (aProfile & EAnyMonoAudioProfiles) + ? EAccMonoAudio : EAccStereoAudio; + Parent().AccMan().AccfwConnectionL()->NotifyAudioLinkCloseL(AccInfo().iAddr, type); + + // let's clear this variable here to be sure it's not used twice accidentally + iCloseAudioProfile = EUnknownProfile; + } + + if (!(AccInfo().iConnProfiles & EAnyAudioProfiles)) + { + Parent().AccMan().RemoveAudioRequest(AccInfo().iAddr); + Parent().ChangeStateL(CBasrvAccStateDetach::NewL(Parent())); + } + + } + +void CBasrvAccStateAttached::OpenAudioL(TAccAudioType aType) + { + TRACE_FUNC + TInt requestId = (aType == EAccMonoAudio) + ? KRequestIdMonoActiveModeRequest : KRequestIdStereoActiveModeRequest; + if (!iAudioOpener) + { + iAudioOpener = CBasrvActive::NewL(*this, CActive::EPriorityLow, requestId); + } + else + { + if (iAudioOpener->IsActive()) + { + LEAVE(KErrAlreadyExists); + } + iAudioOpener->SetRequestId(requestId); + } + Parent().RequestActiveMode(); + + // here we'll give time to the scheduler so that the active mode request has + // a chance to get through before the audio link open request - running + // with EPriorityLow for that + TRequestStatus* myStatus( &iAudioOpener->iStatus ); + *myStatus = KRequestPending; + iAudioOpener->GoActive(); + User::RequestComplete( myStatus, KErrNone ); + } + +void CBasrvAccStateAttached::CloseAudioL(TAccAudioType aType) + { + TRACE_FUNC + + DoCloseAudioL(aType); + } + +void CBasrvAccStateAttached::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_FUNC + TInt status = aActive.iStatus.Int(); + TInt requestid = aActive.RequestId(); + switch (requestid) + { + case KRequestIdOpenMonoAudio: + { + if (!status) + { + if (AccInfo().iSuppProfiles & EHFP) + NewProfileConnection(EHFP); + else + NewProfileConnection(EHSP); + } + TInt err = Parent().AccMan().OpenAudioCompleted(AccInfo().iAddr, EAccMonoAudio, status); + if ( (err && err != KErrAlreadyExists) || (status && status != KErrInUse && status != KErrAlreadyExists)) + { + if (Parent().AccMan().DisconnectIfAudioOpenFails()) + { + Parent().AccMan().RemoveAudioRequest(AccInfo().iAddr); + Parent().ChangeStateL(CBasrvAccStateDetach::NewL(Parent())); + } + } + else + { + UpdateAudioState(EAudioLinkOpen, EAccMonoAudio); + Parent().CancelPowerModeControl(); + AccInfo().iAudioOpenedProfiles |= (AccInfo().iConnProfiles & EAnyMonoAudioProfiles); + Parent().NotifyLinkChange2Rvc(); + } + break; + } + case KRequestIdCloseMonoAudio: + { + UpdateAudioState(EAudioLinkClosed, EAccMonoAudio); + Parent().RequestSniffMode(); + (void) Parent().AccMan().CloseAudioCompleted(AccInfo().iAddr, EAccMonoAudio, status); + break; + } + case KRequestIdOpenStereoAudio: + { + if (!status) + { + NewProfileConnection(EStereo); + } + TInt err = Parent().AccMan().OpenAudioCompleted(AccInfo().iAddr, EAccStereoAudio, status); + if ((status && status != KErrInUse && status != KErrAlreadyExists)) + { + if (status == KErrDisconnected) + { + ProfileDisconnected(EStereo); + } + if (Parent().AccMan().DisconnectIfAudioOpenFails()) + { + Parent().AccMan().RemoveAudioRequest(AccInfo().iAddr); + Parent().ChangeStateL(CBasrvAccStateDetach::NewL(Parent())); + } + } + else if (!err) + { + UpdateAudioState(EAudioLinkOpen, EAccStereoAudio); + Parent().PreventLowPowerMode(); + AccInfo().iAudioOpenedProfiles |= EStereo; + Parent().NotifyLinkChange2Rvc(); + DoConnectRemConCtIfNeededL(); + } + break; + } + case KRequestIdCloseStereoAudio: + { + UpdateAudioState(EAudioLinkClosed, EAccStereoAudio); + Parent().RequestSniffMode(); + (void) Parent().AccMan().CloseAudioCompleted(AccInfo().iAddr, EAccStereoAudio, status); + break; + } + case KRequestIdTimer: + { + TAccAudioType type = (iCloseAudioProfile & EAnyMonoAudioProfiles) + ? EAccMonoAudio : EAccStereoAudio; + Parent().AccMan().AccfwConnectionL()->NotifyAudioLinkCloseL(AccInfo().iAddr, type); + + // this variable needs to be cleared here so that the AccFW isn't notified a second time + // about the same audio link close during disconnection process + iCloseAudioProfile = EUnknownProfile; + break; + } + case KRequestIdMonoActiveModeRequest: + case KRequestIdStereoActiveModeRequest: + { + // the active mode request should have been scheduled at this point and we'll continue + // with audio link open request - going back to standard priority + TProfiles profile = ( requestid == KRequestIdMonoActiveModeRequest ) ? EHFP : EStereo; + Parent().AccMan().PluginMan().Plugin(profile)->OpenAudioLink(AccInfo().iAddr, + iAudioOpener->iStatus); + + TInt requestId = ( requestid == KRequestIdMonoActiveModeRequest ) + ? KRequestIdOpenMonoAudio : KRequestIdOpenStereoAudio; + iAudioOpener->SetPriority( CActive::EPriorityStandard ); + iAudioOpener->SetRequestId( requestId ); + iAudioOpener->GoActive(); + break; + } + case KRequestIdConnectRemConTG: + { + if (!status || status == KErrAlreadyExists) + { + NewProfileConnection(ERemConTG); + Parent().NotifyLinkChange2Rvc(); + } + delete iRemConTGConnector; + iRemConTGConnector = NULL; + break; + } + default: + { + } + } + } + +void CBasrvAccStateAttached::CancelRequest(CBasrvActive& aActive) + { + TRACE_FUNC + TInt request = aActive.RequestId(); + TAccAudioType type = (request == KRequestIdOpenMonoAudio || request == KRequestIdCloseMonoAudio ) ? + EAccMonoAudio : EAccStereoAudio; + TProfiles profile = (type == EAccMonoAudio) ? EAnyMonoAudioProfiles : EStereo; + CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(profile); + if (request == KRequestIdOpenMonoAudio || request == KRequestIdOpenStereoAudio) + { + plugin->CancelOpenAudioLink(AccInfo().iAddr); + Parent().AccMan().OpenAudioCompleted(AccInfo().iAddr, type, KErrCancel); + } + else if (request == KRequestIdCloseMonoAudio || request == KRequestIdCloseStereoAudio) + { + plugin->CancelCloseAudioLink(AccInfo().iAddr); + Parent().AccMan().CloseAudioCompleted(AccInfo().iAddr, type, KErrCancel); + } + else if (request == KRequestIdTimer) + { + iTimer.Cancel(); + } + else if (request == KRequestIdConnectRemConTG) + { + Parent().AccMan().PluginMan().Plugin(ERemConTG)->CancelConnectToAccessory(AccInfo().iAddr); + } + } + +CBasrvAccStateAttached::CBasrvAccStateAttached(CBasrvAcc& aParent, TBool aShowNote) + : CBasrvAccState(aParent, NULL), iShowNote(aShowNote) + { + } + +void CBasrvAccStateAttached::HandleAccOpenedAudio(TProfiles aProfile) + { + TRACE_FUNC + TAccAudioType type = (aProfile & EAnyMonoAudioProfiles) ? EAccMonoAudio : EAccStereoAudio; + TInt latency = Parent().AccMan().PluginMan().AudioLinkLatency(); + + TInt ret = Parent().AccMan().NotifyAccFwAudioOpened(AccInfo().iAddr, type, latency); + + if (ret == KErrNone) + { + UpdateAudioState(EAudioLinkOpen, (aProfile == EStereo) ? EAccStereoAudio : EAccMonoAudio); + + CBasrvAccState::AccOpenedAudio(aProfile); + Parent().NotifyLinkChange2Rvc(); + if (type == EAccStereoAudio) + { + Parent().RequestActiveMode(); + Parent().PreventLowPowerMode(); + Parent().AccMan().PluginMan().Plugin(EStereo)->StartRecording(); + TRAP_IGNORE(DoConnectRemConCtIfNeededL()); + } + else + { + Parent().CancelPowerModeControl(); + } + } + + StatePrint(_L("Attached")); + } + +void CBasrvAccStateAttached::DoCloseAudioL(TAccAudioType aType) + { + TRACE_FUNC + TAccAudioType type = (iCloseAudioProfile & EAnyMonoAudioProfiles) ? EAccMonoAudio : EAccStereoAudio; + if ( type == aType && iTimerActive && iTimerActive->IsActive()) + { + TRACE_STATE(_L("[BTAccStateAttached] Timer is cancelled")) + iTimerActive->Cancel(); + Parent().AccMan().CloseAudioCompleted(AccInfo().iAddr, type, KErrNone); + return; + } + + TInt requestId = (aType == EAccMonoAudio) ? KRequestIdCloseMonoAudio : KRequestIdCloseStereoAudio; + if (!iAudioCloser) + { + iAudioCloser = CBasrvActive::NewL(*this, CActive::EPriorityStandard, requestId); + } + else + { + if (iAudioCloser->IsActive()) + { + LEAVE(KErrAlreadyExists); + } + iAudioCloser->SetRequestId(requestId); + } + TProfiles profile = (aType == EAccMonoAudio) ? EAnyMonoAudioProfiles : EStereo; + AccInfo().iAudioOpenedProfiles &= ~profile; + Parent().NotifyLinkChange2Rvc(); + Parent().AccMan().PluginMan().Plugin(profile)->CloseAudioLink(AccInfo().iAddr, iAudioCloser->iStatus); + iAudioCloser->GoActive(); + } + +void CBasrvAccStateAttached::DoConnectRemConCtIfNeededL() + { + TRACE_FUNC + if (Parent().AccMan().IsAvrcpVolCTSupported() && + IsAvrcpTGCat2SupportedByRemote() && + !(AccInfo().iConnProfiles & ERemConTG) && + !iRemConTGConnector) + { + iRemConTGConnector = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KRequestIdConnectRemConTG); + CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(ERemConTG); + TRACE_ASSERT(plugin, KErrNotFound) + plugin->ConnectToAccessory(AccInfo().iAddr, iRemConTGConnector->iStatus); + iRemConTGConnector->GoActive(); + } + } + +void CBasrvAccStateAttached::UpdateAudioState(TBTAudioLinkState aState, TAccAudioType aType) + { + TBTAudioLinkInfo info; + info.iAddr = AccInfo().iAddr; + info.iProfile = (aType == EAccMonoAudio) ? 0 : 1; + info.iState = aState; + TPckgBuf pkg(info); + RProperty::Set(KPSUidBluetoothEnginePrivateCategory, KBTAudioLinkStatus, pkg); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of Connect state. +* +*/ + + +// INCLUDE FILES +#include "basrvaccstateconnect.h" +#include "basrvaccstateattach.h" +#include "basrvaccstateattached.h" +#include "debug.h" + +const TInt KConnectRequestId = 1; + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccStateConnect* CBasrvAccStateConnect::NewL(CBasrvAcc& aParent) + { + CBasrvAccStateConnect* self = new (ELeave) CBasrvAccStateConnect(aParent); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBasrvAccStateConnect::~CBasrvAccStateConnect() + { + delete iActive; + TRACE_FUNC + } + +void CBasrvAccStateConnect::EnterL() + { + StatePrint(_L("Connect")); + CBTAccPlugin* plugin = NULL; + if (AccInfo().iSuppProfiles & EHFP) + { + iConnectingProfile = EHFP; + } + else if (AccInfo().iSuppProfiles & EHSP) + { + iConnectingProfile = EHSP; + } + else if (AccInfo().iSuppProfiles & EStereo) + { + iConnectingProfile = EStereo; + } + plugin = Parent().AccMan().PluginMan().Plugin(iConnectingProfile); + LEAVE_IF_NULL(plugin) + plugin->ConnectToAccessory(AccInfo().iAddr, iActive->iStatus); + iActive->GoActive(); + } + +CBasrvAccState* CBasrvAccStateConnect::ErrorOnEntry(TInt aReason) + { + TRACE_FUNC + TRAP_IGNORE(Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aReason, AccInfo().iSuppProfiles)); + return NULL; + } + +TBTEngConnectionStatus CBasrvAccStateConnect::ConnectionStatus() const + { + return EBTEngConnecting; + } + + +void CBasrvAccStateConnect::CancelConnect() + { + TRACE_FUNC + iActive->Cancel(); + TRAP_IGNORE(Parent().ChangeStateL(NULL)); + } + +void CBasrvAccStateConnect::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_FUNC + if (aActive.iStatus == KErrNone) + { + AccInfo().iConnProfiles |= iConnectingProfile; + Parent().ChangeStateL(CBasrvAccStateAttach::NewL(Parent(), ETrue)); + } + else + { + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aActive.iStatus.Int(), AccInfo().iSuppProfiles); + Parent().ChangeStateL(NULL); + } + } + +void CBasrvAccStateConnect::CancelRequest(CBasrvActive& /*aActive*/) + { + TRACE_FUNC + Parent().AccMan().PluginMan().Plugin(iConnectingProfile)->CancelConnectToAccessory(AccInfo().iAddr); + } + +CBasrvAccStateConnect::CBasrvAccStateConnect(CBasrvAcc& aParent) + : CBasrvAccState(aParent, NULL) + { + } + +void CBasrvAccStateConnect::ConstructL() + { + iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KConnectRequestId); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of Attach state. +* +*/ + + +// INCLUDE FILES +#include +#include +#include "basrvaccstatedetach.h" +#include "basrvaccstatedisconnect.h" +#include "BTAccFwIf.h" +#include "debug.h" + +const TInt KDetachRequestId = 10; + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccStateDetach* CBasrvAccStateDetach::NewL(CBasrvAcc& aParent) + { + CBasrvAccStateDetach* self=new(ELeave) CBasrvAccStateDetach(aParent); + return self; + } + +CBasrvAccStateDetach::~CBasrvAccStateDetach() + { + delete iActive; + delete iAccfw; + TRACE_FUNC + } + +void CBasrvAccStateDetach::EnterL() + { + StatePrint(_L("Detach")); + // Stop any volume control + AccInfo().iAudioOpenedProfiles = EUnknownProfile; + Parent().NotifyLinkChange2Rvc(); + iAccfw = Parent().AccMan().NewAccfwConnectionInstanceL(); + iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KDetachRequestId); + iAccfw->DetatchAccessory(AccInfo().iAddr, iActive->iStatus); + iActive->GoActive(); + } + +CBasrvAccState* CBasrvAccStateDetach::ErrorOnEntry(TInt aReason) + { + TRACE_FUNC + TRAP_IGNORE(Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aReason, AccInfo().iSuppProfiles)); + CBasrvAccState* next = NULL; + TRAP_IGNORE(next = CBasrvAccStateDisconnect::NewL(Parent())); + return next; + } + +TBTEngConnectionStatus CBasrvAccStateDetach::ConnectionStatus() const + { + return EBTEngDisconnecting; + } + +void CBasrvAccStateDetach::AccessoryDisconnectedL(TProfiles aProfile) + { + TRACE_FUNC + ProfileDisconnected(aProfile); + StatePrint(_L("Detach")); + } + +void CBasrvAccStateDetach::OpenAudioL(TAccAudioType /*aType*/) + { + TRACE_FUNC + LEAVE(KErrDisconnected); + } + +void CBasrvAccStateDetach::CloseAudioL(TAccAudioType /*aType*/) + { + TRACE_FUNC + LEAVE(KErrDisconnected); + } + +void CBasrvAccStateDetach::RequestCompletedL(CBasrvActive& /*aActive*/) + { + TRACE_FUNC + Parent().AccMan().PluginMan().AccOutOfUse(); + TInt callState; + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); + if(!err && (callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized)) + { + Parent().AccMan().ShowNote(EBTClosed, AccInfo().iAddr); + } + + if (AccInfo().iConnProfiles) + { + Parent().ChangeStateL(CBasrvAccStateDisconnect::NewL(Parent())); + } + else + { + Parent().ChangeStateL(NULL); + } + } + +void CBasrvAccStateDetach::CancelRequest(CBasrvActive& /*aActive*/) + { + } + +CBasrvAccStateDetach::CBasrvAccStateDetach(CBasrvAcc& aParent) + : CBasrvAccState(aParent, NULL) + { + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of Disconnect state. +* +*/ + + +// INCLUDE FILES +#include "basrvaccstatedisconnect.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccStateDisconnect* CBasrvAccStateDisconnect::NewL(CBasrvAcc& aParent, TInt aConnErr) + { + CBasrvAccStateDisconnect* self=new(ELeave) CBasrvAccStateDisconnect(aParent, aConnErr); + return self; + } + +CBasrvAccStateDisconnect::~CBasrvAccStateDisconnect() + { + delete iActive; + TRACE_FUNC + } + +void CBasrvAccStateDisconnect::EnterL() + { + StatePrint(_L("Disconnect")); + iProfiles = AccInfo().iConnProfiles; + Parent().RequestActiveMode(); + DoDisconnectL(); + } + +CBasrvAccState* CBasrvAccStateDisconnect::ErrorOnEntry(TInt /*aReason*/) + { + TRACE_FUNC + return NULL; + } + +TBTEngConnectionStatus CBasrvAccStateDisconnect::ConnectionStatus() const + { + if (iConnErr) + return EBTEngConnecting; + return EBTEngDisconnecting; + } + +void CBasrvAccStateDisconnect::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_INFO((_L("Disconnect 0x%02x done, err %d"), aActive.RequestId(), iDiscErr)) + if (!iDiscErr) + iDiscErr = aActive.iStatus.Int(); + AccInfo().iConnProfiles &= ~(aActive.RequestId()); + StatePrint(_L("Disconnect")); + if (!AccInfo().iConnProfiles) + { + if (iConnErr) + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, iConnErr, AccInfo().iSuppProfiles); + else + Parent().AccMan().DisconnectCompletedL(AccInfo().iAddr, iProfiles, KErrNone); + Parent().ChangeStateL(NULL); + } + else + { + DoDisconnectL(); + } + } + +void CBasrvAccStateDisconnect::CancelRequest(CBasrvActive& /*aActive*/) + { + } + +CBasrvAccStateDisconnect::CBasrvAccStateDisconnect(CBasrvAcc& aParent, TInt aConnErr) + : CBasrvAccState(aParent, NULL), iConnErr(aConnErr) + { + } + +void CBasrvAccStateDisconnect::DoDisconnectL() + { + TRACE_FUNC + TProfiles profile = EUnknownProfile; + CBTAccPlugin* plugin = NULL; + if (AccInfo().iConnProfiles & EStereo) + { + profile = EStereo; + } + else if (AccInfo().iConnProfiles & EAnyRemConProfiles) + { + profile = EAnyRemConProfiles; + } + else if (AccInfo().iConnProfiles & EAnyMonoAudioProfiles ) + { + profile = EAnyMonoAudioProfiles; + } + plugin = Parent().AccMan().PluginMan().Plugin(profile); + if (plugin) + { + if (!iActive) + { + iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, profile); + } + iActive->SetRequestId(profile); + plugin->DisconnectAccessory(AccInfo().iAddr, iActive->iStatus); + iActive->GoActive(); + TRACE_INFO((_L("Disconnect 0x%02x ..."), profile)) + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvaccstatequery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,230 @@ +/* +* Copyright (c) 2005-2006 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: Implementation of Query state. +* +*/ + + +// INCLUDE FILES +#include //device type definitions +#include "basrvaccstatequery.h" +#include "basrvaccstateconnect.h" +#include "basrvaccstatedisconnect.h" +#include "basrvaccstateattach.h" +#include "basrvaccstateattached.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvAccStateQuery* CBasrvAccStateQuery::NewL(CBasrvAcc& aParent, TBool aConnectingRequest) + { + CBasrvAccStateQuery* self=new(ELeave) CBasrvAccStateQuery(aParent, aConnectingRequest); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBasrvAccStateQuery::~CBasrvAccStateQuery() + { + delete iQuery; + TRACE_FUNC + } + +void CBasrvAccStateQuery::EnterL() + { + StatePrint(_L("Query")); + // (NOT iConnecting) -> Headset connects to phone, SDP failure is tolerated. + iQuery->QueryAccInfoL(AccInfo().iAddr, !iConnecting); + Parent().RequestActiveMode(); + Parent().PreventLowPowerMode(); + } + +CBasrvAccState* CBasrvAccStateQuery::ErrorOnEntry(TInt aReason) + { + TRACE_FUNC + if (iConnecting) + { + TRAP_IGNORE(Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aReason, 0)); + } + return NULL; + } + +TBTEngConnectionStatus CBasrvAccStateQuery::ConnectionStatus() const + { + return EBTEngConnecting; + } + +void CBasrvAccStateQuery::CancelConnect() + { + TRACE_FUNC + if (iConnecting) + { + delete iQuery; + iQuery = NULL; + TRAP_IGNORE(Parent().ChangeStateL(NULL)); + } + } + +void CBasrvAccStateQuery::DisconnectL() + { + TRACE_FUNC + delete iQuery; + iQuery = NULL; + if (AccInfo().iConnProfiles) + { + Parent().ChangeStateL(CBasrvAccStateDisconnect::NewL(Parent())); + } + else + { + Parent().ChangeStateL(NULL); + } + } + +void CBasrvAccStateQuery::AccessoryDisconnectedL(TProfiles aProfile) + { + TRACE_FUNC + ProfileDisconnected(aProfile); + AccClosedAudio(aProfile); + StatePrint(_L("Query")); + if (!AccInfo().iConnProfiles && !iConnecting) + { + delete iQuery; + iQuery = NULL; + Parent().ChangeStateL(NULL); + } + } + +void CBasrvAccStateQuery::GetAccInfoCompletedL(TInt aErr, const TAccInfo* aAcc, const TBTDeviceClass* aCod) + { + TRACE_FUNC + CBasrvAccState* next = NULL; + if ( ( aErr || !aAcc || !(aAcc->iSuppProfiles & EAnyAudioProfiles) ) && + ( iConnecting || !(AccInfo().iConnProfiles ) )) + { + TInt err = (aErr) ? aErr : KErrNotSupported; + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, err, 0); + Parent().ChangeStateL(next); + return; + } + + if (aAcc) + { + TInt exist_conns = AccInfo().iConnProfiles; + TInt exist_audios = AccInfo().iAudioOpenedProfiles; + AccInfo() = *aAcc; + AccInfo().iAudioOpenedProfiles = exist_audios; + AccInfo().iConnProfiles = exist_conns; + AccInfo().iSuppProfiles |= exist_conns; + } + + // Take HFP supported feature from BTMAC if it is not available + if ( ( AccInfo().iConnProfiles & EHFP ) && + AccInfo().iSupportedFeatures[TAccInfo::EHFPIndex] == 0 ) + { + CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(EHFP);; + AccInfo().SetSupportedFeature((TUint16)plugin->GetRemoteSupportedFeature(), TAccInfo::EHFPIndex); + } + + // if e.g. A2DP is supported by headset but BTSAC is not in ROM, filter it. + Parent().AccMan().FilterProfileSupport(AccInfo()); + + RArray conflicts; + CleanupClosePushL(conflicts); + ResolveConflicts(conflicts); + if (conflicts.Count()) + { + if (iConnecting) + { + Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, KErrAlreadyExists, 0, &conflicts); + } + if (AccInfo().iConnProfiles) + { + next = CBasrvAccStateDisconnect::NewL(Parent()); + } + } + else + { + // Guess if this is a carkit or headset using the CoD info + if (aCod && (aCod->MajorServiceClass() & EMajorServiceAudioService) && + (aCod->MajorDeviceClass() & EMajorDeviceAudioDevice )) + { + if (aCod->MinorDeviceClass() == EMinorDeviceAVHandsfree || + aCod->MinorDeviceClass() == EMinorDeviceAVCarAudio) + { + AccInfo().SetDeviceType(KDTCarKit); + TRACE_INFO((_L("Device is a carkit."))); + } + else + { + AccInfo().SetDeviceType(KDTHeadset); + TRACE_INFO((_L("Device is a headset."))); + } + } + else + { + AccInfo().SetDeviceType(KDTHeadset); + TRACE_INFO((_L("Device is a headset."))); + } + + if (iConnecting) + { + next = CBasrvAccStateConnect::NewL(Parent()); + } + else if (AccInfo().iConnProfiles) + { + next = CBasrvAccStateAttach::NewL(Parent(), iConnecting); + } + } + CleanupStack::PopAndDestroy(&conflicts); + Parent().ChangeStateL(next); + } + +CBasrvAccStateQuery::CBasrvAccStateQuery(CBasrvAcc& aParent, TBool aConnectingRequest) + : CBasrvAccState(aParent, NULL), iConnecting(aConnectingRequest) + { + } + +void CBasrvAccStateQuery::ConstructL() + { + iQuery = CBasrvSdpQuery::NewL(*this); + } + +void CBasrvAccStateQuery::ResolveConflicts(RArray& aConflicts) + { + RPointerArray infos; + TInt err = Parent().AccMan().AccInfos(infos); + + if (err == KErrNone) + { + TInt supportedByThis = AccInfo().iSuppProfiles; + + // HFP and HSP are mutual exclusive, i.e. can only have one connected at a time. + if (supportedByThis & EAnyMonoAudioProfiles) + { + supportedByThis |= EAnyMonoAudioProfiles; + } + + for (TInt i = 0; i < infos.Count(); i++) + { + if ((infos[i]->iAddr != AccInfo().iAddr) && + (infos[i]->iSuppProfiles & supportedByThis)) + { + aConflicts.Append(infos[i]->iAddr); + } + } + + infos.Close(); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2005-2006 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: The base active class definition +* +*/ + + +#include "basrvactive.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBasrvActive* CBasrvActive::New(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + return new CBasrvActive(aObserver, aPriority, aRequestId); + } + +CBasrvActive* CBasrvActive::NewL(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CBasrvActive* self = CBasrvActive::NewLC(aObserver, aPriority, aRequestId); + CleanupStack::Pop(self); + return self; + } + +CBasrvActive* CBasrvActive::NewLC(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CBasrvActive* self = new (ELeave) CBasrvActive(aObserver, aPriority, aRequestId); + CleanupStack::PushL(self); + return self; + } + +CBasrvActive::~CBasrvActive() + { + Cancel(); + TRACE_FUNC + } + +void CBasrvActive::GoActive() + { + TRACE_ASSERT(!IsActive(), -2); + SetActive(); + TRACE_INFO((_L("CBasrvActive: Service %d starts"), iRequestId)) + } + +TInt CBasrvActive::RequestId() const + { + return iRequestId; + } + +void CBasrvActive::SetRequestId(TInt aRequestId) + { + iRequestId = aRequestId; + } + +void CBasrvActive::DoCancel() + { + iObserver.CancelRequest(*this); + TRACE_INFO((_L("Service %d cancelled"), iRequestId)) + } + +void CBasrvActive::RunL() + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("Service %d completed with %d"), iRequestId, iStatus.Int())) + iObserver.RequestCompletedL(*this); + TRACE_FUNC_EXIT + } + +TInt CBasrvActive::RunError(TInt aError) + { + TRACE_INFO((_L("Service %d RunError with %d"), iRequestId, aError)) + (void) aError; + return KErrNone; + } + +CBasrvActive::CBasrvActive(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + : CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) + { + CActiveScheduler::Add(this); + TRACE_FUNC + } + +MBasrvActiveObserver& CBasrvActive::Observer() + { + return iObserver; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvactivenotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvactivenotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2005-2006 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: The base active class definition +* +*/ + + +#include "basrvactivenotifier.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBasrvActiveNotifier* CBasrvActiveNotifier::NewL(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId, const TBTDevAddr& aAddr, TBTGenericInfoNoteType aNote) + { + CBasrvActiveNotifier* self = new (ELeave) CBasrvActiveNotifier( + aObserver, aPriority, aRequestId, aAddr, aNote); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBasrvActiveNotifier::~CBasrvActiveNotifier() + { + Cancel(); + iNotifier.Close(); + TRACE_FUNC + } + +void CBasrvActiveNotifier::GoActive() + { + } + +void CBasrvActiveNotifier::DoCancel() + { + iNotifier.CancelNotifier(KBTGenericInfoNotifierUid); + TRACE_INFO((_L("Service %d cancelled"), RequestId())) + } + +CBasrvActiveNotifier::CBasrvActiveNotifier(MBasrvActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId, const TBTDevAddr& aAddr, TBTGenericInfoNoteType aNote) + : CBasrvActive(aObserver, aPriority, aRequestId) + { + TRACE_FUNC + iPckg().iRemoteAddr.Copy( aAddr.Des() ); + iPckg().iMessageType = aNote; + } + +void CBasrvActiveNotifier::ConstructL() + { + LEAVE_IF_ERROR(iNotifier.Connect()); + iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericInfoNotifierUid, iPckg, iNoResult); + SetActive(); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvmain.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2005-2006 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: Contains global dll entry of BT Accessory Server which also creates +* first instance of the server. +* +*/ + + +#include "debug.h" +#include "BTAccServer.h" // create instance of server +#include "BTAccClientSrv.h" // server name + +static void RunServerL(); + +/** +* Main entry-point for the server process. +* Its a global definition, so GLDEF_C keyword can be omitted though. +**/ +GLDEF_C TInt E32Main() + { + TRACE_STATIC_FUNC + + __UHEAP_MARK; + CTrapCleanup* cleanup=CTrapCleanup::New(); + TInt r=KErrNoMemory; + if (cleanup) + { + TRAP(r,RunServerL()); + delete cleanup; + } + // + __UHEAP_MARKEND; + return r; + } + +/** +Create the active scheduler and server instances, and start the +server. +*/ +static void RunServerL() + { + + User::LeaveIfError(User::RenameThread(KBTAudioManName)); + + // Create and install the active scheduler. + CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; + CleanupStack::PushL(scheduler); + CActiveScheduler::Install(scheduler); + + // Create the server. NB Odd syntax in this line because we never refer to + // it directly- it's always owned by the cleanup stack! + (void)CBTAccServer::NewLC(); + + // Initialisation complete, now signal the client + RProcess::Rendezvous(KErrNone); + + // Ready to run. This only returns when the server is closing down. + CActiveScheduler::Start(); + + // Clean up the server and scheduler. + CleanupStack::PopAndDestroy(2, scheduler); + + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvpluginman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvpluginman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2005-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. +* Version : %version: 1.1.2.2.7 % +* +* Contributors: +* +* Description: +* Loads/unloads plugins and handles messaging between plugins and server class. +* +*/ + + +// INCLUDE FILES +#include // User:: ( User class declaration ) +#include +#include "btaccTypes.h" +#include "basrvpluginman.h" +#include "btaccObserver.h" +#include "btaccPlugin.h" // Plugin interface +#include "debug.h" +#include "btaccParams.h" // T-class consisting of parameteres sent to plugins +#include "utils.h" + +// CONSTANTS + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// NewL +// --------------------------------------------------------- +// +CBasrvPluginMan* CBasrvPluginMan::NewL() + { + CBasrvPluginMan* self=new(ELeave) CBasrvPluginMan(); + return self; + } + +// Destructor +CBasrvPluginMan::~CBasrvPluginMan() + { + TRACE_FUNC + UnloadPlugins(); + iPlugins.Close(); + } + +void CBasrvPluginMan::AccInUse() + { + TRACE_FUNC + TInt count = iPlugins.Count(); + for (TInt i = 0; i < count; i++) + { + iPlugins[i]->AccInUse(); + } + } + +void CBasrvPluginMan::AccOutOfUse() + { + TRACE_FUNC + TInt count = iPlugins.Count(); + for (TInt i = 0; i < count; i++) + { + iPlugins[i]->AccOutOfUse(); + } + } + +TInt CBasrvPluginMan::AvailablePlugins() + { + TInt avai = 0; + TInt count = iPlugins.Count(); + for (TInt i = 0; i < count; i++) + { + avai |= iPlugins[i]->PluginType(); + } + return avai; + } + +void CBasrvPluginMan::LoadPluginsL(MBTAccObserver& aObserver) + { + TRACE_FUNC + if (iPlugins.Count()) + { + return; + } + const TUid KUidBTAccPluginInterface = TUid::Uid(KBTAccPluginInterfaceUid); + RImplInfoPtrArray implementations; + const TEComResolverParams noResolverParams; + REComSession::ListImplementationsL(KUidBTAccPluginInterface, + noResolverParams, + KRomOnlyResolverUid, + implementations); + CleanupResetDestroyClosePushL(implementations); + const TUint count = implementations.Count(); + + TRACE_INFO((_L("number of implementations of plugin interface: %d"), count)) + CBTAccPlugin* plugin( NULL ); + TInt err; + for (TUint i = 0 ; i < count; ++i) + { + CImplementationInformation* impl = implementations[i]; + TPluginParams params(impl->ImplementationUid(), aObserver); + // If loading a plugin failed, + // the consequence is the service provided by this plugin is not available. + // Other services that have been successfully loaded are still usable. + TRAP( err, plugin = CBTAccPlugin::NewL(params) ); + if ( !err ) + { + CleanupStack::PushL(plugin); + iPlugins.AppendL(plugin); + CleanupStack::Pop(plugin); + } + TRACE_INFO((_L("Load plugin \'%S\', err %d"), &(impl->DisplayName()), err ) ); + } + + CleanupStack::PopAndDestroy(&implementations); + if (!iPlugins.Count()) + { + LEAVE(KErrNotFound); + } + } + +// --------------------------------------------------------- +// CBasrvPluginMan::UnloadPlugins +// --------------------------------------------------------- +// +void CBasrvPluginMan::UnloadPlugins() + { + TRACE_FUNC + iPlugins.ResetAndDestroy(); + REComSession::FinalClose(); + } + +CBTAccPlugin* CBasrvPluginMan::Plugin(TProfiles aProfile) + { + TInt count = iPlugins.Count(); + for (TInt i = 0; i < count; i++) + { + if (iPlugins[i]->PluginType() & aProfile) + { + return iPlugins[i]; + } + } + return NULL; + } + +TInt CBasrvPluginMan::AudioLinkLatency() + { + TRACE_FUNC + CBTAccPlugin* plugin = Plugin(EAnyMonoAudioProfiles); + + if (plugin) + { + return plugin->AudioLinkLatency(); + } + else + { + return 0; + } + } + +CBasrvPluginMan::CBasrvPluginMan() + { + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvpowercontrolagent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvpowercontrolagent.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,210 @@ +/* +* Copyright (c) 2005-2007 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 FILES +#include "basrvpowercontrolagent.h" +#include "debug.h" + +enum TActiveRequestId + { + ESniffDelayTimer = 80, + EBbEventSubscribe = 81, + }; + +const TInt KSniffRequesterDelay = 5000000; // 5 secs + +CBasrvPowerControlAgent* CBasrvPowerControlAgent::NewL(const TBTDevAddr& aAddr) + { + CBasrvPowerControlAgent* self = new CBasrvPowerControlAgent(aAddr); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBasrvPowerControlAgent::~CBasrvPowerControlAgent() + { + TRACE_FUNC + delete iBbEventer; + delete iSniffDelayTimer; + iTimer.Close(); + iPlAda.Close(); + iSockServ.Close(); + } + +void CBasrvPowerControlAgent::RequestSniffMode() + { + TRACE_FUNC + if (iState == ESniffModeRequested || iState == ESniffModeTiming) + { + return; + } + if (iState == EActiveModeRequested) + { + iPlAda.CancelLowPowerModeRequester(); + } + iState = ESniffModeTiming; + iTimer.After(iSniffDelayTimer->iStatus, KSniffRequesterDelay); + iSniffDelayTimer->GoActive(); + TRACE_INFO(_L("CBasrvPowerControlAgent, [Sniff mode Timing]")) + } + +void CBasrvPowerControlAgent::RequestActiveMode() + { + TRACE_FUNC + if (iState == EActiveModeRequested) + { + return; + } + if (iState == ESniffModeTiming) + { + iSniffDelayTimer->Cancel(); + } + TInt err = iPlAda.ActivateActiveRequester(); + if (!err) + { + iState = EActiveModeRequested; + TRACE_INFO(_L("CBasrvPowerControlAgent, [Active mode requested]")) + } + else + { + TRACE_INFO((_L("CBasrvPowerControlAgent, ActivateActiveRequester %d"), err)) + iState = EPowerModeDefault; + } + } + +void CBasrvPowerControlAgent::CancelPowerModeControl() + { + TRACE_FUNC + if (iState == ESniffModeTiming) + { + iSniffDelayTimer->Cancel(); + } + else if (iState == ESniffModeRequested || iState == EActiveModeRequested) + { + iPlAda.CancelLowPowerModeRequester(); + } + iState = EPowerModeDefault; + TRACE_INFO(_L("CBasrvPowerControlAgent, [Power mode default]")) + } + +void CBasrvPowerControlAgent::PreventLowPowerMode() + { + TRACE_FUNC + (void) iPlAda.PreventLowPowerModes(EAnyLowPowerMode); + } + +void CBasrvPowerControlAgent::AllowLowPowerMode() + { + TRACE_FUNC + (void) iPlAda.AllowLowPowerModes(EAnyLowPowerMode); + } + + +void CBasrvPowerControlAgent::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_FUNC + switch (aActive.RequestId()) + { + case ESniffDelayTimer: + { + DosniffRequest(); + break; + } + case EBbEventSubscribe: + { + TRACE_INFO((_L("CBasrvPowerControlAgent, err %d, event 0x%02X"), aActive.iStatus.Int(), iBbEvent().EventType())) + if (aActive.iStatus != KErrNone) + return; + switch(iBbEvent().EventType()) + { + case ENotifyActiveMode://0x04 + { + if (iState == ESniffModeTiming || iState == ESniffModeRequested) + { + CancelPowerModeControl(); + } + break; + } + case ENotifySniffMode: //0x08 + { + if (iState == ESniffModeTiming) + { + iSniffDelayTimer->Cancel(); + DosniffRequest(); + } + break; + } + default: + { + TRACE_INFO((_L("CBasrvPowerControlAgent, Uninteresting event (0x%08X)"), iBbEvent().EventType())) + } + } + iPlAda.NotifyNextBasebandChangeEvent(iBbEvent, iBbEventer->iStatus, ENotifyAnyPowerMode); + iBbEventer->GoActive(); + } + } + } + +void CBasrvPowerControlAgent::CancelRequest(CBasrvActive& aActive) + { + TRACE_FUNC + if (aActive.RequestId() == ESniffDelayTimer) + { + iTimer.Cancel(); + } + else if (aActive.RequestId() == EBbEventSubscribe) + { + iPlAda.CancelNextBasebandChangeEventNotifier(); + } + } + +CBasrvPowerControlAgent::CBasrvPowerControlAgent(const TBTDevAddr& aAddr) + : iAddr(aAddr) + { + TRACE_FUNC + } + +void CBasrvPowerControlAgent::ConstructL() + { + LEAVE_IF_ERROR(iSockServ.Connect()) + LEAVE_IF_ERROR(iPlAda.Open(iSockServ, iAddr)) + iBbEventer = CBasrvActive::NewL(*this, CActive::EPriorityStandard, EBbEventSubscribe); + iSniffDelayTimer = CBasrvActive::NewL(*this, CActive::EPriorityStandard, ESniffDelayTimer); + LEAVE_IF_ERROR(iTimer.CreateLocal()) + iPlAda.NotifyNextBasebandChangeEvent(iBbEvent, iBbEventer->iStatus, ENotifyAnyPowerMode); + iBbEventer->GoActive(); + } + +void CBasrvPowerControlAgent::DosniffRequest() + { + TRACE_FUNC + (void) iPlAda.AllowLowPowerModes(EAnyLowPowerMode); + (void) iPlAda.CancelLowPowerModeRequester(); + TInt err = iPlAda.ActivateSniffRequester(); + if (!err) + { + TRACE_INFO(_L("CBasrvPowerControlAgent, [Sniff mode requested]")) + iState = ESniffModeRequested; + } + else + { + TRACE_INFO((_L("CBasrvPowerControlAgent, ActivateSniffRequester %d"), err)) + iState = EPowerModeDefault; + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvrvc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvrvc.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2005-2007 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: Implementation of remote volume control. +* +*/ + + +// INCLUDE FILES +#include "basrvrvc.h" +#include "basrvacc.h" +#include "basrvaccman.h" +#include "basrvpluginman.h" +#include "btaccPlugin.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvRvc* CBasrvRvc::New(CBasrvAcc& aAccMan) + { + CBasrvRvc* self = new CBasrvRvc(aAccMan); + return self; + } + +CBasrvRvc::~CBasrvRvc() + { + CBTAccPlugin* plugin = NULL; + plugin = iAcc.AccMan().PluginMan().Plugin(iRvcMaster); + if (plugin) + plugin->DeActivateRemoteVolumeControl(); + TRACE_FUNC + } + +void CBasrvRvc::Update(TInt aConnectedProfiles, TInt aProfileCarryingAudio) + { + TRACE_FUNC + iConnectedProfiles = aConnectedProfiles; + iProfileCarryingAudio = aProfileCarryingAudio; + DoUpdateRvcMaster(); + } + +CBasrvRvc::CBasrvRvc(CBasrvAcc& aAcc) + : iAcc(aAcc) + { + TRACE_FUNC + } + +void CBasrvRvc::DoUpdateRvcMaster() + { + TRACE_FUNC + TProfiles newMaster = EUnknownProfile; + if ((iProfileCarryingAudio == EStereo) && (iConnectedProfiles & ERemConTG)) + newMaster = ERemConTG; + else if (iProfileCarryingAudio & EAnyMonoAudioProfiles) + newMaster = EAnyMonoAudioProfiles; + TRACE_INFO((_L(" audio carrier 0x%02x, conns 0x%04x"), iProfileCarryingAudio, iConnectedProfiles)) + TRACE_INFO((_L(" [RVC master update] current 0x%02x, new 0x%02x"), iRvcMaster, newMaster)) + + if (iRvcMaster != newMaster) + { + CBTAccPlugin* plugin = iAcc.AccMan().PluginMan().Plugin(iRvcMaster); + if (plugin) + { + plugin->DeActivateRemoteVolumeControl(); + } + plugin = iAcc.AccMan().PluginMan().Plugin(newMaster); + if (plugin) + { + plugin->ActivateRemoteVolumeControl(); + TRACE_INFO((_L(" [RVC master update] 0x%02x took the role"), newMaster)) + } + iRvcMaster = newMaster; + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/basrvsdpquery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/basrvsdpquery.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,392 @@ +/* +* Copyright (c) 2006 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: +* This class handles asynchronous SDP queries +* +*/ + + +// INCLUDE FILES +#include "basrvsdpquery.h" +#include "btaccTypes.h" +#include "debug.h" + +enum TQueryRequestId + { + ECreateView = 70, + EGetResponse = 71 + }; + + +// ================= MEMBER FUNCTIONS ======================= + +CBasrvSdpQuery* CBasrvSdpQuery::NewL(MBasrvSdpQuerier& aQuerier) + { + CBasrvSdpQuery* self = new (ELeave) CBasrvSdpQuery(aQuerier); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +CBasrvSdpQuery::~CBasrvSdpQuery() + { + if (iSdpAgent) + { + iSdpAgent->Cancel(); + } + delete iSdpAgent; + delete iSdpSearchPattern; + iServiceAttrs.Close(); + delete iResponse; + iReg.Close(); + delete iActive; + iRegServ.Close(); + } + +void CBasrvSdpQuery::QueryAccInfoL(const TBTDevAddr& aAddr, TBool aTolerateSdpError) + { + if (iSdpAgent) + { + User::Leave(KErrInUse); + } + iAddr = aAddr; + iServiceAttrs.Reset(); + TBTSdpAttrInt SF; //TBTSupportedFeature SF; + SF.iAttrValue = 0; + SF.iUUID = KAudioSinkUUID; + SF.iAttrID = KSdpAttrIdSupportedFeatures; + iServiceAttrs.Append(SF); // Advanced Audio Distribution Profile - BT Stereo Audio + + SF.iUUID = 0x111e; // HFP + SF.iAttrID = KSdpAttrIdSupportedFeatures; + iServiceAttrs.Append(SF); // BT Handsfree Profile - BT Mono Audio + + SF.iUUID = 0x1108; // HSP + SF.iAttrID = 0x0302; // Atti id of remote volume control + iServiceAttrs.Append(SF); // BT Headset Profile - BT Mono Audio + + SF.iUUID = KAVRemoteControlTargetUUID; + SF.iAttrID = KSdpAttrIdSupportedFeatures; + iServiceAttrs.Append(SF); // Audio Video Remote Control Profile + + SF.iUUID = KAVRemoteControlTargetUUID; + SF.iAttrID = KSdpAttrIdBluetoothProfileDescriptorList; + iServiceAttrs.Append(SF); // Audio Video Remote Control Profile, to find out avrcp 1.4 support + + + /***************************************************** + * Series 60 Customer + * You may want to consider modifying the following + * code to better meet your needs. + *****************************************************/ + // Perform remote SDP query to find out if information about the exact + // model of the accessory is available in the SDP registry. NOTE that + // this query if using a proprietary UUID which will only exist in some + // devices of a certain manufacturer. For other devices this query does + // not find a value. + // + TUUID serviceUuid = TUUID((0x00005555),(0x00001000),(0x80000002),(0xEE000001)); // model number + SF.iUUID = serviceUuid; + SF.iAttrID = 0x0300; // Attri id of device model number + iServiceAttrs.Append(SF); + iCursor = 0; + iTolerateSdpError = aTolerateSdpError; + iSdpAgent = CSdpAgent::NewL(*this, iAddr); + iSdpSearchPattern = CSdpSearchPattern::NewL(); + DoNextServiceRecordRequestL(); + } + +void CBasrvSdpQuery::NextRecordRequestComplete(TInt aError, + TSdpServRecordHandle aHandle, + TInt aTotalRecordsCount) + { + TRAP_IGNORE(NextRecordRequestCompleteL(aError, aHandle, aTotalRecordsCount)); + } + +void CBasrvSdpQuery::AttributeRequestResult( + TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, + CSdpAttrValue* aAttr) + { + TRAP_IGNORE(AttributeRequestResultL(aHandle, aAttrID, aAttr)); + } + +void CBasrvSdpQuery::AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError) + { + TRAP_IGNORE(AttributeRequestCompleteL(aHandle, aError)); + } + +void CBasrvSdpQuery::RequestCompletedL(CBasrvActive& aActive) + { + switch (aActive.RequestId()) + { + case ECreateView: + { + iResponse = NULL; + if (aActive.iStatus > KErrNone) + { + iResponse = CBTRegistryResponse::NewL(iReg); + aActive.SetRequestId(EGetResponse); + iResponse->Start(aActive.iStatus); + aActive.GoActive(); + } + else + { + QueryCompleteL(KErrNone); + } + break; + } + case EGetResponse: + { + QueryCompleteL(KErrNone); + break; + } + } + } + +void CBasrvSdpQuery::CancelRequest(CBasrvActive& /*aActive*/) + { + } + +void CBasrvSdpQuery::ConstructL() + { + } + +CBasrvSdpQuery::CBasrvSdpQuery(MBasrvSdpQuerier& aQuerier) + : iQuerier(aQuerier) + { + } + +void CBasrvSdpQuery::QueryCompleteL(TInt aErr) + { + iSdpAgent->Cancel(); + delete iSdpAgent; + iSdpAgent = NULL; + delete iSdpSearchPattern; + iSdpSearchPattern = NULL; + TBTDeviceClass cod = TBTDeviceClass(); + if ( iResponse && iResponse->Results().Count() > 0 ) + { + cod = (iResponse->Results())[0]->DeviceClass(); + } + if (!aErr) + { + TAccInfo info; + MakeAccInfo(info); + iQuerier.GetAccInfoCompletedL(aErr, &info, &cod); + } + else + { + iQuerier.GetAccInfoCompletedL(aErr, NULL, &cod); + } + } + +void CBasrvSdpQuery::DoNextServiceRecordRequestL() + { + if (iCursor >= iServiceAttrs.Count()) + { + TInt err = iRegServ.Connect(); + if (!err) + err = iReg.Open(iRegServ); + if (err) + { + QueryCompleteL(KErrNone); + } + else + { + iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, ECreateView); + TBTRegistrySearch pattern; + pattern.FindAddress(iAddr); + iReg.CreateView(pattern, iActive->iStatus); + iActive->GoActive(); + } + } + else + { + iSdpSearchPattern->Reset(); + iSdpSearchPattern->AddL(iServiceAttrs[iCursor].iUUID); + iSdpAgent->SetRecordFilterL(*iSdpSearchPattern); + iSdpAgent->NextRecordRequestL(); + } + } + +void CBasrvSdpQuery::NextRecordRequestCompleteL(TInt aError, + TSdpServRecordHandle aHandle, + TInt aTotalRecordsCount) + { + TRACE_INFO((_L("NextRecord err <%d>, Handle <0x%x>, Records Count <%d>"), + aError, aHandle, aTotalRecordsCount)); + + if(aError == KErrEof || (!aError && aTotalRecordsCount == 0)) + { + iServiceAttrs.Remove(iCursor); + DoNextServiceRecordRequestL(); + } + else if(aError) + { + if (!iTolerateSdpError) + { + QueryCompleteL(aError); + } + else + { + for (TInt i = iServiceAttrs.Count() - 1; i >= iCursor; i--) + { + iServiceAttrs.Remove(i); + } + DoNextServiceRecordRequestL(); + } + } + else if(aTotalRecordsCount) + { + iSdpAgent->AttributeRequestL(aHandle, iServiceAttrs[iCursor].iAttrID); + } + } + +void CBasrvSdpQuery::AttributeRequestResultL( + TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, + CSdpAttrValue* aAttr) + { + TRACE_INFO((_L("AttributeRequestResult, attr type %d"), aAttr->Type())); + + // Adds the attribute values synchronously to the result array. + TRAP_IGNORE( aAttr->AcceptVisitorL( *this ) ); + + TRACE_INFO((_L("handle <0x%x>, attr id <0x%04x>, value <%d>"), aHandle, aAttrID, iServiceAttrs[iCursor].iAttrValue)); + (void) aHandle; + (void) aAttrID; + delete aAttr; + } + +void CBasrvSdpQuery::AttributeRequestCompleteL(TSdpServRecordHandle aHandle, TInt aError) + { + TRACE_INFO((_L("AttributeRequestCompleteL err %d"), aError)); (void) aError; + iSdpAgent->Cancel(); + TInt currentCursor = iCursor; + iCursor++; + + if(iServiceAttrs[currentCursor].iUUID == KAVRemoteControlTargetUUID && + iServiceAttrs[currentCursor].iAttrID == KSdpAttrIdSupportedFeatures) + { + // We have some other information (avrcp version) in the same record + // so lets get the information without quering the same record again. + iSdpAgent->AttributeRequestL(aHandle, iServiceAttrs[iCursor].iAttrID); + } + else + { + DoNextServiceRecordRequestL(); + } + } + + void CBasrvSdpQuery::VisitAttributeValueL( CSdpAttrValue &aValue, TSdpElementType aType ) + { + switch ( aType ) + { + case ETypeUint: + { + TRACE_INFO((_L("attr value %d"), aValue.Uint())); + iServiceAttrs[iCursor].iAttrValue = aValue.Uint(); + break; + } + case ETypeInt: + { + TRACE_INFO((_L("attr value %d"), aValue.Int())); + iServiceAttrs[iCursor].iAttrValue = aValue.Int(); + break; + } + case ETypeBoolean: + { + TRACE_INFO((_L("attr value %d"), aValue.Bool())); + iServiceAttrs[iCursor].iAttrValue = aValue.Bool(); + break; + } + } + } + + void CBasrvSdpQuery::StartListL( CSdpAttrValueList &aList ) + { + (void) aList; + } + + void CBasrvSdpQuery::EndListL() + { + + } + +void CBasrvSdpQuery::MakeAccInfo(TAccInfo& aInfo) + { + aInfo.SetBDAddress(iAddr); + if (iServiceAttrs.Count()) + { + aInfo.SetCapturingSupport(EFalse); // default indication as of CR 403-6409 CMLA change + TUUID serviceUuid = TUUID((0x00005555),(0x00001000),(0x80000002),(0xEE000001)); // model number + TUint8 suppProfiles = 0x00; + for ( TUint ii = 0 ; ii < iServiceAttrs.Count() ; ++ii ) + { + if ( iServiceAttrs[ii].iUUID == KAudioSinkUUID ) + { + TRACE_INFO((_L("Accessory is A2DP Sink."))) + suppProfiles |= EStereo; + aInfo.SetSupportedFeature((TUint16)iServiceAttrs[ii].iAttrValue, TAccInfo::EStereoIndex); + } + else if ( iServiceAttrs[ii].iUUID == 0x111e ) // HFP + { + suppProfiles |= EHFP; + TRACE_INFO((_L("Accessory supports Handsfree profile."))) + aInfo.SetSupportedFeature((TUint16)iServiceAttrs[ii].iAttrValue, TAccInfo::EHFPIndex); + } + else if ( iServiceAttrs[ii].iUUID == 0x1108 ) // HSP + { + suppProfiles |= EHSP; + TRACE_INFO((_L("Accessory supports Headset profile."))) + + if (iServiceAttrs[ii].iAttrValue) + { + TRACE_INFO((_L("HSP Remote volume control is supported."))) + // Server is going to feed 0x10 to supported features for headset profile + aInfo.SetSupportedFeature(0x10, TAccInfo::EHSPIndex); + } + } + else if ( iServiceAttrs[ii].iUUID == KAVRemoteControlTargetUUID ) + { + if(iServiceAttrs[ii].iAttrID == KSdpAttrIdSupportedFeatures) + { + suppProfiles |= ERemConTG; // 0x08 remote control profile + TRACE_INFO((_L("Accessory is AVRCP TG, features 0x%02X"), iServiceAttrs[ii].iAttrValue)) + aInfo.SetSupportedFeature(iServiceAttrs[ii].iAttrValue, TAccInfo::ERemConTGIndex); // remote control = Position 3 + } + else // KSdpAttrIdBluetoothProfileDescriptorList, Avrcp version + { + if(iServiceAttrs[ii].iAttrValue == 0x0104) + { + aInfo.iAvrcpVersion = TAccInfo::EAvrcpVersion14; + } + else + { + aInfo.iAvrcpVersion = TAccInfo::EAvrcpVersionNo14; + } + } + } + else if (iServiceAttrs[ii].iUUID == serviceUuid) + { + aInfo.SetModel(iServiceAttrs[ii].iAttrValue); + TRACE_INFO((_L("Accessory is proprietary. Model: %d"), iServiceAttrs[ii].iAttrValue )) + } + } + aInfo.SetSuppportedProfiles(suppProfiles); + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/btaudiomanplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,407 @@ +/* +* Copyright (c) 2006 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: Bluetooth Audio Manager ECom plug-in class definition. +* +*/ + + +#include +#include +#include "btaudiomanplugin.h" +#include "btaccTypes.h" +#include "debug.h" + +enum TRequestId + { + ERequestConnect = 1, + ERequestDisconnect = 2, + ENotifyProfileStatusChange = 3, + ERequestDisconnectAll, + }; + +CBtAudioManPlugin* CBtAudioManPlugin::NewL() + { + CBtAudioManPlugin* self = new (ELeave) CBtAudioManPlugin(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtAudioManPlugin::~CBtAudioManPlugin() + { + delete iActive4ClientReq; + delete iActive4ProfileStatus; + iClient.Close(); + TRACE_FUNC + } + +void CBtAudioManPlugin::SetObserver( MBTEngPluginObserver* aObserver ) + { + iObserver = aObserver; + } + +void CBtAudioManPlugin::GetSupportedProfiles( RProfileArray& aProfiles ) + { + aProfiles.Reset(); + aProfiles.Append(EBTProfileHSP); + aProfiles.Append(EBTProfileHFP); + aProfiles.Append(EBTProfileA2DP); + } + +TBool CBtAudioManPlugin::IsProfileSupported(const TBTProfile aProfile ) const + { + return (aProfile == EBTProfileHSP || + aProfile == EBTProfileHFP || + aProfile == EBTProfileA2DP); + } + +TInt CBtAudioManPlugin::Connect( const TBTDevAddr& aAddr ) + { + TRACE_FUNC + return HandleAsyncRequest(aAddr, ERequestConnect); + } + +void CBtAudioManPlugin::CancelConnect( const TBTDevAddr& aAddr ) + { + if (iBTDevAddrPckgBuf() == aAddr && + iActive4ClientReq && + iActive4ClientReq->IsActive() && + iActive4ClientReq->RequestId() == ERequestConnect ) + { + TRACE_INFO(_L("CBtAudioManPlugin::CancelConnect KErrCancel")) + delete iActive4ClientReq; + iActive4ClientReq = NULL; + if (iObserver) + { + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), + EBTProfileHFP, KErrCancel); + } + } + else + { + TRACE_INFO(_L("CBtAudioManPlugin::CancelConnect KErrNotFound")) + if (iObserver) + { + iObserver->ConnectComplete(aAddr , + EBTProfileHFP, KErrNotFound); + } + } + + } + +TInt CBtAudioManPlugin::Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType /*aDiscType*/ ) + { + TInt req = ERequestDisconnect; + if (aAddr == TBTDevAddr()) + { + req = ERequestDisconnectAll; + } + return HandleAsyncRequest(aAddr, req); + } + +void CBtAudioManPlugin::GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile ) + { + aAddrArray.Reset(); + TProfiles profile = EUnknownProfile; + + if (aConnectedProfile == EBTProfileHSP || aConnectedProfile == EBTProfileHFP) + { + profile = EAnyMonoAudioProfiles; + } + else if (aConnectedProfile == EBTProfileA2DP) + { + profile = EStereo; + } + else + { + return; + } + + //guess there are 2 addresses as a 'best guess' + TInt numAddresses = 2; + TInt count = numAddresses; + RBuf8 addrbuf; + TPtrC8 ptr(addrbuf); + + do + { + //if this is > 1st time round, the buffer must be deleted and the + //count might have changed + addrbuf.Close(); + numAddresses = count; + + //create a buffer using the 'best guess' size + TInt err = addrbuf.Create(KBTDevAddrSize * numAddresses); + + if (err != KErrNone) + { + //we can't do anything if the buffer fails to create, just return + //and ignore the error as there is no error path (maybe this will + //change in the future) + return; + } + + //get the number of connections and the addresses. count can be either + //the number of connections or a system-wide error code + count = iClient.GetConnections(addrbuf, profile); + + if (count < KErrNone) + { + //error occurred so we're finished with the buffer + addrbuf.Close(); + + //ignore the error as there is no error path (maybe this will + //change in the future) + return; + } + } + //iterate if the number of connections is greater than our 'best guess' or + //maybe another connection was established while this was taking place + while (count > numAddresses); + + //iterate through the addresses buffer + while (ptr.Length() >= KBTDevAddrSize) + { + //append each address to the device address array + TInt err = aAddrArray.Append(TBTDevAddr(ptr.Left(KBTDevAddrSize))); + + if (err == KErrNone) + { + //shift the pointer along to the next address + ptr.Set(ptr.Mid(KBTDevAddrSize)); + } + else + { + //error occurred so we're finished with the buffer + addrbuf.Close(); + + //ignore the error as there is no error path (maybe this will + //change in the future) + return; + } + } + + //now finished with the address buffer + addrbuf.Close(); + } + +TBTEngConnectionStatus CBtAudioManPlugin::IsConnected( const TBTDevAddr& aAddr ) + { + TBTEngConnectionStatus stat = (TBTEngConnectionStatus) iClient.IsConnected(aAddr); + TRACE_INFO((_L("IsConnected %d"), stat)) + return stat; + } + +void CBtAudioManPlugin::RequestCompletedL(CBasrvActive& aActive) + { + TRACE_FUNC + switch (aActive.RequestId()) + { + case ENotifyProfileStatusChange: + { + if (aActive.iStatus == KErrNone && iObserver) + { + ReportProfileConnectionEvents(iProfileStatus.iAddr, iProfileStatus.iProfiles, + iProfileStatus.iConnected); + iClient.NotifyConnectionStatus(iProfileStatusPckg, aActive.iStatus); + aActive.GoActive(); + } + break; + } + case ERequestConnect: + { + if (iActive4ClientReq->iStatus.Int() != KErrNone) // might have conflicts, decode iDiagnostic + { + if (iDiagnostic.Length() >= KBTDevAddrSize) + { + RBTDevAddrArray array; + CleanupClosePushL(array); + TPtrC8 ptr(iDiagnostic); + while (ptr.Length() >= KBTDevAddrSize) + { + array.AppendL(TBTDevAddr(ptr.Left(KBTDevAddrSize))); + #ifdef _DEBUG + const TPtrC8 myPtr(array[array.Count() - 1].Des()); + #endif + TRACE_INFO((_L8("conflict <%S>"), &myPtr)) + ptr.Set(ptr.Mid(KBTDevAddrSize)); + } + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), + EBTProfileHFP, iActive4ClientReq->iStatus.Int(), &array); + CleanupStack::PopAndDestroy(&array); + } + else + { + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), + EBTProfileHFP, iActive4ClientReq->iStatus.Int()); + } + } + else + { + TInt profile = 0; + if (iDiagnostic.Length() >= sizeof(TInt)) + { + TPckg pckg(profile); + pckg.Copy(iDiagnostic.Mid(0, sizeof(TInt))); + } + ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), profile, ETrue); + } + delete iActive4ClientReq; + iActive4ClientReq = NULL; + break; + } + case ERequestDisconnect: + { + if (iActive4ClientReq->iStatus.Int() != KErrNone) + { + iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), + EBTProfileHFP, iActive4ClientReq->iStatus.Int()); + } + else + { + TInt profile = 0; + if (iDiagnostic.Length() >= sizeof(TInt)) + { + TPckg pckg(profile); + pckg.Copy(iDiagnostic.Mid(0, sizeof(TInt))); + } + ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), profile, EFalse); + } + delete iActive4ClientReq; + iActive4ClientReq = NULL; + break; + } + case ERequestDisconnectAll: + { + iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), + EBTProfileHFP, iActive4ClientReq->iStatus.Int()); + break; + } + } + } + +void CBtAudioManPlugin::CancelRequest(CBasrvActive& aActive) + { + if (aActive.RequestId() == ENotifyProfileStatusChange ) + { + iClient.CancelNotifyConnectionStatus(); + } + else if (aActive.RequestId() == ERequestConnect ) + { + iClient.CancelConnectToAccessory(); + } + } + +CBtAudioManPlugin::CBtAudioManPlugin() : iProfileStatusPckg(iProfileStatus) + { + TRACE_FUNC + } + +void CBtAudioManPlugin::ConstructL() + { + LEAVE_IF_ERROR(iClient.Connect()); + iActive4ProfileStatus = CBasrvActive::NewL(*this, CActive::EPriorityStandard, ENotifyProfileStatusChange); + iClient.NotifyConnectionStatus(iProfileStatusPckg, iActive4ProfileStatus->iStatus); + iActive4ProfileStatus->GoActive(); + } + +TInt CBtAudioManPlugin::HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId) + { + TInt err = KErrNone; + if (! iClient.Handle() ) + { + err = iClient.Connect(); + } + if ( err ) + { + return err; + } + if ( iActive4ClientReq ) + { + err = KErrServerBusy; + } + if (!err) + { + iActive4ClientReq = CBasrvActive::New(*this, CActive::EPriorityStandard, aRequestId); + if (iActive4ClientReq) + { + iBTDevAddrPckgBuf() = aAddr; + if (aRequestId == ERequestConnect) + { + iDiagnostic.Zero(); + iClient.ConnectToAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic); + } + else if (aRequestId == ERequestDisconnect) + { + iClient.DisconnectAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic); + } + else // if (aRequestId == ERequestDisconnectAll) + { + iClient.DisconnectAllGracefully(iActive4ClientReq->iStatus); + } + iActive4ClientReq->GoActive(); + } + else + { + err = KErrNoMemory; + } + } + return err; + } + +void CBtAudioManPlugin::ReportProfileConnectionEvents(const TBTDevAddr& aAddr, const TInt aProfiles, TBool aConnected) + { + TRACE_FUNC + TRACE_INFO((_L("status %d profiles 0x%04X"), aConnected, aProfiles)) + TBTEngConnectionStatus status = IsConnected(aAddr); + if (iObserver) + { + if (aConnected) + { + if (aProfiles & EHFP) + { + iObserver->ConnectComplete(aAddr, EBTProfileHFP, KErrNone); + } + if (aProfiles & EHSP) + { + iObserver->ConnectComplete(aAddr, EBTProfileHSP, KErrNone); + } + if (aProfiles & EStereo) + { + iObserver->ConnectComplete(aAddr, EBTProfileA2DP, KErrNone); + } + } + else + { + if( status != EBTEngConnected ) + { + if (aProfiles & EHFP) + { + iObserver->DisconnectComplete(aAddr, EBTProfileHFP, KErrNone); + } + if (aProfiles & EHSP) + { + iObserver->DisconnectComplete(aAddr, EBTProfileHSP, KErrNone); + } + if (aProfiles & EStereo) + { + iObserver->DisconnectComplete(aAddr, EBTProfileA2DP, KErrNone); + } + } + } + } + } + +// diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudioman/src/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/src/proxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2006 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: implementation of ECom framework +* +*/ + + +// INCLUDE FILES +#include +#include +#include "BTAccInfoMainService.h" +#include "BTAccInfoCmdHandler.h" +#include "btaudiomanplugin.h" + +// Map the interface implementation UIDs to implementation factory functions +const TImplementationProxy ImplementationTable[] = + { + { { 0x1020897C }, (TProxyNewLPtr) CBTAccInfoMainService::NewL }, + { { 0x1020897D }, (TProxyNewLPtr) CBTAccInfoCmdHandler::NewL }, + { { 0x1020897B }, (TProxyNewLPtr) CBtAudioManPlugin::NewL }, + }; + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// Exported proxy for instantiation method resolution. +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/bwins/btaudiostreamerU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/bwins/btaudiostreamerU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,6 @@ +EXPORTS + ?NewL@CBTAudioStreamer@@SAPAV1@XZ @ 1 NONAME ; class CBTAudioStreamer * CBTAudioStreamer::NewL(void) + ?SetNewFrameLength@CBTAudioStreamer@@QAEHII@Z @ 2 NONAME ; int CBTAudioStreamer::SetNewFrameLength(unsigned int, unsigned int) + ?StartL@CBTAudioStreamer@@QAEXAAVRSocket@@IPAVCBTAudioStreamInputBase@@I@Z @ 3 NONAME ; void CBTAudioStreamer::StartL(class RSocket &, unsigned int, class CBTAudioStreamInputBase *, unsigned int) + ?Stop@CBTAudioStreamer@@QAEXXZ @ 4 NONAME ; void CBTAudioStreamer::Stop(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/eabi/btaudiostreameru.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/eabi/btaudiostreameru.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,8 @@ +EXPORTS + _ZN16CBTAudioStreamer17SetNewFrameLengthEjj @ 1 NONAME + _ZN16CBTAudioStreamer4NewLEv @ 2 NONAME + _ZN16CBTAudioStreamer4StopEv @ 3 NONAME + _ZN16CBTAudioStreamer6StartLER7RSocketjP23CBTAudioStreamInputBasej @ 4 NONAME + _ZTI16CBTAudioStreamer @ 5 NONAME ; ## + _ZTV16CBTAudioStreamer @ 6 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2005-2006 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: Build information file for project BT Audio Streamer +* +*/ + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/btaudiostreamer.h |../../inc/btaudiostreamer.h +../rom/btaudiostreamer.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btaudiostreamer.iby) + +PRJ_MMPFILES +../group/btaudiostreamer.mmp + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/group/btaudiostreamer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/group/btaudiostreamer.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2005-2006 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: Project definition file for project BT Audio Streamer +* +*/ + +#include + +TARGET btaudiostreamer.dll +CAPABILITY CAP_GENERAL_DLL +TARGETTYPE DLL +UID 0x1000008d 0x10208976 + +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE btaudiostreamer.cpp +SOURCE btaudiostreamsender.cpp +SOURCE btaudiostreamsendersbc.cpp + +USERINCLUDE ../inc +SYSTEMINCLUDE ../../inc ../../../inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY EUSER.LIB // user library +LIBRARY ESOCK.LIB // socket services +LIBRARY rtp.lib // RTP implementation +LIBRARY efsrv.lib // file server +LIBRARY bluetooth.lib // TBTSockAddr +LIBRARY a2dpoptimisation.lib // A2DP optimisation API + +DEBUGLIBRARY flogger.lib // file logging services diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/inc/btaudiostreamer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/inc/btaudiostreamer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2005-2006 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: This is an interface class that exports streamer's functions +* for its clients. The functionality is implemented in +* BTAudioStreamerSender, this class forwards the function +* calls to it. +* +*/ + + +#ifndef __BTAUDIOSTREAMER_H__ +#define __BTAUDIOSTREAMER_H__ + +#include +#include + +#include "btaudiostreaminputbase.h" + +class CBTAudioStreamSender; + +/** + * An observer pattern. + * + * This class defines an observer interface for BT Audio Stream Sender. + * + * @lib btaudiostreamer.lib + * @since S60 v3.1 + */ +NONSHARABLE_CLASS(MBTAudioStreamSenderObserver) + { + public: + virtual void NotifyBufferSent(const TDesC8& aBuffer ) = 0; // Buffer sent. + virtual void NotifyErrorSending(const TDesC8& aBuffer ) = 0; // Could not send a packet at all. + }; + +/** + * BT Audio Streamer class. + * + * This class implements the audio streaming over A2DP. + * It acts as an interface between the controller, BT Audio Adaptation and RTP API. + * It uses helper class CBTAudioStreamSender to handle + * the frame contruction and sending. + * + * @lib btaudiostreamer.lib + * @since S60 v3.1 + */ +class CBTAudioStreamer : public CBase, public MBTAudioStreamObserver, public MBTAudioStreamSenderObserver + { + public: + + IMPORT_C static CBTAudioStreamer* NewL(); + + /** + * A method for preparing the BT Audio Streamer for incoming data. + * + * @since S60 v3.1 + * @param aSocket Bluetooth socket instance, needed for getting the RTP sending class instance. + * @param aFrameLength Length of a single audio data frame, needed for calculating the send packet size. + * @param aAudioInput The API where the data is received and where the sending of packets will be confirmed. + * @return void. + */ + IMPORT_C TInt SetNewFrameLength(const TUint aFrameLength, const TUint aTargetBitrate); + + /** + * A method for preparing the BT Audio Streamer for incoming data. + * + * @since S60 v3.1 + * @param aSocket Bluetooth socket instance, needed for getting the RTP sending class instance. + * @param aFrameLength Length of a single audio data frame, needed for calculating the send packet size. + * @param aAudioInput The API where the data is received and where the sending of packets will be confirmed. + * @return void. + */ + IMPORT_C void StartL(RSocket& aSocket, const TUint aFrameLength, CBTAudioStreamInputBase* aAudioInput, const TUint aTargetBitrate); + + /** + * A method for cleaning up the BT Audio Streamer after streaming data. + * + * @since S60 v3.1 + * @param void. + * @return void. + */ + IMPORT_C void Stop(); + + virtual ~CBTAudioStreamer(); + + /** + * From MBTAudioStreamObserver. + * This method receives data from the data producer. + * + * @since S60 v3.1 + * @param aBuffer contains the audio data frames. + * @return a Symbian OS wide error code. + */ + TInt Receive(const TDesC8& aBuffer); + + /** + * From MBTAudioStreamObserver. + * This method receives data and timestamps from the data producer. + * + * @since S60 v3.1 + * @param aBuffer contains the audio data frames. + * @param aTimestamp The timestamp of the audio data frames. + * 34 minutes max. interval should not be a problem to us. + * @return a Symbian OS wide error code. + */ + TInt Receive(const TDesC8& aBuffer, TTimeIntervalMicroSeconds aTimestamp); + + /** + * From MBTAudioStreamSenderObserver. + * This method is used for reporting that the referred buffer has been sent. + * This tells the data producer that we're ready to receive more data. + * + * @since S60 v3.1 + * @param aBuffer refers to the original bufffer that we received in Receive method. + * @return void. + */ + void NotifyBufferSent( const TDesC8& aBuffer ); + + /** + * From MBTAudioStreamSenderObserver. + * This method is used for reporting that the buffer wasn't sent because of an error. + * This method then informs the error observer class. + * + * @since S60 v3.1 + * @param aBuffer refers to the original bufffer that we received in Receive method. + * @return void. + */ + void NotifyErrorSending( const TDesC8& aBuffer ); + + private: + CBTAudioStreamer(); + void ConstructL(); + + private: + /** + * This stores a pointer to the audio input interface. + * After a buffer has been processed, this interface must be informed. + */ + CBTAudioStreamInputBase* iAudioInput; + + /** + * This points to a helper class that handles the sending of a frame. + * Own. + */ + CBTAudioStreamSender* iSender; + + /** + * RTP session object that is needed for sending RTP frames. + */ + RRtpSession iRtpSession; + + /** + * This stores the state of the streamer. + */ + TBool iStarted; + + }; + +#endif // __BTAUDIOSTREAMER_H__ \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/inc/btaudiostreamerdebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/inc/btaudiostreamerdebug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2005 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: Debug definitions for BT Audio Streamer +* +*/ + + +#ifndef BTAUDIOSTREAMER_DEBUG_H +#define BTAUDIOSTREAMER_DEBUG_H + +#include + + +#ifdef _DEBUG + +// Print options + +#define KPRINTERROR 0x00000001 // Print error +#define KPRINTFTRACE 0x00000002 // Print function trace +#define KPRINTSTATE 0x00000004 // Print state machine infos + +const TInt KDebugMask = KPRINTERROR | KPRINTFTRACE | KPRINTSTATE ; + + +// Un-comment/comment this definition to enable/disable memory tracing +//#define MEMTRACE + +#ifdef __WINS__ + +// File logging for WINS +#define __FLOGGING__ + +#else + +// Logging with RDebug for target HW +#define __CLOGGING__ + +#endif //__WINS__ + +#endif // _DEBUG + + +// ================================================================== +// File logging +// ================================================================== +// +#if defined(__FLOGGING__) + +#include + +_LIT(KLogFile,"BTAudioStreamerLog.txt"); +_LIT(KLogDirFullName,"c:\\logs\\bt\\"); +_LIT(KLogDir,"BT"); + +#include +#include + +#define FLOG(a) { FPrint(a); } + +#define FTRACE(a) { a; } + +#define BT_AUDIO_STREAMER_TRACE_OPT(a,p) {if((KDebugMask)&(a))p;} + + + + +inline void FPrint(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#ifdef MEMTRACE + TInt size; + User::Heap().AllocSize(size); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, _L("[BTAudioStreamer]\t MEM\tAllocated from heap: %d B. Total heap size: %d B"), size, User::Heap().Size()); +#endif + } + + +inline void FHex(const TUint8* aPtr, TInt aLen) + { + RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); + } + + +inline void FHex(const TDesC8& aDes) + { + FHex(aDes.Ptr(), aDes.Length()); + } + + +// ================================================================== +// RDebug logging +// ================================================================== +// +#elif defined(__CLOGGING__) + +#include + +#define FLOG(a) { RDebug::Print(a); } + +#define FHex(a) + +#define FTRACE(a) { a; } + +#define BT_AUDIO_STREAMER_TRACE_OPT(a,p) {if((KDebugMask)&(a))p;} + + +inline void FPrint(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + TInt tmpInt = VA_ARG(list, TInt); + TInt tmpInt2 = VA_ARG(list, TInt); + TInt tmpInt3 = VA_ARG(list, TInt); + VA_END(list); + RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3); + } + + +// ================================================================== +// No loggings --> Reduced binary size +// ================================================================== +// +#else // if no __FLOGGING__ and no __CLOGGING__ + +#define FLOG(a) + +#define FTRACE(a) + +#define FHex(a) + +#define BT_AUDIO_STREAMER_TRACE_OPT(a,p) + +#endif // ...loggings + +#endif // BTAUDIOSTREAMER_DEBUG_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/inc/btaudiostreamsender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/inc/btaudiostreamsender.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,350 @@ +/* +* Copyright (c) 2006 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: This class implements the audio data sending behaviour +* that is common to all codecs. +* +*/ + + + +#ifndef __BTAUDIOSTREAMSENDER_H__ +#define __BTAUDIOSTREAMSENDER_H__ + +#include +#include + +#include "btaudiostreamer.h" + +/** + * This class handles the sending of RTP frames on general level. + * + * This class takes care of all the operations related to an RTP frame that are + * common to all formats. Such operations are e.g. timestamp handling and + * frame sending. + * + * The child classes of this are used for handling the encoder specific + * frame handling. This class specifies and calls pure virtual methods that + * must be implemented by an encoder specific child class. + * + * @lib btaudiostreamer.lib + * @since S60 v3.1 + */ +NONSHARABLE_CLASS(CBTAudioStreamSender) : public CActive + { + public: + static CBTAudioStreamSender* NewL(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession); + ~CBTAudioStreamSender(); + + /** + * A callback for registering with RTP API + * + * @since S60 v3.1 + * @param aPtr An pointer to an instance that handles the callback. + * @param aEvent Handle to the event that occurred. + * @return void. + */ + static void PacketSent(CBTAudioStreamSender* aPtr, const TRtpEvent& aEvent); + /** + * A callback for registering with RTP API + * + * @since S60 v3.1 + * @param aPtr An instance who handles the callback. + * @param aEvent Handle to the event that occurred. + * @return void. + */ + static void SendError(CBTAudioStreamSender* aPtr, const TRtpEvent& aEvent); + + /** + * Method for actually handling the RTP API callbacks for sent packets. + * + * @since S60 v3.1 + * @return void. + */ + virtual void DoPacketSent(); + + /** + * Method for actually handling the RTP API callback for send errors. + * + * @since S60 v3.1 + * @return void. + */ + virtual void DoSendError(); + + virtual TInt SetNewFrameLength(TUint aOutboundMTUSize, const TUint aFrameLength, const TUint aTargetBitrate); + + /** + * This method prepares the Stream Sender for incoming audio buffers. + * + * @since S60 v3.1 + * @param aOutboundMTUSize The MTU size for outgoing L2CAP link. + * @param aFrameLength The length of one audio data frame. + * @return void. + */ + virtual void StartL(TUint aOutboundMTUSize, const TUint aFrameLength, const TUint aTargetBitrate); + + /** + * This method contains the code for closing the RTP API and cleaning up. + * + * @since S60 v3.1 + * @return void. + */ + virtual void Stop(); + + /** + * An implementation of the buffer handling method. + * + * @since S60 v3.1 + * @param aBuffer contains the audio data frames. + * @param aTimestamp The timestamp of the audio data frames. + * @return a Symbian OS wide error code. + */ + virtual TInt SendThisBuffer(const TDesC8& aBuffer, TTimeIntervalMicroSeconds aTimestamp); + + protected: + void ConstructL(); + CBTAudioStreamSender(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession); + + void RunL(); + void DoCancel(); + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method moves the audio frames from buffer to SendPacket in encoder specific way. + * + * @since S60 v3.1 + * @param aBuffer contains the audio data frames. + * @return a Symbian OS wide error code. + */ + virtual TInt AddBufferToSendPacket(const TDesC8& aBuffer) = 0; + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method places a header to SendPacket in encoder specific way. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt AddHeaderToSendPacket(TPtr8& aPayloadDesC) = 0; + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method handles the encoder specific operations that should be done after the packet + * has been sent. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt PacketSendingCompleted(TPtr8& aPayloadDesC) = 0; + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method handles the encoder specific packet length calculation. + * + * @since S60 v3.1 + * @param aOutboundMTUSize The MTU size for outgoing L2CAP link. + * @param aFrameLength The length of one audio data frame. + * @return a Symbian OS wide error code. + */ + virtual TInt CalculatePacketLength(TUint aOutboundMTUSize, const TUint aFrameLength) = 0; + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method returns the maximum number of frames in one outgoing packet. + * + * @since S60 Timebox 9.2 + * @return number of frames in one send packet. + */ + virtual TUint MaxFramesPerPacket() = 0; + + /** + * + * This method calculates the playing time of one frame in microseconds. + * The result is encoder specific. + * + * @since S60 Timebox 9.2 + * @param void. + * @return a duration of one frame. + */ + virtual TUint CalculateFrameDuration(const TUint aFrameLength, const TUint aTargetBitrate) = 0; + + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method handles the encoder specific initialisation. + * + * @since S60 v3.1 + * @param void. + * @return void. + */ + virtual TInt InitSender(RRtpSendPacket& aSendPacket, TPtr8& aPayloadDesC, const TUint aTargetBitrate) = 0; + + /** + * A pure virtual method that must be implemented by the encoder specific child class. + * This method adjusts the incoming timestamp if buffers don't fill the SendPacket exactly. + * + * @since S60 v5.0 + * @param aTimestamp A 64 bit representation of the timestamp to adjust. This will change during the call. + * @return void. + */ + virtual void AdjustTimestamp(TInt64 &aTimestamp) = 0; + + + private: + /** + * An inline method that empties the received buffer. + * This method uses encoder specific inherited class to handles the encoder specific data. + * and then decides whether to send the data out or request for more data. + * + * @since S60 v3.1 + * @param void. + * @return void. + */ + inline void ConsumeBuffer(); + + /** + * An inline method that switches to new sendpacket when the length of frame has changed. + * This method also initializes the sender to use the new packet. + * + * @since S60 v3.1 + * @param void. + * @return void. + */ + inline void SwitchToNewSendPacket(); + + /** + * An inline method that self completes this active object. + * The purpose of this is to set the data provider thread free + * and continue execution in this thread's context. + * + * @since S60 v3.1 + * @param void. + * @return void. + */ + inline void ProceedToPacketSending(); + + + private: + + /** + * The possible states of the Streamer. + */ + enum TStreamerState + { + EStopped, + EBuffering, + ESending, + EErrorSending + }; + + /** + * A2DP optimiser object that is needed for prioritising A2DP audio over other data. + */ + RA2dpOptimiser iA2DPOptimiser; + + /** + * This stores a reference to the observer of this class. + */ + MBTAudioStreamSenderObserver& iObserver; + + /** + * RTP session reference, needed for creating the SendSource. + */ + RRtpSession& iRtpSession; + + /** + * RRtpSendSoure is needed for SendPacket management. + */ + RRtpSendSource iSendSrc; + + /** + * This stores the timestamp which we must place in the header. + */ + TInt64 iTimestamp; + + /** + * This stores the timestamp which we must place in the header. + */ + TInt64 iAdjustedTimestamp; + + + /** + * This stores the current state of the streamer. + */ + TStreamerState iStreamerState; + + /** + * This stores a reference to the buffer until it has + * been emptied and can be given back to the audio adaptation. + */ + const TDesC8 *iBuffer; + + /** + * These assist with creating RTP payloads with proper header and content. + */ + RRtpSendPacket* iCurrentSendPacket; + RRtpSendPacket* iSpareSendPacket; + + /** + * A pointer to the send packet's contents. + * It is used to abstract away the container of the data. + */ + TPtr8 iPayloadDesC; + + /** + * An instance of our thread. This is needed for self completing + * the requests, which forces the ActiveScheduler to call our RunL. + */ + RThread iThread; + + /** + * This stores the new framelength when the streaming parameters are changing. + */ + TInt iNewFrameLength; + + /** + * This stores the target bitrate. The reason for this is that it is not applied + * immediately, but after the current packet is sent. + */ + TUint iTargetBitrate; + + /** + * This tells if the frame length is changing. If it is, then we won't put + * frames of new length into the same packet with the old frames. + * After sending the old frames a new sendpacket is taken into use. + */ + TBool iChangingFrameLength; + + /** + * This tells whether we should keep the previous timestamp or overwrite + * it with the most recent one. + */ + TBool iKeepPreviousTimestamp; + + /** + * This tells whether we should keep moving data from buffer to an incoming frame. + * The value is set to ETrue when new frame arrives and when the buffer was completely consumed + * and sent, this value is set to EFalse. + */ + TBool iNonprocessedDataInBuffer; + + /** + * This tells if the streaming optimiser service is available. + */ + TBool iLinkOptimiserAvailable; + + }; + +#endif // __BTAUDIOSTREAMSENDER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/inc/btaudiostreamsendersbc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/inc/btaudiostreamsendersbc.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2006 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: This class implements the SBC codec specific data handling. +* +*/ + + + + +#ifndef __BTAUDIOSTREAMSENDERSBC_H__ +#define __BTAUDIOSTREAMSENDERSBC_H__ + +#include "btaudiostreamsender.h" + +/** + * SBC codec specific implementation of CBTAudioStreamSender base class + * + * This class wraps the handling of SBC frames and it can place the + * media packet header in place. + + * @lib btaudiostreamer.lib + * @since S60 v3.1 + */ +NONSHARABLE_CLASS(CBTAudioStreamSenderSBC) : public CBTAudioStreamSender + { + public: + static CBTAudioStreamSenderSBC* NewL(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession); + virtual ~CBTAudioStreamSenderSBC(); + + private: + CBTAudioStreamSenderSBC(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession); + + /** + * From CBTAudioStreamSender. + * This method places to received buffer into the send packet in SBC specific way. + * + * @since S60 v3.1 + * @param aBuffer contains the SBC frames. + */ + virtual TInt AddBufferToSendPacket(const TDesC8& aBuffer); + + /** + * From CBTAudioStreamSender. + * This method places the SBC codec specific media packet header in its place. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt AddHeaderToSendPacket(TPtr8& aPayloadDesC); + + /** + * From CBTAudioStreamSender. + * This method does the cleanup work after the packet has been sent. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt PacketSendingCompleted(TPtr8& aPayloadDesC); + + /** + * From CBTAudioStreamSender. + * This method is used for calculating the required packet length. + * It takes the header's into account and tries to fit as many frames + * to the packet that can fit to the outgoing MTU. + * + * @since S60 v3.1 + * @param aOutboundMTUSize The MTU size for outgoing L2CAP link. + * @param aFrameLength The length of one SBC frame. + */ + virtual TInt CalculatePacketLength(TUint aOutboundMTUSize, TUint aFrameLength); + + /** + * From CBTAudioStreamSender. + * This method prepares the class for sending packets. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt InitSender(RRtpSendPacket& aSendPacket, TPtr8& aPayloadDesC, const TUint aTargetBitrate); + + /** + * From CBTAudioStreamSender. + * This method corrects the timestamp value when incoming buffers can't fit in one sendpacket. + * + * @since S60 v5.0 + * @param void. + * @return void. + */ + virtual void AdjustTimestamp(TInt64 &aTimestamp); + + /** + * + * This method calculates the playing time of one frame in microseconds. + * Information is used also internally for correcting the timestamp values. + * + * @since S60 v5.0 + * @param void. + * @return a duration of one frame. + */ + virtual TUint CalculateFrameDuration(const TUint aFrameLength, const TUint aTargetBitrate); + + /** + * This method returns the maximum number of frames in one outgoing packet. + * + * @since S60 Timebox 9.2 + * @return number of frames in one send packet. + */ + virtual TUint MaxFramesPerPacket(); + + + private: + + /** + * Stores the corrected timestamp value. + */ + TInt64 iTimestampOfFirstFrameInSendPacket; + + /** + * Stores the length of one SBC frame. + */ + TInt iFrameLength; + + /** + * Stores the length of one SBC frame. Used when the frame length changes. + */ + TInt iNewFrameLength; + + /** + * Stores the duration of one SBC frame in microseconds. Used for correcting the timestamps in long buffers. + */ + TInt iDurationOfFrame; + + /** + * Used for calculating how many frames can fit in one SendPacket. + */ + TInt iSpaceNeededForBuffer; + + /** + * Stores the number of frames we have moved from buffer to packet so far. + * This variable is needed when the whole buffer can't fit in the current packet. + */ + TInt iNumOfFramesAlreadyMoved; + + /** + * Stores the maximum number of frames that we can place in one packet. + */ + TInt iMaxNumOfFrames; + + /** + * This stores the number of frames in send packet. + * This information is needed for A2DP media packet header. + */ + TInt iNumOfFramesInSendPacket; + + /** + * This stores the end position of the SendPacket's payload. + */ + const TUint8 *iPtrEndOfPayload; + + /** + * This stores the number of frames that haven't been sent yet. It's needed if + * there's more incoming frames than can fit in single SendPacket. + */ + TInt iNumOfFramesLeftInBuffer; + + /** + * This tells if it is time to start using the passed in timestamp as reference. + */ + TBool iTimestampChangeFlag; + + }; + +#endif // __BTAUDIOSTREAMSENDERSBC_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/rom/btaudiostreamer.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/rom/btaudiostreamer.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef __BTAUDIOSTREAMER_IBY__ +#define __BTAUDIOSTREAMER_IBY__ + +#if defined __BT_STEREO_AUDIO + +file=ABI_DIR\BUILD_DIR\btaudiostreamer.dll SHARED_LIB_DIR\btaudiostreamer.dll + +#endif // __BT_STEREO_AUDIO + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/src/btaudiostreamer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/src/btaudiostreamer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2005 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: Contains an implementation of CBTAudioStreamer class. +* +*/ + + +#include +#include + +#include "btaudiostreamerdebug.h" +#include "btaudiostreamer.h" +#include "btaudiostreamsender.h" + +const TInt KL2CAPDefaultMTUSize = 672; + +// --------------------------------------------------------------------------- +// Constructor. +// --------------------------------------------------------------------------- +// +CBTAudioStreamer::CBTAudioStreamer() : iStarted(EFalse) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::CBTAudioStreamer() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::CBTAudioStreamer() <-"))); + } + +// --------------------------------------------------------------------------- +// Static factory method. +// --------------------------------------------------------------------------- +// +EXPORT_C CBTAudioStreamer* CBTAudioStreamer::NewL() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::NewL() ->"))); + CBTAudioStreamer* self = new (ELeave) CBTAudioStreamer(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::NewL() <-"))); + return self; + } + +// --------------------------------------------------------------------------- +// Symbian OS second phase contruction. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamer::ConstructL() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::ConstructL() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::ConstructL() <-"))); + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CBTAudioStreamer::~CBTAudioStreamer() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::~CBTAudioStreamer() ->"))); + Stop(); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::~CBTAudioStreamer() <-"))); + } + +// --------------------------------------------------------------------------- +// This method prepares the streamer for incoming data. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTAudioStreamer::SetNewFrameLength(const TUint aFrameLength, const TUint aTargetBitrate) +{ + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::SetNewFrameLength() ->"))); + TInt retVal = KErrGeneral; + if(iStarted != EFalse) + { + TInt outboundMTUSize; + // if(aSocket.GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, outboundMTUSize) != KErrNone) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Failed to get outbound MTU size, using L2CAP default value"))); + outboundMTUSize = KL2CAPDefaultMTUSize; + } + retVal = iSender->SetNewFrameLength(outboundMTUSize, aFrameLength, aTargetBitrate); + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Error: Not started!"))); + retVal = KErrNotReady; + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::SetNewFrameLength() <-"))); + return retVal; +} + +// --------------------------------------------------------------------------- +// This method prepares the streamer for incoming data. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTAudioStreamer::StartL(RSocket& aSocket, const TUint aFrameLength, CBTAudioStreamInputBase *aAudioInput, const TUint aTargetBitrate) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::StartL() ->"))); + iAudioInput = aAudioInput; + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Framelength: %d"), aFrameLength)); + + if(iStarted != EFalse) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Error: Already started!"))); + User::Leave(KErrInUse); + } + + TInt inboundMTUSize = 0; + if(aSocket.GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, inboundMTUSize) != KErrNone) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Failed to get inbound MTU size, using L2CAP default value"))); + inboundMTUSize = KL2CAPDefaultMTUSize; + } + + iRtpSession.OpenL(aSocket, inboundMTUSize); + iSender = CBTAudioStreamSender::NewL(*this, iRtpSession); + + TInt outboundMTUSize; + if(aSocket.GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, outboundMTUSize) != KErrNone) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Failed to get outbound MTU size, using L2CAP default value"))); + outboundMTUSize = KL2CAPDefaultMTUSize; + } + + iSender->StartL(outboundMTUSize, aFrameLength, aTargetBitrate); + + iStarted = ETrue; + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::StartL() <-"))); + } + +// ------------------------------------------------------------------------------------------ +// This method cleans up the streamer and releases the resources it reserved for streaming. +// ------------------------------------------------------------------------------------------ +// +EXPORT_C void CBTAudioStreamer::Stop() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::Stop() ->"))); + + if(iStarted != EFalse) // Don't delete things unless we have started, thus created those. + { + if(iSender) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Stopping and deleting the stream sender."))); + iSender->Stop(); + delete iSender; + iSender = NULL; + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Error! Stream sender was deleted while the streamer was running!"))); + } + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Closing RTP session."))); + iRtpSession.Close(); + } + + iAudioInput = NULL; + iStarted = EFalse; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::Stop() <-"))); + } + +TInt CBTAudioStreamer::Receive(const TDesC8& /*aBuffer*/) + { + return KErrNotSupported; + } + +TInt CBTAudioStreamer::Receive(const TDesC8& aBuffer, TTimeIntervalMicroSeconds aTimestamp) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::Receive() ->"))); + TInt retval = iSender->SendThisBuffer(aBuffer, aTimestamp); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::Receive() <-"))); + return retval; + } + +void CBTAudioStreamer::NotifyBufferSent( const TDesC8 &aBuffer ) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::NotifyBufferSent() ->"))); + if(iAudioInput) iAudioInput->BufferEmptied(aBuffer); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::NotifyBufferSent() <-"))); + } + +void CBTAudioStreamer::NotifyErrorSending( const TDesC8 &/*aBuffer*/ ) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::NotifyErrorSending() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamer::NotifyErrorSending() <-"))); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/src/btaudiostreamsender.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/src/btaudiostreamsender.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,538 @@ +/* +* Copyright (c) 2005 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: Contains an implementation of CBTAudioStreamSender class. +* +*/ + + +#include "btaudiostreamsender.h" +#include "btaudiostreamsendersbc.h" +#include "btaudiostreamerdebug.h" +#include // TBTSockAddr + +// --------------------------------------------------------------------------- +// Constructor. +// --------------------------------------------------------------------------- +// +CBTAudioStreamSender::CBTAudioStreamSender(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession) : + CActive(EPriorityHigh), + iObserver(aObserver), + iRtpSession(aSession), + iPayloadDesC(NULL,NULL), + iLinkOptimiserAvailable(EFalse) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::CBTAudioStreamSender() ->"))); + CActiveScheduler::Add(this); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::CBTAudioStreamSender() <-"))); + } + +// --------------------------------------------------------------------------- +// Symbian OS second phase contruction. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::ConstructL() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ConstructL() ->"))); + + iSendSrc = iRtpSession.NewSendSourceL(); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t New send source created."))); + iSendSrc.PrivRegisterEventCallbackL(ERtpSendSucceeded, (TRtpCallbackFunction)CBTAudioStreamSender::PacketSent, this); + iSendSrc.PrivRegisterEventCallbackL(ERtpSendFail, (TRtpCallbackFunction)CBTAudioStreamSender::SendError, this); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Callbacks registered."))); + + iStreamerState = EStopped; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: EStopped"))); + + iThread = RThread(); + + iCurrentSendPacket = new (ELeave) RRtpSendPacket; + + iSpareSendPacket = new (ELeave) RRtpSendPacket; + + if(iA2DPOptimiser.Open() == KErrNone) + { + iLinkOptimiserAvailable = ETrue; + } + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ConstructL() <-"))); + } + +// --------------------------------------------------------------------------- +// Static factory method. +// --------------------------------------------------------------------------- +// +CBTAudioStreamSender* CBTAudioStreamSender::NewL(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::NewL() ->"))); + if (!aSession.IsOpen()) + { + User::Leave(KErrArgument); + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::NewL() <-"))); + return CBTAudioStreamSenderSBC::NewL(aObserver, aSession); + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CBTAudioStreamSender::~CBTAudioStreamSender() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::~CBTAudioStreamSender() ->"))); + Cancel(); + if(iCurrentSendPacket) + { + if(iCurrentSendPacket->IsOpen() != EFalse) + { + iCurrentSendPacket->Close(); + } + delete iCurrentSendPacket; + iCurrentSendPacket = NULL; + } + + if(iSpareSendPacket) + { + if(iSpareSendPacket->IsOpen() != EFalse) + { + iSpareSendPacket->Close(); + } + delete iSpareSendPacket; + iSpareSendPacket = NULL; + } + iSendSrc.Close(); + + if(iLinkOptimiserAvailable) + { + iA2DPOptimiser.Close(); + } + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::~CBTAudioStreamSender() <-"))); + } + +// --------------------------------------------------------------------------- +// This is the static callback method which CBTAudioStreamSender registers with the RtpSession to be called +// when a packet is _successfully_ sent. It is a static method so simply calls a processing +// method on the class pointed to be aPtr (which is the CBTAudioStreamSender which registered the cb). +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::PacketSent(CBTAudioStreamSender* aPtr, const TRtpEvent& /*aEvent*/) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::PacketSent() ->"))); + aPtr->DoPacketSent(); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::PacketSent() <-"))); + } + +// --------------------------------------------------------------------------- +// An instance method which is called by the static callback function. We simply notify the +// observer if all data has been sent. If it hasn't, then we send more data. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::DoPacketSent() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::DoPacketSent() ->"))); + + // First check if we're Stopping. + if(iStreamerState == EStopped) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t Stopping and packet sending completed."))); + iObserver.NotifyBufferSent(*iBuffer); // Return the buffer. + return; // No need to do more here, we're stopping. + } + else + { + iStreamerState = EBuffering; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: EBuffering"))); + } + + PacketSendingCompleted(iPayloadDesC); + + // If we're here, then there either is data in the buffer or it has been emptied completely. + // Check this by calling the method again. If we consumed the buffer completely, + // the method just signals the observer. + if(iNonprocessedDataInBuffer != EFalse) + { + // Check if we need to start using new sendpacket. + if(iChangingFrameLength != EFalse) + { + SwitchToNewSendPacket(); + } + ConsumeBuffer(); + } + else + { + iObserver.NotifyBufferSent(*iBuffer); + } + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::DoPacketSent() <-"))); +} + +// --------------------------------------------------------------------------- +// This is the static callback method which CBTAudioStreamSender registers with the RtpSession to be called +// when a packet sending fails. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::SendError(CBTAudioStreamSender* aPtr, const TRtpEvent& /*aEvent*/) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendError() ->"))); + aPtr->DoSendError(); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendError() <-"))); + } + +// --------------------------------------------------------------------------- +// An instance method which is called by the static callback function. +// We set the state to EErrorSending and handle the error next time in RunL. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::DoSendError() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::DoSendError() ->"))); + + iStreamerState = EErrorSending; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: EErrorSending"))); + if (!IsActive()) + { + TRequestStatus *status = &iStatus; + iStatus = KRequestPending; + iThread.RequestComplete(status, KErrNone); + SetActive(); + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::DoSendError() <-"))); + } + +// --------------------------------------------------------------------------- +// This method is for setting the sender up. +// --------------------------------------------------------------------------- +// +TInt CBTAudioStreamSender::SetNewFrameLength(TUint aOutboundMTUSize, const TUint aFrameLength, const TUint aTargetBitrate) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SetNewFrameLength() ->"))); + TInt retVal = KErrGeneral; + + // Don't proceed if the previous change is not completed yet. + if(iChangingFrameLength != EFalse) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Previous frame length change still ongoing!"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SetNewFrameLength() <-"))); + return KErrInUse; + } + + if(iSpareSendPacket) + { + __ASSERT_DEBUG(!iSpareSendPacket->IsOpen(),User::Invariant()); + } + + TInt requiredPacketLength = CalculatePacketLength(aOutboundMTUSize, aFrameLength); + + if(requiredPacketLength > 0) + { + iNewFrameLength = aFrameLength; + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Creating new sendpacket."))); + __ASSERT_DEBUG(iSpareSendPacket, User::Invariant()); + TRAPD(ret, *iSpareSendPacket = iSendSrc.NewSendPacketL(requiredPacketLength)); + if( ret ) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t ERROR! Creating new sendpacket failed."))); + return KErrGeneral; + } + iChangingFrameLength = ETrue; + retVal = KErrNone; + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t Error! Packet length must be greater than zero!"))); + retVal = KErrArgument; + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SetNewFrameLength() <-"))); + + iTargetBitrate = aTargetBitrate; + return retVal; + } + + +// --------------------------------------------------------------------------- +// This method is for setting the sender up. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::StartL(TUint aOutboundMTUSize, const TUint aFrameLength, const TUint aTargetBitrate) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::StartL() ->"))); + if(iCurrentSendPacket) + { + __ASSERT_DEBUG(!iCurrentSendPacket->IsOpen(),User::Invariant()); + } + TInt requiredPacketLength = CalculatePacketLength(aOutboundMTUSize, aFrameLength); + + if(requiredPacketLength > 0) + { + __ASSERT_DEBUG(iCurrentSendPacket, User::Invariant()); + *iCurrentSendPacket = iSendSrc.NewSendPacketL(requiredPacketLength); + iTargetBitrate = aTargetBitrate; + InitSender(*iCurrentSendPacket, iPayloadDesC, iTargetBitrate); + iStreamerState = EBuffering; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: EBuffering"))); + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t Error! Packet length must be greater than zero!"))); + User::Leave(KErrArgument); + } + + // Streaming started, optimise the ACL link if optimiser service is available. + if(iLinkOptimiserAvailable) + { + // The below code is to get the connected device's BT Address. + TBTSockAddr addr; + iRtpSession.RtpSocket()->RemoteName(addr); + TUint accessLatency = MaxFramesPerPacket() * CalculateFrameDuration(aFrameLength, aTargetBitrate); + // Not checking the return code, because it doesn't matter if it fails. + iA2DPOptimiser.OptimiseAclForAudioStreaming(addr.BTAddr(), aTargetBitrate, accessLatency); + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::StartL() <-"))); + } + +// --------------------------------------------------------------------------- +// This method is for closing the sender down. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::Stop() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::Stop() ->"))); + // Make sure that the packet is not out at the moment. + Cancel(); + if(iCurrentSendPacket->IsOpen() != EFalse) + { + iCurrentSendPacket->Close(); + } + + if(iSpareSendPacket->IsOpen() != EFalse) + { + iSpareSendPacket->Close(); + } + + // Remove the ACL link optimisation if optimiser service is available. + if(iLinkOptimiserAvailable) + { + TBTSockAddr addr; + iRtpSession.RtpSocket()->RemoteName(addr); + // Not checking the return code, because it doesn't matter if it fails. + iA2DPOptimiser.RemoveAclOptimisation(addr.BTAddr()); + } + iStreamerState = EStopped; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: EStopped"))); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::Stop() <-"))); + } + +// --------------------------------------------------------------------------- +// From class CBTAudioStreamSender. +// RunL will be called when ConsumeBuffer has decided that we have enough +// frames for one packet, or DoSendError was called. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::RunL() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::RunL() ->"))); + switch(iStreamerState) + { + case ESending: + { + // Set A2DP media packet header. + AddHeaderToSendPacket(iPayloadDesC); + + // Use the timestamp from the first buffer. + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Adjust and set timestamp."))); + iCurrentSendPacket->SetTimestamp(iAdjustedTimestamp); + + // Set the length and send the packet. + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Set length."))); + iCurrentSendPacket->WritePayload().SetLength(iPayloadDesC.Length()); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Send."))); + iCurrentSendPacket->Send(); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Packet has transferred to RTP API."))); + } + break; + case EBuffering: + { + // Note: Here we will check that no packets were discarded while waiting for the sending to complete. + // If that happens, we could inform SAC and then try to decrease the bitrate. + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Packet sent succesfully."))); + iPayloadDesC.Zero(); + } + break; + case EErrorSending: + { + // Note: Inform the observer + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Packet sending failed."))); + iPayloadDesC.Zero(); + PacketSendingCompleted(iPayloadDesC); + iStreamerState = EBuffering; + + // Tell client that we're ready for more data. Method name is misleading, but we will request for more + // until the observer tells us to stop. + iObserver.NotifyBufferSent(*iBuffer); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: EBuffering"))); + } + break; + default: + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Error: RunL is in incorrect state!"))); + } + break; + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::RunL() <-"))); + } + +// --------------------------------------------------------------------------- +// For sending the frames. +// --------------------------------------------------------------------------- +// +TInt CBTAudioStreamSender::SendThisBuffer(const TDesC8& aBuffer, TTimeIntervalMicroSeconds aTimestamp) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendThisBuffer() ->"))); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Received timestamp low: %d"), I64LOW(aTimestamp.Int64()))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Received timestamp high: %d"), I64HIGH(aTimestamp.Int64()))); + + // Store the buffer's address for later reference. + iBuffer = &aBuffer; + + if(iChangingFrameLength != EFalse) + { + // Check the new framelength... + if(aBuffer.Length() == iNewFrameLength) // Check if the buffer exactly of the new length. + { + // If we have data with previous frame length in buffer, send it first. + if(iNonprocessedDataInBuffer != EFalse) + { + ProceedToPacketSending(); + return KErrNone; + } + else // Else we can switch to new packet immediately and continue processing this buffer. + { + SwitchToNewSendPacket(); + } + } + else if(aBuffer.Length() > iNewFrameLength) // Check if it's safe to peek at index iNewFrameLength. + { + if(aBuffer[iNewFrameLength] == 0x9c) // Check if the index iNewFrameLength the syncword. + { + // If we have data with previous frame length in buffer, send it first. + if(iNonprocessedDataInBuffer != EFalse) + { + ProceedToPacketSending(); + return KErrNone; + } + else // Else we can switch to new packet immediately and continue processing this buffer. + { + SwitchToNewSendPacket(); + } + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender: Still waiting for packets of the new frame length..."))); + } + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender: Still waiting for packets of the new frame length..."))); + // Encoder has not yet started to use the new frame length. + } + } + else if(iStreamerState != EBuffering) + { + // Previous sending is not yet completed or there is was an error that is not yet handled. + // Just discard the incoming frame. + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender error: Previous buffer sending hasn't completed - discarding this buffer."))); + iObserver.NotifyBufferSent(aBuffer); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendThisBuffer() <-"))); + return KErrOverflow; + } + + // Store the timestamp for later use. + iTimestamp = aTimestamp.Int64(); + + iNonprocessedDataInBuffer = ETrue; + ConsumeBuffer(); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendThisBuffer() <-"))); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Cancellation. +// --------------------------------------------------------------------------- +// +void CBTAudioStreamSender::DoCancel() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::DoCancel() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::DoCancel() <-"))); + } + +inline void CBTAudioStreamSender::ConsumeBuffer() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ConsumeBuffer() ->"))); + if (!IsActive()) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ConsumeBuffer() ok to send"))); + + TInt spaceLeftInSendPacket = AddBufferToSendPacket(*iBuffer); + iAdjustedTimestamp = iTimestamp; // take a copy, because we want to keep the original timestamp. + if(spaceLeftInSendPacket >= 0) + { + iNonprocessedDataInBuffer = EFalse; // This indicates that there's no need to call this method after sending. + } + ProceedToPacketSending(); + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ConsumeBuffer() <-"))); + } + + +inline void CBTAudioStreamSender::ProceedToPacketSending() +{ + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ProceedToPacketSending() ->"))); + iStreamerState = ESending; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTSTATE, FLOG(_L("[BTAudioStreamer]\t State changed to: ESending"))); + TRequestStatus *status = &iStatus; + iStatus = KRequestPending; + iThread.RequestComplete(status, KErrNone); + SetActive(); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::ProceedToPacketSending() <-"))); +} + +inline void CBTAudioStreamSender::SwitchToNewSendPacket() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SwitchToNewSendPacket() ->"))); + + // Make the iCurrentSendPacket point to the spare packet opened when the frame length change came. + RRtpSendPacket* oldSendPacket; + oldSendPacket = iCurrentSendPacket; + iCurrentSendPacket = iSpareSendPacket; + iSpareSendPacket = oldSendPacket; + + // The previously used send packet (which has now become the spare send packet) can be closed. + oldSendPacket->Close(); + + // The rest of the initializations: + InitSender(*iCurrentSendPacket, iPayloadDesC, iTargetBitrate); + + iChangingFrameLength = EFalse; + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SwitchToNewSendPacket() <-"))); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/src/btaudiostreamsendersbc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/src/btaudiostreamsendersbc.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2005 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: Contains an implementation of CBTAudioStreamSenderSBC class. +* +*/ + + +#include "btaudiostreamsendersbc.h" +#include "btaudiostreamerdebug.h" + +const TInt KA2DPMediaPacketHeaderLength = 1; +const TInt KA2DPMediaPacketHeaderIndex = 0; +const TInt KRTPHeaderLength = 12; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Constructor. +// --------------------------------------------------------------------------- +// +CBTAudioStreamSenderSBC::CBTAudioStreamSenderSBC(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession): + CBTAudioStreamSender(aObserver, aSession) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CBTAudioStreamSenderSBC() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CBTAudioStreamSenderSBC() <-"))); + } + +// --------------------------------------------------------------------------- +// Factory method. +// --------------------------------------------------------------------------- +// +/*static*/ CBTAudioStreamSenderSBC* CBTAudioStreamSenderSBC::NewL(MBTAudioStreamSenderObserver& aObserver, RRtpSession& aSession) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::NewL() ->"))); + + CBTAudioStreamSenderSBC* self = new (ELeave) CBTAudioStreamSenderSBC(aObserver, aSession); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::NewL() <-"))); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CBTAudioStreamSenderSBC::~CBTAudioStreamSenderSBC() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::~CBTAudioStreamSenderSBC() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::~CBTAudioStreamSenderSBC() <-"))); + } + +// --------------------------------------------------------------------------- +// From class CBTAudioStreamSender. +// This method stores the frames to the frame buffer and +// when we have enough frames. +// --------------------------------------------------------------------------- +// +TInt CBTAudioStreamSenderSBC::AddHeaderToSendPacket(TPtr8& aPayloadDesC) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::AddHeaderToSendPacket() ->"))); + aPayloadDesC[KA2DPMediaPacketHeaderIndex] = iNumOfFramesInSendPacket; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::AddHeaderToSendPacket() <-"))); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// From class CBTAudioStreamSender. +// This method stores the frames to the frame buffer and +// when we have enough frames. +// --------------------------------------------------------------------------- +// +TInt CBTAudioStreamSenderSBC::AddBufferToSendPacket(const TDesC8& aBuffer) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::AddBufferToSendPacket() ->"))); + // Copy data from the buffer to the outgoing packet. + // The return code means how many frames can still fit in the SendPacket. + // - If there's more space, the value > 0. In this case we need more data. + // - If the buffer is full and all data was consumed, the value == 0. In this case the packet must be sent. + // - If the buffer is full and all data didn't fit in it, the value < 0. The packet must be sent and this method called again with the same frame. + + // Calculate how many frames there's left in the buffer. Note that iFrameLength must always be greater than zero. + TInt numOfFramesLeftInBuffer = (aBuffer.Length() / iFrameLength) - iNumOfFramesAlreadyMoved ; + + // If the whole buffer can fit in packet, move it completely, otherwise move as many frames as can fit. + TInt numOfFramesToMove = numOfFramesLeftInBuffer <= iMaxNumOfFrames - iNumOfFramesInSendPacket ? + numOfFramesLeftInBuffer : + iMaxNumOfFrames - iNumOfFramesInSendPacket; + + // Some traces for seeing what's going on. + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Filling sendpacket..."))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t %d frames can fit in packet."), iMaxNumOfFrames)); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t %d frames have already been moved from current buffer to sendpacket."), iNumOfFramesAlreadyMoved)); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t %d frames left to move from current buffer."), numOfFramesLeftInBuffer)); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t %d frames already in current packet."), iNumOfFramesInSendPacket)); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t => Moving %d frames."), numOfFramesToMove)); + + // Move the number of frames calculated above to the packet: + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t replacing sendpacket content from %d, length is %d..."), KA2DPMediaPacketHeaderLength + iNumOfFramesInSendPacket * iFrameLength, numOfFramesToMove * iFrameLength)); + + // Make the ptrNextFrameInBuffer point to the first frame that hasn't been moved. + const TUint8 * ptrNextFrameInBuffer = aBuffer.Ptr() + iNumOfFramesAlreadyMoved * iFrameLength; + memcpy((void *)iPtrEndOfPayload, (void *)ptrNextFrameInBuffer, numOfFramesToMove * iFrameLength); + iPtrEndOfPayload += numOfFramesToMove * iFrameLength; + ptrNextFrameInBuffer += numOfFramesToMove * iFrameLength; + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t %d frames moved from buffer to packet."), numOfFramesToMove)); + + // If we have now moved them all, reset the counter, otherwise update it for the next round. + iNumOfFramesAlreadyMoved = numOfFramesLeftInBuffer == numOfFramesToMove ? 0 : iNumOfFramesAlreadyMoved + numOfFramesToMove; + + // update the information needed for building the header later (in sending phase): + iNumOfFramesInSendPacket += numOfFramesToMove; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t iNumOfFramesInSendPacket incremented, it is now %d"), iNumOfFramesInSendPacket)); + + numOfFramesLeftInBuffer -= numOfFramesToMove; + + // return the number of frames that will still fit in the packet: + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t returning: %d"), iMaxNumOfFrames - iNumOfFramesInSendPacket - numOfFramesLeftInBuffer)); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::AddBufferToSendPacket() <-"))); + return (iMaxNumOfFrames - iNumOfFramesInSendPacket - numOfFramesLeftInBuffer); + } + +// --------------------------------------------------------------------------- +// From class CBTAudioStreamSender. +// This method stores the frames to the frame buffer and +// when we have enough frames. +// --------------------------------------------------------------------------- +// +TInt CBTAudioStreamSenderSBC::PacketSendingCompleted(TPtr8& aPayloadDesC) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::PacketSendingCompleted() ->"))); + iNumOfFramesInSendPacket = 0; + iPtrEndOfPayload = aPayloadDesC.Ptr() + KA2DPMediaPacketHeaderLength; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::PacketSendingCompleted() <-"))); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// From class CBTAudioStreamSender. +// This method sets up the sender and calculates the required packet +// length according to its own implementation. +// --------------------------------------------------------------------------- +// +TInt CBTAudioStreamSenderSBC::InitSender(RRtpSendPacket& aSendPacket, TPtr8& aPayloadDesC, const TUint aTargetBitrate) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::InitSender() ->"))); + iFrameLength = iNewFrameLength; + iMaxNumOfFrames = iSpaceNeededForBuffer / iFrameLength; + + // Make the descriptor point in the beginning of the send packet. + aPayloadDesC.Set(const_cast(aSendPacket.WritePayload().Ptr()), iSpaceNeededForBuffer, iSpaceNeededForBuffer); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Descriptor inited, space needed: %d bytes."), iSpaceNeededForBuffer)); + + iPtrEndOfPayload = aPayloadDesC.Ptr() + KA2DPMediaPacketHeaderLength; + + iNumOfFramesInSendPacket = 0; + + iTimestampOfFirstFrameInSendPacket = 0; + + iDurationOfFrame = CalculateFrameDuration(iFrameLength, aTargetBitrate); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t iDurationOfFrame: %d"), iDurationOfFrame)); + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::InitSender() <-"))); + return KErrNone; + } + +TInt CBTAudioStreamSenderSBC::CalculatePacketLength(TUint aOutboundMTUSize, const TUint aFrameLength) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CalculatePacketLength() <-"))); + if(aFrameLength > 0) // Must not be zero, and cannot be according to A2DP spec. + { + iNewFrameLength = aFrameLength; + + iSpaceNeededForBuffer = ((aOutboundMTUSize - KA2DPMediaPacketHeaderLength - KRTPHeaderLength) / iNewFrameLength) * iNewFrameLength + KA2DPMediaPacketHeaderLength; + + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CalculatePacketLength() <-"))); + return iSpaceNeededForBuffer; + } + else + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Length parameter is zero!"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CalculatePacketLength() <-"))); + return 0; + } + } + +TUint CBTAudioStreamSenderSBC::CalculateFrameDuration(const TUint aFrameLength, const TUint aTargetBitrate) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CalculateFrameInterval() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::CalculateFrameInterval() <-"))); + return static_cast(static_cast(aFrameLength * 8) / static_cast(aTargetBitrate) * 1000000.0); + } + +TUint CBTAudioStreamSenderSBC::MaxFramesPerPacket() + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::FramesPerPacket() ->"))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::FramesPerPacket() <-"))); + return iMaxNumOfFrames; + } + +void CBTAudioStreamSenderSBC::AdjustTimestamp(TInt64& aTimestamp) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::AdjustTimestamp() ->"))); + + // The buffer has been emptied, but there may be space for additional frames in sendpacket. + // So keep the current timestamp until the sendpacket becomes full. + if(iNumOfFramesAlreadyMoved == 0) + { + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t Buffer became empty."))); + iTimestampChangeFlag = ETrue; + } + + if(iNumOfFramesInSendPacket == iMaxNumOfFrames) // Adjust the timestamp only when the sendpacket is full. + { + if(iTimestampChangeFlag != EFalse) + { + // When the buffer been emptied earlier, take the new timestamp into use and adjust it by the amount of frames we just moved. + iTimestampOfFirstFrameInSendPacket = aTimestamp + iDurationOfFrame * iNumOfFramesAlreadyMoved; + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t New timestamp %d (low) is in use."), I64LOW(aTimestamp))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t New timestamp %d (high) is in use."), I64HIGH(aTimestamp))); + iTimestampChangeFlag = EFalse; + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Timestamp is %d (low)"), I64LOW(iTimestampOfFirstFrameInSendPacket))); + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Timestamp is %d (high)"), I64HIGH(iTimestampOfFirstFrameInSendPacket))); + + // Use the timestamp first and then do a normal adjustment for the next round. + aTimestamp = iTimestampOfFirstFrameInSendPacket; + iTimestampOfFirstFrameInSendPacket = iTimestampOfFirstFrameInSendPacket + iMaxNumOfFrames * iDurationOfFrame; + } + BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSenderSBC::AdjustTimestamp() <-"))); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/Bmarm/BtAudioStreamerApiTestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/Bmarm/BtAudioStreamerApiTestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/Bwins/BtAudioStreamerApiTestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/Bwins/BtAudioStreamerApiTestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/EABI/BtAudioStreamerApiTestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/EABI/BtAudioStreamerApiTestU.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/conf/BtAudioStreamerApiTest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/conf/BtAudioStreamerApiTest.cfg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,23 @@ +//BtAudioStreamer tests + +[Test] +title BT Initialization Test +create BtAudioStreamerApiTest tester +tester InitializationTest +delete tester +[Endtest] + +[Test] +title BT Start/Stop Audio Streamer Test +create BtAudioStreamerApiTest tester +tester StartStopTest +delete tester +[Endtest] + + +[Test] +title BT Set New Frame Length Test +create BtAudioStreamerApiTest tester +tester SetNewFrameLengthTest +delete tester +[Endtest] diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/BtAudioStreamerApiTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/BtAudioStreamerApiTest.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 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: +* +*/ + +#if defined(__S60_) + // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET BtAudioStreamerApiTest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +SECUREID 0x101F457F + +CAPABILITY ALL -TCB + +//TARGETPATH ?target_path +DEFFILE BtAudioStreamerApiTest.def + +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + + +SOURCEPATH ../src +SOURCE BtAudioStreamerApiTest.cpp +SOURCE BtAudioStreamerApiTestBlocks.cpp BtAudioStreamerObserver.cpp + + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY btaudiostreamer.lib +LIBRARY btaudioadaptation.lib +LIBRARY esock.lib + +LANG SC + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/BtAudioStreamerApiTest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/BtAudioStreamerApiTest.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +; +; Copyright (c) 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: +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\udeb\BtAudioStreamerApiTest.dll"-"c:\Sys\Bin\BtAudioStreamerApiTest.dll" +"..\init\BtAudioStreamerApiTest.ini"-"e:\testing\init\BtAudioStreamerApiTest.ini" +"..\conf\BtAudioStreamerApiTest.cfg"-"e:\testing\conf\BtAudioStreamerApiTest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/BtAudioStreamerApiTest_phone.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/BtAudioStreamerApiTest_phone.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +; +; Copyright (c) 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: +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x1028315F], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\urel\BtAudioStreamerApiTest.dll"-"c:\Sys\Bin\BtAudioStreamerApiTest.dll" +"..\init\BtAudioStreamerApiTest_phone.ini"-"c:\testframework\testframework.ini" +"..\conf\BtAudioStreamerApiTest.cfg"-"c:\testframework\BtAudioStreamerApiTest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTEXPORTS + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +BtAudioStreamerApiTest.mmp + +PRJ_MMPFILES + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/build_sis.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/build_sis.bat Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +call abld test build armv5 +call makesis BtAudioStreamerApiTest.pkg +call signsis BtAudioStreamerApiTest.sis BtAudioStreamerApiTest.sisx rd.cer rd-key.pem diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/build_sis_phone.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group/build_sis_phone.bat Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +call abld test build armv5 +call makesis BtAudioStreamerApiTest_phone.pkg +call signsis BtAudioStreamerApiTest_phone.sis BtAudioStreamerApiTest_phone.sisx rd.cer rd-key.pem diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/inc/BtAudioStreamerApiTest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/inc/BtAudioStreamerApiTest.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + + +#ifndef BTAUDIOSTREAMERAPITEST_H +#define BTAUDIOSTREAMERAPITEST_H + +// INCLUDES +#include +#include +#include +#include +#include +#include + +#include "bt_sock.h" +#include "btaudiostreamer.h" +#include "btaudiostreaminputbase.h" +#include "BtAudioStreamerObserver.h" + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +//_LIT( KBtAudioStreamerApiTestLogPath, "\\logs\\testframework\\bt\\" ); +_LIT( KBtAudioStreamerApiTestLogPath, "e:\\testing\\stiflogs\\" ); +// Log file +_LIT( KBtAudioStreamerApiTestLogFile, "BtAudioStreamerApiTest.txt" ); +_LIT( KBtAudioStreamerApiTestLogFileWithTitle, "BtAudioStreamerApiTest_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CBtAudioStreamerApiTest; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CBtAudioStreamerApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CBtAudioStreamerApiTest) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBtAudioStreamerApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CBtAudioStreamerApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CBtAudioStreamerApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Example test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt InitializationTest( CStifItemParser& aItem ); + virtual TInt StartStopTest( CStifItemParser& aItem ); + virtual TInt SetNewFrameLengthTest( CStifItemParser& aItem ); + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + TInt ConfigureEncoderInterface(); + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + CBTAudioStreamer* iBtAudioStreamer; + CBTAudioStreamInputBase* iBtAudioStreamInputBase; + CBtAudioStreamerObserver* iBtAudioStreamerObserver; + CSbcEncoderIntfc* iSbcEncoderIntfc; + + RSocketServ iSocketServer; + RSocket iSocket; + + }; + +#endif // BTAUDIOSTREAMERAPITEST_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/inc/BtAudioStreamerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/inc/BtAudioStreamerObserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTAUDIOSTREAMEROBSERVER_H_ +#define BTAUDIOSTREAMEROBSERVER_H_ + +#include +#include "btaudiostreaminputbase.h" + +NONSHARABLE_CLASS( CBtAudioStreamerObserver ) : public MBTAudioErrorObserver +{ +public: + static CBtAudioStreamerObserver* NewL( CStifLogger* aLog ); + ~CBtAudioStreamerObserver(); + + virtual TInt Error(const TInt aError); + +private: + CBtAudioStreamerObserver( CStifLogger* aLog ); + void ConstructL(); + +private: + CStifLogger* iLog; + +}; + +#endif /*BTAUDIOSTREAMEROBSERVER_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/init/BtAudioStreamerApiTest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/init/BtAudioStreamerApiTest.ini Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,218 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= e:\testing\logs\ +TestReportFileName= BtAudioStreamerApiTest + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= e:\testing\conf\BtAudioStreamerApiTest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/init/BtAudioStreamerApiTest_phone.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/init/BtAudioStreamerApiTest_phone.ini Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,218 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= c:\logs\testframework\bt\ +TestReportFileName= BtAudioStreamerApiTest + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\BtAudioStreamerApiTest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/src/BtAudioStreamerApiTest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/src/BtAudioStreamerApiTest.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + + +// INCLUDE FILES +#include +#include "BtAudioStreamerApiTest.h" +#include + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::CBtAudioStreamerApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBtAudioStreamerApiTest::CBtAudioStreamerApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CBtAudioStreamerApiTest::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KBtAudioStreamerApiTestLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KBtAudioStreamerApiTestLogFile); + } + + iLog = CStifLogger::NewL( KBtAudioStreamerApiTestLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + + iBtAudioStreamer = CBTAudioStreamer::NewL(); + iBtAudioStreamerObserver = CBtAudioStreamerObserver::NewL( iLog ); + iBtAudioStreamInputBase = CBTAudioStreamInputBase::NewL( *iBtAudioStreamer, *iBtAudioStreamerObserver ); + } + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBtAudioStreamerApiTest* CBtAudioStreamerApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CBtAudioStreamerApiTest* self = new (ELeave) CBtAudioStreamerApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CBtAudioStreamerApiTest::~CBtAudioStreamerApiTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + } + +//----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CBtAudioStreamerApiTest::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("BtAudioStreamerApiTest.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CBtAudioStreamerApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/src/BtAudioStreamerApiTestBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/src/BtAudioStreamerApiTestBlocks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,359 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include "BtAudioStreamerApiTest.h" + + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CBtAudioStreamerApiTest::Delete() + { + delete iBtAudioStreamInputBase; + iBtAudioStreamInputBase = NULL; + delete iBtAudioStreamerObserver; + iBtAudioStreamerObserver = NULL; + delete iBtAudioStreamer; + iBtAudioStreamer = NULL; + } + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CBtAudioStreamerApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + ENTRY( "InitializationTest", CBtAudioStreamerApiTest::InitializationTest ), + ENTRY( "StartStopTest", CBtAudioStreamerApiTest::StartStopTest ), + ENTRY( "SetNewFrameLengthTest", CBtAudioStreamerApiTest::SetNewFrameLengthTest ), + //ADD NEW ENTRY HERE + // [test cases entries] - Do not remove + + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::InitializationTest +// ----------------------------------------------------------------------------- +// +TInt CBtAudioStreamerApiTest::InitializationTest( CStifItemParser& aItem ) + { + + _LIT(KL2CAPDesC,"L2CAP"); + TInt res; + TProtocolDesc protocolDesc; + TProtocolName protocolName( KL2CAPDesC ); + + iLog -> Log( _L( "BtAudioStreamer pointer value: %d" ), iBtAudioStreamer ); + STIF_ASSERT_NOT_NULL( iBtAudioStreamer ); + iLog -> Log( _L( "BtAudioStreamer pointer value: %d" ), iBtAudioStreamInputBase ); + STIF_ASSERT_NOT_NULL( iBtAudioStreamInputBase ); + + res = iSocketServer.Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Server connection failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Connected to socket server" ) ); + + res = iSocketServer.FindProtocol( TProtocolName( KL2CAPDesC ), protocolDesc ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Searching protocol failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Protocol info found" ) ); + + res = iSocket.Open( iSocketServer, protocolDesc.iAddrFamily, protocolDesc.iSockType, protocolDesc.iProtocol ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Socket opening failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Socket opened" ) ); + + iSocket.Close(); + iSocketServer.Close(); + iLog -> Log( _L( "Test case passed" ) ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::StartStopTest +// ----------------------------------------------------------------------------- +// + +TInt CBtAudioStreamerApiTest::StartStopTest( CStifItemParser& aItem ) + { + _LIT(KL2CAPDesC,"L2CAP"); + TInt res; + TProtocolDesc protocolDesc; + TProtocolName protocolName( KL2CAPDesC ); + + iBtAudioStreamer = CBTAudioStreamer::NewL(); + iLog -> Log( _L( "BtAudioStreamer pointer value: %d" ), iBtAudioStreamer ); + STIF_ASSERT_NOT_NULL( iBtAudioStreamer ); + + iBtAudioStreamerObserver = CBtAudioStreamerObserver::NewL( iLog ); + + iBtAudioStreamInputBase = CBTAudioStreamInputBase::NewL( *iBtAudioStreamer, *iBtAudioStreamerObserver ); + iLog -> Log( _L( "BtAudioStreamer pointer value: %d" ), iBtAudioStreamInputBase ); + STIF_ASSERT_NOT_NULL( iBtAudioStreamInputBase ); + + res = iBtAudioStreamInputBase -> SetFormat(KMMFFourCCCodeSBC); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Audio input format setting failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Audio input format set" ) ); + + res = iSocketServer.Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Server connection failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Connected to socket server" ) ); + + res = iSocketServer.FindProtocol( TProtocolName( KL2CAPDesC ), protocolDesc ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Searching protocol failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Protocol info found" ) ); + + res = iSocket.Open( iSocketServer, protocolDesc.iAddrFamily, protocolDesc.iSockType, protocolDesc.iProtocol ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Socket opening failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Socket opened" ) ); + + TUint frameLength = 8; + TUint bitRate = 44100; + + TRAP( res, iBtAudioStreamer -> StartL( iSocket, frameLength, iBtAudioStreamInputBase, bitRate )); + + iLog -> Log( _L( "Start result: %d" ), res ); + + STIF_ASSERT_EQUALS( KErrNone, res ); + + iBtAudioStreamer -> Stop(); + + iSocket.Close(); + iSocketServer.Close(); + iLog -> Log( _L( "Test case passed" ) ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtAudioStreamerApiTest::SetNewFrameLengthTest +// ----------------------------------------------------------------------------- +// + +TInt CBtAudioStreamerApiTest::SetNewFrameLengthTest( CStifItemParser& aItem ) + { + _LIT(KL2CAPDesC,"L2CAP"); + TInt res; + TProtocolDesc protocolDesc; + TProtocolName protocolName( KL2CAPDesC ); + + iBtAudioStreamer = CBTAudioStreamer::NewL(); + iLog -> Log( _L( "BtAudioStreamer pointer value: %d" ), iBtAudioStreamer ); + STIF_ASSERT_NOT_NULL( iBtAudioStreamer ); + + iBtAudioStreamerObserver = CBtAudioStreamerObserver::NewL( iLog ); + + iBtAudioStreamInputBase = CBTAudioStreamInputBase::NewL( *iBtAudioStreamer, *iBtAudioStreamerObserver ); + iLog -> Log( _L( "BtAudioStreamer pointer value: %d" ), iBtAudioStreamInputBase ); + STIF_ASSERT_NOT_NULL( iBtAudioStreamInputBase ); + + res = iBtAudioStreamInputBase -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Audio input connection failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Connected to audio input" ) ); + + res = iBtAudioStreamInputBase -> SetFormat( KMMFFourCCCodeSBC ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Audio input set format failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Audio input format set" ) ); + + iSbcEncoderIntfc = reinterpret_cast< CSbcEncoderIntfc* > ( iBtAudioStreamInputBase -> EncoderInterface( KUidSbcEncoderIntfc ) ); + + res = iSocketServer.Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Server connection failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Connected to socket server" ) ); + + res = iSocketServer.FindProtocol( TProtocolName( KL2CAPDesC ), protocolDesc ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Searching protocol failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Protocol info found" ) ); + + res = iSocket.Open( iSocketServer, protocolDesc.iAddrFamily, protocolDesc.iSockType, protocolDesc.iProtocol ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Socket opening failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Socket opened" ) ); + +// TInt option = 0; +// res = iSocket.SetOpt( KL2CAPInboundMTU, KSolBtL2CAP, option ); +// if ( res != KErrNone ) +// { +// iLog -> Log( _L( "Socket option setting with value: %d" ), res ); +// return res; +// } +// iLog -> Log( _L( "Socket option set" ) ); + + TUint frameLength = 8; + TUint newFrameLength = 10; + TUint bitRate = 44100; + + + TRAP( res, iBtAudioStreamer -> StartL( iSocket, frameLength, iBtAudioStreamInputBase, bitRate )); + + iLog -> Log( _L( "Start result: %d" ), res ); + + STIF_ASSERT_EQUALS( KErrNone, res ); + + res = iBtAudioStreamInputBase -> Start(); +// if ( res != KErrNone ) +// { +// iLog -> Log( _L( "Starting audio input failed with value: %d" ), res ); +// return res; +// } +// iLog -> Log( _L( "Audio input started" ) ); + + res = iBtAudioStreamer -> SetNewFrameLength( newFrameLength, bitRate ); + if ( res != KErrNone ) + { + iLog -> Log( _L( "Setting new frame length failed with value: %d" ), res ); + return res; + } + iLog -> Log( _L( "Frame length changed" ) ); + + iBtAudioStreamer -> Stop(); + iBtAudioStreamInputBase -> Stop(); + + iSocket.Close(); + iSocketServer.Close(); + iLog -> Log( _L( "Test case passed" ) ); + return KErrNone; + } + + +TInt CBtAudioStreamerApiTest::ConfigureEncoderInterface() + { + return KErrNone; + } +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// [End of File] - Do not remove diff -r 000000000000 -r f63038272f30 bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/src/BtAudioStreamerObserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/src/BtAudioStreamerObserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 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 "BtAudioStreamerObserver.h" + +CBtAudioStreamerObserver::CBtAudioStreamerObserver( CStifLogger* aLog ) + { + iLog = aLog; + } + +CBtAudioStreamerObserver::~CBtAudioStreamerObserver() + { + } + +CBtAudioStreamerObserver* CBtAudioStreamerObserver::NewL( CStifLogger* aLog ) + { + CBtAudioStreamerObserver* self = new ( ELeave )CBtAudioStreamerObserver( aLog ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +void CBtAudioStreamerObserver::ConstructL() + { + } + +TInt CBtAudioStreamerObserver::Error(const TInt aError) + { + iLog -> Log( _L( "MBTAudioErrorObserver::Error entered" ) ); + return KErrNone; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/data/btctrldcmoadapter.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/data/btctrldcmoadapter.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +/* + * ============================================================================== + * Copyright (c) 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 + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x20028777; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001FD40; + implementations = + { + // Info for BluetoothCtrlDcmoAdapter + IMPLEMENTATION_INFO + { + implementation_uid = 0x20028778; + version_no = 1; + display_name = "BluetoothCtrlDcmoAdapter"; + default_data = "text/wml||Allow/Disallow Bluetooth."; + opaque_data = "Bluetooth"; + } + }; + } + }; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +/* + * ============================================================================== + * Copyright (c) 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 + +PRJ_PLATFORMS + +DEFAULT + +PRJ_EXPORTS +../rom/btctrldcmoadapter.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btctrldcmoadapter.iby) + +PRJ_MMPFILES +btctrldcmoadapter.mmp + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/group/btctrldcmoadapter.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/group/btctrldcmoadapter.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* + * ============================================================================== + * Copyright (c) 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 + +CAPABILITY CAP_ECOM_PLUGIN +TARGET btctrldcmoadapter.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x20028777 +VENDORID VID_DEFAULT + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom + +USERINCLUDE ../inc + +SOURCEPATH ../data +START RESOURCE btctrldcmoadapter.rss +TARGET btctrldcmoadapter.rsc +END + +SOURCEPATH ../src +SOURCE btctrldcmoadapterproxy.cpp +SOURCE btctrldcmoadapter.cpp + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY commonengine.lib +LIBRARY btfeatures.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/inc/btctrldcmoadapter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/inc/btctrldcmoadapter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,64 @@ +// +/* + * ============================================================================== + * Copyright (c) 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: + * + * ============================================================================== + */ + +#ifndef BTCTRLDCMOADAPTER_H +#define BTCTRLDCMOADAPTER_H + +#include +#include + + +// An implementation of the CDCMOInterface definition +class CBluetoothCtrlDcmoAdapter : public CDCMOInterface + { +public: + // Standardised safe construction which leaves nothing the cleanup stack. + static CBluetoothCtrlDcmoAdapter* NewL(TAny* aInitParams); + + // Destructor + ~CBluetoothCtrlDcmoAdapter(); + +private: + // Implementation of CDCMOInterface + virtual TDCMOStatus GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue); + virtual TDCMOStatus GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue); + virtual TDCMOStatus SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue); + virtual TDCMOStatus SetDCMOPluginStrAttributeValueL(TDCMONode aId, const TDes& aStrValue); + virtual void GetLocalizedNameL( HBufC*& aLocName ); + +private: + + enum TBluetoothDcmoPanic + { + EPropertyBufferTooSmall = 0, + EDescriptionBufferTooSmall = 1 + }; + + // Construction + CBluetoothCtrlDcmoAdapter(TAny* aInitParams); + static TDCMOStatus MapFeatureControlError(TInt aErrorCode); + static void Panic(TBluetoothDcmoPanic aPanic); + +private: + // Parameters taken from client + CDCMOInterface::TDCMOInterfaceInitParams* iInitParams; + }; + +#endif // BTCTRLDCMOADAPTER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/rom/btctrldcmoadapter.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/rom/btctrldcmoadapter.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* +* ============================================================================ +* Copyright (c) 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 + +#ifndef __BTCTRLDCMOADAPTER_IBY__ +#define __BTCTRLDCMOADAPTER_IBY__ + +// nothing should be installed from this .iby file if the following feature is not defined +// FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION +// +#ifdef FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION + +ECOM_PLUGIN(btctrldcmoadapter.dll,btctrldcmoadapter.rsc) + +#endif // FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION + +#endif //__BTCTRLDCMOADAPTER_IBY__ diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,258 @@ +/* + * ============================================================================== + * Copyright (c) 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 + +#include +#include + +#include "btctrldcmoadapter.h" + +_LIT(KBluetoothDcmoPanicName, "BT DCMO Adapter"); + +_LIT( KBluetoothControlProperty, "Bluetooth" ); +_LIT( KDisableBluetoothDescription, "Used to enable/disable the Bluetooth connectivity." ); // Description +_LIT( KRuntimeResourceFileName, "z:dcmo.rsc" ); + +TDCMOStatus CBluetoothCtrlDcmoAdapter::MapFeatureControlError(TInt aErrorCode) + { + TDCMOStatus status = EDcmoFail; + + switch (aErrorCode) + { + case KErrNone: + status = EDcmoSuccess; + break; + case KErrPermissionDenied: + case KErrAccessDenied: + status = EDcmoAccessDenied; + break; + case KErrNotFound: + status = EDcmoNotFound; + break; + default: + break; + } + return status; + } + +// Construction and destruction functions + +CBluetoothCtrlDcmoAdapter* CBluetoothCtrlDcmoAdapter::NewL(TAny* aParams) + { + CBluetoothCtrlDcmoAdapter* self = new (ELeave ) CBluetoothCtrlDcmoAdapter(aParams); + return self; + } + +CBluetoothCtrlDcmoAdapter::~CBluetoothCtrlDcmoAdapter() + { + } + +CBluetoothCtrlDcmoAdapter::CBluetoothCtrlDcmoAdapter(TAny* aInitParams) + : iInitParams(reinterpret_cast(aInitParams)) + { + } + +// Implementation of CDCMOInterface + +// +// See excerpts from OMA DCMO spec below +// +TDCMOStatus CBluetoothCtrlDcmoAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue) +{ + TDCMOStatus status = EDcmoFail; + + switch(aId) + { + /* + This node is used with Exec command to enable the Device Capability to transfer the Device Capability + from Disabled State to Enabled state. + */ + case EEnable: + { + BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EDisabled; + switch (aValue) + { + case 0: + mode = BluetoothFeatures::EDisabled; + break; + case 1: + mode = BluetoothFeatures::EEnabled; + break; + case 2: + mode = BluetoothFeatures::EDataProfilesDisabled; + break; + default: + User::Leave(KErrArgument); + } + TRAPD(err,BluetoothFeatures::SetEnterpriseEnablementL(mode)); + status = MapFeatureControlError(err); + } + break; + default: + break; + } + + return status; +} + +// +// See excerpts from OMA DCMO spec below +// +TDCMOStatus CBluetoothCtrlDcmoAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue) +{ + TDCMOStatus status = EDcmoSuccess; + + switch(aId) + { + /* + This node specifies the group name, defined in section 6.1 “Grouping of properties” of [DPE-TS], + for a collection of Device Capabilities + */ + case EGroup: + aValue = EConnectivity; + break; + /* + This leaf node indicates whether the Device Capability is removable and whether it is currently + attached to the device. + If the leaf exists then the Device Capability is removable. + If the value of this node is “True” the Device Capability is currently attached to the device; + if the value of this node is “False” the Device Capability is currently detached from the device; + + NB: Returning EFalse here prevents the node from being inserted into DDF, so Bluetooth is NON-removable media. + */ + case EAttached: + aValue = EFalse; + break; + /* + This leaf node indicates whether the Device Capability is enabled regardless whether + the Device Capability is attached or not. + If the value of this node is “True” the Device Capability is in Enabled State. + If the value of is “False” the Device Capability is in Disabled State; + The ‘Attached’ property is independent of ‘Enabled’ property. A Device Capability MAY have ‘True’ + as value for ‘Enabled’ node while having ‘False’ as value for the ‘Attached’ node. That means + the Device Capability is still not available and can’t be used until it is attached to the Device, + but will be useable once the Device Capability is attached. + */ + case EEnabled: + { + BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EnterpriseEnablementL(); + switch (mode) + { + case BluetoothFeatures::EDisabled: + aValue = 0; + break; + case BluetoothFeatures::EEnabled: + aValue = 1; + break; + case BluetoothFeatures::EDataProfilesDisabled: + aValue = 2; + break; + default: + User::Leave(KErrArgument); + } + } + break; + /* + This leaf node specifies whether the user is able to enable a Device Capability. + If the node is not present or the value is False, the user is allowed to enable the Device Capability. + If the node is present and the value is True, the user is not allowed to enable the Device Capability. + */ + case EDenyUserEnable: + aValue = ETrue; + break; + /* + This leaf node specifies whether the user is notified with the DCMO Operation result when + enable/disable Primitive is executed. + If the node is not present or the value is ‘False’, the user will not be notified about the result of + the operation. + If the node is present and the value is ‘True’, the user will be notified about the result of + the operation. + */ + case ENotifyUser: + aValue = ETrue; + break; + default: + break; + } + + return status; +} + +TDCMOStatus CBluetoothCtrlDcmoAdapter::SetDCMOPluginStrAttributeValueL(TDCMONode /* aId */, + const TDes& /* aStrValue */) +{ + // Nothing to do + return EDcmoFail; +} + +TDCMOStatus CBluetoothCtrlDcmoAdapter::GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue) +{ + TDCMOStatus status = EDcmoSuccess; + switch(aId) + { + /* + This leaf node specifies the property name, which is defined in section 6.2 “DPE vocabulary List” + of [DPE-TS], for a Device Capability. + */ + case EProperty: + __ASSERT_DEBUG(aStrValue.MaxLength() >= KBluetoothControlProperty().Length(),Panic(CBluetoothCtrlDcmoAdapter::EPropertyBufferTooSmall)); + aStrValue = KBluetoothControlProperty().Left(aStrValue.MaxLength()); + break; + /* + This leaf node specifies the description for this Device Capability. + */ + case EDescription: + __ASSERT_DEBUG(aStrValue.MaxLength() >= KDisableBluetoothDescription().Length(),Panic(CBluetoothCtrlDcmoAdapter::EDescriptionBufferTooSmall)); + aStrValue = KDisableBluetoothDescription().Left(aStrValue.MaxLength()); + break; + default: + status = EDcmoNotFound; + break; + } + + return status; +} + +void CBluetoothCtrlDcmoAdapter::GetLocalizedNameL(HBufC*& aLocName) + { + TFileName* fileName = new(ELeave) TFileName; + CleanupStack::PushL(fileName); + TParse* parseObj = new(ELeave) TParse(); + CleanupStack::PushL(parseObj); + User::LeaveIfError(parseObj->Set(KRuntimeResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL)); + *fileName = parseObj->FullName(); + CleanupStack::PopAndDestroy(parseObj); + + CStringResourceReader* resReader = CStringResourceReader::NewL(*fileName); + CleanupStack::PushL(resReader); + + TPtrC buf; + buf.Set(resReader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH)); + aLocName = buf.AllocL() ; + + CleanupStack::PopAndDestroy(2,fileName); //resReader,fileName + } + +void CBluetoothCtrlDcmoAdapter::Panic(TBluetoothDcmoPanic aPanic) + { + User::Panic(KBluetoothDcmoPanicName, aPanic); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapterproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapterproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +/* + * ============================================================================== + * Copyright (c) 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 "btctrldcmoadapter.h" + +// Map the interface UIDs to implementation factory functions +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x20028778, CBluetoothCtrlDcmoAdapter::NewL), + }; + +// Exported proxy for instantiation method resolution +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btbearer/inc/btpluginnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btbearer/inc/btpluginnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2006 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: This is the BT bearer plugin notifier header file. +* +*/ + + +#ifndef __BTPLUGINNOTIFIER_H__ +#define __BTPLUGINNOTIFIER_H__ + + +#include +#include +#include +#include +#include + + +/** + * BT Plug in module for local connectivity daemon. + * + * This active object checks BT state from central repository and start + * watching BT ON/OFF state. If BT is ON, it connects to BTEngine server. + * It continues to watch the key and when it has changed, it notifies + * the daemon through its callback function. + * + * @lib btbearer.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTPluginNotifier ) : public CActive + { + +public: + + /** Enumeration of CenRep key types */ + enum TCenRepKeyType + { + EKeyInt, + EKeyReal, + EKeyBinary, + EKeyString + }; + + /** + * Two-phase constructor + * + * @param aObserver Reference to the callback class. + * @param aUid The UID that identifies the repository. + * @param aKeyType Key type. + * @param aId The ID of the key. + * @return CBTPluginNotifier Initialized object. + */ + static CBTPluginNotifier* NewL( MLocodBearerPluginObserver& aObserver, + TUid aUid, TCenRepKeyType aKeyType, + TUint32 aId ); + + /** + * Destructor + */ + virtual ~CBTPluginNotifier(); + +private: + + /** + * C++ default constructor + */ + CBTPluginNotifier( MLocodBearerPluginObserver& Param, TUid aUid, + TCenRepKeyType aKeyType, TUint32 aId ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * Subscribes to the change of central repository keys + * + * @since S60 v3.2 + */ + void SubscribeL(); + +// from base class CActive + + /** + * From CActive. + * Called by the active scheduler when our subscription + * to the setting has been cancelled. + * + * @since S60 v3.2 + */ + void DoCancel(); + + /** + * From CActive. + * Called by the active scheduler when the status has changed. + * + * @since S60 v3.2 + */ + void RunL(); + + /** + * From CActive + * Called by the active scheduler when RunL() leaves, aError contains the leave code. + * + * @since S60 5.0 + */ + int RunError(TInt aError); + +private: // data + + /** + * The UID that identifies the setting category. + */ + TUid iUid; + + /** + * ID for BT power state in the central repository + */ + TUint32 iId; + + /** + * Central repository key type + */ + TCenRepKeyType iKeyType; + + /** + * Reference to the observer. + */ + MLocodBearerPluginObserver& iHandler; + + /** + * Session with the central repository. + * Own. + */ + CRepository* iSession; + + }; + + +#endif // __BTPLUGINNOTIFIER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btbearer/inc/btpluginprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btbearer/inc/btpluginprovider.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2006 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: This is the BT bearer plugin header file. +* +*/ + + +#ifndef __BTPLUGINPROVIDER_H__ +#define __BTPLUGINPROVIDER_H__ + + +#include + + +class CBTPluginNotifier; + + +/** + * BT Plug in module for local connectivity daemon. + * + * This module is loaded by local connectivity daemon if the _BT feature flag + * is defined. It checks BT state from central repository and starts watching + * BT ON/OFF state. If BT is ON, it connects to BTEngine server. It continues + * to watch the key and when it is changed, it notifies the daemon through + * its callback function. + * + * @lib btbearer.lib + * @since S60 v3.2 + */ + +NONSHARABLE_CLASS( CBTBearerPlugin ) : public CLocodBearerPlugin + { + +public: + + /** + * Two-phase constructor + */ + static CBTBearerPlugin* NewL( TLocodBearerPluginParams& aParam ); + + /** + * Destructor + */ + virtual ~CBTBearerPlugin(); + +private: + + /** + * C++ default constructor + */ + CBTBearerPlugin( TLocodBearerPluginParams& aParam ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + +private: // data + + /** + * Active object that monitors the BT state. + * Own. + */ + CBTPluginNotifier* iBTPluginNotifier; + + }; + + +#endif // __BTPLUGINPROVIDER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btbearer/src/btpluginnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btbearer/src/btpluginnotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2006 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: BT Bearer plugin notification implementation file +* +*/ + + + +#include +#include +#include +#include "btpluginnotifier.h" +#include "debug.h" +#include + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTPluginNotifier::CBTPluginNotifier( MLocodBearerPluginObserver& aParam, + TUid aUid, TCenRepKeyType aKeyType, TUint32 aId ) +: CActive( EPriorityStandard ), + iUid( aUid ), + iId( aId ), + iKeyType( aKeyType ), + iHandler( aParam ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTPluginNotifier::ConstructL() + { + TRACE_FUNC_ENTRY + iSession = CRepository::NewL( iUid ); + TInt power = EBTPowerOff; + iSession->Get( iId, power ); + + TInt offlineModeOff = ECoreAppUIsNetworkConnectionAllowed; + CRepository* repository = CRepository::NewL( KCRUidCoreApplicationUIs ); + repository->Get(KCoreAppUIsNetworkConnectionAllowed, offlineModeOff ); + delete repository; + + CBTEngSettings* settings = CBTEngSettings::NewL(); + + BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EnterpriseEnablementL(); + TRACE_INFO( ( _L( "mode = %d" ), mode) ) + if( power == EBTPowerOn && offlineModeOff == ECoreAppUIsNetworkConnectionAllowed && mode != BluetoothFeatures::EDisabled ) + { + // BT was on before boot, turn it on again + TRACE_INFO( ( _L( "Turning BT on" ) ) ) + TInt err = settings->SetPowerState( EBTPowerOn ); + TRACE_INFO( ( _L( "SetPowerState returned %d" ), err ) ) + if( !err ) + { + iHandler.NotifyBearerStatus( ELocodBearerBT, power ); + } + } + else + { + TRACE_INFO( ( _L( "Turning BT off" ) ) ) + (void) settings->SetPowerState( EBTPowerOff ); // Result is not important here + } + delete settings; + if ( mode != BluetoothFeatures::EDisabled ) // only subscribe if there's any point (NB changing Enterprise Disabling mode requires a reboot) + SubscribeL(); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTPluginNotifier* CBTPluginNotifier::NewL( MLocodBearerPluginObserver& aParam, + TUid aUid, TCenRepKeyType aKeyType, TUint32 aId ) + { + TRACE_FUNC_ENTRY + CBTPluginNotifier* self = new( ELeave ) CBTPluginNotifier( aParam, aUid, + aKeyType, aId ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTPluginNotifier::~CBTPluginNotifier() + { + TRACE_FUNC_ENTRY + Cancel(); + delete iSession; + } + + +// --------------------------------------------------------------------------- +// CBTPluginNotifier::SubscribeL +// --------------------------------------------------------------------------- +// +void CBTPluginNotifier::SubscribeL() + { + TRACE_FUNC_ENTRY + if( IsActive() ) + { + return; + } + User::LeaveIfError( iSession->NotifyRequest( iId, iStatus ) ); + SetActive(); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when our subscription +// to the setting has been cancelled. +// --------------------------------------------------------------------------- +// +void CBTPluginNotifier::DoCancel() + { + iSession->NotifyCancel( iId ); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the status has changed. +// --------------------------------------------------------------------------- +// +void CBTPluginNotifier::RunL() + { + TUint32 status = static_cast( iStatus.Int() ); + TRACE_FUNC_ARG( ( _L( "RunL1 iStatus: %d]" ), status ) ) + + if( status != iId && status != NCentralRepositoryConstants::KInvalidNotificationId ) + { + return; + } + SubscribeL(); + switch( iKeyType ) + { + case EKeyInt: + { + TRACE_INFO( ( _L( "[CBTPluginNotifier::RunL2 %d]" ), status ) ) + TInt newValue = 1; + iSession->Get( iId, newValue ); + iHandler.NotifyBearerStatus( ELocodBearerBT, newValue ); + } + break; + default: + { + TRACE_INFO( ( _L( "[CBTPluginNotifier::RunL3 %d]" ), status ) ) + } + break; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when RunL leaves. +// --------------------------------------------------------------------------- +// +int CBTPluginNotifier::RunError(TInt aError) + { + TRACE_FUNC_ARG( ( _L( "RunError aError: %d]" ), aError ) ) + (void) aError; + return KErrNone; + } + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btbearer/src/btpluginprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btbearer/src/btpluginprovider.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2006 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: BT Bearer plugin implementation. +* +*/ + + + +#include "btpluginprovider.h" +#include "btpluginnotifier.h" +#include "debug.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTBearerPlugin::CBTBearerPlugin( TLocodBearerPluginParams& aParam ) +: CLocodBearerPlugin( aParam ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTBearerPlugin::ConstructL() + { + TRACE_FUNC_ENTRY + iBTPluginNotifier = CBTPluginNotifier::NewL( Observer(), + KCRUidBluetoothPowerState, + CBTPluginNotifier::EKeyInt, + KBTPowerState ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTBearerPlugin* CBTBearerPlugin::NewL( TLocodBearerPluginParams& aParam ) + { + CBTBearerPlugin* self = new( ELeave ) CBTBearerPlugin( aParam ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTBearerPlugin::~CBTBearerPlugin() + { + delete iBTPluginNotifier; + iBTPluginNotifier = NULL; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btbearer/src/btpluginproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btbearer/src/btpluginproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2006 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: ECOM proxy table for this plugin +* +*/ + + + +#include +#include +#include "btpluginprovider.h" + + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Definition of ECOM interface UID +// --------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( KFeatureIdBt, CBTBearerPlugin::NewL ) + }; + + +// --------------------------------------------------------------------------- +// ECOM factory method +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) + { + aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + return ImplementationTable; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengconnman/inc/btengconnhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengconnman/inc/btengconnhandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,265 @@ +/* +* Copyright (c) 2006 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: Implements the actual connection management, and receives +* notifications of Bluetooth connection events. +* +*/ + + + +#ifndef BTENGCONNHANDLER_H +#define BTENGCONNHANDLER_H + + +//#include + +#include "btengactive.h" +#include "btengclient.h" +#include "btengclientserver.h" + +class MBTEngConnObserver; + + +/** + * Class CBTEngConnHandler + * + * ?more_complete_description + * + * @lib ?library + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngConnHandler ) : public CBase, public MBTEngActiveObserver + { + +public: + + /** + * Two-phase constructor + */ + static CBTEngConnHandler* NewL( MBTEngConnObserver* aObserver ); + + /** + * Destructor + */ + virtual ~CBTEngConnHandler(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + inline TInt ConnectDevice( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + inline TInt CancelConnectDevice( const TBTDevAddr& aAddr ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + inline TInt DisconnectDevice( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + inline TInt IsDeviceConnected( const TBTDevAddr& aAddr, + TBTEngConnectionStatus& aConnected ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + inline TInt IsDeviceConnectable( const TBTDeviceClass& aDeviceClass, + TBool& aConnectable ); + + /** + * ?description + * + * @since S60 v5.1 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + inline TInt IsDeviceConnectable( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + void GetConnectedAddressesL( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + TInt NotifyConnectionEvents( MBTEngConnObserver* aObserver ); + + /** + * ?description + * + * @since S60 v3.2 + * @return ?description + */ + TInt CancelNotifyConnectionEvents(); + + /** + * Set a pairing observer in BTEngine. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device that is being paired. + * @param aActivate If ETrue, the observer will be activated, otherwise + * the observer will be removed. + * @return KErrNone on success, otherwise a system-wide error code. + */ + static TInt SetPairingObserver( const TBTDevAddr& aAddr, TBool aActivate ); + + /** + * ?description + * + * @since S60 v3.2 + * @return ?description + */ + inline TInt PrepareDiscovery(); + + + /** + * Pair a device + * + * @since S60 v5.1 + * @param aAddr the address of the device to pair with + * @param aDeviceClass the device class of the device to pair with + * @return KErrNone if this request has been accepted; an error situation otherwise. + */ + TInt StartPairing( const TBTDevAddr& aAddr, const TBTDeviceClass& aDeviceClass ); + + /** + * cancel the outstanding pairing request. + */ + void CancelPairing(); + +private: +// from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Handles the notification of a change in the connection status. + * + * @since S60 v3.2 + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Handles an error during processing of connection status event. + * + * @since S60 v3.2 + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngConnHandler( MBTEngConnObserver* aObserver ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + void HandleConnectionEvent( TInt aStatus ); + +private: // data + + /** + * Client-server package to which the event result is copied. + */ + TBTEngEventPkg iEventPkg; + + /** + * Address of the remote device to pair with. + */ + TBTDevAddrPckgBuf iPairAddr; + + /** + * The CoD of the remote device to pair with. + */ + TUint32 iPairDevCod; + + /** + * Session with BTEng server side. + */ + RBTEng iBTEng; + + /** + * The actual active object for receiving event notifications. + * Own. + */ + CBTEngActive* iConnEventActive; + + /** + * The actual active object for pairing a device. + * Own. + */ + CBTEngActive* iPairActive; + + /** + * Reference to receiver of connection events. + * Not own. + */ + MBTEngConnObserver* iObserver; + + }; + + +#include "btengconnhandler.inl" + + +#endif // BTENGCONNHANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengconnman/inc/btengconnhandler.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengconnman/inc/btengconnhandler.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2006 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: Inline definitions of methods forwarded to RBTEng. +* +*/ + + + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::ConnectDevice( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ) + { + return iBTEng.ConnectDevice( aAddr, aDeviceClass ); + } + + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::CancelConnectDevice( const TBTDevAddr& aAddr ) + { + return iBTEng.CancelConnectDevice( aAddr ); + } + + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::DisconnectDevice( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ) + { + return iBTEng.DisconnectDevice( aAddr, aDiscType ); + } + + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::IsDeviceConnected( const TBTDevAddr& aAddr, + TBTEngConnectionStatus& aConnected ) + { + return iBTEng.IsDeviceConnected( aAddr, aConnected ); + } + + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::IsDeviceConnectable( + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ) + { + return iBTEng.IsDeviceConnectable(TBTDevAddr(), aDeviceClass, aConnectable ); + } + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::IsDeviceConnectable( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ) + { + return iBTEng.IsDeviceConnectable( aAddr, aDeviceClass, aConnectable ); + } + +// ----------------------------------------------------------------------------- +// ?implementation_description +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngConnHandler::PrepareDiscovery() + { + return iBTEng.PrepareDiscovery(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengconnman/src/btengconnhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengconnman/src/btengconnhandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,338 @@ +/* +* Copyright (c) 2006 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: Implements the actual connection management, and receives +* notifications of Bluetooth connection events. +* +*/ + + + +#include + +#include "btengconnhandler.h" +#include "btengconnman.h" +#include "debug.h" + +/** ID to identify the outstanding asynchronous request. */ +enum TRequestId + { + EConnectionEventId = 50, + EPairDeviceId + }; + +/** Max. number of addresses that can be passed to the server + side for getting connected addresses */ +const TInt KBTEngMaxAddrArraySize = 10; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngConnHandler::CBTEngConnHandler( MBTEngConnObserver* aObserver ) +: iObserver( aObserver ) + { + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngConnHandler::ConstructL() + { + TRACE_FUNC_ENTRY + User::LeaveIfError( iBTEng.Connect() ); + if( iObserver ) + { + NotifyConnectionEvents( iObserver ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngConnHandler* CBTEngConnHandler::NewL( MBTEngConnObserver* aObserver ) + { + CBTEngConnHandler* self = new( ELeave ) CBTEngConnHandler( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngConnHandler::~CBTEngConnHandler() + { + TRACE_FUNC_ENTRY + CancelNotifyConnectionEvents(); + CancelPairing(); + iBTEng.Close(); + } + +// --------------------------------------------------------------------------- +// Gets the connected device addresses; If a profile is defined, only +// connections for that profile are returned. +// --------------------------------------------------------------------------- +// +void CBTEngConnHandler::GetConnectedAddressesL( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ) + { + aAddrArray.Reset(); + TInt devAddrSize = sizeof( TBTDevAddr ); + HBufC8* addrBuf = HBufC8::NewLC( KBTEngMaxAddrArraySize * devAddrSize ); + TPtr8 ptr = addrBuf->Des(); + TPckgBuf profilePkg( aConnectedProfile ); + User::LeaveIfError( iBTEng.GetConnectedAddresses( ptr, profilePkg ) ); + while( ptr.Length() >= KBTDevAddrSize ) + { + TBTDevAddr addr( ptr.Mid( ptr.Length() - devAddrSize, KBTDevAddrSize ) ); + ptr.SetLength( Max( ptr.Length() - devAddrSize, 0 ) ); + aAddrArray.Append( addr ); + } + CleanupStack::PopAndDestroy( addrBuf ); + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngConnHandler::NotifyConnectionEvents( MBTEngConnObserver* aObserver ) + { + TRACE_FUNC_ENTRY + ASSERT( aObserver ); + iObserver = aObserver; + TInt err = KErrNone; + if( iConnEventActive && iConnEventActive->IsActive() ) + { + CancelNotifyConnectionEvents(); + } + if( !iConnEventActive ) + { + // Use a higher prioritty than normal, because we want + // to be notified fast (e.g. to update the UI). + TRAP( err, iConnEventActive = CBTEngActive::NewL( *this, EConnectionEventId, + CActive::EPriorityUserInput ) ); + } + if( !err && iConnEventActive->RequestStatus() != KErrServerTerminated ) + { + err = iBTEng.NotifyConnectionEvents( iEventPkg, iConnEventActive->RequestStatus() ); + if( !err ) + { + iConnEventActive->GoActive(); + } + } + return err; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngConnHandler::CancelNotifyConnectionEvents() + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + if( iConnEventActive && iConnEventActive->IsActive() ) + { + err = iBTEng.CancelNotifyConnectionEvents(); + iConnEventActive->CancelRequest(); + } + delete iConnEventActive; + iConnEventActive = NULL; + return err; + } + +// ----------------------------------------------------------------------------- +// Request server side to activate/deactivate a pair observer +// ----------------------------------------------------------------------------- +// +TInt CBTEngConnHandler::SetPairingObserver( const TBTDevAddr& aAddr, + TBool aActivate ) + { + RBTEng bteng; + TInt err = bteng.Connect(); + if ( !err ) + { + err = bteng.SetPairingObserver( aAddr, aActivate ); + } + bteng.Close(); + return err; + } + +// --------------------------------------------------------------------------- +// Request BTEng to pair the device +// --------------------------------------------------------------------------- +// +TInt CBTEngConnHandler::StartPairing( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ) + { + TRACE_FUNC_ENTRY + TInt err( KErrNone ); + if( iPairActive && iPairActive->IsActive() ) + { + err = KErrServerBusy; + } + + if( !iPairActive ) + { + // Use a higher prioritty than normal, because we want + // to be notified fast (e.g. to update the UI). + TRAP( err, iPairActive = CBTEngActive::NewL( *this, EPairDeviceId, + CActive::EPriorityUserInput ) ); + } + if ( !err ) + { + iPairAddr() = aAddr; + iPairDevCod = aDeviceClass.DeviceClass(); + iBTEng.PairDevice( iPairAddr, iPairDevCod, iPairActive->RequestStatus() ); + iPairActive->GoActive(); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Cancel any outstanding operation, free resources. +// --------------------------------------------------------------------------- +// +void CBTEngConnHandler::CancelPairing() + { + TRACE_FUNC_ENTRY + if( iPairActive && iPairActive->IsActive() ) + { + iBTEng.CancelPairDevice(); + } + delete iPairActive; + iPairActive = NULL; + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Called by the active object when a change in connection status has occured. +// --------------------------------------------------------------------------- +// +void CBTEngConnHandler::RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "ID: %d status: %d" ), aId, aStatus ) ) + + (void) aActive; + switch ( aId ) + { + case EConnectionEventId: + { + HandleConnectionEvent( aStatus ); + break; + } + case EPairDeviceId: + { + if ( iObserver ) + { + iObserver->PairingComplete( iPairAddr(), aStatus ); + } + } + } + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Called when RequestCompletedL/RunL leaves. +// --------------------------------------------------------------------------- +// +void CBTEngConnHandler::HandleError( CBTEngActive* aActive, TInt aId, TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "error: %d" ), aError ) ) + // Should any info be passed to the client?? + (void) aActive; + (void) aId; + (void) aError; + } + +void CBTEngConnHandler::HandleConnectionEvent( TInt aStatus ) + { + TBTDevAddr addr; + RBTDevAddrArray conflictsArray; + TBTEngConnectionStatus connStatus = EBTEngNotConnected; + // Subscribe to the next event first. + (void) NotifyConnectionEvents( iObserver ); + addr = iEventPkg().iAddr; + connStatus = iEventPkg().iConnEvent; + if( iEventPkg().iConflictsBuf.Length() > 0 ) + { + // Parse conflicts array buffer + TInt devAddrSize = sizeof( TBTDevAddr ); + while( iEventPkg().iConflictsBuf.Length() >= KBTDevAddrSize ) + { + TInt len = iEventPkg().iConflictsBuf.Length(); + TPtrC8 ptr = iEventPkg().iConflictsBuf.Mid( len - devAddrSize, + KBTDevAddrSize ); + TBTDevAddr addr( ptr ); + conflictsArray.Append( addr ); + iEventPkg().iConflictsBuf.SetLength( Max( len - devAddrSize, 0 ) ); + } + } + + switch( connStatus ) + { + // The enumeration allows for more information than can be + // signalled to the client. Anyway allow for all cases. + case EBTEngNotConnected: + case EBTEngDisconnecting: + { + // Add device address logging here! + TRACE_INFO( ( _L( "[BTENG]\t device X disconnected" ) ) ) + iObserver->DisconnectComplete( addr, aStatus ); + } + break; + case EBTEngConnecting: + case EBTEngConnected: + { + // Note! Even though the status can say connected, it can + // mean that the device is not connected because an error + // occurred during connection establishment! + + // Add device address logging here! + TRACE_INFO( ( _L( "[BTENG]\t device X connected" ) ) ) + if ( conflictsArray.Count() ) + { + iObserver->ConnectComplete( addr, aStatus, &conflictsArray ); + } + else + { + iObserver->ConnectComplete( addr, aStatus, NULL ); + } + } + break; + default: + { + TRACE_INFO( ( _L( "[BTENG]\t Wrong connection status (%d)!!" ), + connStatus ) ) + } + break; + } + conflictsArray.Close(); + + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengconnman/src/btengconnman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengconnman/src/btengconnman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,295 @@ +/* +* Copyright (c) 2006-2008 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: Bluetooth Engine API for connection management functionality. +* +*/ + + + +#include +#include +#include + +#include "btengconnman.h" +#include "btengconnhandler.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngConnMan::CBTEngConnMan( MBTEngConnObserver* aObserver ) +: iObserver( aObserver ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngConnMan::ConstructL() + { + TRACE_FUNC_ENTRY + // Check if BT is supported at all + FeatureManager::InitializeLibL(); + TBool btSupported = FeatureManager::FeatureSupported( KFeatureIdBt ); + FeatureManager::UnInitializeLib(); + if( !btSupported ) + { + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t ConstructL: BT not supported!!" ) ) ) + User::Leave( KErrNotSupported ); + } + iConnHandler = CBTEngConnHandler::NewL( iObserver ); + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngConnMan* CBTEngConnMan::NewL( MBTEngConnObserver* aObserver ) + { + CBTEngConnMan* self = CBTEngConnMan::NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngConnMan* CBTEngConnMan::NewLC( MBTEngConnObserver* aObserver ) + { + CBTEngConnMan* self = new( ELeave ) CBTEngConnMan( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngConnMan::~CBTEngConnMan() + { + TRACE_FUNC_ENTRY + delete iConnHandler; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::Connect( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ) + { + TRACE_FUNC_ENTRY + return iConnHandler->ConnectDevice( aAddr, aDeviceClass ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngConnMan::CancelConnect( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + (void) iConnHandler->CancelConnectDevice( aAddr ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::Disconnect( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ) + { + TRACE_FUNC_ENTRY + return iConnHandler->DisconnectDevice( aAddr, aDiscType ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::IsConnected( const TBTDevAddr& aAddr, + TBTEngConnectionStatus& aConnected ) + { + TRACE_FUNC_ENTRY + return iConnHandler->IsDeviceConnected( aAddr, aConnected ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::IsConnectable( const TBTDeviceClass& aDeviceClass, + TBool& aConnectable ) + { + TRACE_FUNC_ENTRY + return iConnHandler->IsDeviceConnectable( aDeviceClass, aConnectable ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::SetObserver( MBTEngConnObserver* aObserver ) + { + TRACE_FUNC_ENTRY + return iConnHandler->NotifyConnectionEvents( aObserver ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngConnMan::RemoveObserver() + { + TRACE_FUNC_ENTRY + iConnHandler->CancelNotifyConnectionEvents(); + } + + +// --------------------------------------------------------------------------- +// Get the connected addresses of all baseband connections. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::GetConnectedAddresses( RBTDevAddrArray& aAddrArray ) + { + TRACE_FUNC_ENTRY + TRAPD( err, iConnHandler->GetConnectedAddressesL( aAddrArray, + EBTProfileUndefined ) ); + return err; + } + + +// --------------------------------------------------------------------------- +// Get the connected addresses for a specified profile (that is managed +// through BT Engine). +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::GetConnectedAddresses( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ) + { + TRACE_FUNC_ENTRY + TRAPD( err, iConnHandler->GetConnectedAddressesL( aAddrArray, + aConnectedProfile ) ); + return err; + } + + +// --------------------------------------------------------------------------- +// Initiate pairing with the specified device +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::PairDevice( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + TBTDeviceClass deviceClass; + return PairDevice( aAddr, deviceClass ); + } + + +// --------------------------------------------------------------------------- +// Initiate pairing with the specified device (which advertises +// specified service class). +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::PairDevice( const TBTDevAddr& aAddr, TBTDeviceClass aDeviceClass ) + { + TRACE_FUNC_ENTRY + return iConnHandler->StartPairing( aAddr, aDeviceClass ); + } + + +// --------------------------------------------------------------------------- +// Cancels an ongoing pairing. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngConnMan::CancelPairDevice() + { + TRACE_FUNC_ENTRY + if( iConnHandler ) + { + iConnHandler->CancelPairing(); + } + } + + +// --------------------------------------------------------------------------- +// Tell BTEng to start observing the status of an ongoing pairing. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::StartPairingObserver( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + return CBTEngConnHandler::SetPairingObserver( aAddr, ETrue ); + } + + +// --------------------------------------------------------------------------- +// Tell BTEng to stop observing the status of an ongoing pairing. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngConnMan::PrepareDiscovery() + { + TRACE_FUNC_ENTRY + (void) iConnHandler->PrepareDiscovery(); + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::StopPairingObserver( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + return CBTEngConnHandler::SetPairingObserver( aAddr, EFalse ); + } + +// --------------------------------------------------------------------------- +// Check if the remote device is connectable or not. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngConnMan::IsConnectable( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ) + { + TRACE_FUNC_ENTRY + return iConnHandler->IsDeviceConnectable( aAddr, aDeviceClass, aConnectable ); + } + +// --------------------------------------------------------------------------- +// Default implementation of BTEng ConnMan result observer. +// --------------------------------------------------------------------------- +// +EXPORT_C void MBTEngConnObserver::PairingComplete( TBTDevAddr& aAddr, TInt aErr ) + { + (void) aAddr; + (void) aErr; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdevman/inc/btengdevmanpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdevman/inc/btengdevmanpanic.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,30 @@ +// Copyright (c) 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: +// + +#ifndef BTENGDEVMANPAN_H +#define BTENGDEVMANPAN_H + +_LIT(KBtEngDevManPanic,"BtDevMan"); + +enum TBtEngDevManPanicCode + { + EBtEngDevManPanicNullObserver, + EBtEngDevManPanicNullResultArray, + EBtEngDevManPanicNullWaiter + }; + +void Panic(TBtEngDevManPanicCode aPanic); + +#endif // PBAPPANIC_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdevman/src/btengdevman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdevman/src/btengdevman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,552 @@ +/* +* Copyright (c) 2006, 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: Implementation of the Bluetooth Engine Device Management API +* +*/ + + + +#include + +#include "btengdevman.h" +#include "btengconstants.h" +#include "debug.h" +#include "btengdevmanpanic.h" + +void Panic(TBtEngDevManPanicCode aPanic) + { + User::Panic(KBtEngDevManPanic, aPanic); + } + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngDevMan::CBTEngDevMan( MBTEngDevManObserver* aObserver ) +: CActive( EPriorityStandard ), + iState( EStateIdle ), + iCreatingView( EFalse ), + iObserver( aObserver ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngDevMan::ConstructL() + { + TRACE_FUNC_ENTRY + // Check if BT is supported at all + FeatureManager::InitializeLibL(); + TBool btSupported = FeatureManager::FeatureSupported( KFeatureIdBt ); + FeatureManager::UnInitializeLib(); + if( !btSupported ) + { + TRACE_INFO( ( _L( "[BTENGDEVMAN]\t ConstructL: BT not supported" ) ) ) + User::Leave( KErrNotSupported ); + } + + User::LeaveIfError( iRegServ.Connect() ); + User::LeaveIfError( iRegistry.Open( iRegServ ) ); + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngDevMan* CBTEngDevMan::NewL( MBTEngDevManObserver* aObserver ) + { + CBTEngDevMan* self = CBTEngDevMan::NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngDevMan* CBTEngDevMan::NewLC( MBTEngDevManObserver* aObserver ) + { + CBTEngDevMan* self = new( ELeave ) CBTEngDevMan( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngDevMan::~CBTEngDevMan() + { + TRACE_FUNC_ENTRY + Cancel(); + iRegistry.Close(); + iRegServ.Close(); + delete iResponse; + delete iModifiedDevice; + } + + +// --------------------------------------------------------------------------- +// Add a device into the Bluetooth device registry. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDevMan::AddDevice( const CBTDevice& aDevice ) + { + TRACE_FUNC_ENTRY + __ASSERT_ALWAYS( iObserver, Panic(EBtEngDevManPanicNullObserver) ); + TInt err = KErrNone; + if( iState != EStateIdle ) + { + err = KErrInUse; + } + else + { + TRAP( err, iRegistry.AddDeviceL( aDevice, iStatus ) ); + if( err == KErrNone ) + { + iState = EStateAddDevice; + SetActive(); + } + } + TRACE_FUNC_EXIT + return err; + } + + +// --------------------------------------------------------------------------- +// Get an array of devices which matches the search criteria. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDevMan::GetDevices( const TBTRegistrySearch& aCriteria, + CBTDeviceArray* aResultArray ) + { + TRACE_FUNC_ENTRY + __ASSERT_ALWAYS( aResultArray, Panic(EBtEngDevManPanicNullResultArray) ); + TInt err = KErrNone; + if( iState != EStateIdle ) + { + err = KErrInUse; + } + else + { + ASSERT( !iResultArray && !iAsyncWaiter ); + iResultArray = aResultArray; + iRegistry.CreateView( aCriteria, iStatus ); + iState = EStateGetDevices; + iCreatingView = ETrue; + SetActive(); + if( !iObserver ) + { + // Synchronous version of GetDevices, will not use callback. + iAsyncWaiter = new CActiveSchedulerWait(); + if( !iAsyncWaiter ) + { + Cancel(); + return KErrNoMemory; + } + iAsyncWaiter->Start(); + err = iStatus.Int(); + iResultArray = NULL; + delete iAsyncWaiter; + iAsyncWaiter = NULL; + } + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// Delete the devices which matches the search criteria. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDevMan::DeleteDevices( const TBTRegistrySearch& aCriteria ) + { + TRACE_FUNC_ENTRY + __ASSERT_ALWAYS( iObserver, Panic(EBtEngDevManPanicNullObserver) ); + TInt err = KErrNone; + if( iState != EStateIdle ) + { + err = KErrInUse; + } + else + { + iRegistry.CreateView( aCriteria, iStatus ); + iState = EStateDeleteDevices; + iCreatingView = ETrue; + SetActive(); + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// Modify a device in the Bluetooth device registry. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDevMan::ModifyDevice( const CBTDevice& aDevice ) + { + TRACE_FUNC_ENTRY + __ASSERT_ALWAYS( iObserver, Panic(EBtEngDevManPanicNullObserver) ); + TInt err = KErrNone; + if( iState != EStateIdle ) + { + err = KErrInUse; + } + else + { + ASSERT( !iModifiedDevice ); + TRAP( err, iModifiedDevice = aDevice.CopyL() ); + } + if( !err ) + { + TBTRegistrySearch searchPattern; + searchPattern.FindAddress( iModifiedDevice->BDAddr() ); + iRegistry.CreateView( searchPattern, iStatus ); + iState = EStateModifyDevice; + iModifyState = ECheckPairing; + iCreatingView = ETrue; + SetActive(); + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Handle request completion, eventually making the callback. +// --------------------------------------------------------------------------- +// +void CBTEngDevMan::RunL() + { + TRACE_FUNC_ARG( ( _L( "status: %d" ), iStatus.Int() ) ) + TInt count = User::LeaveIfError(iStatus.Int()); + if( iCreatingView ) + { + // First stage completed, got a view on the registry. + iCreatingView = EFalse; + // When creating a view, iStatus represents + // the number of matching results. + if( count ) + { + ASSERT(iState >= EStateIdle && iState <= EStateDeleteDevices); + if( iState == EStateDeleteDevices ) + { + iRegistry.DeleteAllInView( iStatus ); + SetActive(); + } + else + { + iResponse = CBTRegistryResponse::NewL( iRegistry ); + iResponse->Start( iStatus ); + SetActive(); + } + } + else + { + if( iState == EStateGetDevices ) + { + iState = EStateIdle; + if( iObserver ) + { + CBTDeviceArray* clientArray = iResultArray; + iResultArray = NULL; + iObserver->HandleGetDevicesComplete( KErrNone, clientArray ); + } + else + { + __ASSERT_ALWAYS(iAsyncWaiter,Panic(EBtEngDevManPanicNullWaiter)); + iAsyncWaiter->AsyncStop(); // Synchronous version + } + } + else + { + iState = EStateIdle; + iObserver->HandleDevManComplete( KErrNone ); + } + } + } + else + { + // Second stage completed. + switch( iState ) + { + case EStateGetDevices: + { + (void) iRegistry.CloseView(); + RBTDeviceArray& resultArray = iResponse->Results(); + while (resultArray.Count()) + { + CBTDevice* dev = resultArray[ 0 ]; + resultArray.Remove( 0 ); + iResultArray->AppendL( dev ); + } + delete iResponse; + iResponse = NULL; + iState = EStateIdle; + if( iObserver ) + { + CBTDeviceArray* clientArray = iResultArray; + iResultArray = NULL; + iObserver->HandleGetDevicesComplete( count, clientArray ); + } + else + { + __ASSERT_ALWAYS(iAsyncWaiter,Panic(EBtEngDevManPanicNullWaiter)); + iAsyncWaiter->AsyncStop(); // Synchronous version + } + } + break; + case EStateModifyDevice: + { + DoModifyDeviceL(); + if( iModifyState != ECheckNone ) + { + break; + } + delete iModifiedDevice; + iModifiedDevice = NULL; + delete iResponse; + iResponse = NULL; + } // Fall through + case EStateDeleteDevices: + { + (void) iRegistry.CloseView(); + } // Fall through + case EStateAddDevice: + { + iState = EStateIdle; + iObserver->HandleDevManComplete( count ); + } + break; + case EStateIdle: + default: + { + ASSERT(EFalse); + TRACE_INFO( ( _L( "[BTEngDevMan]\t RunL - bad state! %d" ), iState ) ) + } + break; + } + } + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called if something leaves in RunL. +// --------------------------------------------------------------------------- +// +TInt CBTEngDevMan::RunError( TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "state: %d (modifystate: %d); error: %d" ), + iState, iModifyState, aError ) ) + // Reset all state information + iModifyState = ECheckNone; + iCreatingView = EFalse; + // Clean up all used resources + (void) iRegistry.CloseView(); // An error is returned if there is no + // open view -> can be safely ignored. + delete iResponse; + iResponse = NULL; + // Inform the client + if( iState == EStateGetDevices ) + { + iState = EStateIdle; + if( iObserver ) + { + CBTDeviceArray* clientArray = iResultArray; + iResultArray = NULL; + iObserver->HandleGetDevicesComplete( aError, clientArray ); + } + else + { + __ASSERT_ALWAYS(iAsyncWaiter,Panic(EBtEngDevManPanicNullWaiter)); + iAsyncWaiter->AsyncStop(); // Synchronous version + } + } + else + { + iState = EStateIdle; + iObserver->HandleDevManComplete( aError ); + } + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Cancel current outstanding operation, if any. +// --------------------------------------------------------------------------- +// +void CBTEngDevMan::DoCancel() + { + TRACE_FUNC_ENTRY + iRegistry.CancelRequest( iStatus ); + (void) iRegistry.CloseView(); + iState = EStateIdle; + iModifyState = ECheckNone; + iCreatingView = EFalse; + if( iResponse ) + { + iResponse->Cancel(); + delete iResponse; + iResponse = NULL; + } + delete iModifiedDevice; + iModifiedDevice = NULL; + if( iAsyncWaiter ) + { + iAsyncWaiter->AsyncStop(); + } + iResultArray = NULL; + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Process result of a registry search, when GetDevice or +// ModifyDevice has been called. +// --------------------------------------------------------------------------- +// +void CBTEngDevMan::DoModifyDeviceL() + { + TRACE_FUNC_ENTRY + if( iModifyState == ECheckFinal ) + { + // Modifications have completed. + iModifyState = ECheckNone; + return; + } + + // We searched for a device address, so assume that + // there is only one match. + ASSERT(iResponse->Results().Count() > 0); + CBTDevice* regDevice = iResponse->Results()[ 0 ]; + // Modifications to CBTDevice parameteres could include multiple + // asynchronous operations. Therefore each possibilbe modification + // is checked. The order is always the same so that we can know what + // the next step is. + if( iModifyState == ECheckPairing ) + { + // IsValidPaired returns if the pairing bit has been set. + // IsPaired returns if the device is actually paired. + if( ( regDevice->IsValidPaired() && regDevice->IsPaired() ) && + ( !iModifiedDevice->IsValidPaired() || !iModifiedDevice->IsPaired() ) ) + { + TRACE_INFO( _L( "[BTEngDevMan]\t DoModifyDeviceL UnpairDevice ") ); + // check if client request to ban or unpair a device paired with Just Works + if ( regDevice->LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable && + regDevice->IsValidUiCookie() && + ( regDevice->UiCookie() & EBTUiCookieJustWorksPaired ) ) + { + // Remove the UI cookie bit for Just Works pairing. Modifying registry + // will be called at nameless device checking. + TInt32 cookie = regDevice->UiCookie() & ~EBTUiCookieJustWorksPaired; + iModifiedDevice->SetUiCookie( cookie ); + TRACE_INFO( _L( "[BTEngDevMan]\t DoModifyDeviceL removed JW cookie ") ); + } + // Unpairing is requested. + iRegistry.UnpairDevice( iModifiedDevice->BDAddr(), iStatus ); + SetActive(); + // The reverse operation (pairing) is not performed through DevMan. + } + iModifyState = ECheckDevName; + } + if( !IsActive() && iModifyState == ECheckDevName ) + { + // Check that there is a valid device name, and that it is not + // the same as the registered name, or that the registry does not + // contain a valid name yet. + if( iModifiedDevice->IsValidDeviceName() && + ( !regDevice->IsValidDeviceName() || + ( iModifiedDevice->DeviceName() != regDevice->DeviceName() ) ) ) + { + TRACE_INFO( _L( "[BTEngDevMan]\t DoModifyDeviceL ModifyBluetoothDeviceName ") ); + iRegistry.ModifyBluetoothDeviceNameL( iModifiedDevice->BDAddr(), + iModifiedDevice->DeviceName(), + iStatus ); + SetActive(); + } + iModifyState = ECheckFriendlyName; + } + if( !IsActive() && iModifyState == ECheckFriendlyName ) + { + // Check that there is a valid friendly name, and that it is not + // the same as the registered name, or that the friendly name + // is removed. + if( ( iModifiedDevice->IsValidFriendlyName() && + ( iModifiedDevice->FriendlyName() != regDevice->FriendlyName() ) ) || + ( !iModifiedDevice->IsValidFriendlyName() && + regDevice->IsValidFriendlyName() ) ) + { + TRACE_INFO( _L( "[BTEngDevMan]\t DoModifyDeviceL ModifyFriendlyDeviceName ") ); + // If CBTDevice does not contain a valid friendly name, + // KNullDesC is returned. + iRegistry.ModifyFriendlyDeviceNameL( iModifiedDevice->BDAddr(), + iModifiedDevice->FriendlyName(), + iStatus ); + SetActive(); + } + iModifyState = ECheckNameless; + } + if( !IsActive() && iModifyState == ECheckNameless ) + { + iModifyState = ECheckNone; + if( iModifiedDevice->AsNamelessDevice() != regDevice->AsNamelessDevice() ) + { + TRACE_INFO( _L( "[BTEngDevMan]\t DoModifyDeviceL Modify NamelessDevice ") ); + // Update all other parameters. + iRegistry.ModifyDevice( iModifiedDevice->AsNamelessDevice(), iStatus ); + SetActive(); + iModifyState = ECheckFinal; // One more cycle needed to complete. + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// This is the default implementation of the MBTEngDevManObserver methods +// HandleDevManComplete just returns. +// --------------------------------------------------------------------------- +// +EXPORT_C void MBTEngDevManObserver::HandleDevManComplete( TInt /*aErr*/ ) + { + } + + +// --------------------------------------------------------------------------- +// This is the default implementation of the MBTEngDevManObserver methods +// HandleGetDevicesComplete just returns. +// --------------------------------------------------------------------------- +// +EXPORT_C void MBTEngDevManObserver::HandleGetDevicesComplete( TInt /*aErr*/, + CBTDeviceArray* /*aDeviceArray*/ ) + { + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/inc/btengdevicesearch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/inc/btengdevicesearch.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2006 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: Helper class declaration for performing device discovery. +* +*/ + + + +#ifndef BTENGDEVICESEARCH_H +#define BTENGDEVICESEARCH_H + + +#include +#include +#include "btengactive.h" + +class MBTEngSdpResultReceiver; + +/** + * Class CBTEngDeviceSearch + * + * ?more_complete_description + * + * @lib ?library + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngDeviceSearch ) : public CBase, + public MBTEngActiveObserver + { + +public: + + /** + * Two-phase constructor + */ + static CBTEngDeviceSearch* NewL(); + + /** + * Destructor + */ + virtual ~CBTEngDeviceSearch(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + TInt StartSearch( CBTDevice* aDevice, + TNameEntry* aNameEntry, + const TBTDeviceClass& aDeviceClass, + MBTEngSdpResultReceiver* aNotifier ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + void CancelSearch(); + + TInt GetEirServiceUUIDs( const TBTDevAddr& aAddr, + TNameEntry* aNameEntry, + MBTEngSdpResultReceiver* aNotifier); + + void CancelGetEirServiceUUIDs(); + +// from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Callback to notify that an outstanding request has completed. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ); + + /** + * Callback to notify that an error has occurred in RunL. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngDeviceSearch(); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + TInt DoGetDeviceEir(const TBTDevAddr& aAddr ); + + void HandleDeviceSelectionResultL(TInt aErr); + + void HandleDeviceEirDataResult(TInt aErr); + + /** + * Notifies the caller of the search result. + */ + void NotifyClient(TInt aErr); + +private: + enum TClientRequest + { + EDeviceSearch, + EGetDeviceEir + }; + +private: // data + + /** + * Hanlde to the search notifier. + */ + RNotifier iNotifier; + + /** + * Selection parameters package buffer. + */ + TBTDeviceSelectionParamsPckg iSelectionPckg; + + /** + * Response parameters package buffer. + */ + TBTDeviceResponseParamsPckg iResponsePckg; + + /** + * Our actual active object. + * Own. + */ + CBTEngActive* iActive; + + /** + * Socket server for Host Resolver. + * Own. + */ + RSocketServ iSocketServer; + + /** + * Hose Resolver to get cached EIR. + * Own. + */ + RHostResolver iHostResolver; + + /** + * used for getting cached EIR. + */ + TInquirySockAddr iInquirySockAddr; + + /** + * Client's object to store the results. + * Not own. + */ + CBTDevice* iDevice; + + /** + * Client's object to store EIR data. + * Not own. + */ + TNameEntry* iNameEntry; + + /** + * Reference to receiver of results. + * Not own. + */ + MBTEngSdpResultReceiver* iResultNotifier; + + TClientRequest iClientReq; + + }; + + +#endif // BTENGDEVICESEARCH diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/inc/btengsdpattrparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/inc/btengsdpattrparser.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2006 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: Helper class for parsing SDP attribute query results. +* +*/ + + + +#ifndef BTENGSDPATTRPARSER_H +#define BTENGSDPATTRPARSER_H + + +#include + +#include "btengdiscovery.h" + + +/** + * Class CBTEngSdpAttrParser + * + * ?more_complete_description + * + * @lib ?library + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSdpAttrParser ) : public CBase, + public MSdpAttributeValueVisitor + { + +public: + + /** + * Two-phase constructor + */ + static CBTEngSdpAttrParser* NewL( RSdpResultArray* aResultArray ); + + /** + * Destructor + */ + virtual ~CBTEngSdpAttrParser(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + void SetAttributeID( TSdpAttributeID aAttrId ); + +// from base class MSdpAttributeValueVisitor + + /** + * From MSdpAttributeValueVisitor. + * Called to pass an attribute value. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void VisitAttributeValueL( CSdpAttrValue &aValue, TSdpElementType aType ); + + /** + * From MSdpAttributeValueVisitor. + * Called to indicate the start of a list of attribute values. + * This call is followed by a call to VisitAttributeValueL() + * for each attribute value in the list, and concluded by + * a call to EndList(). + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void StartListL( CSdpAttrValueList &aList ); + + /** + * From MSdpAttributeValueVisitor. + * Called to indicate the end of a list of attribute values. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void EndListL(); + +private: + + /** + * C++ default constructor + */ + CBTEngSdpAttrParser( RSdpResultArray* aResultArray ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + +private: // data + + /** + * ?description_of_member + */ + TInt iNestingLevel; + + /** + * ?description_of_member + */ + TSdpAttributeID iAttrId; + + /** + * Reference to the array for storing the parsed result. + * Not own. + */ + RSdpResultArray* iResultArray; + + }; + + +#endif // BTENGSDPATTRPARSER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/inc/btengsdpquery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/inc/btengsdpquery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,227 @@ +/* +* Copyright (c) 2006 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: Helper class for performing SDP queries. +* +*/ + + +#ifndef BTENGSDPQUERY_H +#define BTENGSDPQUERY_H + +#include "btengdiscovery.h" + +class CBTEngSdpAttrParser; + +/** Array definition for storing SDP record handles */ +typedef RPointerArray RSdpAttrValueArray; + + +/** + * Class CBTEngSdpQuery + * + * ?more_complete_description + * + * @lib btengdiscovery.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSdpQuery ) : public CBase, public MSdpAgentNotifier + { + +public: + + /** ?description */ + enum TSdpQueryType + { + EQueryIdle, + EServiceQuery, + EAttrQuery, + EServiceAttrQuery + }; + + /** + * Two-phase constructor + */ + static CBTEngSdpQuery* NewL( MBTEngSdpResultReceiver* aNotifier ); + + /** + * Destructor + */ + virtual ~CBTEngSdpQuery(); + + /** + * ?description + * + * @since S60 v3.2 + */ + void Cancel(); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @param aService ?description + */ + void RemoteSdpQueryL( const TBTDevAddr& aAddr, const TUUID& aService ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @param aHandle ?description + * @param aAttrId ?description + */ + void RemoteSdpQueryL( const TBTDevAddr& aAddr, + const TSdpServRecordHandle aHandle, + const TSdpAttributeID aAttrId ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @param aService ?description + * @param aAttrId ?description + */ + void RemoteSdpQueryL( const TBTDevAddr& aAddr, const TUUID& aService, + const TSdpAttributeID aAttrId ); + +// from base class MSdpAgentNotifier + + /** + * From MSdpAgentNotifier. + * Called when an service record request operation completes. + * + * @since S60 v3.2 + * @param aError KErrNone if successful; KErrEof if there are no more + * SDP records left to be read; or an SDP error. + * @param aHandle Service record for which the query was made. + * @param aTotalRecordsCount Total number of matching records. + */ + virtual void NextRecordRequestComplete( TInt aError, + TSdpServRecordHandle aHandle, + TInt aTotalRecordsCount ); + + /** + * From MSdpAgentNotifier. + * Called when an attribute request wants to pass up a result. + * + * @since S60 v3.2 + * @param aHandle Service record for which the query was made. + * @param aAttrID ID of the attribute obtained. + * @param @param aAttrValue Attribute value obtained. + */ + virtual void AttributeRequestResult( TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, + CSdpAttrValue* aAttrValue ); + + /** + * From MSdpAgentNotifier. + * Called when an attribute request wants to signal the completion + * of a attribute request. + * + * @since S60 v3.2 + * @param aHandle Service record for which the query was made. + * @param aError An error. + */ + virtual void AttributeRequestComplete( TSdpServRecordHandle aHandle, + TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngSdpQuery( MBTEngSdpResultReceiver* aNotifier ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * Helper function to pass back an error to our client. + * + * @since S60 v3.2 + * @param aError The error to return to the result observer. + */ + void NotifyError( TInt aError ); + + /** + * Helper function to check that + * + * @since S60 v3.2 + * @param aAddr ?description + * @return KErrNone if sucessful, + * KErrNotReady if no SDP result notifier has been set, + * otherwise the error code indicating the error situation. + */ + void CheckSdpAgentL( const TBTDevAddr& aAddr ); + +private: // data + + /** + * Flag to check if an SDP query is ongoing. + */ + TSdpQueryType iQueryType; + + /** + * Flag to check if an SDP query is ongoing. + */ + TBTDevAddr iBDAddr; + + /** + * Attribute ID for second step of ServiceAttributeSearch + * operation; otherwise NULL. + */ + TSdpAttributeID iRequestedAttrId; + + /** + * Result array of discovered service record handles. + */ + RSdpRecHandleArray iRecHandleArray; + + /** + * Result array of discovered service record attributes. + */ + RSdpResultArray iAttrResArray; + + /** + * Array for temporarily storing CSdpAttrValue objects. The actual + * value is used through the RSdpResultArray member. + */ + RSdpAttrValueArray iAttrValArray; + + /** + * ?description_of_pointer_member + * Own. + */ + CSdpAgent* iSdpAgent; + + /** + * Parser for decoding SDP attribute values. + * Own. + */ + CBTEngSdpAttrParser* iParser; + + /** + * Reference to receiver of remote SDP query results. + * Not own. + */ + MBTEngSdpResultReceiver* iResultNotifier; + + }; + +#endif // BTENGSDPQUERY_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/src/btengdevicesearch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/src/btengdevicesearch.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,337 @@ +/* +* Copyright (c) 2006 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: Helper class implementation for performing device discovery. +* +*/ + + +#include "btengdevicesearch.h" +#include "btengdiscovery.h" +#include "debug.h" + +/** + * the request ID for device search using RNotifer. + */ +const TInt KDevSearchAoReqId = 40; + +/* + * the request ID for EIR service uuids using host resolver + */ +const TInt KDevEirServiceListAoReqId = 41; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngDeviceSearch::CBTEngDeviceSearch() + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::ConstructL() + { + User::LeaveIfError( iNotifier.Connect() ); + iActive = CBTEngActive::NewL( *this, KDevSearchAoReqId, + CActive::EPriorityStandard ); + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngDeviceSearch* CBTEngDeviceSearch::NewL() + { + CBTEngDeviceSearch* self = new( ELeave ) CBTEngDeviceSearch(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngDeviceSearch::~CBTEngDeviceSearch() + { + if( iNotifier.Handle()&& iActive->IsActive()) + { + iNotifier.CancelNotifier( KDeviceSelectionNotifierUid ); + iActive->CancelRequest(); + } + delete iActive; + iNotifier.Close(); + iHostResolver.Close(); + iSocketServer.Close(); + } + +// --------------------------------------------------------------------------- +// Start the device discovery notifier. +// --------------------------------------------------------------------------- +// +TInt CBTEngDeviceSearch::StartSearch( CBTDevice* aDevice, TNameEntry* aNameEntry, + const TBTDeviceClass& aDeviceClass, MBTEngSdpResultReceiver* aNotifier ) + { + TRACE_FUNC_ENTRY + TInt err ( KErrNone ); + if( iActive->IsActive() ) + { + err = KErrInUse; + } + if( !err && !iNotifier.Handle() ) + { + err = iNotifier.Connect(); + } + if( !err ) + { + iClientReq = EDeviceSearch; + iResultNotifier = aNotifier; + iNameEntry = aNameEntry; + iDevice = aDevice; + // Selection parameters + TBTDeviceSelectionParams params; + params.SetDeviceClass( aDeviceClass ); + iSelectionPckg = TBTDeviceSelectionParamsPckg( params ); + // Response parameters + TBTDeviceResponseParams result; + iResponsePckg = TBTDeviceResponseParamsPckg( result ); + iActive->SetRequestId( KDevSearchAoReqId ); + iNotifier.StartNotifierAndGetResponse( iActive->RequestStatus(), + KDeviceSelectionNotifierUid, + iSelectionPckg, iResponsePckg ); + iActive->GoActive(); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Cancel an ongoing device discovery. +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::CancelSearch() + { + TRACE_FUNC_ENTRY + if( iActive->IsActive() && iClientReq == EDeviceSearch) + { + if (iActive->RequestId() == KDevSearchAoReqId) + { + iNotifier.CancelNotifier( KDeviceSelectionNotifierUid ); + iActive->CancelRequest(); + iNotifier.Close(); + NotifyClient(KErrAbort); + } + else if (iActive->RequestId() == KDevEirServiceListAoReqId) + { + iHostResolver.Cancel(); + iHostResolver.Close(); + } + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Get cached EIR data from host resolver and extract service uuids +// --------------------------------------------------------------------------- +// +TInt CBTEngDeviceSearch::GetEirServiceUUIDs( const TBTDevAddr& aAddr, + TNameEntry* aNameEntry, MBTEngSdpResultReceiver* aNotifier) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + if( iActive->IsActive() ) + { + err = KErrInUse; + } + if (!err) + { + iClientReq = EGetDeviceEir; + iResultNotifier = aNotifier; + iNameEntry = aNameEntry; + err = DoGetDeviceEir(aAddr); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Cancel an ongoing EIR services retieval. +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::CancelGetEirServiceUUIDs() + { + TRACE_FUNC_ENTRY + if( iActive->IsActive() && iClientReq == EGetDeviceEir) + { + iHostResolver.Cancel(); + iHostResolver.Close(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Callback to notify that an outstanding request has completed. +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "status: %d") , aStatus ) ) + (void) aActive; + if ( aId == KDevSearchAoReqId ) + { + HandleDeviceSelectionResultL(aStatus); + } + else if (aId == KDevEirServiceListAoReqId) + { + HandleDeviceEirDataResult( aStatus ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Callback to notify that an error has occurred in RunL. +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "error: %d") , aError ) ) + (void) aActive; + (void) aId; + iNotifier.Close(); + iHostResolver.Close(); + NotifyClient(aError); + } + +// --------------------------------------------------------------------------- +// get device eir from cache +// --------------------------------------------------------------------------- +// +TInt CBTEngDeviceSearch::DoGetDeviceEir(const TBTDevAddr& aAddr) + { + TRACE_FUNC_ENTRY + TInt err (KErrNone); + if (!iSocketServer.Handle()) + { + err = iSocketServer.Connect(); + } + + TProtocolDesc pInfo; + if (!err) + { + _LIT(KBTLinkManagerProtocol, "BTLinkManager"); + err = iSocketServer.FindProtocol( KBTLinkManagerProtocol(), pInfo ); + } + if (!err) + { + err = iHostResolver.Open(iSocketServer, pInfo.iAddrFamily, pInfo.iProtocol); + } + if( !err ) + { + iInquirySockAddr = TInquirySockAddr(); + iInquirySockAddr.SetBTAddr(aAddr ); + iInquirySockAddr.SetAction( KHostResCache ); + iActive->SetRequestId( KDevEirServiceListAoReqId ); + iHostResolver.GetByAddress( iInquirySockAddr, *iNameEntry, iActive->RequestStatus() ); + iActive->GoActive(); + } + TRACE_FUNC_EXIT + return err; + } + +void CBTEngDeviceSearch::HandleDeviceSelectionResultL(TInt aErr) + { + TRACE_FUNC_ENTRY + TInt err (aErr); + iNotifier.Close(); + if (!err) + { + // Copy information to returned device + iDevice->SetDeviceAddress( iResponsePckg().BDAddr() ); + iDevice->SetDeviceNameL( BTDeviceNameConverter::ToUTF8L( + iResponsePckg().DeviceName() ) ); + iDevice->SetDeviceClass( iResponsePckg().DeviceClass() ); + } + if (!err && iNameEntry) + { + err = DoGetDeviceEir(iResponsePckg().BDAddr()); + } + // if an error happens, or the caller doesn't need the EIR part, complete + // the request. Otherwise the client will be called after getting EIR + // completes. + if (err || !iNameEntry) + { + NotifyClient(err); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// extracting service uuids from the device EIR data returned by host resolver +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::HandleDeviceEirDataResult(TInt aErr) + { + TRACE_FUNC_ENTRY + iHostResolver.Close(); + + if ( iClientReq == EDeviceSearch) + { + // Device search has already completed correctly, so + // we don't pass GetEir error + NotifyClient( KErrNone ); + } + else + { + NotifyClient( aErr ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Callback to notify that the caller's request has completed. +// --------------------------------------------------------------------------- +// +void CBTEngDeviceSearch::NotifyClient(TInt aErr) + { + TRACE_FUNC_ENTRY + if( iResultNotifier && iClientReq == EDeviceSearch) + { + if (iNameEntry) + { + iResultNotifier->DeviceSearchComplete( iDevice, iNameEntry, aErr ); + } + else + { + iResultNotifier->DeviceSearchComplete( iDevice, aErr ); + } + } + if (iResultNotifier && iClientReq == EGetDeviceEir) + { + iResultNotifier->GetEirServiceUUIDsComplete(iNameEntry, aErr); + } + TRACE_FUNC_EXIT + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/src/btengdiscovery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/src/btengdiscovery.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,429 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine API for device discovery functionality. +* +*/ + + + +#include + +#include "btengdiscovery.h" +#include "btengsdpdbhandler.h" +#include "btengsdpquery.h" +#include "btengdevicesearch.h" +#include "debug.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngDiscovery::CBTEngDiscovery( MBTEngSdpResultReceiver* aNotifier ) +: iResultNotifier( aNotifier ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngDiscovery::ConstructL() + { + TRACE_FUNC_ENTRY + // Check if BT is supported at all + FeatureManager::InitializeLibL(); + TBool btSupported = FeatureManager::FeatureSupported( KFeatureIdBt ); + FeatureManager::UnInitializeLib(); + if( !btSupported ) + { + TRACE_INFO( ( _L( "[BTENGDISC]\t ConstructL: BT not supported" ) ) ) + User::Leave( KErrNotSupported ); + } + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngDiscovery* CBTEngDiscovery::NewL( MBTEngSdpResultReceiver* aNotifier ) + { + CBTEngDiscovery* self = CBTEngDiscovery::NewLC( aNotifier ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngDiscovery* CBTEngDiscovery::NewLC( MBTEngSdpResultReceiver* aNotifier ) + { + CBTEngDiscovery* self = new( ELeave ) CBTEngDiscovery( aNotifier ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngDiscovery::~CBTEngDiscovery() + { + TRACE_FUNC_ENTRY + delete iSdpDbHandler; + delete iSdpQueryHandler; + delete iDevSearchHandler; + } + + +// --------------------------------------------------------------------------- +// Searches for remote BT devices, by launching the device discovery notifier. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::SearchRemoteDevice( CBTDevice* aDevice, + TUint aServiceClass ) + { + TRACE_FUNC_ENTRY + TInt err = SearchRemoteDevice(aDevice, NULL, aServiceClass); + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// device search version supporting EIR data retrieval +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::SearchRemoteDevice( CBTDevice* aDevice, + TNameEntry* aNameEntry, TUint aServiceClass ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + if( !iDevSearchHandler ) + { + TRAP( err, iDevSearchHandler = CBTEngDeviceSearch::NewL() ); + } + if( !err ) + { + err = iDevSearchHandler->StartSearch( aDevice, aNameEntry, aServiceClass, + iResultNotifier ); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Cancels an ongoing search for remote BT devices. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngDiscovery::CancelSearchRemoteDevice() + { + TRACE_FUNC_ENTRY + if( iDevSearchHandler ) + { + iDevSearchHandler->CancelSearch(); + } + } + +// --------------------------------------------------------------------------- +// Gets the service uuids in the cached EIR data of the device +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::GetEirServiceUUIDs( const TBTDevAddr& aAddr, + TNameEntry* aNameEntry) + { + TRACE_FUNC_ENTRY + __ASSERT_DEBUG( aNameEntry != NULL, User::Panic(_L("null pointer in GetEirServiceUUIDs"),KErrArgument)); + TInt err = KErrNone; + if( !iDevSearchHandler ) + { + TRAP( err, iDevSearchHandler = CBTEngDeviceSearch::NewL() ); + } + if( !err ) + { + err = iDevSearchHandler->GetEirServiceUUIDs(aAddr, aNameEntry, + iResultNotifier ); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// cancels ongoing EIR service list retrieval. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngDiscovery::CancelGetEirServiceUUIDs() + { + if( iDevSearchHandler ) + { + iDevSearchHandler->CancelGetEirServiceUUIDs(); + } + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::RegisterSdpRecord( const TUUID& aService, + const TUint aChannel, TSdpServRecordHandle& aHandle ) + { + TRACE_FUNC_ENTRY + TInt err = CheckSdpDbHandler(); + if( !err ) + { + TRAP( err, iSdpDbHandler->RegisterSdpRecordL( aService, aChannel, aHandle ) ); + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::DeleteSdpRecord( const TSdpServRecordHandle aHandle ) + { + TRACE_FUNC_ENTRY + TInt err = CheckSdpDbHandler(); + if( !err ) + { + TRAP( err, iSdpDbHandler->DeleteSdpRecordL( aHandle ) ); + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngDiscovery::SetNotifier( MBTEngSdpResultReceiver* aNotifier ) + { + ASSERT( aNotifier ); + iResultNotifier = aNotifier; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::RemoteSdpQuery( const TBTDevAddr& aAddr, + const TUUID& aService ) + { + TRACE_FUNC_ENTRY + TInt err = CheckSdpQueryHandler(); + if( !err ) + { + TRAP( err, iSdpQueryHandler->RemoteSdpQueryL( aAddr, aService ) ); + } + TRACE_FUNC_EXIT + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::RemoteSdpQuery( const TBTDevAddr& aAddr, + const TSdpServRecordHandle aHandle, const TSdpAttributeID aAttrId ) + { + TRACE_FUNC_ENTRY + TInt err = CheckSdpQueryHandler(); + if( !err ) + { + TRAP( err, iSdpQueryHandler->RemoteSdpQueryL( aAddr, aHandle, aAttrId ) ); + } + TRACE_FUNC_EXIT + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::RemoteSdpQuery( const TBTDevAddr& aAddr, + const TUUID& aService, const TSdpAttributeID aAttrId ) + { + TRACE_FUNC_ENTRY + TInt err = CheckSdpQueryHandler(); + if( !err ) + { + TRAP( err, iSdpQueryHandler->RemoteSdpQueryL( aAddr, aService, aAttrId ) ); + } + TRACE_FUNC_EXIT + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::RemoteProtocolChannelQuery( const TBTDevAddr& aAddr, + const TUUID& aService ) + { + return RemoteSdpQuery( aAddr, aService, KSdpAttrIdProtocolDescriptorList ); + } + + +// --------------------------------------------------------------------------- +// Cancels an ongoing search for remote SDP services. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngDiscovery::CancelRemoteSdpQuery() + { + TRACE_FUNC_ENTRY + if( iSdpQueryHandler ) + { + iSdpQueryHandler->Cancel(); + } + } + +// --------------------------------------------------------------------------- +// Closes a remote SDP connection. The method should be called after RemoteSdpQuery +// and RemoteProtocolChannelQuery methods are completed and the CBTEngDiscovery obejct +// is still kept alive. +// --------------------------------------------------------------------------- +// +EXPORT_C void CBTEngDiscovery::CloseRemoteSdpConnection() + { + TRACE_FUNC_ENTRY + if( iSdpQueryHandler ) + { + delete iSdpQueryHandler; + iSdpQueryHandler = NULL; + } + } + +// --------------------------------------------------------------------------- +// Parses the element type at specified index from the specified result array. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::ParseNextSdpAttrValueType( + RSdpResultArray& aResultArray, TInt aIndex, TSdpElementType& aType ) + { + if( aIndex >= aResultArray.Count() ) + { + // Check if this points to a valid position, within range [0, count-1]. + return KErrEof; + } + aType = aResultArray[ aIndex ].iAttrType; + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// Parses the element type at specified index from the specified result array. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngDiscovery::ParseRfcommChannel( RSdpResultArray& aResultArray, + TInt& aChannel ) + { + TInt err = KErrNone; + TInt index = 0; + TSdpElementType type = ETypeNil; + while( index < aResultArray.Count() ) + { + err = ParseNextSdpAttrValueType( aResultArray, index, type ); + // Could be refined to check for the RFCOMM identifier??? + if( !err && type == ETypeUint ) + { + aChannel = aResultArray[ index ].iAttrValue.iValNumeric; + break; + } + index++; + } + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngDiscovery::CheckSdpDbHandler() + { + TInt err = KErrNone; + if( !iSdpDbHandler ) + { + // Trap is necessary here as this is a non-leaving fuction. + TRAP( err, iSdpDbHandler = CBTEngSdpDbHandler::NewL() ); + } + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngDiscovery::CheckSdpQueryHandler() + { + if( !iResultNotifier ) + { + return KErrNotReady; + } + TInt err = KErrNone; + if( !iSdpQueryHandler ) + { + // Trap is necessary here as this is a non-leaving fuction. + TRAP( err, iSdpQueryHandler = CBTEngSdpQuery::NewL( iResultNotifier ) ); + } + return err; + } + + +// --------------------------------------------------------------------------- +// Default implementation of EIR version DeviceSearchComplete +// --------------------------------------------------------------------------- +// +EXPORT_C void MBTEngSdpResultReceiver::DeviceSearchComplete( CBTDevice* aDevice, + TNameEntry* aNameEntry, + TInt aErr) + { + TRACE_FUNC_ENTRY + (void) aDevice; + (void) aNameEntry, + (void) aErr; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Default implementation of GetEirServiceUUIDsComplete +// --------------------------------------------------------------------------- +// +EXPORT_C void MBTEngSdpResultReceiver::GetEirServiceUUIDsComplete( + TNameEntry* aNameEntry, + TInt aErr ) + { + TRACE_FUNC_ENTRY + (void) aNameEntry, + (void) aErr; + TRACE_FUNC_EXIT + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/src/btengsdpattrparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/src/btengsdpattrparser.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2006 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: Helper class for parsing SDP attribute query results. +* +*/ + + + +//#include + +#include "btengsdpattrparser.h" + +//const ?type ?constant_var = ?constant; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSdpAttrParser::CBTEngSdpAttrParser( RSdpResultArray* aResultArray ) + : iResultArray( aResultArray ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSdpAttrParser::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSdpAttrParser* CBTEngSdpAttrParser::NewL( RSdpResultArray* aResultArray ) + { + CBTEngSdpAttrParser* self = new( ELeave ) CBTEngSdpAttrParser( aResultArray ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSdpAttrParser::~CBTEngSdpAttrParser() + { + } + + +// --------------------------------------------------------------------------- +// Set the current attribute ID, to add to the result array. +// --------------------------------------------------------------------------- +// +void CBTEngSdpAttrParser::SetAttributeID( TSdpAttributeID aAttrId ) + { + iAttrId = aAttrId; + } + + +// --------------------------------------------------------------------------- +// From class MSdpAttributeValueVisitor. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpAttrParser::VisitAttributeValueL( CSdpAttrValue& aValue, + TSdpElementType aType ) + { + TBTEngSdpAttrValue attrValue; + attrValue.iAttrId = iAttrId; + attrValue.iAttrType = aType; + switch( aType ) + { + case ETypeNil: + { + attrValue.iAttrValue.iValNumeric = 0; // To be checked + } + break; + case ETypeUint: + { + attrValue.iAttrValue.iValNumeric = aValue.Uint(); + } + break; + case ETypeInt: + { + attrValue.iAttrValue.iValNumeric = aValue.Int(); + } + break; + case ETypeUUID: + { + attrValue.iAttrValue.iValString.Set( aValue.UUID().Des() ); + } + break; + case ETypeString: + { + attrValue.iAttrValue.iValString.Set( aValue.Des() ); + } + break; + case ETypeBoolean: + { + attrValue.iAttrValue.iValNumeric = aValue.Bool(); + } + break; + case ETypeURL: + { + attrValue.iAttrValue.iValString.Set( aValue.Des() ); + } + break; + case ETypeDES: + case ETypeDEA: + case ETypeEncoded: + default: + // Don't add any value + break; + } + iResultArray->Append( attrValue ); + } + + +// --------------------------------------------------------------------------- +// From class MSdpAttributeValueVisitor. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpAttrParser::StartListL( CSdpAttrValueList& aList ) + { + // Increase counter to check the nested lists + iNestingLevel++; + (void) aList; + } + + +// --------------------------------------------------------------------------- +// From class MSdpAttributeValueVisitor. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpAttrParser::EndListL() + { + // Decrease counter to check the nested lists and signal completion. + iNestingLevel--; + if( iNestingLevel == 0 ) + { + ; // Parsing completed + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengdiscovery/src/btengsdpquery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengdiscovery/src/btengsdpquery.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,360 @@ +/* +* Copyright (c) 2006 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: Helper class for performing SDP queries. +* +*/ + + + +#include + +#include "btengsdpquery.h" +#include "btengdiscovery.h" +#include "btengsdpattrparser.h" +#include "debug.h" + + +/** Array granularity for storing SDP attribute values (the number + * of attributes returned from an attribute search is expected + * to be small). + */ +const TInt KBTEngDefaultGranularity = 2; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSdpQuery::CBTEngSdpQuery( MBTEngSdpResultReceiver* aNotifier ) +: iAttrValArray( KBTEngDefaultGranularity ), + iResultNotifier( aNotifier ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::ConstructL() + { + TRACE_FUNC_ENTRY + iParser = CBTEngSdpAttrParser::NewL( &iAttrResArray ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSdpQuery* CBTEngSdpQuery::NewL( MBTEngSdpResultReceiver* aNotifier ) + { + CBTEngSdpQuery* self = new( ELeave ) CBTEngSdpQuery( aNotifier ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSdpQuery::~CBTEngSdpQuery() + { + TRACE_FUNC_ENTRY + Cancel(); + delete iSdpAgent; + delete iParser; + iResultNotifier = NULL; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::Cancel() + { + TRACE_FUNC_ENTRY + if( iQueryType != EQueryIdle ) + { + // Only call the agent when a search is active, as it + // involves some cleanup which is not necessary for every call. + iSdpAgent->Cancel(); + iQueryType = EQueryIdle; + } + iRecHandleArray.Close(); + iAttrResArray.Close(); + iAttrValArray.ResetAndDestroy(); + iRequestedAttrId = 0; + } + + +// --------------------------------------------------------------------------- +// Service query +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::RemoteSdpQueryL( const TBTDevAddr& aAddr, const TUUID& aService ) + { + TRACE_FUNC_ENTRY + CheckSdpAgentL( aAddr ); + if( iQueryType == EQueryIdle ) + { + iQueryType = EServiceQuery; + iAttrResArray.Close(); + iAttrValArray.ResetAndDestroy(); + iRequestedAttrId = 0; + } + iRecHandleArray.Close(); + CSdpSearchPattern* searchPattern = CSdpSearchPattern::NewL(); + CleanupStack::PushL( searchPattern ); + searchPattern->AddL( aService ); + iSdpAgent->SetRecordFilterL( *searchPattern ); // Copies searchpattern. + iSdpAgent->NextRecordRequestL(); + CleanupStack::PopAndDestroy( searchPattern ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Attribute query +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::RemoteSdpQueryL( const TBTDevAddr& aAddr, + const TSdpServRecordHandle aHandle, const TSdpAttributeID aAttrId ) + { + TRACE_FUNC_ENTRY + CheckSdpAgentL( aAddr ); + // this could be part of a ServiceSearchAttribute query. + if( iQueryType == EQueryIdle ) + { + iQueryType = EAttrQuery; + iRecHandleArray.Close(); + } + iRequestedAttrId = aAttrId; + iAttrResArray.Close(); + iAttrValArray.ResetAndDestroy(); + iSdpAgent->AttributeRequestL( aHandle, aAttrId ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ServiceAttribute query +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::RemoteSdpQueryL( const TBTDevAddr& aAddr, const TUUID& aService, + const TSdpAttributeID aAttrId ) + { + TRACE_FUNC_ENTRY + if( iQueryType != EQueryIdle ) + { + User::Leave( KErrInUse ); + } + iQueryType = EServiceAttrQuery; + iRequestedAttrId = aAttrId; + iRecHandleArray.Close(); + iAttrResArray.Close(); + iAttrValArray.ResetAndDestroy(); + // First query for the requested service. + RemoteSdpQueryL( aAddr, aService ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MSdpAgentNotifier. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::NextRecordRequestComplete( TInt aError, + TSdpServRecordHandle aHandle, TInt aTotalRecordsCount ) + { + TRACE_FUNC_ENTRY + if( aError == KErrNone && aTotalRecordsCount > 0 ) + { + // Store the result and wait for the next. + iRecHandleArray.Append( aHandle ); + TRAP( aError, iSdpAgent->NextRecordRequestL() ); + } + else if( aError == KErrEof ) + { + // The last notification does not contain any result anymore. + if( iQueryType == EServiceAttrQuery ) + { + if( iRecHandleArray.Count() > 0 ) + { + // Request the attribute for all matching service records. + TRAP( aError, RemoteSdpQueryL( iBDAddr, iRecHandleArray[ 0 ], + iRequestedAttrId ) ); + } + else + { + // No matches, inform the client. + iQueryType = EQueryIdle; + iResultNotifier->ServiceAttributeSearchComplete( aHandle, + iAttrResArray, + aError ); + } + } + else + { + // This was a ServiceSearch, inform our client of the result. + TInt recCount = iRecHandleArray.Count(); + if( recCount > 0 ) + { + // KErrEof is used to indicate no matching records. + aError = KErrNone; + } + iQueryType = EQueryIdle; + iResultNotifier->ServiceSearchComplete( iRecHandleArray, recCount, + aError ); + } + } + NotifyError( aError ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MSdpAgentNotifier. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::AttributeRequestResult( TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue ) + { + TRACE_FUNC_ENTRY + // Ownership of CSdpAttrValue is passed here. Store the object so + // that the result array can point to string values rather than + // copy them (the object is anyway already constructed). + iAttrValArray.Append( aAttrValue ); + iParser->SetAttributeID( aAttrID ); + // Adds the attribute values synchronously to the result array. + TRAP_IGNORE( aAttrValue->AcceptVisitorL( *iParser ) ); + (void) aHandle; + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MSdpAgentNotifier. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::AttributeRequestComplete( TSdpServRecordHandle aHandle, + TInt aError ) + { + TRACE_FUNC_ENTRY + if( aError ) + { + NotifyError( aError ); + return; + } + + if( iQueryType == EAttrQuery ) + { + // This was a AttributeSearch, inform our client of the result. + iQueryType = EQueryIdle; + iResultNotifier->AttributeSearchComplete( aHandle, iAttrResArray, aError ); + } + else if( iQueryType == EServiceAttrQuery ) + { + TInt index = iRecHandleArray.Find( aHandle ); + if( index <= KErrNotFound ) + { + NotifyError( KErrCorrupt ); + return; + } + // Pop the handle, since we don't need it anymore. + iRecHandleArray.Remove( index ); + if( iRecHandleArray.Count() == 0 ) + { + // This was the last result. + aError = KErrEof; + iQueryType = EQueryIdle; + } + iResultNotifier->ServiceAttributeSearchComplete( aHandle, iAttrResArray, + aError ); + if( aError != KErrEof && iQueryType == EServiceAttrQuery ) + { + // Request the attribute from the next matching record (if + // not cancelled in the callback, hence the check for the + // querytype) This will reset the attribute result array. + TRAP( aError, RemoteSdpQueryL( iBDAddr, iRecHandleArray[ 0 ], + iRequestedAttrId ) ); + NotifyError( aError ); // Does nothing if there is no error. + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::NotifyError( TInt aError ) + { + if( aError == KErrNone || aError == KErrEof || iResultNotifier == NULL ) + { + return; + } + TSdpQueryType query = iQueryType; + iQueryType = EQueryIdle; // Need to set this before calling clients, + // as they may call us straight again. + if( query == EServiceQuery ) + { + iResultNotifier->ServiceSearchComplete( RSdpRecHandleArray(), 0, aError ); + } + else if( query == EAttrQuery ) + { + iResultNotifier->AttributeSearchComplete( 0, RSdpResultArray(), aError ); + } + if( query == EServiceAttrQuery ) + { + iResultNotifier->ServiceAttributeSearchComplete( 0, RSdpResultArray(), + aError ); + } + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSdpQuery::CheckSdpAgentL( const TBTDevAddr& aAddr ) + { + if( !iSdpAgent || aAddr != iBDAddr ) + { + delete iSdpAgent; + iSdpAgent = NULL; + iBDAddr = aAddr; + iSdpAgent = CSdpAgent::NewL( *this, iBDAddr ); + } + else + { + iSdpAgent->Cancel(); + } + if( iQueryType != EQueryIdle && iQueryType != EServiceAttrQuery ) + { + // Another query is ongoing and has not been cancelled. + User::Leave( KErrInUse ); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengsettings/inc/btengsettingsnotify.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengsettings/inc/btengsettingsnotify.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2006 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: Helper class for handling change notifications of +* PubSub properties and CenRep keys. +* +*/ + + +#ifndef BTENGSETTINGSNOTIFY_H +#define BTENGSETTINGSNOTIFY_H + + +#include "btengactive.h" +#include "btengclient.h" + +class MBTEngSettingsObserver; +class CRepository; + +/** + * Class CBTEngSettingsNotify + * + * ?more_complete_description + * + * @lib btengsettings.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSettingsNotify ) : public CBase, + public MBTEngActiveObserver + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives notification + * that a setting has changed. + * @return Pointer to the constructed CBTEngSettingsNotify object. + */ + static CBTEngSettingsNotify* NewL( MBTEngSettingsObserver* aObserver ); + + /** + * Destructor + */ + virtual ~CBTEngSettingsNotify(); + + /** + * Toggles the Bluetooth power state (on or off). Power will be switched on + * for the duriation of the session. It will also be turned off (gracefully, + * if no permanent connection exists) if this object is destroyed. + * Note: power will only be switched off gracefully if it has also been + * switched on through this method, otherwise KErrAccessDenied will be + * returned. + * + * @since S60 v5.0 + * @return KErrNone on success, otherwise a system wide error code. + */ + TInt TogglePowerTemporarily(); + +// from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Handle a setting change. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Handle an error in the setting change handling. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives notification + * that a setting has changed. + */ + CBTEngSettingsNotify( MBTEngSettingsObserver* aObserver ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + +private: // data + + /** + * Active object for watching power mode setting changes. + * Own. + */ + CBTEngActive* iPowerKeyWatcher; + + /** + * Active object for watching visibility mode setting changes. + * Own. + */ + CBTEngActive* iVisiKeyWatcher; + + /** + * Session with the central repository for power mode setting. + * Own. + */ + CRepository* iPowerKeyCenRep; + + /** + * Session with the central repository for visibility mode setting. + * Own. + */ + CRepository* iVisiKeyCenRep; + + /** + * Client to notify of changes. + * Not own. + */ + MBTEngSettingsObserver* iObserver; + + /** + * Handle to BTEng server for turning Bluetooth on temporarily. + */ + RBTEng iBTeng; + }; + + +#endif // BTENGSETTINGSNOTIFY_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengsettings/src/btengsettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengsettings/src/btengsettings.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,445 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine API for managing device settings. +* +*/ + + + +#include +#include +#include + +#include "btengsettings.h" +#include "btengprivatecrkeys.h" +#include "btengsettingsnotify.h" +#include "btengclient.h" +#include "debug.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSettings::CBTEngSettings( MBTEngSettingsObserver* aObserver ) +: iObserver( aObserver ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSettings::ConstructL() + { + TRACE_FUNC_ENTRY + // Check if BT is supported at all + FeatureManager::InitializeLibL(); + TBool btSupported = FeatureManager::FeatureSupported( KFeatureIdBt ); + FeatureManager::UnInitializeLib(); + if( !btSupported ) + { + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t ConstructL: BT not supported!!" ) ) ) + User::Leave( KErrNotSupported ); + } + if( iObserver ) + { + iSettingsWatcher = CBTEngSettingsNotify::NewL( iObserver ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngSettings* CBTEngSettings::NewL( MBTEngSettingsObserver* aObserver ) + { + CBTEngSettings* self = CBTEngSettings::NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +EXPORT_C CBTEngSettings* CBTEngSettings::NewLC( MBTEngSettingsObserver* aObserver ) + { + CBTEngSettings* self = new( ELeave ) CBTEngSettings( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSettings::~CBTEngSettings() + { + TRACE_FUNC_ENTRY + delete iSettingsWatcher; + } + + +// --------------------------------------------------------------------------- +// Gets the current BT hardware power state +// (on or off) from central repository. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::GetPowerState( TBTPowerStateValue& aState ) + { + TRACE_FUNC_ENTRY + aState = EBTPowerOff; + TRAPD( err, GetCenRepKeyL( KCRUidBluetoothPowerState, KBTPowerState, + (TInt&) aState, EBTPowerOff, EBTPowerOn ) ); + return err; + } + + +// --------------------------------------------------------------------------- +// Sets the Bluetooth hardware power state. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::SetPowerState( TBTPowerStateValue aState ) + { + TRACE_FUNC_ENTRY + if( aState != EBTPowerOff && aState != EBTPowerOn ) + { + return KErrArgument; + } + RBTEng bteng; + TInt err = bteng.Connect(); + if( !err ) + { + err = bteng.SetPowerState( aState, EFalse ); + bteng.Close(); + } + TRACE_FUNC_EXIT + return err; + } + + +// --------------------------------------------------------------------------- +// Gets the current Bluetooth hardware visibility mode +// (visible or hidden) from central repository. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::GetVisibilityMode( TBTVisibilityMode& aMode ) + { + TRACE_FUNC_ENTRY + aMode = EBTVisibilityModeGeneral; + TRAPD( err, GetCenRepKeyL( KCRUidBTEngPrivateSettings, KBTDiscoverable, + (TInt&) aMode, EBTVisibilityModeHidden, + EBTVisibilityModeGeneral, + EBTVisibilityModeTemporary, + EBTVisibilityModeTemporary ) ); + return err; + } + + +// --------------------------------------------------------------------------- +// Sets the Bluetooth hardware visibility mode. The visible mode can also +// be temporary visible, specified by the aTime parameter (time in seconds). +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::SetVisibilityMode( TBTVisibilityMode aMode, TInt aTime ) + { + TRACE_FUNC_ENTRY + if( aMode != EBTVisibilityModeHidden && aMode != EBTVisibilityModeGeneral && + aMode != EBTVisibilityModeTemporary ) + { + return KErrArgument; + } + RBTEng bteng; + TInt err = bteng.Connect(); + if( !err ) + { + err = bteng.SetVisibilityMode( aMode, aTime ); + bteng.Close(); + } + + TRACE_FUNC_EXIT + return err; + } + + +// --------------------------------------------------------------------------- +// Gets the Bluetooth friendly name the Bluetooth stack. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::GetLocalName( TDes& aName ) + { + TRACE_FUNC_ENTRY + aName.Zero(); + TBool nameStatus = EFalse; + TBuf tmpName; + + TInt err = GetLocalNameModified( nameStatus ); + + if( err || nameStatus == EBTLocalNameDefault ) + { + return err; + } + + err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetDeviceName, aName ); + if( !err ) + { + err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetDeviceName, tmpName ); + if ( tmpName.Compare( aName ) ) + { + // The name has not yet been updated. Use the new one. + aName.Copy( tmpName ); + } + } + + if( err || !aName.Length() ) + { + // An error occured, try still registry + aName.Zero(); + err = HandleBTRegistryNameSetting( const_cast( aName ) ); + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t registry set result: %d"), err) ); + } + + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t GetLocalName - result %d, name: %S" ), + err, &aName ) ) + return err; + } + +// --------------------------------------------------------------------------- +// Sets the Bluetooth friendly name. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::SetLocalName( const TDes& aName ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_ARG( ( _L( "aName lenght: %d" ), aName.Length() ) ) + if( aName.Length() == 0 || aName.Length() > KMaxBluetoothNameLen ) + { + // Zero-length name means that the name has not been set; + // such reset should not be done through BTEngSettings. + return KErrArgument; + } + + TInt err = RProperty::Set( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetDeviceName, aName ); + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t RProperty::Set: %d"), err) ); + + // Always update the name to registry + TInt err2 = HandleBTRegistryNameSetting( const_cast( aName ) ); + + TBool nameChanged = EFalse; + if( !err || !err2 ) + { + // Check if this is the first time name setting. + err = GetLocalNameModified( nameChanged ); + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t GetLocalNameModified: err %d, namechanged %d"), + err, nameChanged) ); + } + + if( ( !err || !err2 ) && nameChanged == EBTLocalNameDefault ) + { + // Set the name as changed. + CRepository* cenRep = NULL; + TRAP( err, cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ) ); + if( !err ) + { + err = cenRep->Set( KBTLocalNameChanged, EBTLocalNameSet ); + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t cenRep->Set( KBTLocalNameChanged, EBTLocalNameSet ): %d"), err) ); + } + delete cenRep; + } + + TRACE_FUNC_RES( ( _L( "result %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// Sets the Bluetooth hardware power state for temporary connections. +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::ChangePowerStateTemporarily() + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + if( !iSettingsWatcher ) + { + TRAP( err, iSettingsWatcher = CBTEngSettingsNotify::NewL( NULL ) ); + } + if( !err ) + { + err = iSettingsWatcher->TogglePowerTemporarily(); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Get the Bluetooth offline mode settings +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CBTEngSettings::GetOfflineModeSettings( + TCoreAppUIsNetworkConnectionAllowed& aOffline, + TBTEnabledInOfflineMode& aOfflineAllowed ) + { + TRACE_FUNC_ENTRY + aOffline = ECoreAppUIsNetworkConnectionAllowed; + aOfflineAllowed = EBTEnabledInOfflineMode; + TRAPD( err, GetCenRepKeyL( KCRUidCoreApplicationUIs, + KCoreAppUIsNetworkConnectionAllowed, (TInt&) aOffline, + ECoreAppUIsNetworkConnectionNotAllowed, + ECoreAppUIsNetworkConnectionAllowed ) ); + if( !err && aOffline == ECoreAppUIsNetworkConnectionNotAllowed ) + { + TRAP( err, GetCenRepKeyL( KCRUidBluetoothEngine, KBTEnabledInOffline, + (TInt&) aOfflineAllowed, EBTDisabledInOfflineMode, + EBTEnabledInOfflineMode ) ); + } + return err; + } + + +// --------------------------------------------------------------------------- +// Checks from central repository whether the Bluetooth friendly name +// has been modified . +// --------------------------------------------------------------------------- +// +TInt CBTEngSettings::GetLocalNameModified( TBool& aStatus ) + { + TRACE_FUNC_ENTRY + + aStatus = (TBool) EBTLocalNameDefault; + TRAPD( err, GetCenRepKeyL( KCRUidBTEngPrivateSettings, KBTLocalNameChanged, + (TInt&) aStatus, EBTLocalNameDefault, + EBTLocalNameSet ) ); + return err; + } + + +// --------------------------------------------------------------------------- +// Gets the specified CenRep key and checks if it is within a valid range; +// if not, it it reset to the default value. +// --------------------------------------------------------------------------- +// +void CBTEngSettings::GetCenRepKeyL( const TUid aUid, const TInt aKey, TInt& aValue, + const TInt aMinRange1, const TInt aMaxRange1, + const TInt aMinRange2, const TInt aMaxRange2 ) + { + TRACE_FUNC_ARG( ( _L( "aKey: %d" ), aKey ) ) +// [SvV] Test that both logging macro do the same: + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t GetCenRepKeyL - start (aKey: %d)" ), aKey ) ) + TInt val = aValue; + + CRepository* cenRep = CRepository::NewL( aUid ); + TInt err = cenRep->Get( aKey, val ); + // Check that the value is within the allowed ranges. + TBool validRange = ETrue; + if( val < aMinRange1 || val > aMaxRange1 ) + { + // The value is not within the first range + if( !aMinRange2 && !aMaxRange2 ) + { + // No second range is specified, so the value is out-of-range. + validRange = EFalse; + } + else if( !( val >= aMinRange2 && val <= aMaxRange2 ) ) + { + // The value is not within the second range either, + // so the value is out-of-range. + validRange = EFalse; + } + } + if( err || !validRange ) + { + TRACE_INFO( ( _L( "Error occured! err(%d) val(%d), range %d-%d (2nd: %d-%d)" ), + err, val, aMinRange1, aMaxRange1, aMinRange2, aMaxRange2 ) ) + // If an error occured, we cannot trust the central repository, + // so return to default value to be safe. + val = aValue; // Revert to the original value + (void) cenRep->Set( aKey, val ); // Just try once, ignore return value + } + delete cenRep; + aValue = val; + + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t GetCenRepKeyL - key value: %d; err: %d" ), + val, err ) ) + TRACE_FUNC_RES( ( _L( "key value: %d; err: %d" ), val, err ) ) + User::LeaveIfError( err ); + } + + +// --------------------------------------------------------------------------- +// Gets or sets the BT local name from Bluetooth Registry. +// --------------------------------------------------------------------------- +// +TInt CBTEngSettings::HandleBTRegistryNameSetting( TDes& aName ) + { + TRACE_FUNC_ENTRY + RBTRegServ btRegServ; + RBTLocalDevice btReg; + TInt err = btRegServ.Connect(); + if( !err ) + { + err = btReg.Open( btRegServ ); + } + TBTLocalDevice localDev; + if( !err ) + { + // Read the BT local name from BT Registry. + err = btReg.Get( localDev ); + } + + if( !err ) + { + // BT registry keeps the device name in UTF-8 format. + TBuf8 utf8Name; + if( aName.Length() == 0 ) + { + // The error can be > 0 if there are unconverted characters. + err = CnvUtfConverter::ConvertToUnicodeFromUtf8( aName, + localDev.DeviceName() ); + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t getting name from registry: err %d %S" ), + err, &aName)) + } + else + { + // Write the supplied name to BT Registry. + // The error can be > 0 if there are unconverted characters. + err = CnvUtfConverter::ConvertFromUnicodeToUtf8( utf8Name, aName ); + if( !err ) + { + localDev.SetDeviceName( utf8Name ); + err = btReg.Modify( localDev ); + } + TRACE_INFO( ( _L( "[BTENGSETTINGS]\t setting name to registry:err %d, %S" ), + err, &aName)) + } + } + + btReg.Close(); + btRegServ.Close(); + TRACE_FUNC_EXIT + + return err; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btengsettings/src/btengsettingsnotify.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btengsettings/src/btengsettingsnotify.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,217 @@ +/* +* Copyright (c) 2006 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: ?Description +* +*/ + + + +#include +#include + +#include "btengprivatecrkeys.h" +#include "btengsettingsnotify.h" +#include "btengsettings.h" +#include "debug.h" + +const TInt KPowerKeyReqId = 20; +const TInt KVisibilityKeyReqId = 21; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSettingsNotify::CBTEngSettingsNotify( MBTEngSettingsObserver* aObserver ) +: iObserver( aObserver ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSettingsNotify::ConstructL() + { + TRACE_FUNC_ENTRY + if( iObserver ) + { + // Power status: + iPowerKeyWatcher = CBTEngActive::NewL( *this, KPowerKeyReqId, + CActive::EPriorityStandard ); + iPowerKeyCenRep = CRepository::NewL( KCRUidBluetoothPowerState ); + iPowerKeyCenRep->NotifyRequest( KBTPowerState, + iPowerKeyWatcher->RequestStatus() ); + iPowerKeyWatcher->GoActive(); + // Visibility mode: + iVisiKeyWatcher = CBTEngActive::NewL( *this, KVisibilityKeyReqId, + CActive::EPriorityStandard ); + iVisiKeyCenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + iVisiKeyCenRep->NotifyRequest( KBTDiscoverable, + iVisiKeyWatcher->RequestStatus() ); + iVisiKeyWatcher->GoActive(); + } + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSettingsNotify* CBTEngSettingsNotify::NewL( MBTEngSettingsObserver* aObserver ) + { + CBTEngSettingsNotify* self = new( ELeave ) CBTEngSettingsNotify( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSettingsNotify::~CBTEngSettingsNotify() + { + if ( iPowerKeyCenRep ) + { + iPowerKeyCenRep->NotifyCancel( KBTPowerState ); + } + delete iPowerKeyWatcher; // Will call Cancel() + delete iPowerKeyCenRep; + if ( iVisiKeyCenRep ) + { + iVisiKeyCenRep->NotifyCancel( KBTDiscoverable ); + } + delete iVisiKeyWatcher; // Will call Cancel() + delete iVisiKeyCenRep; + if( iBTeng.Handle() ) + { + iBTeng.Close(); + } + } + + +// --------------------------------------------------------------------------- +// Toggles Bluetooth power based on the existence of a session. +// --------------------------------------------------------------------------- +// +TInt CBTEngSettingsNotify::TogglePowerTemporarily() + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + if( !iBTeng.Handle() ) + { + err = iBTeng.Connect(); + if( !err ) + { + err = iBTeng.SetPowerState( EBTPowerOn, ETrue ); + } + } + else + { + iBTeng.Close(); + } + return err; + } + + +// --------------------------------------------------------------------------- +// From class MBTEngCenRepNotify. +// Handles notification of a setting change, and informs our observer. +// --------------------------------------------------------------------------- +// +void CBTEngSettingsNotify::RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "Id(%d), status(%d)" ), aId, aStatus ) ) + + if( aId == KPowerKeyReqId && aStatus == KBTPowerState ) + { + iPowerKeyCenRep->NotifyRequest( KBTPowerState, + iPowerKeyWatcher->RequestStatus() ); + iPowerKeyWatcher->GoActive(); + TInt value = 0; + TInt err = iPowerKeyCenRep->Get( KBTPowerState, value ); + if( !err ) + { + iObserver->PowerStateChanged( (TBTPowerStateValue) value ); + } + } + else if( aId == KVisibilityKeyReqId && aStatus == KBTDiscoverable ) + { + iVisiKeyCenRep->NotifyRequest( KBTDiscoverable, + iVisiKeyWatcher->RequestStatus() ); + iVisiKeyWatcher->GoActive(); + TInt value = 0; + TInt err = iVisiKeyCenRep->Get( KBTDiscoverable, value ); + if( !err ) + { + iObserver->VisibilityModeChanged( (TBTVisibilityMode) value ); + } + } + else + { + // Coudl be a repository-wide reset (KInvalidNotificationId), + // or an invalid key ID. Anyway we know the ID of the active + // object, so we can just reset the watcher. + HandleError( aActive, aId, aStatus ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngCenRepNotify. +// Handles error situation by just re-ordering notification from CenRep. +// --------------------------------------------------------------------------- +// +void CBTEngSettingsNotify::HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "Id(%d), status(%d)" ), aId, aError ) ) + (void) aError; + if( aId == KPowerKeyReqId ) + { + delete iPowerKeyCenRep; + iPowerKeyCenRep = NULL; + TRAPD( err, iPowerKeyCenRep = + CRepository::NewL( KCRUidBluetoothPowerState ) ); + if( !err ) + { + iPowerKeyCenRep->NotifyRequest( KBTPowerState, + aActive->RequestStatus() ); + aActive->GoActive(); + } + } + else if( aId == KVisibilityKeyReqId ) + { + delete iVisiKeyCenRep; + iVisiKeyCenRep = NULL; + TRAPD( err, iVisiKeyCenRep = + CRepository::NewL( KCRUidBTEngPrivateSettings ) ); + if( !err ) + { + iVisiKeyCenRep->NotifyRequest( KBTDiscoverable, + aActive->RequestStatus() ); + aActive->GoActive(); + } + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btfeatures/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btfeatures/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 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 + +PRJ_MMPFILES +btfeatures.mmp diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btfeatures/btfeatures.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btfeatures/btfeatures.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 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 + +/** + Device supports bluetooth data profiles disabled. +*/ +const TInt KFeatureIdTempFfBluetoothDataProfilesDisabled = 0x1000001; + +/** + Device supports bluetooth disabled. +*/ +const TInt KFeatureIdTempFfBluetoothDisabled = 0x1000002; + + +EXPORT_C void BluetoothFeatures::SetEnterpriseEnablementL(BluetoothFeatures::TEnterpriseEnablementMode aMode) + { + // This method is only provided for use by the Bluetooth DCMO plugin. + // Hence we should be running in the DCMO server process. + _LIT_SECURE_ID(KDcmoServerSecureUid, 0x2001FE47); + RProcess proc; + if ( proc.SecureId() != KDcmoServerSecureUid ) + { + User::Leave(KErrPermissionDenied); + } + + const TUid KBtDisabledUid = {KFeatureIdTempFfBluetoothDisabled}; + const TUid KBtDataProfilesDisabledUid = {KFeatureIdTempFfBluetoothDataProfilesDisabled}; + + RFeatureControl featureControl; + User::LeaveIfError(featureControl.Connect()); + CleanupClosePushL(featureControl); + switch ( aMode ) + { + case EDisabled: + User::LeaveIfError(featureControl.EnableFeature(KBtDisabledUid)); + User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid)); + break; + case EDataProfilesDisabled: + User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid)); + User::LeaveIfError(featureControl.EnableFeature(KBtDataProfilesDisabledUid)); + break; + case EEnabled: + User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid)); + User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid)); + break; + default: + User::Leave(KErrArgument); + break; + } + CleanupStack::PopAndDestroy(&featureControl); + } + +EXPORT_C BluetoothFeatures::TEnterpriseEnablementMode BluetoothFeatures::EnterpriseEnablementL() + { + TEnterpriseEnablementMode mode = EDisabled; + + FeatureManager::InitializeLibL(); + const TBool bluetoothDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDisabled); + if ( !bluetoothDisabled ) + { + const TBool dataProfilesDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDataProfilesDisabled); + if ( dataProfilesDisabled ) + { + mode = EDataProfilesDisabled; + } + else + { + mode = EEnabled; + } + } + FeatureManager::UnInitializeLib(); + + return mode; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btfeatures/btfeatures.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btfeatures/btfeatures.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 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 + +TARGET btfeatures.dll +TARGETTYPE dll +UID 0x1000008d 0x20029f17 + +CAPABILITY CAP_CLIENT_DLL +VENDORID VID_DEFAULT + +SOURCEPATH . +SOURCE btfeatures.cpp + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY featmgr.lib + +deffile ~/btfeatures.def diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btfeatures/bwins/btfeaturesu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btfeatures/bwins/btfeaturesu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,4 @@ +EXPORTS + ?SetEnterpriseEnablementL@BluetoothFeatures@@YAXW4TEnterpriseEnablementMode@1@@Z @ 1 NONAME ; void BluetoothFeatures::SetEnterpriseEnablementL(enum BluetoothFeatures::TEnterpriseEnablementMode) + ?EnterpriseEnablementL@BluetoothFeatures@@YA?AW4TEnterpriseEnablementMode@1@XZ @ 2 NONAME ; enum BluetoothFeatures::TEnterpriseEnablementMode BluetoothFeatures::EnterpriseEnablementL(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btfeatures/eabi/btfeaturesu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btfeatures/eabi/btfeaturesu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,4 @@ +EXPORTS + _ZN17BluetoothFeatures21EnterpriseEnablementLEv @ 1 NONAME + _ZN17BluetoothFeatures24SetEnterpriseEnablementLENS_25TEnterpriseEnablementModeE @ 2 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btpsmplugin/inc/btengpsmplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btpsmplugin/inc/btengpsmplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2007 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: Handle BT power state related to PSM mode +* +*/ + + +#ifndef BTPSMPLUGIN_H +#define BTPSMPLUGIN_H + +#include +#include + + +/** + * Plug-in of PowerSaveMode (PSM) + * implements PSM plug-in and setting configuration API, + * handles BT power state when entering and leaving PSM mode. + * + * @since S60 v5.1 + */ +class CBTPsmPlugin : public CPsmPluginBase, + public MBTEngSettingsObserver + { + public: + + /** + * Two-phased constructor. + * + * @param aInitParams Passed by the caller. + */ + static CBTPsmPlugin* NewL(TPsmPluginCTorParams& aInitParams); + + /** + * Destructor. + */ + virtual ~CBTPsmPlugin(); + + /** + * From CPsmPluginBase + * + * Notifies plugin about the power save mode change. There is only one + * active plugin at a time in psmserver, meaning that when this plugin has done + * its mode change, next plugin has process time to complete its mode change. + * Because of this it is good not to make any heavy process during this mode change. + * + * @since S60 v5.1 + * @param aMode Mode to change to. + */ + void NotifyModeChange( const TInt aMode ); + + /** + * From MBTEngSettingsObserver + * When BT PowerState is changed in PSM mode, write it into PSM data storage. + * + * @since S60 v5.1 + * @param aState EBTPowerOff if the BT hardware has been turned off, + * EBTPowerOn if it has been turned off. + */ + void PowerStateChanged( TBTPowerStateValue aState ); + + /** + * From MBTEngSettingsObserver + * Power Saving Mode change does not affect Bluetooth visibility. + * + * @since S60 v5.1 + * @param aState EBTDiscModeHidden if the BT hardware is in hidden mode, + * EBTDiscModeGeneral if it is in visible mode. + */ + void VisibilityModeChanged( TBTVisibilityMode /*aState*/ ); + + private: + + /** + * Default C++ constructor + * + * @param aInitParams Passed by the caller. + */ + CBTPsmPlugin(TPsmPluginCTorParams& aInitParams); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v5.1 + */ + void ConstructL(); + + /** + * Leave function called by NotifyModeChange(). + * + * @since S60 v5.1 + */ + void NotifyModeChangeL(); + + /** + * Handle whether and how to update the current BT Power state + * + * @since S60 v5.1 + */ + void HandlePowerStateL(); + + /** + * Get setting from PSM configuration file + * + * @since S60 v5.1 + * @return TBTPowerStateValue The power state stored in PSM configuration storage. + */ + TBTPowerStateValue GetSettingsFromPsmStorageL(); + + /** + * Save configuration into PSM storage. Backup the setting before entering PSM + * or update the setting when the user changes BT PowerState in PSM mode + * + * @param aState The current BT power state. + */ + void SavePsmConfigurationL(TBTPowerStateValue aState); + + private: // data + + /** + * BTEng Settings class + * Owned + */ + CBTEngSettings* iBtEngSettings; + + /** + * TPsmsrvMode type defination in psmtypes.h + */ + TInt iMode; + + /** + * Flag if allow the change of power state to be written into PSM storage. + * EFalse is the default value, when EBTPowerOn before PSM is activated. + * ETrue when EBTPowerOff or active connections before PSM is activated, + * or when PowerON becomes OFF after PSM is activated. + */ + TBool iAllowToConfig; + }; + +#endif // BTPSMPLUGIN_H \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btpsmplugin/src/btpsmplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btpsmplugin/src/btpsmplugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,259 @@ +/* +* Copyright (c) 2006-2007 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: Implement PSM plug-in and handle BT PowerState with PSM mode +* +*/ + + +#include +#include +#include +#include + +#include "btengpsmplugin.h" +#include "debug.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CBTPsmPlugin::NewL +// Two phased constructor +// --------------------------------------------------------------------------- +// +CBTPsmPlugin* CBTPsmPlugin::NewL(TPsmPluginCTorParams& aInitParams) + { + CBTPsmPlugin* self = new (ELeave) CBTPsmPlugin(aInitParams); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CBTPsmPlugin::~CBTPsmPlugin +// Destructor +// --------------------------------------------------------------------------- +// +CBTPsmPlugin::~CBTPsmPlugin() + { + TRACE_FUNC_ENTRY + + delete iBtEngSettings; + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class CPSMBase +// CBTPsmPlugin::NotifyModeChange() +// Handle BT power state when PowerSaveMode enables/disables. +// --------------------------------------------------------------------------- +// +void CBTPsmPlugin::NotifyModeChange( const TInt aMode ) + { + iMode = aMode; + TRAP_IGNORE(NotifyModeChangeL()); + } + +// --------------------------------------------------------------------------- +// From class MBTEngSettingsObserver +// CBTPsmPlugin::PowerStateChanged() +// Save the changed power state into PSM storage as settings in Normal mode +// if the change was caused by the user. +// --------------------------------------------------------------------------- +// +void CBTPsmPlugin::PowerStateChanged( TBTPowerStateValue aState ) + { + TRACE_FUNC_ENTRY + + if( iMode == EPsmsrvModePowerSave && iAllowToConfig) + { + TRAP_IGNORE( SavePsmConfigurationL( aState ) ); + } + + if( !iAllowToConfig ) + { + iAllowToConfig = ETrue; + } + + TRACE_FUNC_EXIT + }; + +// --------------------------------------------------------------------------- +// From class MBTEngSettingsObserver +// CBTPsmPlugin::VisibilityModeChanged() +// Power Saving Mode change does not affect Bluetooth visibility. +// --------------------------------------------------------------------------- +// +void CBTPsmPlugin::VisibilityModeChanged( TBTVisibilityMode /*aState*/ ) + { + } + +// --------------------------------------------------------- +// CBTPsmPlugin::CBTPsmPlugin +// Default C++ constructor +// --------------------------------------------------------- +CBTPsmPlugin::CBTPsmPlugin( TPsmPluginCTorParams& aInitParams ) + : CPsmPluginBase( aInitParams ), iMode( KErrNotFound ), iAllowToConfig( EFalse ) + { + } + +// --------------------------------------------------------- +// CBTPsmPlugin::ConstructL +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------- +// +void CBTPsmPlugin::ConstructL() + { + TRACE_FUNC_ENTRY + + iBtEngSettings = CBTEngSettings::NewL(this); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CBTPsmPlugin::NotifyModeChangeL() +// Leave function called by NotifyModeChange() +// Handle BT power state when PowerSaveMode enables/disables. +// --------------------------------------------------------------------------- +// +void CBTPsmPlugin::NotifyModeChangeL() + { + TRACE_FUNC_ENTRY + TInt connNum = 0; + TInt retVal = RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetPHYCount, connNum); + TRACE_INFO((_L("[BTPsmPlugin]\t GetPHYCount result: %d"), retVal)); + + if( iMode == EPsmsrvModePowerSave ) + { + if( !retVal ) + { + TRACE_INFO((_L("[BTPsmPlugin]\t PHYCount=: %d"), connNum)); + + if( connNum > 0 ) // active connection exists + { + iAllowToConfig = ETrue; + } + else //no active connections + { + HandlePowerStateL(); + } + } + } + + if( iMode == EPsmsrvModeNormal ) + { + if( !retVal && connNum == 0 ) // active connection exists + { + HandlePowerStateL(); + } + iAllowToConfig = EFalse; + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CBTPsmPlugin::HandlePowerStateL() +// Handle how to change BT power state +// --------------------------------------------------------------------------- +// +void CBTPsmPlugin::HandlePowerStateL() + { + TRACE_FUNC_ENTRY + + TBTPowerStateValue powerBeforeChange; + iBtEngSettings->GetPowerState( powerBeforeChange ); + if( powerBeforeChange == EBTPowerOff ) + { + iAllowToConfig = ETrue; + } + + TBTPowerStateValue powerToChange = EBTPowerOff; + TRAPD(err, powerToChange = GetSettingsFromPsmStorageL() ); + TRACE_INFO((_L("[BTPsmPlugin]\t CBTPsmPlugin::GetSettingsFromPsmStorageL Leave status: %d"), err)); + // If we can't read previous BT state information from PSM configuration, + // BT Power is not toogled only if PSM is switching of. + // When switching PSM On BT should be always turned Off. + // Active connections were checked before. + if( powerBeforeChange != powerToChange && ( !err || iMode == EPsmsrvModePowerSave ) ) + { + TInt errCode = iBtEngSettings->SetPowerState( powerToChange ); + TRACE_INFO((_L("[BTPsmPlugin]\t CBTPsmPlugin::HandlePowerStateL() %d"), errCode)); + } + + if( iMode == EPsmsrvModePowerSave ) + { + SavePsmConfigurationL( powerBeforeChange ); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CBTPsmPlugin::GetSettingsFromPsmStorageL() +// Retrive power state from PSM configuration file +// --------------------------------------------------------------------------- +// +TBTPowerStateValue CBTPsmPlugin::GetSettingsFromPsmStorageL() + { + TRACE_FUNC_ENTRY + + TPsmsrvConfigInfo info; + info.iConfigId = 1; + info.iConfigType = EConfigTypeInt; + info.iIntValue = 0; + info.iBlocked = EFalse; + + RConfigInfoArray configInfoArray; + CleanupClosePushL( configInfoArray ); + + configInfoArray.AppendL( info ); + iSettingsProvider.GetSettingsL(configInfoArray, KCRUidBluetoothPowerState.iUid); + + TBTPowerStateValue power = EBTPowerOff; + if( configInfoArray.Count() > 0 ) + { + power = (TBTPowerStateValue) configInfoArray[0].iIntValue; + } + CleanupStack::PopAndDestroy( &configInfoArray ); + + TRACE_FUNC_EXIT + return power; + } + +// --------------------------------------------------------- +// CBTPsmPlugin::UpdatePsmConfiguration +// Write BTPowerState into PSM Configuration file +// --------------------------------------------------------- +// +void CBTPsmPlugin::SavePsmConfigurationL(TBTPowerStateValue aState) + { + TRACE_FUNC_ENTRY + + TPsmsrvConfigInfo infoForNormal; + infoForNormal.iConfigId = 1; + infoForNormal.iConfigType = EConfigTypeInt; + infoForNormal.iIntValue = aState; + infoForNormal.iBlocked = EFalse; + + RConfigInfoArray configInfo; + configInfo.AppendL(infoForNormal); + iSettingsProvider.BackupSettingsL( configInfo, KCRUidBluetoothPowerState.iUid ); + configInfo.Close(); + + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btpsmplugin/src/btpsmpluginimpltable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btpsmplugin/src/btpsmpluginimpltable.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2007 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: ECOM proxy table for this plugin +* +*/ + + +#include +#include + +#include "btengpsmplugin.h" + + +const TImplementationProxy KBtPsmPluginImplTable[] = + { + // UPDATE THIS - Uid for plugin implementation: + //This impl is for Power Saving Mode in EPM (Energy and Power Management). + IMPLEMENTATION_PROXY_ENTRY( 0x2000CFE6, CBTPsmPlugin::NewL ), + }; + + +// --------------------------------------------------------------------------- +// ImplementationGroupProxy +// Gate/factory function +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KBtPsmPluginImplTable) / sizeof(TImplementationProxy); + return KBtPsmPluginImplTable; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btrfsplugin/inc/btrfsplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btrfsplugin/inc/btrfsplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2008 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: +* +* +*/ + + + +#ifndef BTRFSPLUGIN_H +#define BTRFSPLUGIN_H + +// INCLUDES +#include + +#include "rfsPlugin.h" + +// CLASS DECLARATION + +class CBTRFSPlugin: public CRFSPlugin + { +public: + + /** + * Two-phased constructor. + * @param aInitParams initial parameters + */ + static CBTRFSPlugin* NewL(TAny* aInitParams); + + /** + * Destructor. + */ + virtual ~CBTRFSPlugin(); + + /** + * + * @param + */ + void RestoreFactorySettingsL( const TRfsReason aType ); + + /** + * + * @param + */ + void GetScriptL( const TRfsReason aType, TDes& aPath ); + + /** + * + * @param + */ + void ExecuteCustomCommandL( const TRfsReason aType, TDesC& aCommand ); +private: + + /** + * C++ default constructor. + */ + CBTRFSPlugin(); + + /** + * Constructor. + * @param aInitParams initial parameters + */ + CBTRFSPlugin(TAny* aInitParams); + + /** + * Constructor + */ + void ConstructL(); + }; + + + +#endif // BTRFSPLUGIN_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btrfsplugin/src/Proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btrfsplugin/src/Proxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2008 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: +* This class export ECom interface implementations. +* +*/ + + +#include +#include + +#include "btrfsplugin.h" + +// Map the interface UIDs to implementation factory functions +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x200159EA, CBTRFSPlugin::NewL) + }; + +// Exported proxy for instantiation method resolution +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/btrfsplugin/src/btrfsplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/btrfsplugin/src/btrfsplugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2008-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 FILES +#include +#include "btrfsplugin.h" +#include "debug.h" // bteng debug utility + +// LOCAL CONSTANTS +_LIT(KScriptPath, "z:\\resource\\btrfs.txt"); + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBTRFSPlugin::CBTRFSPlugin() : CRFSPlugin() + { + } + +CBTRFSPlugin::CBTRFSPlugin(TAny* /*aInitParams*/) : CRFSPlugin() + { + } + +// Destructor +CBTRFSPlugin::~CBTRFSPlugin() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// NewL +// --------------------------------------------------------- +// +CBTRFSPlugin* CBTRFSPlugin::NewL(TAny* aInitParams) + { + TRACE_FUNC_ENTRY + CBTRFSPlugin* self = new (ELeave) CBTRFSPlugin(aInitParams); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + TRACE_FUNC_EXIT + return self; + } + + +// --------------------------------------------------------- +// ConstructL +// --------------------------------------------------------- +// +void CBTRFSPlugin::ConstructL() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +void CBTRFSPlugin::RestoreFactorySettingsL( const TRfsReason /*aType*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +void CBTRFSPlugin::GetScriptL( const TRfsReason /*aType*/, TDes& aPath ) + { + TRACE_FUNC_ENTRY + aPath.Copy( KScriptPath); + TRACE_FUNC_EXIT + } + +void CBTRFSPlugin::ExecuteCustomCommandL( const TRfsReason /*aType*/, + TDesC& /*aCommand*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/bttoggle/inc/bttoggle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/bttoggle/inc/bttoggle.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,193 @@ +/* +* Copyright (c) 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: Bluetooth Toggle application meant used by Telephony for + * switching on/off Bluetooth when a long key press of asterisk + * is detected + * +*/ + + +#ifndef __BTTOGGLE_H__ +#define __BTTOGGLE_H__ + +// Include Files + +#include +#include +#include +#include + +// Function Prototypes + +GLDEF_C TInt E32Main(); + +_LIT(KBTTogglePanicCat, "BTToggle Panic"); + +/** + *TBTTogglePanic - Panics that can be raised by the BTToggle component. + */ +enum TBTTogglePanic + { + EBTToggleInvalidStateCloseConnectionQuery = 0, // A notifier could not be started for ECloseConnectionQuery as another notifier is already being waited on. + EBTToggleInvalidStatePowerModeQuery = 1, // A notifier could not be started for EPowerModeQuery as another notifier is already being waited on. + EBTToggleInvalidStateChangeBtPowerMode = 2, // A notifier could not be started by CBTToggle::ChangeBtPowerMode() as another notifier is already being waited on. + }; + +void Panic(TBTTogglePanic aPanic); + +/** + * Class used for switching BT on/off. + * + * @lib bttoggle.exe + * @since S60 5.1 + */ +NONSHARABLE_CLASS(CBTToggle): public CActive + { + public: + + /** + * Two-phase constructor + * @since S60 v5.1 + * @return Pointer to the constructed CBTToggle object. + */ + static CBTToggle* NewL(); + + /** + * Destructor + */ + ~CBTToggle(); + + /** + * Toggles Bluetooth on/off + * + * @since S60 v5.1 + * @return void + */ + void ToggleBT(); + + /** + * Checks whether phone is in offline mode. + * + * @since S60 v5.1 + * + * @return TBool - ETrue: offline mode enabled; + * EFalse: diffrent than offline + */ + TBool CheckOfflineMode(); + + /** + * Switches BT on using PowerMode notifier + * + * @since S60 v5.1 + * + * @return void + */ + void SwitchBtOnWithPowerNotif(); + + private: //From CActive + + void RunL(); + TInt RunError(TInt /*aError*/); + void DoCancel(); + + private: + + /** + * C++ default constructor + * + * @since S60 v5.1 + */ + CBTToggle(); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v5.1 + */ + void ConstructL(); + + /** + * Shows the notification if Bluetooth is switched on/off. + * + * @since S60 v5.1 + * @param aStatus The type of notification to be shown; + * ETrue - BT switched on; EFalse - BT switched off. + * + * @return void + */ + void ShowNotification(TBool aStatus); + + /** + * Switches BT on or off and shows standard notification + * + * @since S60 v5.1 + * @param TBTPowerStateValue aNewPowerMode + * + * @return TInt Symbian error code + */ + TInt ChangeBtPowerMode(TBTPowerStateValue aNewPowerMode); + + + private: //Data types + + enum TToggleActiveNotifier + { + ENoneQuery = 0, + EPowerModeQuery, + ECloseConnectionQuery, + EFakeNotif + }; + + private: //Data + /** + * + */ + CBTEngSettings* iSettings; //own + + /** + * Handle to the notifier + */ + RNotifier iNotifier; + + /** + * Result package from the notifier's asynchronous call + * (Generic Query notifier) + */ + TPckgBuf iConnQuery; + + /** + ** Result package from the notifier's asynchronous call + * (Power Mode notifier) + */ + TPckgBuf iPowerResult; + + /** + * Notifier which is currently being in use + */ + TToggleActiveNotifier iActiveNotifier; + + /** + * P&S key. Shows whether the BT has open connection + */ + RProperty iLinkCountProperty; + + /** + * Notifier's buffer holder + */ + TBTGenericQueryNotiferParamsPckg iPckgGenericQuery; + }; + + +#endif // __BTTOGGLE_H__ + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/bttoggle/src/bttoggle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,366 @@ +/* +* Copyright (c) 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: Bluetooth Toggle application is being used by Telephony for + * switching on/off Bluetooth when a long key press of asterisk + * is detected + * +*/ + + + +// Include Files +#include "bttoggle.h" +#include "btengprivatecrkeys.h" +#include "btengsrvbbconnectionmgr.h" +#include "debug.h" + +#include +#include + +void Panic(TBTTogglePanic aPanic) + { + User::Panic(KBTTogglePanicCat, aPanic); + } + +LOCAL_C void DoStartL() + { + //Create active scheduler (to run active objects) + CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); + CleanupStack::PushL (scheduler ); + CActiveScheduler::Install (scheduler ); + + CBTToggle* bttoggle = CBTToggle::NewL(); + bttoggle->ToggleBT(); + + CActiveScheduler::Start(); + + delete bttoggle; + CleanupStack::PopAndDestroy (scheduler ); + return; + } + +// Global Functions +GLDEF_C TInt E32Main() + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + + // Run application code inside TRAP harness + TRAPD(mainError, DoStartL()); + if (mainError) + { + TRACE_INFO((_L("[BTENG][BTTOGGLE]DoStartL error: %d" ), mainError)) + } + delete cleanup; + return KErrNone; + } + +// ========================================================== +// CBTToggle::CBTToggle() +// Constructor +// ========================================================== +// +CBTToggle::CBTToggle() : CActive(EPriorityStandard) + { + } + +// ========================================================== +// CBTToggle::~CBTToggle() +// Destructor +// ========================================================== +// +CBTToggle::~CBTToggle() + { + TRACE_FUNC_ENTRY + + Cancel(); + delete iSettings; + iNotifier.Close(); + iLinkCountProperty.Close(); + + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBTToggle::ConstructL +// +// ========================================================== +// +void CBTToggle::ConstructL() + { + TRACE_FUNC_ENTRY + iSettings = CBTEngSettings::NewL(NULL); + CActiveScheduler::Add(this); + iActiveNotifier = ENoneQuery; + TInt errConnect = iNotifier.Connect(); + if (errConnect) + { + TRACE_INFO((_L("[BTENG][BTTOGGLE] iNotifier connect fail: %d" ), errConnect)) + User::Leave(errConnect); + } + User::LeaveIfError( iLinkCountProperty.Attach( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount ) ); + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBTToggle::NewL +// +// ========================================================== +// +CBTToggle* CBTToggle::NewL() + { + TRACE_FUNC_ENTRY + CBTToggle* self = new ( ELeave ) CBTToggle(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + TRACE_FUNC_EXIT + return self; + } + +// ========================================================== +// CBTToggle::ToggleBT +// Toggles Bluetooth on or off and shows dialog +// (if the BT is switched for the first time after flashing) +// and notification +// ========================================================== +// +void CBTToggle::ToggleBT() + { + TRACE_FUNC_ENTRY + + TBTPowerStateValue state; + iSettings->GetPowerState(state); + + //BT off + if (EBTPowerOff == state) + { + TBool isInOffline = CheckOfflineMode(); + if (isInOffline) //Offline mode + { + TRACE_INFO((_L("[BTENG][BTTOGGLE]Offline mode") )) + SwitchBtOnWithPowerNotif(); + } + else //other than offline + { + TBuf localName; + iSettings->GetLocalName(localName); + + //There is no BT local name defined + if (0 >= localName.Length()) + { + SwitchBtOnWithPowerNotif(); + } + else //BT name already defined + { + ChangeBtPowerMode(EBTPowerOn); + } + } + } + else //BT on + { + TInt linkCount = 0; + TInt errLinkCount = iLinkCountProperty.Get( linkCount ); + TRACE_INFO((_L("[BTENG][BTTOGGLE] linkCount: %d error: %d" ), linkCount, errLinkCount)) + + //BT Connected or error obtaining link count (in the case of error, we are cautious and assume BT is connected) + if (errLinkCount || linkCount > 0) + { + TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") )) + __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateCloseConnectionQuery)); + + iActiveNotifier = ECloseConnectionQuery; + iPckgGenericQuery().iMessageType = EBTSwitchOffAnyway; + iPckgGenericQuery().iNameExists = EFalse; + iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery ); + SetActive(); + } + //No open connections + else + { + TRACE_INFO((_L("[BTENG][BTTOGGLE] No BT connections") )) + ChangeBtPowerMode(EBTPowerOff); + } + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBTToggle::CheckOfflineMode +// Checks whether current profile is Offline +// ========================================================== +// +TBool CBTToggle::CheckOfflineMode() + { + TRACE_FUNC_ENTRY + TCoreAppUIsNetworkConnectionAllowed offline = ECoreAppUIsNetworkConnectionAllowed; + TBTEnabledInOfflineMode enabledInOffline; + iSettings->GetOfflineModeSettings(offline, enabledInOffline); + TRACE_FUNC_EXIT + return !offline; + } + +// ========================================================== +// CBTToggle::SwitchBtOnWithPowerNotif +// Switches BT on using Power Mode notifier +// ========================================================== +// +void CBTToggle::SwitchBtOnWithPowerNotif() + { + TRACE_FUNC_ENTRY + __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStatePowerModeQuery)); + + iActiveNotifier = EPowerModeQuery; + // EBTNameQuery is used here as the message type, since the local device name may be modified by the user upon power-on. + iPckgGenericQuery().iMessageType = EBTNameQuery; + iNotifier.StartNotifierAndGetResponse(iStatus, KPowerModeSettingNotifierUid, iPckgGenericQuery, iPowerResult ); + SetActive(); + TRACE_FUNC_EXIT + } + + +// ========================================================== +// CBTToggle::ChangeBtPowerMode +// Change BT Power Mode using CBTEngSettings API +// and show notification +// ========================================================== +// +TInt CBTToggle::ChangeBtPowerMode(TBTPowerStateValue aNewPowerState) + { + TRACE_FUNC_ENTRY + __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateChangeBtPowerMode)); + + TRequestStatus *stat = &iStatus; + TInt errPower = iSettings->SetPowerState(aNewPowerState); + + if (KErrNone == errPower) + { + ShowNotification( static_cast(aNewPowerState) ); + } + iActiveNotifier = EFakeNotif; + iStatus = KRequestPending; + User::RequestComplete(stat, KErrNone); + SetActive(); + + TRACE_FUNC_EXIT + return errPower; + } + +// ========================================================== +// CBTToggle::ShowNotification +// Presents generic info notification about BT on (ETrue) +// and BT off (EFalse) +// ========================================================== +// +void CBTToggle::ShowNotification( TBool aStatus ) + { + TRACE_FUNC_ENTRY + TBTGenericInfoNotiferParamsPckg pckgGenericInfo; + TBuf8 result; + + //BT turned on + if (aStatus) + { + pckgGenericInfo().iMessageType = EBTSwitchedOn; + } + //BT turned off + else + { + pckgGenericInfo().iMessageType = EBTSwitchedOff; + } + + //Cancel if there is any outstanding notification + Cancel(); + + //Start new notification + iNotifier.StartNotifier(KBTGenericInfoNotifierUid, pckgGenericInfo, result); + + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBTToggle::DoCancel +// Cancel +// ========================================================== +// +void CBTToggle::DoCancel() + { + TRACE_FUNC_ENTRY + if ( EPowerModeQuery == iActiveNotifier ) + { + iNotifier.CancelNotifier(KPowerModeSettingNotifierUid); + } + else if ( ECloseConnectionQuery == iActiveNotifier ) + { + iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); + } + + // For all cancels, we must reset iActiveNotifier back to ENoneQuery + // to permit another request to be made. + iActiveNotifier = ENoneQuery; + + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBTToggle::RunL +// Inherited from CActive +// ========================================================== +// +void CBTToggle::RunL() + { + TRACE_FUNC_ENTRY + + User::LeaveIfError(iStatus.Int()); + + // For all completes, we must reset iActiveNotifier back to ENoneQuery + // to permit another request to be made. + switch (iActiveNotifier) + { + case EPowerModeQuery: + iActiveNotifier = ENoneQuery; + ShowNotification(ETrue); + CActiveScheduler::Stop(); + break; + case ECloseConnectionQuery: + iActiveNotifier = ENoneQuery; + if (iConnQuery()) //user wants to stop existing connection + { + ChangeBtPowerMode(EBTPowerOff); + } + else + { + CActiveScheduler::Stop(); + } + break; + default: //ENoneQuery or EFakeNotif + iActiveNotifier = ENoneQuery; + CActiveScheduler::Stop(); + } + + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBTToggle::RunError +// Inherited from CActive +// ========================================================== +// +TInt CBTToggle::RunError(TInt aError) + { + TRACE_INFO((_L("[BTENG][BTTOGGLE]RunL error %d"), aError )) + CActiveScheduler::Stop(); + + return aError; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/bwins/btengconnmanU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/bwins/btengconnmanU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,21 @@ +EXPORTS + ?CancelConnect@CBTEngConnMan@@QAEXABVTBTDevAddr@@@Z @ 1 NONAME ; void CBTEngConnMan::CancelConnect(class TBTDevAddr const &) + ?CancelPairDevice@CBTEngConnMan@@QAEXXZ @ 2 NONAME ; void CBTEngConnMan::CancelPairDevice(void) + ?Connect@CBTEngConnMan@@QAEHABVTBTDevAddr@@ABVTBTDeviceClass@@@Z @ 3 NONAME ; int CBTEngConnMan::Connect(class TBTDevAddr const &, class TBTDeviceClass const &) + ?Disconnect@CBTEngConnMan@@QAEHABVTBTDevAddr@@W4TBTDisconnectType@@@Z @ 4 NONAME ; int CBTEngConnMan::Disconnect(class TBTDevAddr const &, enum TBTDisconnectType) + ?GetConnectedAddresses@CBTEngConnMan@@QAEHAAV?$RArray@VTBTDevAddr@@@@@Z @ 5 NONAME ; int CBTEngConnMan::GetConnectedAddresses(class RArray &) + ?GetConnectedAddresses@CBTEngConnMan@@QAEHAAV?$RArray@VTBTDevAddr@@@@W4TBTProfile@@@Z @ 6 NONAME ; int CBTEngConnMan::GetConnectedAddresses(class RArray &, enum TBTProfile) + ?IsConnectable@CBTEngConnMan@@QAEHABVTBTDeviceClass@@AAH@Z @ 7 NONAME ; int CBTEngConnMan::IsConnectable(class TBTDeviceClass const &, int &) + ?IsConnected@CBTEngConnMan@@QAEHABVTBTDevAddr@@AAW4TBTEngConnectionStatus@@@Z @ 8 NONAME ; int CBTEngConnMan::IsConnected(class TBTDevAddr const &, enum TBTEngConnectionStatus &) + ?NewL@CBTEngConnMan@@SAPAV1@PAVMBTEngConnObserver@@@Z @ 9 NONAME ; class CBTEngConnMan * CBTEngConnMan::NewL(class MBTEngConnObserver *) + ?NewLC@CBTEngConnMan@@SAPAV1@PAVMBTEngConnObserver@@@Z @ 10 NONAME ; class CBTEngConnMan * CBTEngConnMan::NewLC(class MBTEngConnObserver *) + ?PairDevice@CBTEngConnMan@@QAEHABVTBTDevAddr@@@Z @ 11 NONAME ; int CBTEngConnMan::PairDevice(class TBTDevAddr const &) + ?PairingComplete@MBTEngConnObserver@@UAEXAAVTBTDevAddr@@H@Z @ 12 NONAME ; void MBTEngConnObserver::PairingComplete(class TBTDevAddr &, int) + ?PrepareDiscovery@CBTEngConnMan@@QAEXXZ @ 13 NONAME ; void CBTEngConnMan::PrepareDiscovery(void) + ?RemoveObserver@CBTEngConnMan@@QAEXXZ @ 14 NONAME ; void CBTEngConnMan::RemoveObserver(void) + ?SetObserver@CBTEngConnMan@@QAEHPAVMBTEngConnObserver@@@Z @ 15 NONAME ; int CBTEngConnMan::SetObserver(class MBTEngConnObserver *) + ?StartPairingObserver@CBTEngConnMan@@SAHABVTBTDevAddr@@@Z @ 16 NONAME ; int CBTEngConnMan::StartPairingObserver(class TBTDevAddr const &) + ?PairDevice@CBTEngConnMan@@QAEHABVTBTDevAddr@@VTBTDeviceClass@@@Z @ 17 NONAME ; int CBTEngConnMan::PairDevice(class TBTDevAddr const &, class TBTDeviceClass) + ?IsConnectable@CBTEngConnMan@@QAEHABVTBTDevAddr@@ABVTBTDeviceClass@@AAH@Z @ 18 NONAME ; int CBTEngConnMan::IsConnectable(class TBTDevAddr const &, class TBTDeviceClass const &, int &) + ?StopPairingObserver@CBTEngConnMan@@SAHABVTBTDevAddr@@@Z @ 19 NONAME ; int CBTEngConnMan::StopPairingObserver(class TBTDevAddr const &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/bwins/btengdevmanU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/bwins/btengdevmanU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,10 @@ +EXPORTS + ?AddDevice@CBTEngDevMan@@QAEHABVCBTDevice@@@Z @ 1 NONAME ; int CBTEngDevMan::AddDevice(class CBTDevice const &) + ?DeleteDevices@CBTEngDevMan@@QAEHABVTBTRegistrySearch@@@Z @ 2 NONAME ; int CBTEngDevMan::DeleteDevices(class TBTRegistrySearch const &) + ?GetDevices@CBTEngDevMan@@QAEHABVTBTRegistrySearch@@PAV?$CArrayPtrFlat@VCBTDevice@@@@@Z @ 3 NONAME ; int CBTEngDevMan::GetDevices(class TBTRegistrySearch const &, class CArrayPtrFlat *) + ?HandleDevManComplete@MBTEngDevManObserver@@UAEXH@Z @ 4 NONAME ; void MBTEngDevManObserver::HandleDevManComplete(int) + ?HandleGetDevicesComplete@MBTEngDevManObserver@@UAEXHPAV?$CArrayPtrFlat@VCBTDevice@@@@@Z @ 5 NONAME ; void MBTEngDevManObserver::HandleGetDevicesComplete(int, class CArrayPtrFlat *) + ?ModifyDevice@CBTEngDevMan@@QAEHABVCBTDevice@@@Z @ 6 NONAME ; int CBTEngDevMan::ModifyDevice(class CBTDevice const &) + ?NewL@CBTEngDevMan@@SAPAV1@PAVMBTEngDevManObserver@@@Z @ 7 NONAME ; class CBTEngDevMan * CBTEngDevMan::NewL(class MBTEngDevManObserver *) + ?NewLC@CBTEngDevMan@@SAPAV1@PAVMBTEngDevManObserver@@@Z @ 8 NONAME ; class CBTEngDevMan * CBTEngDevMan::NewLC(class MBTEngDevManObserver *) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/bwins/btengdiscoveryU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/bwins/btengdiscoveryU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,22 @@ +EXPORTS + ?CancelRemoteSdpQuery@CBTEngDiscovery@@QAEXXZ @ 1 NONAME ; void CBTEngDiscovery::CancelRemoteSdpQuery(void) + ?CancelSearchRemoteDevice@CBTEngDiscovery@@QAEXXZ @ 2 NONAME ; void CBTEngDiscovery::CancelSearchRemoteDevice(void) + ?DeleteSdpRecord@CBTEngDiscovery@@QAEHK@Z @ 3 NONAME ; int CBTEngDiscovery::DeleteSdpRecord(unsigned long) + ?NewL@CBTEngDiscovery@@SAPAV1@PAVMBTEngSdpResultReceiver@@@Z @ 4 NONAME ; class CBTEngDiscovery * CBTEngDiscovery::NewL(class MBTEngSdpResultReceiver *) + ?NewLC@CBTEngDiscovery@@SAPAV1@PAVMBTEngSdpResultReceiver@@@Z @ 5 NONAME ; class CBTEngDiscovery * CBTEngDiscovery::NewLC(class MBTEngSdpResultReceiver *) + ?ParseNextSdpAttrValueType@CBTEngDiscovery@@SAHAAV?$RArray@VTBTEngSdpAttrValue@@@@HAAW4TSdpElementType@@@Z @ 6 NONAME ; int CBTEngDiscovery::ParseNextSdpAttrValueType(class RArray &, int, enum TSdpElementType &) + ?ParseRfcommChannel@CBTEngDiscovery@@SAHAAV?$RArray@VTBTEngSdpAttrValue@@@@AAH@Z @ 7 NONAME ; int CBTEngDiscovery::ParseRfcommChannel(class RArray &, int &) + ?RegisterSdpRecord@CBTEngDiscovery@@QAEHABVTUUID@@IAAK@Z @ 8 NONAME ; int CBTEngDiscovery::RegisterSdpRecord(class TUUID const &, unsigned int, unsigned long &) + ?RemoteProtocolChannelQuery@CBTEngDiscovery@@QAEHABVTBTDevAddr@@ABVTUUID@@@Z @ 9 NONAME ; int CBTEngDiscovery::RemoteProtocolChannelQuery(class TBTDevAddr const &, class TUUID const &) + ?RemoteSdpQuery@CBTEngDiscovery@@QAEHABVTBTDevAddr@@ABVTUUID@@@Z @ 10 NONAME ; int CBTEngDiscovery::RemoteSdpQuery(class TBTDevAddr const &, class TUUID const &) + ?RemoteSdpQuery@CBTEngDiscovery@@QAEHABVTBTDevAddr@@ABVTUUID@@G@Z @ 11 NONAME ; int CBTEngDiscovery::RemoteSdpQuery(class TBTDevAddr const &, class TUUID const &, unsigned short) + ?RemoteSdpQuery@CBTEngDiscovery@@QAEHABVTBTDevAddr@@KG@Z @ 12 NONAME ; int CBTEngDiscovery::RemoteSdpQuery(class TBTDevAddr const &, unsigned long, unsigned short) + ?SearchRemoteDevice@CBTEngDiscovery@@QAEHPAVCBTDevice@@I@Z @ 13 NONAME ; int CBTEngDiscovery::SearchRemoteDevice(class CBTDevice *, unsigned int) + ?SetNotifier@CBTEngDiscovery@@QAEXPAVMBTEngSdpResultReceiver@@@Z @ 14 NONAME ; void CBTEngDiscovery::SetNotifier(class MBTEngSdpResultReceiver *) + ?CloseRemoteSdpConnection@CBTEngDiscovery@@QAEXXZ @ 15 NONAME ; void CBTEngDiscovery::CloseRemoteSdpConnection(void) + ?GetEirServiceUUIDs@CBTEngDiscovery@@QAEHABVTBTDevAddr@@PAV?$TPckgBuf@VTNameRecord@@@@@Z @ 16 NONAME ; int CBTEngDiscovery::GetEirServiceUUIDs(class TBTDevAddr const &, class TPckgBuf *) + ?DeviceSearchComplete@MBTEngSdpResultReceiver@@UAEXPAVCBTDevice@@PAV?$TPckgBuf@VTNameRecord@@@@H@Z @ 17 NONAME ; void MBTEngSdpResultReceiver::DeviceSearchComplete(class CBTDevice *, class TPckgBuf *, int) + ?GetEirServiceUUIDsComplete@MBTEngSdpResultReceiver@@UAEXPAV?$TPckgBuf@VTNameRecord@@@@H@Z @ 18 NONAME ; void MBTEngSdpResultReceiver::GetEirServiceUUIDsComplete(class TPckgBuf *, int) + ?SearchRemoteDevice@CBTEngDiscovery@@QAEHPAVCBTDevice@@PAV?$TPckgBuf@VTNameRecord@@@@I@Z @ 19 NONAME ; int CBTEngDiscovery::SearchRemoteDevice(class CBTDevice *, class TPckgBuf *, unsigned int) + ?CancelGetEirServiceUUIDs@CBTEngDiscovery@@QAEXXZ @ 20 NONAME ; void CBTEngDiscovery::CancelGetEirServiceUUIDs(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/bwins/btengsettingsU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/bwins/btengsettingsU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,12 @@ +EXPORTS + ?GetLocalName@CBTEngSettings@@QAEHAAVTDes16@@@Z @ 1 NONAME ; int CBTEngSettings::GetLocalName(class TDes16 &) + ?GetPowerState@CBTEngSettings@@QAEHAAW4TBTPowerStateValue@@@Z @ 2 NONAME ; int CBTEngSettings::GetPowerState(enum TBTPowerStateValue &) + ?GetVisibilityMode@CBTEngSettings@@QAEHAAW4TBTVisibilityMode@@@Z @ 3 NONAME ; int CBTEngSettings::GetVisibilityMode(enum TBTVisibilityMode &) + ?NewL@CBTEngSettings@@SAPAV1@PAVMBTEngSettingsObserver@@@Z @ 4 NONAME ; class CBTEngSettings * CBTEngSettings::NewL(class MBTEngSettingsObserver *) + ?NewLC@CBTEngSettings@@SAPAV1@PAVMBTEngSettingsObserver@@@Z @ 5 NONAME ; class CBTEngSettings * CBTEngSettings::NewLC(class MBTEngSettingsObserver *) + ?SetLocalName@CBTEngSettings@@QAEHABVTDes16@@@Z @ 6 NONAME ; int CBTEngSettings::SetLocalName(class TDes16 const &) + ?SetPowerState@CBTEngSettings@@QAEHW4TBTPowerStateValue@@@Z @ 7 NONAME ; int CBTEngSettings::SetPowerState(enum TBTPowerStateValue) + ?SetVisibilityMode@CBTEngSettings@@QAEHW4TBTVisibilityMode@@H@Z @ 8 NONAME ; int CBTEngSettings::SetVisibilityMode(enum TBTVisibilityMode, int) + ?GetOfflineModeSettings@CBTEngSettings@@QAEHAAW4TCoreAppUIsNetworkConnectionAllowed@@AAW4TBTEnabledInOfflineMode@@@Z @ 9 NONAME ; int CBTEngSettings::GetOfflineModeSettings(enum TCoreAppUIsNetworkConnectionAllowed &, enum TBTEnabledInOfflineMode &) + ?ChangePowerStateTemporarily@CBTEngSettings@@QAEHXZ @ 10 NONAME ; int CBTEngSettings::ChangePowerStateTemporarily(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/cenrep/keys_bteng.xls Binary file bluetoothengine/bteng/cenrep/keys_bteng.xls has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/conf/bteng.confml Binary file bluetoothengine/bteng/conf/bteng.confml has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/conf/bteng_10204DA9.crml Binary file bluetoothengine/bteng/conf/bteng_10204DA9.crml has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/conf/bteng_10204DAA.crml Binary file bluetoothengine/bteng/conf/bteng_10204DAA.crml has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/conf/bteng_10204DAB.crml Binary file bluetoothengine/bteng/conf/bteng_10204DAB.crml has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/conf/bteng_10204DAC.crml Binary file bluetoothengine/bteng/conf/bteng_10204DAC.crml has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/10204DA9.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/data/10204DA9.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/20002774.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/data/20002774.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2006 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: Defines the LCD Bearer Plugin implementation UID. +* +*/ + + + +#include +#include +#include "locodplugin.hrh" + +// --------------------------------------------------------------------------- +// theInfo +// ECOM registration info +// --------------------------------------------------------------------------- +// +RESOURCE REGISTRY_INFO theInfo + { + resource_format_version = RESOURCE_FORMAT_VERSION_2; + dll_uid = 0x20002774; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KLOCODBEARERINTERFACEUID; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = KFeatureIdBt; + version_no = 1; + display_name = "Locod BT Plugin"; + default_data = ""; + opaque_data = ""; + // This implementation CANNOT be overridden + // by a RAM-based plug-in. + rom_only = 1; + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/200100C4.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/data/200100C4.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2007-2008 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: Resource definitions for project BtuiPsmPlugin +* +*/ + + +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x200100C4; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x2000B189; // Interface UID for power save mode server CPsmPluginBase + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2000CFE6; //implementation UID + version_no = 1; + display_name = "PSM Plugin"; // Plugin debug name + } + + }; + + } + }; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/200159E9.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/data/200159E9.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2008-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 "ecom/registryinfo.rh" + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x200159E9; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x102073BB; + implementations = + { + // Info for BTRFSPlugin + IMPLEMENTATION_INFO + { + implementation_uid = 0x200159EA; + version_no = 1; + display_name = "BTRFSPlugin"; + default_data = "ND"; // N = Normal RFS, D = Deep RFS, I = Init RFS (FirstBoot RFS) + opaque_data = ""; + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/btengsdp.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/data/btengsdp.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,2246 @@ +/* +* Copyright (c) 2002-2006 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: SDP Service Record definitions of Bluetooth profiles. These +* are used by Bluetooth Engine to register SDP service records. +* +*/ + + + +#include "btengsdp.rh" + + +#define SERVICE_ID_DUN "0x1103" +#define SERVICE_ID_OPP "0x1105" +#define SERVICE_ID_FTP "0x1106" +#define SERVICE_ID_AUDIOSOURCE "0x110a" +#define SERVICE_ID_FAX "0x1111" +#define SERVICE_ID_HS_GW "0x1112" +#define SERVICE_ID_BIP "0x111b" +#define SERVICE_ID_HF_GW "0x111f" +#define SERVICE_ID_BPP "0x1120" +#define SERVICE_ID_SAP "0x112d" +#define SERVICE_ID_DI "0x1200" +#define SERVICE_ID_NOKIA_PC_SUITE "0x000050050000100080000002EE000001" +#define SERVICE_ID_NOKIA_SYNCML_SERVER "0x000056010000100080000002EE000001" +#define SERVICE_ID_SYNCML_CLIENT "0x000000020000100080000002EE000002" +#define SERVICE_ID_SYNCML_DM_SERVER "0x000000030000100080000002EE000002" +#define SERVICE_ID_SYNCML_DM_CLIENT "0x000000040000100080000002EE000002" + +#define SERVICE_CLASS_ID_DUN 0x1103 +#define SERVICE_CLASS_ID_OPP 0x1105 +#define SERVICE_CLASS_ID_FTP 0x1106 +#define SERVICE_CLASS_ID_HEADSET 0x1108 +#define SERVICE_CLASS_ID_A2DP 0x110D +#define SERVICE_CLASS_ID_FAX 0x1111 +#define SERVICE_CLASS_ID_HS_GW 0x1112 +#define SERVICE_CLASS_ID_IMAGING 0x111A +#define SERVICE_CLASS_ID_IMAGING_RESPONDER 0x111B +#define SERVICE_CLASS_ID_HF 0x111E +#define SERVICE_CLASS_ID_HF_GW 0x111F +#define SERVICE_CLASS_ID_DIRECT_PR_REF_OBJECTS 0x1120 +#define SERVICE_CLASS_ID_BASIC_PRINTING 0x1122 +#define SERVICE_CLASS_ID_SAP 0x112D +#define SERVICE_CLASS_ID_DI 0x1200 +#define SERVICE_CLASS_ID_GENERIC_NETWORKING 0x1201 +#define SERVICE_CLASS_ID_GENERIC_AUDIO 0x1203 +#define SERVICE_CLASS_ID_GENERIC_TELEPHONEY 0x1204 +#define SERVICE_CLASS_ID_AUDIOSOURCE 0x110A + +#define SERVICE_NAME_DUN "Dial-Up Networking" +#define SERVICE_NAME_OPP "OBEX Object Push" +#define SERVICE_NAME_FTP "OBEX File Transfer" +#define SERVICE_NAME_FAX "Fax" +#define SERVICE_NAME_HF_GW "Hands-Free Audio Gateway" +#define SERVICE_NAME_HS_GW "Headset Audio Gateway" +#define SERVICE_NAME_AUDIOSOURCE "Audio Source" +#define SERVICE_NAME_BIP "Imaging" +#define SERVICE_NAME_BPP "Basic Printing" +#define SERVICE_NAME_SAP "SIM Access" +#define SERVICE_NAME_DI "PnP Information" +#define SERVICE_NAME_NOKIA_PC_SUITE "Nokia OBEX PC Suite Services" +#define SERVICE_NAME_NOKIA_SYNCML_SERVER "Nokia SyncML Server" +#define SERVICE_NAME_SYNCML_CLIENT "SyncMLClient" +#define SERVICE_NAME_SYNCML_DM_SERVER "SyncML DM Server" +#define SERVICE_NAME_SYNCML_DM_CLIENT "SyncML DM Client" + + +// --------------------------------------------------------------------------- +// r_service_record_list +// Mapping of service class UUIDs to service record definitions +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD_LIST r_service_record_list + { + service_ids = + { + SERVICE_ID_DUN, + SERVICE_ID_OPP, + SERVICE_ID_FTP, + SERVICE_ID_FAX, + SERVICE_ID_HF_GW, + SERVICE_ID_HS_GW, + SERVICE_ID_AUDIOSOURCE, + SERVICE_ID_BIP, + SERVICE_ID_BPP, + SERVICE_ID_SAP, + SERVICE_ID_DI, + SERVICE_ID_NOKIA_PC_SUITE, + SERVICE_ID_NOKIA_SYNCML_SERVER, + SERVICE_ID_SYNCML_CLIENT, + SERVICE_ID_SYNCML_DM_SERVER, + SERVICE_ID_SYNCML_DM_CLIENT + }; + + service_records = + { + r_service_record_dun, + r_service_record_opp, + r_service_record_ftp, + r_service_record_fax, + r_service_record_hf_gw, + r_service_record_hs_gw, + r_service_record_audiosource, + r_service_record_bip, + r_service_record_bpp, + r_service_record_sap, + r_service_record_di, + r_service_record_nokia_pc_suite, + r_service_record_nokia_syncml_server, + r_service_record_syncml_client, + r_service_record_syncml_dm_server, + r_service_record_syncml_dm_client + }; + } + + +// --------------------------------------------------------------------------- +// r_service_record_dun +// Dial-up networking profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_dun + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_DUN; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_DUN; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_DUN; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_opp +// OBEX push profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_opp + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_OPP; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_OPP; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_OPP; } }; + }, + + ATTRIBUTE + { + id = ESupportedFormatsList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_BYTE { value = 0xff; } + }; + } + }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_ftp +// File Transfer Profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_ftp + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_FTP; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_FTP; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_FTP; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_fax +// Fax profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_fax + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_FAX; }, + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_GENERIC_TELEPHONEY; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 0; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_FAX; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_FAX; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_hf_gw +// Handsfree profile (Gateway role) service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_hf_gw + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_HF_GW; }, + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_GENERIC_AUDIO; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_HF; }, + ELEMENT_WORD { value = 0x0105; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_HF_GW; } }; + }, + + ATTRIBUTE + { + id = ESupportedFeatures; + element = { ELEMENT_WORD { value = 0x00ef;} }; + }, + + ATTRIBUTE + { + id = EHFNetwork; + element = { ELEMENT_BYTE { value = 0x01; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_hs_gw +// Headset profile (Gateway role) service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_hs_gw + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_HS_GW; }, + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_GENERIC_AUDIO; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_HEADSET; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_HS_GW; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_audiosource +// A2DP (Audiosource role) service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_audiosource + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_AUDIOSOURCE; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; }, + ELEMENT_WORD { value = 0x0019; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolAVDTP; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_A2DP; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_AUDIOSOURCE; } }; + }, + + ATTRIBUTE + { + id = ESupportedFeatures; + element = { ELEMENT_WORD { value = 0x0001; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_bip +// Basic Imaging Profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_bip + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_IMAGING_RESPONDER; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_IMAGING; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = ESupportedCapabilities; + element = { ELEMENT_BYTE { value = 0x01; } }; + }, + + ATTRIBUTE + { + id = ESupportedFeatures; + element = { ELEMENT_WORD { value = 0x01; } }; + }, + + ATTRIBUTE + { + id = ESupportedFunctions; + element = { ELEMENT_LONG { value = 0x03; } }; + }, + + ATTRIBUTE + { + id = ETotalImagingDataCapacity; + element = + { + ELEMENT_LONG_64 + { + long_64 = { 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_BIP; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_bpp +// Basic Printing Profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_bpp + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_DIRECT_PR_REF_OBJECTS; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_BASIC_PRINTING; }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_BPP; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_sap +// SIM Access Profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_sap + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_SAP; }, + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_GENERIC_TELEPHONEY; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 0; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_SAP; }, + ELEMENT_WORD { value = 0x0101; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_SAP; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_nokia_pc_suite +// PC Suite service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_nokia_pc_suite + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x01 + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x01 + }; + }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_NOKIA_PC_SUITE; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_nokia_syncml_server +// SyncML server service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_nokia_syncml_server + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x56, 0x01, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x01 + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x56, 0x01, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x01 + }; + }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_NOKIA_SYNCML_SERVER; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_syncml_client +// SyncML client service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_syncml_client + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x02 + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x02 + }; + }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_SYNCML_CLIENT; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_syncml_dm_server +// Device management server service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_syncml_dm_server + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x02 + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x02 + }; + }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_SYNCML_DM_SERVER; } }; + } + }; + } + +// --------------------------------------------------------------------------- +// r_service_record_syncml_dm_client +// Device management client service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_syncml_dm_client + { + attribute_list = + { + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x02 + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EServiceRecordState; + element = { ELEMENT_LONG{} }; + }, + + ATTRIBUTE + { + id = EProtocolDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocol2CAP; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolRFCOMM; }, + ELEMENT_BYTE { value = 1; } + }; + }, + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EProtocolOBEX; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EProfileDescriptorList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID_128 + { + uuid_128 = + { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x02, 0xee, 0x00, 0x00, 0x02 + }; + }, + ELEMENT_WORD { value = 0x0100; } + }; + } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_SYNCML_DM_CLIENT; } }; + } + }; + } + + +// --------------------------------------------------------------------------- +// r_service_record_di +// Device Identification profile service record +// --------------------------------------------------------------------------- +// +RESOURCE SERVICE_RECORD r_service_record_di + { + attribute_list = + { + ATTRIBUTE + { + id = ESpecificationID; + element = { ELEMENT_WORD { value = 0x0102; } }; + }, + + ATTRIBUTE + { // Product ID is assigned by the Bluetooth SIG + id = EVendorID; + // To be overwritten by product-defined value. + element = { ELEMENT_WORD { value = 0x0001; } }; + }, + + ATTRIBUTE + { // Product ID is unique for each product + // (assignments managed by the vendor). + id = EProductID; + // S60 RnD platform value, to be overwritten. + element = { ELEMENT_WORD { value = 0x001e; } }; + }, + + ATTRIBUTE + { + id = EVersion; + element = { ELEMENT_WORD { value = 0x0; } }; + }, + + ATTRIBUTE + { + id = EPrimaryRecord; + element = { ELEMENT_BOOL { value = 0x01; } }; + }, + + ATTRIBUTE + { + id = EVendorIDSource; + element = { ELEMENT_WORD { value = 0x0001; } }; + }, + + ATTRIBUTE + { + id = EServiceClassIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = SERVICE_CLASS_ID_DI; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EBrowseGroupList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_UUID { uuid = EPublicBrowseGroup; } + }; + } + }; + }, + + ATTRIBUTE + { + id = ELanguageBaseAttributeIDList; + element = + { + ELEMENT_DES + { + elements = + { + ELEMENT_WORD { value = ELangValue; }, + ELEMENT_WORD { value = ECharacterSetValue; }, + ELEMENT_WORD { value = ELangBaseIDValue; } + }; + } + }; + }, + + ATTRIBUTE + { + id = EDefaultNameOffset; + element = { ELEMENT_TEXT { text = SERVICE_NAME_DI; } }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/btrfs.txt Binary file bluetoothengine/bteng/data/btrfs.txt has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/data/bttoggle_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/data/bttoggle_reg.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2004 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 + +UID2 KUidAppRegistrationResourceFile +UID3 0x2001FD3D + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "bttoggle"; + } + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/eabi/btengconnmanu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/eabi/btengconnmanu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +EXPORTS + _ZN13CBTEngConnMan10DisconnectERK10TBTDevAddr17TBTDisconnectType @ 1 NONAME + _ZN13CBTEngConnMan10PairDeviceERK10TBTDevAddr @ 2 NONAME + _ZN13CBTEngConnMan11IsConnectedERK10TBTDevAddrR22TBTEngConnectionStatus @ 3 NONAME + _ZN13CBTEngConnMan11SetObserverEP18MBTEngConnObserver @ 4 NONAME + _ZN13CBTEngConnMan13CancelConnectERK10TBTDevAddr @ 5 NONAME + _ZN13CBTEngConnMan13IsConnectableERK14TBTDeviceClassRi @ 6 NONAME + _ZN13CBTEngConnMan16CancelPairDeviceEv @ 7 NONAME + _ZN13CBTEngConnMan20StartPairingObserverERK10TBTDevAddr @ 8 NONAME + _ZN13CBTEngConnMan21GetConnectedAddressesER6RArrayI10TBTDevAddrE @ 9 NONAME + _ZN13CBTEngConnMan21GetConnectedAddressesER6RArrayI10TBTDevAddrE10TBTProfile @ 10 NONAME + _ZN13CBTEngConnMan4NewLEP18MBTEngConnObserver @ 11 NONAME + _ZN13CBTEngConnMan5NewLCEP18MBTEngConnObserver @ 12 NONAME + _ZN13CBTEngConnMan7ConnectERK10TBTDevAddrRK14TBTDeviceClass @ 13 NONAME + _ZN18MBTEngConnObserver15PairingCompleteER10TBTDevAddri @ 14 NONAME + _ZTI13CBTEngConnMan @ 15 NONAME ; ## + _ZTI18MBTEngConnObserver @ 16 NONAME ; ## + _ZTV13CBTEngConnMan @ 17 NONAME ; ## + _ZTV18MBTEngConnObserver @ 18 NONAME ; ## + _ZN13CBTEngConnMan14RemoveObserverEv @ 19 NONAME + _ZN13CBTEngConnMan16PrepareDiscoveryEv @ 20 NONAME + _ZN13CBTEngConnMan10PairDeviceERK10TBTDevAddr14TBTDeviceClass @ 21 NONAME + _ZN13CBTEngConnMan13IsConnectableERK10TBTDevAddrRK14TBTDeviceClassRi @ 22 NONAME + _ZN13CBTEngConnMan19StopPairingObserverERK10TBTDevAddr @ 23 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/eabi/btengdevmanu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/eabi/btengdevmanu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,14 @@ +EXPORTS + _ZN12CBTEngDevMan10GetDevicesERK17TBTRegistrySearchP13CArrayPtrFlatI9CBTDeviceE @ 1 NONAME + _ZN12CBTEngDevMan12ModifyDeviceERK9CBTDevice @ 2 NONAME + _ZN12CBTEngDevMan13DeleteDevicesERK17TBTRegistrySearch @ 3 NONAME + _ZN12CBTEngDevMan4NewLEP20MBTEngDevManObserver @ 4 NONAME + _ZN12CBTEngDevMan5NewLCEP20MBTEngDevManObserver @ 5 NONAME + _ZN12CBTEngDevMan9AddDeviceERK9CBTDevice @ 6 NONAME + _ZN20MBTEngDevManObserver20HandleDevManCompleteEi @ 7 NONAME + _ZN20MBTEngDevManObserver24HandleGetDevicesCompleteEiP13CArrayPtrFlatI9CBTDeviceE @ 8 NONAME + _ZTI12CBTEngDevMan @ 9 NONAME ; ## + _ZTI20MBTEngDevManObserver @ 10 NONAME ; ## + _ZTV12CBTEngDevMan @ 11 NONAME ; ## + _ZTV20MBTEngDevManObserver @ 12 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/eabi/btengdiscoveryu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/eabi/btengdiscoveryu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +EXPORTS + _ZN15CBTEngDiscovery11SetNotifierEP23MBTEngSdpResultReceiver @ 1 NONAME + _ZN15CBTEngDiscovery14RemoteSdpQueryERK10TBTDevAddrRK5TUUID @ 2 NONAME + _ZN15CBTEngDiscovery14RemoteSdpQueryERK10TBTDevAddrRK5TUUIDt @ 3 NONAME + _ZN15CBTEngDiscovery14RemoteSdpQueryERK10TBTDevAddrmt @ 4 NONAME + _ZN15CBTEngDiscovery15DeleteSdpRecordEm @ 5 NONAME + _ZN15CBTEngDiscovery17RegisterSdpRecordERK5TUUIDjRm @ 6 NONAME + _ZN15CBTEngDiscovery18ParseRfcommChannelER6RArrayI18TBTEngSdpAttrValueERi @ 7 NONAME + _ZN15CBTEngDiscovery18SearchRemoteDeviceEP9CBTDevicej @ 8 NONAME + _ZN15CBTEngDiscovery20CancelRemoteSdpQueryEv @ 9 NONAME + _ZN15CBTEngDiscovery24CancelSearchRemoteDeviceEv @ 10 NONAME + _ZN15CBTEngDiscovery25ParseNextSdpAttrValueTypeER6RArrayI18TBTEngSdpAttrValueEiR15TSdpElementType @ 11 NONAME + _ZN15CBTEngDiscovery26RemoteProtocolChannelQueryERK10TBTDevAddrRK5TUUID @ 12 NONAME + _ZN15CBTEngDiscovery4NewLEP23MBTEngSdpResultReceiver @ 13 NONAME + _ZN15CBTEngDiscovery5NewLCEP23MBTEngSdpResultReceiver @ 14 NONAME + _ZTI15CBTEngDiscovery @ 15 NONAME ; ## + _ZTV15CBTEngDiscovery @ 16 NONAME ; ## + _ZN15CBTEngDiscovery24CloseRemoteSdpConnectionEv @ 17 NONAME + _ZN15CBTEngDiscovery18GetEirServiceUUIDsERK10TBTDevAddrP8TPckgBufI11TNameRecordE @ 18 NONAME + _ZN15CBTEngDiscovery18SearchRemoteDeviceEP9CBTDeviceP8TPckgBufI11TNameRecordEj @ 19 NONAME + _ZN15CBTEngDiscovery24CancelGetEirServiceUUIDsEv @ 20 NONAME + _ZN23MBTEngSdpResultReceiver20DeviceSearchCompleteEP9CBTDeviceP8TPckgBufI11TNameRecordEi @ 21 NONAME + _ZN23MBTEngSdpResultReceiver26GetEirServiceUUIDsCompleteEP8TPckgBufI11TNameRecordEi @ 22 NONAME + _ZTI23MBTEngSdpResultReceiver @ 23 NONAME ; ## + _ZTV23MBTEngSdpResultReceiver @ 24 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/eabi/btengsettingsu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/eabi/btengsettingsu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,14 @@ +EXPORTS + _ZN14CBTEngSettings12GetLocalNameER6TDes16 @ 1 NONAME + _ZN14CBTEngSettings12SetLocalNameERK6TDes16 @ 2 NONAME + _ZN14CBTEngSettings13GetPowerStateER18TBTPowerStateValue @ 3 NONAME + _ZN14CBTEngSettings13SetPowerStateE18TBTPowerStateValue @ 4 NONAME + _ZN14CBTEngSettings17GetVisibilityModeER17TBTVisibilityMode @ 5 NONAME + _ZN14CBTEngSettings17SetVisibilityModeE17TBTVisibilityModei @ 6 NONAME + _ZN14CBTEngSettings4NewLEP22MBTEngSettingsObserver @ 7 NONAME + _ZN14CBTEngSettings5NewLCEP22MBTEngSettingsObserver @ 8 NONAME + _ZTI14CBTEngSettings @ 9 NONAME ; ## + _ZTV14CBTEngSettings @ 10 NONAME ; ## + _ZN14CBTEngSettings22GetOfflineModeSettingsER35TCoreAppUIsNetworkConnectionAllowedR23TBTEnabledInOfflineMode @ 11 NONAME + _ZN14CBTEngSettings27ChangePowerStateTemporarilyEv @ 12 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/backup_registration.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2006 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: Build information file for project bteng +* +*/ + + +#include + +#include "../btfeatures/bld.inf" + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/btengprivatecrkeys.h |../../inc/btengprivatecrkeys.h +../inc/btengprivatepskeys.h |../../inc/btengprivatepskeys.h +../inc/btotgpairpub.inl |../../inc/btotgpairpub.inl +../inc/btengutil.h |../../inc/btengutil.h +../rom/bteng.iby CORE_MW_LAYER_IBY_EXPORT_PATH(bteng.iby) +../data/10204DA9.xml /epoc32/release/winscw/udeb/z/private/2000B187/10204DA9.xml +../data/10204DA9.xml /epoc32/release/winscw/urel/z/private/2000B187/10204DA9.xml +../data/10204DA9.xml /epoc32/data/z/private/2000B187/10204DA9.xml + +../conf/bteng.confml MW_LAYER_CONFML(bteng.confml) +../conf/bteng_10204DA9.crml MW_LAYER_CRML(bteng_10204DA9.crml) +../conf/bteng_10204DAA.crml MW_LAYER_CRML(bteng_10204DAA.crml) +../conf/bteng_10204DAB.crml MW_LAYER_CRML(bteng_10204DAB.crml) +../conf/bteng_10204DAC.crml MW_LAYER_CRML(bteng_10204DAC.crml) + + +// Backup registration file +backup_registration.xml /epoc32/data/z/private/10005950/backup_registration.xml +backup_registration.xml /epoc32/release/winscw/udeb/z/private/10005950/backup_registration.xml +backup_registration.xml /epoc32/release/winscw/urel/z/private/10005950/backup_registration.xml +../data/btrfs.txt /epoc32/data/z/resource/btrfs.txt +../data/btrfs.txt /epoc32/release/winscw/udeb/z/resource/btrfs.txt +../data/btrfs.txt /epoc32/release/winscw/urel/z/resource/btrfs.txt + + +PRJ_MMPFILES +bteng.mmp +btengconnman.mmp +btengdevman.mmp +btengdiscovery.mmp +btengsettings.mmp +btbearer.mmp +btrfsplugin.mmp +btpsmplugin.mmp +bttoggle.mmp + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btbearer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btbearer.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 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: Project definition file for project btbearer +* +*/ + + + +#include +#include + +TARGET btbearer.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x20002774 + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +SOURCEPATH ../btbearer/src +SOURCE btpluginproxy.cpp +SOURCE btpluginprovider.cpp +SOURCE btpluginnotifier.cpp + +START RESOURCE ../../data/20002774.rss +HEADER +TARGET btbearer.rsc +END // RESOURCE + +USERINCLUDE ../inc +USERINCLUDE ../btbearer/inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom +SYSTEMINCLUDE ../../../inc + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY centralrepository.lib +LIBRARY btengsettings.lib +LIBRARY btfeatures.lib +DEBUGLIBRARY flogger.lib // File logging services diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/bteng.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/bteng.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006 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: Project definition file for project BTEng +* +*/ + + + +#include +#include + +TARGET btengsrv.exe +TARGETTYPE exe +UID 0x1000008d 0x10005950 + +CAPABILITY CAP_SERVER NetworkControl PowerMgmt CommDD +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE btengserver.cpp +SOURCE btengsrvsession.cpp +SOURCE btengsrvstate.cpp +SOURCE btengsrvpluginmgr.cpp +SOURCE btengsrvbbconnectionmgr.cpp +SOURCE btengsdpdbhandler.cpp +SOURCE btengsrvkeywatcher.cpp +SOURCE btengactive.cpp +SOURCE btengpairman.cpp +SOURCE btengpairbase.cpp +SOURCE btengincpair.cpp +SOURCE btengotgpair.cpp +START RESOURCE ../data/btengsdp.rss +HEADER +TARGETPATH RESOURCE_FILES_DIR +END // RESOURCE + +USERINCLUDE ../inc +SYSTEMINCLUDE ../../inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY btmanclient.lib +LIBRARY sdpdatabase.lib +LIBRARY esock.lib +LIBRARY btdevice.lib +LIBRARY bluetooth.lib +LIBRARY centralrepository.lib +LIBRARY charconv.lib +LIBRARY bafl.lib +LIBRARY efsrv.lib +LIBRARY featmgr.lib +LIBRARY aknnotify.lib +LIBRARY btfeatures.lib + +LIBRARY btpowercontrol.lib +#ifndef __WINS__ +LIBRARY dutmode.lib +#endif //__WINS__ +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btengconnman.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btengconnman.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project definition file for project BTEngConnMan +* +*/ + + +#include +#include + +TARGET btengconnman.dll +TARGETTYPE dll +UID 0x1000008d 0x2000277C + +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +SOURCEPATH ../btengconnman/src +SOURCE btengconnman.cpp +SOURCE btengconnhandler.cpp +SOURCEPATH ../src +SOURCE btengclient.cpp +SOURCE btengactive.cpp + +USERINCLUDE ../inc +USERINCLUDE ../btengconnman/inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY btdevice.lib +LIBRARY bluetooth.lib +LIBRARY esock.lib +LIBRARY featmgr.lib +LIBRARY centralrepository.lib // Central Repository +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btengdevman.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btengdevman.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2006 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: Project definition file for project BTEngDevMan +* +*/ + + +#include +#include + +TARGET btengdevman.dll +TARGETTYPE dll +UID 0x1000008d 0x2000277D + +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +SOURCEPATH ../btengdevman/src +SOURCE btengdevman.cpp + +USERINCLUDE ../inc +USERINCLUDE ../btengdevman/inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY btmanclient.lib +LIBRARY btdevice.lib +LIBRARY featmgr.lib +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btengdiscovery.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btengdiscovery.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006 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: Project definition file for project BTEngDiscovery +* +*/ + + +#include +#include + +TARGET btengdiscovery.dll +TARGETTYPE dll +UID 0x1000008d 0x2000277E + +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +SOURCEPATH ../btengdiscovery/src +SOURCE btengdiscovery.cpp +SOURCE btengsdpquery.cpp +SOURCE btengsdpattrparser.cpp +SOURCE btengdevicesearch.cpp +SOURCEPATH ../src +SOURCE btengactive.cpp +SOURCE btengsdpdbhandler.cpp + +USERINCLUDE ../inc +USERINCLUDE ../btengdiscovery/inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY bluetooth.lib +LIBRARY btdevice.lib +LIBRARY sdpdatabase.lib +LIBRARY sdpagent.lib +LIBRARY btextnotifiers.lib +LIBRARY bafl.lib +LIBRARY efsrv.lib +LIBRARY featmgr.lib +LIBRARY esock.lib +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btengsettings.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btengsettings.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006 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: Project definition file for project BTEngSettings +* +*/ + + +#include +#include + +TARGET btengsettings.dll +TARGETTYPE dll +UID 0x1000008d 0x2000277F + +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +SOURCEPATH ../btengsettings/src +SOURCE btengsettings.cpp +SOURCE btengsettingsnotify.cpp +SOURCEPATH ../src +SOURCE btengactive.cpp +SOURCE btengclient.cpp + +USERINCLUDE ../inc +USERINCLUDE ../btengsettings/inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY btdevice.lib +LIBRARY bluetooth.lib +LIBRARY btmanclient.lib +LIBRARY centralrepository.lib +LIBRARY featmgr.lib +LIBRARY charconv.lib +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btpsmplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btpsmplugin.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2007-2008 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: Project definition file for project btpsmplugin +* This module supports Bluetooth power state handling +* for power save mode. +* +*/ + + +#include +#include +#include + + +TARGET btpsmplugin.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x200100C4// UPDATE THIS + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +SOURCEPATH ../src + + +START RESOURCE ../data/200100C4.rss +TARGET btpsmplugin.rsc +END + + + + +SYSTEMINCLUDE ../../inc //for private API headers (BluetoothEngine subsystem) +SYSTEMINCLUDE ../../../inc //for internal API headers (localconnectivity) +SYSTEMINCLUDE /epoc32/include/ecom +MW_LAYER_SYSTEMINCLUDE + + +LIBRARY btengsettings.lib // main settings view +LIBRARY euser.lib apparc.lib cone.lib // Symbian OS framework libraries +LIBRARY bluetooth.lib // Bluetooth device address handling routines +LIBRARY ecom.lib +DEBUGLIBRARY flogger.lib // File logging services + +//**** End of .mmp ***** +SOURCEPATH ../btpsmplugin/src +SOURCE btpsmplugin.cpp btpsmpluginimpltable.cpp + +USERINCLUDE ../btpsmplugin/inc ../inc diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/btrfsplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/btrfsplugin.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2008-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 + +TARGET btrfsplugin.dll + +TARGETTYPE PLUGIN + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +UID 0x10009D8D 0x200159E9 + +SOURCEPATH ../btrfsplugin/src +SOURCE btrfsplugin.cpp +SOURCE Proxy.cpp + +START RESOURCE ../../data/200159E9.rss +TARGET btrfsplugin.rsc +END + +USERINCLUDE ../inc ../btrfsplugin/inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib // Base library +LIBRARY ecom.lib // ECom library +LIBRARY hal.lib // HAL library +DEBUGLIBRARY flogger.lib \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/group/bttoggle.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/group/bttoggle.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 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: Project definition file for project ?myapp +* +*/ + + +#include +#include + +TARGET bttoggle.exe +TARGETTYPE exe +UID 0x100039CE 0x2001FD3D + +CAPABILITY CAP_APPLICATION WriteDeviceData LocalServices NetworkControl +VENDORID VID_DEFAULT + +SOURCEPATH ../bttoggle/src +SOURCE bttoggle.cpp + +START RESOURCE ../../data/bttoggle_reg.rss +TARGETPATH /private/10003a3f/apps +END + +USERINCLUDE ../bttoggle/inc +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib // Base library +LIBRARY btengsettings.lib // Bluetooth Settings +LIBRARY centralrepository.lib // CenRep +LIBRARY bluetooth.lib // Bluetooth Sockets +LIBRARY avkon.lib // AVKON + +DEBUGLIBRARY flogger.lib + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2006 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: Active object helper class. +* +*/ + + + +#ifndef BTENGACTIVE_H +#define BTENGACTIVE_H + + +#include + +class CBTEngActive; + +/** ?description */ +//const ?type ?constant_var = ?constant; + + +/** + * Class MBTEngActiveObserver + * + * Callback class for receiving a completed active object event. + * Users of CBTEngActive need to derive from this class. + * + * @lib bteng*.lib + * @since S60 v3.2 + */ +class MBTEngActiveObserver + { + +public: + + /** + * Callback to notify that an outstanding request has completed. + * + * @since S60 v3.2 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) = 0; + + /** + * Callback to notify that an error has occurred in RunL. + * + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ) = 0; + + }; + + +/** + * Class CBTEngActive + * + * ?more_complete_description + * + * @lib bteng*.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngActive ) : public CActive + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives notification + * that the request has been completed. + * @return Pointer to the constructed CBTEngActive object. + */ + static CBTEngActive* NewL( MBTEngActiveObserver& aObserver, + TInt aId, TInt aPriority ); + + /** + * Destructor + */ + virtual ~CBTEngActive(); + + /** + * Get the request ID of this active object. + * + * @since S60 v3.2 + * @return The request ID of this active object. + */ + inline TInt RequestId(); + + /** + * Set a new request ID for this active object. + * + * @since S60 v3.2 + * @param The new request ID of this active object. + */ + inline void SetRequestId( TInt aId ); + + /** + * Activate the active object. + * + * @since S60 v3.2 + */ + inline void GoActive(); + + /** + * Cancel an outstanding request. + * + * @since S60 v3.2 + */ + inline void CancelRequest(); + + /** + * Get a reference to the active object request status. + * + * @since S60 v3.2 + * @return Reference to the active object request status. + */ + TRequestStatus& RequestStatus(); + +// from base class CActive + + /** + * From CActive. + * Called by the active scheduler when the request has been cancelled. + * + * @since S60 v3.2 + */ + void DoCancel(); + + /** + * From CActive. + * Called by the active scheduler when the request has been completed. + * + * @since S60 v3.2 + */ + void RunL(); + + /** + * From CActive. + * Called by the active scheduler when an error in RunL has occurred. + * + * @since S60 v3.2 + */ + TInt RunError( TInt aError ); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives notification + * that the request has been completed. + * @param aId ID of the request (for the client to keep track of multiple + * active objects). + * @param aPriority Priority of + */ + CBTEngActive( MBTEngActiveObserver& aObserver, TInt aId, TInt aPriority ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + +private: // data + + /** + * ID of the request (used only by our client). + */ + TInt iRequestId; + + /** + * Our observer. + * Not own. + */ + MBTEngActiveObserver& iObserver; + + }; + + +#include "btengactive.inl" + + +#endif // BTENGACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengactive.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengactive.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2006 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: Active object helper class inline function definitions. +* +*/ + + + +// ----------------------------------------------------------------------------- +// Get the identifier of this instance. +// ----------------------------------------------------------------------------- +// +inline TInt CBTEngActive::RequestId() + { + return iRequestId; + } + + +// ----------------------------------------------------------------------------- +// Set the identifier of this instance. +// ----------------------------------------------------------------------------- +// +inline void CBTEngActive::SetRequestId( TInt aId ) + { + iRequestId = aId; + } + + +// ----------------------------------------------------------------------------- +// Activate the active object. +// ----------------------------------------------------------------------------- +// +inline void CBTEngActive::GoActive() + { + SetActive(); + } + + +// ----------------------------------------------------------------------------- +// Cancel an outstanding request. +// ----------------------------------------------------------------------------- +// +inline void CBTEngActive::CancelRequest() + { + Cancel(); + } + + +// ----------------------------------------------------------------------------- +// Get a reference to the active object request status. +// ----------------------------------------------------------------------------- +// +inline TRequestStatus& CBTEngActive::RequestStatus() + { + return iStatus; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengclient.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2006 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: BTEng server header definition +* +*/ + + + +#ifndef BTENGCLIENT_H +#define BTENGCLIENT_H + + +#include + +#include "btengdomaincrkeys.h" +#include "btengclientserver.h" +#include "btengconstants.h" + + +/** + * Class RBTEng + * + * ?more_complete_description + * + * @lib bteng*.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( RBTEng ) : public RSessionBase + { + +public: + + /** + * Constructor. + * + * @since S60 v3.2 + */ + RBTEng(); + + /** + * ?description + * + * @since S60 v3.2 + */ + TInt Connect(); + + /** + * Get the version information about the client. + * + * @since S60 v3.2 + * @return ?description + */ + TVersion Version(); + + /** + * Set Bluetooth power state. + * + * @since S60 v3.2 + * @param aState The new power state. + * @param aTemp Turn BT off after use (ETrue) or not (EFalse). + * @return ?description + */ + TInt SetPowerState( const TBTPowerStateValue aState, const TBool aTemp ); + + /** + * Set Bluetooth power state. + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @return ?description + */ + TInt SetVisibilityMode( const TBTVisibilityMode aMode, const TInt aTime ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @return ?description + */ + TInt ConnectDevice( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @return ?description + */ + TInt CancelConnectDevice( const TBTDevAddr& aAddr ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @return ?description + */ + TInt DisconnectDevice( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @param ?arg2 ?description + * @return ?description + */ + TInt IsDeviceConnected( const TBTDevAddr& aAddr, + TBTEngConnectionStatus& aConnected ); + + /** + * ?description + * + * @since S60 v5.1 + * @param aAddr ?description + * @param ?arg2 ?description + * @return ?description + */ + TInt IsDeviceConnectable( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aAddr ?description + * @return ?description + */ + TInt GetConnectedAddresses( TDes8& aArrayPkg, TBTEngParamPkg& aProfilePkg ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aEvent ?description + * @return ?description + */ + TInt NotifyConnectionEvents( TDes8& aEvent, TRequestStatus& aStatus ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aEvent ?description + * @return ?description + */ + TInt CancelNotifyConnectionEvents(); + + /** + * Set a pairing observer in BTEngine. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device that is being paired. + * @param aActivate If ETrue, the observer will be activated, otherwise + * the observer will be removed. + * @return KErrNone on success, otherwise a system-wide error code. + */ + TInt SetPairingObserver( const TBTDevAddr& aAddr, TBool aActivate ); + + /** + * ?description + * + * @since S60 v3.2 + * @return ?description + */ + TInt PrepareDiscovery(); + + /** + * Pair a device. + * @param aAddr The address of the remote device to be paired. + * @param aDeviceClass the CoD of the device to be paired. + * @param aStatus contains the pair result at request completion. + */ + void PairDevice( const TBTDevAddrPckgBuf& aAddr, + const TUint32& aDeviceClass, + TRequestStatus& aStatus ); + + /** + * Cancels an outstanding pair request + */ + void CancelPairDevice(); + + }; + + +#endif // BTENGCLIENT_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengclientserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengclientserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2006 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: Definitions for BTEng client-server interface. +* +*/ + + + +#ifndef BTENGCLIENTSERVER_H +#define BTENGCLIENTSERVER_H + +#include +#include +#include "btengconstants.h" + +/** BTEngServer process name */ +_LIT( KBTEngServerName, "btengsrv" );// Temp "bteng" ); + +/** BTEng Uid3 for creating the server process */ +const TUid KBTEngServerUid3 = { 0x10005950 }; + +/** + * BTEngServer version numbers; + * Major version number is 2 to distinguish from old BTServer architecture. + */ +const TInt KBTEngServerVersionMajor = 2; +const TInt KBTEngServerVersionMinor = 0; +const TInt KBTEngServerVersionBuild = 0; + +/** + * Opcodes used in the client-server interface + * for identifying the requested function. + */ +enum TBTEngServerRequest + { + EBTEngSetPowerState= 0x21, // 33 + EBTEngSetVisibilityMode, // 34 + EBTEngConnectDevice, // 35 + EBTEngCancelConnectDevice, // 36 + EBTEngDisconnectDevice, // 37 + EBTEngIsDeviceConnected, // 38 + EBTEngIsDeviceConnectable, // 39 + EBTEngGetConnectedAddresses, // 40 + EBTEngNotifyConnectionEvents, // 41 + EBTEngCancelEventNotifier, // 42 + EBTEngPrepareDiscovery, // 43 + EBTEngSetPairingObserver, // 44 + EBTEngPairDevice, // 45 + EBTEngCancelPairDevice, // 46 + }; + +/** TBTDevAddr class size */ +const TInt KTBTDevAddrSize = 8; + +/** Maximum conflicts array size for client-server interface. */ +const TInt KBTEngMaxConflictsArraySize = 3 * KTBTDevAddrSize; + +/** + * Data structure for passing connection status events + * from server to client. + */ +struct TBTEngEventMsg + { + TBTDevAddr iAddr; + TBTEngConnectionStatus iConnEvent; + TBuf8 iConflictsBuf; + }; + + +/** Package buffer for transferring parameters between client and server. */ +typedef TPckgBuf TBTEngParamPkg; + +/** Package buffer to pass the device class between client and server. */ +typedef TPckgBuf TBTEngDevClassPkg; + +/** Package buffer for transferring the connection event message. */ +typedef TPckgBuf TBTEngEventPkg; + + +#endif // BTENGCLIENTSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengincpair.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengincpair.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2008 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: Incoming Pairing handler definition +* +*/ + + +#ifndef BTENGINCPAIR_H_ +#define BTENGINCPAIR_H_ + +#include +#include "btengpairbase.h" + +/** + * Class CBTEngIncPair + * + * Handles an incoming pairing. + * + * @since S60 S60 v5.1 + */ +NONSHARABLE_CLASS( CBTEngIncPair ) : public CBTEngPairBase + { +public: + + /** + * Two-phase constructor + * @param aParent the owner of this observer + * @param aAddr the remote device this observer is targeted to + */ + static CBTEngIncPair* NewL( CBTEngPairMan& aParent, + const TBTDevAddr& aAddr); + + /** + * Destructor + */ + ~CBTEngIncPair(); + + +private: // From CBTEngPairBase + + /** + * Start observing the result of pairing which was originated from + * the remote device. + * @param the address of the remote device to be paired + * @return KErrNone if this request is accepted; otherwise an error code + */ + TInt ObserveIncomingPair( const TBTDevAddr& aAddr ); + + /** + * Start an outgoing pairing with the remote device. + * @param the address of the remote device to be paired + * @return KErrNone if this request is accepted; otherwise an error code + */ + void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ); + + /** + * Cancels pairing handling with the specified device + * @param aAddr the address of the device the pairing is with + */ + void StopPairHandling( const TBTDevAddr& aAddr ); + + /** + * Handle a pairing result with the remote device which this is for. + * Must be specialized by subclass. + * + * @param aResult The status code of the pairing or authentication result. + */ + void DoHandlePairServerResult( TInt aResult ); + + /** + * Handles event of registry new paired event with the remote + * device this is for. + * @aType the type of authentication with the device. + */ + void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ); + +private: // from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Callback to notify that an outstanding request has completed. + * + * @since S60 v5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Callback to notify that an error has occurred in RunL. + * + * @since S60 v5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngIncPair(CBTEngPairMan& aParent, const TBTDevAddr& aAddr); + + /** + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * Start monitoring physical link events if it hasn't yet. + * + * @since S60 v5.1 + * + */ + void MonitorPhysicalLink(); + + /** + * Opens physical link adaptor with the device. + * + * @since S60 v5.1 + * @return KErrNone if the physical link exists. + * + */ + TInt OpenPhysicalLinkAdaptor(); + + /** + * Cancel all outstanding requests. + * + * @since S60 v5.1 + */ + void CancelPlaNotification(); + + /** + * Handle a physical link event. + * + * @since S60 v5.1 + * @param aResult The status code of the event. + */ + void HandlePhysicalLinkResultL( TInt aResult ); + +private: + + /** + * Package buffer for retrieving physical link events. + */ + TBTBasebandEvent iBbEvent; + + /** + * Subsession with the socket server for + * getting physical link event notifications. + */ + RBTPhysicalLinkAdapter iPla; + + /** + * iPairingOkTimer is activated if the link goes down. + * If it expires it means the pairing process has failed, + * then the error popup will be shown. + * If the pairing process ends correctly, DoHandleRegistryNewPairedEvent + * will be called and it will cancel the timer. + * iActivePairingOk is the active object associated to the timer. + */ + RTimer iPairingOkTimer; + CBTEngActive* iActivePairingOk; + }; + +#endif /*BTENGINCPAIR_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengotgpair.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengotgpair.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2006 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: Helper class for performing pairing (i.e. bonding) +* with another device. +* +*/ + +#ifndef BTENGOTGPAIR_H_ +#define BTENGOTGPAIR_H_ + +#include +#include +#include +#include "btengpairbase.h" +#include "btengprivatepskeys.h" + +/** + * Perform a outgoing pair with a BT device. + * + * @lib ?library + * @since S60 v5.1 + */ +NONSHARABLE_CLASS( CBTEngOtgPair ) : public CBTEngPairBase + { + +public: + + /** + * Two-phase constructor + * @param aParent the owner of this object + * @param aAddr the remote device this observer is targeted to + */ + static CBTEngPairBase* NewL( CBTEngPairMan& aParent, + const TBTDevAddr& aAddr ); + + /** + * Destructor + */ + ~CBTEngOtgPair(); + +private: // From CBTEngPairBase + + /** + * Start observing the result of pairing which was originated from + * the remote device. + * @param the address of the remote device to be paired + * @return KErrNone if this request is accepted; otherwise an error code + */ + TInt ObserveIncomingPair( const TBTDevAddr& aAddr ); + + /** + * Start an outgoing pairing with the remote device. + * @param the address of the remote device to be paired + * @return KErrNone if this request is accepted; otherwise an error code + */ + void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ); + + /** + * Cancel any outstanding pairing operation. + */ + void CancelOutgoingPair(); + + /** + * Cancels pairing handling with the specified device + * @param aAddr the address of the device the pairing is with + */ + void StopPairHandling( const TBTDevAddr& aAddr ); + + /** + * Handle a pairing result with the remote device which this is for. + * Must be specialized by subclass. + * + * @param aResult The status code of the pairing or authentication result. + */ + void DoHandlePairServerResult( TInt aResult ); + + /** + * Handles registry new paired event for the remote + * device this is pairing with. + * @aType the type of authentication with the device. + */ + void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ); + +private: // from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Callback to notify that an outstanding request has completed. + * + * @since S60 v5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Callback to notify that an error has occurred in RunL. + * + * @since S60 v5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngOtgPair( CBTEngPairMan& aParent, const TBTDevAddr& aAddr ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * Starts an actual pair operation. + */ + void DoPairingL(); + + /** + * Cancel any outstanding pairing operation. + */ + void DoCancelOutgoingPair(); + +private: // data + + /** + * Socket address of the remote device to pair with. + */ + TBTSockAddr iSockAddr; + + /** + * The CoD of the device to be paired + */ + TUint32 iCod; + + /** + * Dedicated bonding session to the pairing server. + */ + RBluetoothDedicatedBondingInitiator iBondingSession; + + /** + * socket for creating L2CAP link with the remote device. + */ + RSocket iSocket; + + /** + * Timer for recovery from Repeated Attempts + */ + RTimer iTimer; + + /** + * used for getting and setting outgoing pair state + */ + RProperty iOutgoProperty; + + /** + * the current pairing mode this class is in + */ + TBTOutgoingPairMode iPairMode; + + }; + + +#endif // BTENGOTGPAIR_H_ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengpairbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengpairbase.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,200 @@ +/* +* Copyright (c) 2008 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: the base class of pairing handling +* +*/ + + +#ifndef BTENGPAIRBASE_H_ +#define BTENGPAIRBASE_H_ + +#include +#include +#include +#include "btengactive.h" + +class CBTEngPairMan; + +/** Identification for asynchronous operations */ +enum TPairBaseActiveRequestId + { + EDevicePairUserNotification = 1 + }; + +/** + * Class CBTEngPairBase + * + * The base class for pairing handling. + * When the pairing has completed (successfully or unsuccessfully), the user + * is informed of the result + * + * @since S60 S60 v5.1 + */ +NONSHARABLE_CLASS( CBTEngPairBase ) : public CBase, public MBTEngActiveObserver + { +public: + + /** + * Destructor + */ + virtual ~CBTEngPairBase(); + + /** + * Handle a pairing result from the pairing server. + * + * @param aAddr the address of the remote device which the result is for. + * @param aResult The status code of the pairing or authentication result. + */ + void HandlePairServerResult( const TBTDevAddr& aAddr, TInt aResult ); + + /** + * Handles event of new paired device event in registry. + * @param aDev the remote device which the pair is with. + */ + void HandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ); + + /** + * Start observing the result of the pairing originated by + * the remote device. + * Must be specialized by subclass. + * @param the address of the remote device to be paired + * @return KErrNone if this request is accepted; otherwise an error code + */ + virtual TInt ObserveIncomingPair( const TBTDevAddr& aAddr ) = 0; + + /** + * Start an outgoing pairing with the remote device. + * Must be specialized by subclass. + * @param the address of the remote device to be paired + * @return KErrNone if this request is accepted; otherwise an error code + */ + virtual void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) = 0; + + /** + * Cancel the outstanding pairing operation. + */ + virtual void CancelOutgoingPair(); + + /** + * Cancels pairing handling with the specified device + * @param aAddr the address of the device the pairing is with + */ + virtual void StopPairHandling( const TBTDevAddr& aAddr ) = 0; + +protected: + + /** + * Handle a pairing result with the remote device which this is for. + * Must be specialized by subclass. + * + * @param aResult The status code of the pairing or authentication result. + */ + virtual void DoHandlePairServerResult( TInt aResult ) = 0; + + /** + * Handles event of registry new paired event with the remote + * device this is for. + * Must be specialized by subclass. + * @aType the type of authentication with the device. + */ + virtual void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) = 0; + +protected: + + /** + * C++ default constructor + */ + CBTEngPairBase(CBTEngPairMan& aParent, const TBTDevAddr& aAddr); + + /** + * Symbian 2nd-phase constructor + */ + void BaseConstructL(); + + /** + * Cancels notifying user about the pairing result. + */ + void CancelNotifier(); + + /** + * Show the pairing result and ask the user to authorize the device if + * pair succeeded. + * + * @since S60 v5.1 + */ + void ShowPairingNoteAndAuthorizeQuery(); + + /** + * Invalidate the pair result flag of this + */ + void UnSetPairResult(); + + /** + * Sets the pair result and validate pair result flag + */ + void SetPairResult( TInt aResult ); + + /** + * Tells if the pair result has been set. + * @ETrue if the result has been set. + */ + TBool IsPairResultSet(); + + /** + * Tells if this is notifying user the pairing result. + * @return ETrue if this is is notifying user the pairing result + */ + TBool IsNotifyingPairResult(); + +protected: + + /** + * Address of the remote device we are trying to pair. + */ + TBTDevAddr iAddr; + + /** + * Contains the final result of pairing with the remote device + */ + TInt iPairResult; + + /** + * Pair result flag, ETrue if iPairResult is been set. + */ + TBool iPairResultSet; + + /** + * Reference to the owner of this object. + */ + CBTEngPairMan& iParent; + + /** + * Package buffer for passing parameters to authorization notifier. + */ + TBTPairedDeviceSettingParamsPckg iAuthoPckg; + + /** + * Session with the notifier server. + * Own. + */ + RNotifier iNotifier; + + /** + * Active object helper for asynchronous operations. + * Own. + */ + CBTEngActive* iActive; + }; + +#endif /*BTENGPAIRBASE_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengpairman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengpairman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,318 @@ +/* +* Copyright (c) 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: Pairing manager header definition +* +*/ + +#ifndef BTENGPAIRMANAGER_H_ +#define BTENGPAIRMANAGER_H_ + +#include +#include +#include +#include "btengactive.h" +#include "btengconstants.h" + +class CBTEngPairBase; +class CBTEngServer; + +/** + * Class CBTEngPairMan + * + * This class manages pairing with BT devices. + * The responsibility of handling incoming and outgoing pairings is + * delegated to CBTEngIncPair and CBTEngOtgPair respectively. + * + * @since S60 S60 v5.1 + */ +NONSHARABLE_CLASS( CBTEngPairMan ) : public CBase, public MBTEngActiveObserver + { +public: + + /** + * Two-phase constructor + */ + static CBTEngPairMan* NewL( CBTEngServer& aServer ); + + /** + * Destructor + */ + ~CBTEngPairMan(); + + /** + * Cancels an outstanding pairing request. + */ + void CancelOutgoingPair(); + + /** + * Process commands relevant to pairing + */ + void ProcessCommandL( const RMessage2& aMessage ); + + /** + * Cancels an outstanding command. + * @param aOpcode the identifier of the command to be cancelled. + */ + void CancelCommand( TInt aOpCode ); + + /** + * Handle a change in BTRegistry remote device table. + * + * @since S60 v5.1 + */ + void RemoteRegistryChangeDetected(); + + /** + * Gets the instance of pairing server. + * @return the server instance. NULL if dedicated bonding is unavailable. + */ + RBluetoothPairingServer* PairingServer(); + + /** + * gets the reference of socket server session + */ + RSocketServ& SocketServ(); + + /** + * gets the reference of registry session. + */ + RBTRegServ& BTRegServ(); + + /** + * Transfer responsiblity to the specified object. + * @param aPairer the object to which the responsibility is transfered. + */ + void RenewPairer( CBTEngPairBase* aPairer ); + + /** + * Be notified when handling of an outgoing pair has been completed. + * @param aErr the result of pairing + * + */ + void OutgoingPairCompleted( TInt aErr ); + + /** + * Unpair a device via registry + */ + void UnpairDevice( const TBTDevAddr& aAddr ); + + /** + * Add the bit indicating the device is user-aware Just worked paired to + * UI cookie. + */ + TInt AddUiCookieJustWorksPaired( const TBTNamelessDevice& aDev ); + + /** + * Update a nameless device in registry + */ + TInt UpdateRegDevice( const TBTNamelessDevice& aDev ); + + + /** + * Returns the service (limited to services managed in bteng scope) + * level connection status of the specified device. + * + * @param aAddr the address of the device + * @return one of TBTEngConnectionStatus enums + */ + TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); + +private: // from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Callback to notify that an outstanding request has completed. + * + * @since S60 v5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Callback to notify that an error has occurred in RunL. + * + * @since S60 v5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngPairMan( CBTEngServer& aServer ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * Activate / deactivate a pair observer + */ + TInt SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate); + + /** + * Pair a BT device. + */ + void PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod ); + + /** + * Cancel all subscribes to pairng server + */ + void CancelSubscribe(); + + /** + * subscribe to receive SSP pairing result from pairing server + */ + void SubscribeSspPairingResult(); + + /** + * Subscribe to receive authentication result from pairing server + */ + void SubscribeAuthenticateResult(); + + /** + * Handle a pairing result from the pairing server. + * + * @since S60 v5.1 + * @param aResult The status code of the authentication result. + */ + void HandlePairingResultL( const TBTDevAddr& aAddr, TInt aResult ); + + /** + * Creates a registry view which shall contain all paired devices. + */ + void CreatePairedDevicesView( TInt aReqId ); + + /** + * retrieves paired devices from registry. + */ + void GetPairedDevices( TInt aReqId ); + + /** + * handles the completion of paired device view creation + */ + void HandleCreatePairedDevicesViewCompletedL( TInt aStatus, TInt aReqId ); + + /** + * handles the completion of getting paired devices + */ + void HandleGetPairedDevicesCompletedL( TInt aStatus, TInt aReqId ); + + /** + * Copy the paired devices to internal array storage. + */ + void UpdatePairedDeviceListL(); + + /** + * Checks if any devices have been paired or unpaired. For each new paired device, + * the pair event will be delegated to corresponding pair observer if it exists; + * otherwise create a new pair observer for this pair event. + */ + void CheckPairEventL(); + +private: + + /** + * Owner of this class. + * Not owned. + */ + CBTEngServer& iServer; + + /** + * Registry sub session for remote device db + */ + RBTRegistry iBTRegistry; + + /** + * contains the list of all paired devices. + * Using heap here to make efficient array swap. + */ + RArray* iPairedDevices; + + /** + * temporary instance to retrieve paired devices. + */ + CBTRegistryResponse* iPairedDevicesResp; + + /** + * the counter of not handled registry events. + */ + TInt iNotHandledRegEventCounter; + + /** + * Session with the pairing server. + * Allocate it in heap to ease the handling for + * situation of unavailable dedicated pairing service. + * + * own. + */ + RBluetoothPairingServer* iPairingServ; + + /** + * Subsession with the pairing server for + * getting the simple pairing result. + * own + */ + RBluetoothPairingResult iPairingResult; + + /** + * Subsession with the pairing server for + * getting the authentication result. + * own + */ + RBluetoothAuthenticationResult iAuthenResult; + + /** + * the address with which a simple pairing has been performed + */ + TBTDevAddr iSimplePairingRemote; + + /** + * the address with which an authentication has been performed + */ + TBTDevAddr iAuthenticateRemote; + + /** + * Active object helper for receiving simple pairing results. + * Own. + */ + CBTEngActive* iSSPResultActive; + + /** + * Active object helper for receiving authentication results. + * Own. + */ + CBTEngActive* iAuthenResultActive; + + /** + * AO for registry operations + */ + CBTEngActive* iRegistryActive; + + /** + * pair hanlder at the time. + * Own. + */ + CBTEngPairBase* iPairer; + }; + +#endif /*BTENGPAIRMANAGER_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengprivatecrkeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengprivatecrkeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine private central repository key definitions. +* +*/ + + +#ifndef BTENG_PRIVATE_CR_KEYS_H +#define BTENG_PRIVATE_CR_KEYS_H + + +#include + + +/** Bluetooth Discoverability Settings CenRep UID */ +const TUid KCRUidBTEngPrivateSettings = { 0x10204DAC }; + + +/** + * CenRep key for storing Bluetooth visibility settings. + * Stores the Bluetooth visibility mode. + * + * Possible integer values (the value are as published + * in the Bluetooth Core Specification): + * ( 0x00 No scanning (no scans enabled) + * 0x01 Inquiry scan only (inquiry Scan enabled, page scan disabled) ) + * 0x02 Hidden mode (page scan enabled, inquiry scan disabled) + * 0x03 General discoverability mode (Page enabled, inquiry scan enabled) + * 0x100 Temporarily visibile (first value after reserved range) + * + * Default value: 3 + * + */ +const TUint32 KBTDiscoverable = 0x00000001; + + +/** + * CenRep key for storing Bluetooth local device name settings. + * Stores the local name status (if the user has changed the + * local device name). + * + * Possible integer values: + * 0 User has not changed local device name + * 1 User has set the local deive name + * + * Default value: 0 + */ +const TUint32 KBTLocalNameChanged = 0x00000002; + + +/** Enumeration for local name changed status */ +enum TBTLocalNameStatus + { + EBTLocalNameDefault = 0, + EBTLocalNameSet + }; + + +/** + * CenRep key for storing Bluetooth SIM Access Profile settings. + * Stores the Bluetooth SIM Access Profile state. + * + * Possible integer values: + * 0 SAP disabled + * 1 SAP enabled + * + * Default value: 0 + */ +const TUint32 KBTSapEnabled = 0x00000003; + +const TUint32 KBtHidKeyboardLayout = 0x00000004; + +/** Enumeration for Bluetooth SAP setting */ +enum TBTSapMode + { + EBTSapDisabled = 0, + EBTSapEnabled + }; + + +#endif // BTENG_PRIVATE_CR_KEYS_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengprivatepskeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengprivatepskeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine private publish & subscribe key definitions. +* +*/ + + +#ifndef BTENG_PRIVATE_PS_KEYS_H +#define BTENG_PRIVATE_PS_KEYS_H + + +#include +#include + +/** Bluetooth private category publish and subscribe UID */ +const TUid KPSUidBluetoothEnginePrivateCategory = { 0x101FFE47 }; + + +/** + * Publish and Subscribe key for passing serialized BT AT Codec + * between HFP RemCon Bearer and Command Handler. + * + * Default value (in binary format): "" + */ +const TUint KBTATCodec = 0x01; + + +/** + * Publish and Subscribe key for storing the last paired device + * that was denied to connect by the user. + * + * Default value (in string format): "" + */ +const TUint KBTBlockDevAddr = 0x02; + + +/** +* Publish and Subscribe key for storing info of last audio device +* that tried to connect. Used by BT notifier only +* +* The key will contain the following information in 8 bit descriptor +* A;B;C +* Where: +* A is 0/1 depending if the last audio connection attempt was denied(0) or accepted(1) +* B is the bt device adress as exacly 12 hex digits +* C is the time the attempt was accepted or denied as 64 bit integer. + +* Example: +* 0;0015a00f42dd;63304481516638125 +*/ + +const TUint KBTAuthorInfoPerDevice = 0x03; + +/** + * Publishes outgoing pairing information for purposes of: + * - Ensure a single ongoing outgoing pair request in Bluetooth Engine; + * - BTNotif decides if auto pair with default pin shall be used or not; + */ +const TUint KBTOutgoingPairing = 0x04; + +enum TBTOutgoingPairMode + { + /** + * not outgoing pairing operation + */ + EBTOutgoingPairNone = 0, + + /** + * outgoing automatic 0000 pin pairing with headset in progress + */ + EBTOutgoingHeadsetAutoPairing, + + /** + * outgoing manual pairing with headset in progress + */ + EBTOutgoingHeadsetManualPairing, + + /** + * outgoing pairing with non-headset device in progress + */ + EBTOutgoingNoneHeadsetPairing, + }; + +class TBTOutgoingPairProperty + { +public: + TBTOutgoingPairMode iMode; + TBTDevAddr iAddr; + }; + +/* +* PS Key to indicate the status of bluetooth audio link. Value is of type TBTAudioLinkInfo +* where iState == open / closed +* iProfile == mono (0) or Stereo (1) +* iAddr == bluetooth device address +*/ +const TUint KBTAudioLinkStatus = 0x05; + +enum TBTAudioLinkState { + EAudioLinkOpen = 0, + EAudioLinkClosed = 1 +}; + +class TBTAudioLinkInfo + { +public: + TBTAudioLinkState iState; + TUint iProfile; // mono 0, stereo 1 + TBTDevAddr iAddr; + }; + +/** + * Publish and Subscribe to save last connection attemmp time. + * + */ +const TUint KBTConnectionTimeStamp = 0x06; + +/** + * Publish and Subscribe to store status for is query + * to turn bt off is showing or not. + */ +const TUint KBTTurnBTOffQueryOn = 0x07; + +enum TBTBtQueryValue + { + EBTQueryOff, + EBTQueryOn + }; + +/** + * P&S to publish ongoing notifier operations with BT devices. + * + * Data type: binary. + * + * Set and get the data via class TBTNotifLockPublish + * from btnotiflock.h. + * + * This info is used to lock some operations in btui and btnotifer: + * For a heaset which was paired from phone, connecting operation + * shall wait until trusting device has been asked from user and + * user selection has been performed; + * For a device which initiated pairing with phone, query of + * accepting connection request from this device shall wait until + * pairing note has been shown and trusting device has + * been asked from user and user selection has been performed. + */ +const TUint KBTNotifierLocks = 0x08; + +#endif // BTENG_PRIVATE_PS_KEYS_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsdp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsdp.hrh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2002-2006 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: Resource headers for Bluetooth Engine SDP attribute +* definitions and values. +* +*/ + + + +#ifndef BTENGSDP_HRH +#define BTENGSDP_HRH + + +/** SDP assigned numbers and implementation specific definitions. + * These constants are according to specifications of Bluetooth + * profiles. Attribute definitions can be found from the SDP + * specification in BT 2.0 Core specification. + */ + +/** SDP attribute identifier codes */ +enum TSdpAttributeId + { + EServiceRecordHandle = 0x0000, + EServiceClassIDList = 0x0001, + EServiceRecordState = 0x0002, + EServiceID = 0x0003, + EProtocolDescriptorList = 0x0004, + EBrowseGroupList = 0x0005, + ELanguageBaseAttributeIDList = 0x0006, + EServiceInfoTimeToLive = 0x0007, + EServiceAvailability = 0x0008, + EProfileDescriptorList = 0x0009, + EDocumentationURL = 0x000A, + EClientExecutableURL = 0x000B, + EIconURL = 0x000C, + EAdditionalProtocolDescLists = 0x000D, + EDefaultNameOffset = 0x0100, + EVersionNumberList = 0x0200, + EServiceVersion = 0x0300, + EHFNetwork = 0x0301, + ERemoteVolumeControl = 0x0302, + ESupportedFormatsList = 0x0303, + EAudioFeedbackSupport = 0x0305, + ESecurityDescription = 0x030A, + ENetAccessType = 0x030B, + ESupportedCapabilities = 0x0310, + ESupportedFeatures = 0x0311, + ESupportedFunctions = 0x0312, + ETotalImagingDataCapacity = 0x0313, + ESupportedRepositories = 0x0314 + }; + +/** Protocol UUIDs */ +enum TSdpProtocolDescriptor + { + EProtocolSDP = 0x0001, + EProtocolRFCOMM = 0x0003, + EProtocolOBEX = 0x0008, + EProtocolBNEP = 0x000F, + EProtocolHIDP = 0x0011, + EProtocolAVCTP = 0x0017, + EProtocolAVDTP = 0x0019, + EProtocol2CAP = 0x0100 + }; + +/** Default Language Attributes */ +enum TSdpLanguageBase + { + ELangValue = 0x454e, // "EN" + ECharacterSetValue = 0x006a, // UTF-8 + ELangBaseIDValue = 0x0100 + }; + +/** Public browse group UUID */ +enum TSdpBrowseGroup + { + EPublicBrowseGroup = 0x1002 + }; + +/** Attribute IDs for the Device Identification profile */ +enum TDIAttributeId + { + ESpecificationID = 0x0200, + EVendorID = 0x0201, + EProductID = 0x0202, + EVersion = 0x0203, + EPrimaryRecord = 0x0204, + EVendorIDSource = 0x0205 + }; + +/** Date element types */ +enum TResourceElementType + { + EElemTypeWord = 1, + EElemTypeLong = 2, + EElemTypeUUID = 3, + EElemTypeText = 4, + EElemTypeByte = 5, + EElemTypeList = 6, + EElemTypeUUID128 = 7, + EElemTypeLink = 8, + EElemTypeLong64 = 9, + EElemTypeBool = 10 + }; + +/** Maximum string length */ +#define TEXT_LEN_MAX 34 + +#endif // BTENGSDP_HRH diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsdp.rh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsdp.rh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2002-2006 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: Resource headers for Bluetooth Engine SDP record definitions. +* +*/ + + + +#ifndef BTENGSDP_RH +#define BTENGSDP_RH + + +#include "btengsdp.hrh" + + +// --------------------------------------------------------------------------- +// Structure for mapping of service class UUIDs to service record resources. +// --------------------------------------------------------------------------- +// +STRUCT SERVICE_RECORD_LIST + { + LTEXT8 service_ids[]; + LINK service_records[]; + } + +// --------------------------------------------------------------------------- +// Service record. +// --------------------------------------------------------------------------- +// +STRUCT SERVICE_RECORD + { + STRUCT attribute_list[]; + } + +// --------------------------------------------------------------------------- +// Service record attribute. +// --------------------------------------------------------------------------- +// +STRUCT ATTRIBUTE + { + WORD id; + STRUCT element; + } + +// --------------------------------------------------------------------------- +// Universal unique identifier (short form). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_UUID + { + BYTE type = EElemTypeUUID; + LONG uuid; + } + +// --------------------------------------------------------------------------- +// Universal unique identifier (long form). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_UUID_128 + { + BYTE type = EElemTypeUUID128; + LEN BYTE BYTE uuid_128[]; + } + +// --------------------------------------------------------------------------- +// Numeric data element type (8-bit). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_BYTE + { + BYTE type = EElemTypeByte; + BYTE value = 1; + } + +// --------------------------------------------------------------------------- +// Numeric data element type (16-bit). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_WORD + { + BYTE type = EElemTypeWord; + WORD value = 0; + } + +// --------------------------------------------------------------------------- +// Numeric data element type (32-bit). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_LONG + { + BYTE type = EElemTypeLong; + LONG value = 0; + } + +// --------------------------------------------------------------------------- +// Numeric data element type (64-bit). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_LONG_64 + { + BYTE type = EElemTypeLong64; + LEN BYTE BYTE long_64[]; + } + +// --------------------------------------------------------------------------- +// String data element type. +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_TEXT + { + BYTE type = EElemTypeText; + LTEXT8 text( TEXT_LEN_MAX ); + } + +// --------------------------------------------------------------------------- +// Data element sequence data element type. +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_DES + { + BYTE type = EElemTypeList; + STRUCT elements[]; + } + +// --------------------------------------------------------------------------- +// Boolean data element type (8-bit). +// --------------------------------------------------------------------------- +// +STRUCT ELEMENT_BOOL + { + BYTE type = EElemTypeBool; + BYTE value = 0; + } + +#endif // BTENGSDP_RH diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsdpdbhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsdpdbhandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 2006 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: Helper class for SDP database management. +* +*/ + + +#ifndef BTENGSDPDBHANDLER_H +#define BTENGSDPDBHANDLER_H + +#include + +class TResourceReader; + + +/** + * ?one_line_short_description + * + * ?more_complete_description + * + * @lib btengdiscovery.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSdpDbHandler ) : public CBase + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @return Pointer to the constructed CBTEngSdpDbHandler object. + */ + static CBTEngSdpDbHandler* NewL(); + + /** + * Destructor + */ + virtual ~CBTEngSdpDbHandler(); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aChannel RFCOMM channel to be filled in into the record. + * @param aHandle ?description + */ + void RegisterSdpRecordL( const TUUID& aService, TInt aChannel, + TSdpServRecordHandle& aHandle ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aVendorId Vendor ID to be filled in into the DI record. + * @param aProductId Product ID to be filled in into the DI record. + * @param aHandle ?description + */ + void RegisterSdpRecordL( const TUUID& aService, TInt aVendorId, + TInt aProductId, TSdpServRecordHandle& aHandle ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aHandle ?description + */ + void RegisterSdpRecordL( const TUUID& aService, + TSdpServRecordHandle& aHandle ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aHandle Handle to the SDP record to be deleted. Note that + * this has to be a valid (existing) SDP record. + */ + void DeleteSdpRecordL( const TSdpServRecordHandle aHandle ); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + */ + CBTEngSdpDbHandler(); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aChannel ?description + * @return ?description + */ + void BuildAttributeLC( CSdpAttrValue*& aAttrVal, TResourceReader& aReader, + TInt aAttrId ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aChannel ?description + * @return ?description + */ + void BuildAttrValueLC( CSdpAttrValue*& aAttrVal, TResourceReader& aReader, + TUint aAttrType, TInt aAttrId ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aChannel ?description + * @return ?description + */ + void BuildAttrDesLC( CSdpAttrValue*& aAttrVal, TResourceReader& aReader, + TInt aAttrId ); + + /** + * ?description + * + * @since S60 v3.2 + * @param aService ?description + * @param aChannel ?description + * @return ?description + */ + void ReadRecordResourceL( const TDesC8& aService, TResourceReader& aReader, + HBufC8*& aRecordBuf ); + +private: // data + + /** + * RFComm channel number. + * (to be replaced with a more flexible structure + * so that e.g. DI profile values can be set too). + */ + TUint iChannel; + + /** + * DI profile vendor ID. + */ + TUint iVendorId; + + /** + * DI profile product ID. + */ + TUint iProductId; + + /** + * Session to SDP database. + */ + RSdp iSdp; + + /** + * Subsession to SDP database for managing SDP records. + */ + RSdpDatabase iDb; + + }; + +#endif // BTENGSDPDBHANDLER diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsecpolicy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsecpolicy.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2006 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: Security policy for BTEng client-server interface. +* +*/ + + + +#ifndef BTENGSECPOLICY_H +#define BTENGSECPOLICY_H + + +/** BTEng policy range count */ +const TUint KBTEngRangeCount = 5; + +/** Ranges of BTEng opcodes */ +const TInt KBTEngRanges[ KBTEngRangeCount ] = + { + 0, // Range 0: 0 - 32 (Out of range) + 33, // Range 1: EBTEngSetPowerState + // EBTEngSetScanMode + 35, // Range 2: EBTEngConnectDevice + // EBTEngCancelConnectDevice + // EBTEngDisconnectDevice + // EBTEngIsDeviceConnected + // EBTEngIsDeviceConnectable + // EBTEngGetConnectedAddresses + // EBTEngNotifyConnectionEvents + // EBTEngCancelEventNotifier + // EBTEngPrepareDiscovery + 44, // Range 3: EBTEngSetPairingObserver + // EBTEngPairDevice + // EBTEngCancelPairDevice + 47 // Range x: Out of range + }; + +/** Mapping of ranges to policies */ +const TUint8 KBTEngElementsIndex[ KBTEngRangeCount ] = + { + CPolicyServer::ENotSupported, //applies to 0th range (out of range) + 1, //policy 1 applies to 1st range + 0, //policy 0 applies to 2nd range + 1, //policy 1 applies to 3rd range + CPolicyServer::ENotSupported //applies to 9th range(out of range IPC) + }; + +/** BTEng security policies */ +const CPolicyServer::TPolicyElement KBTEngPolicyElements[] = + { + { _INIT_SECURITY_POLICY_C1( ECapabilityLocalServices ), + CPolicyServer::EFailClient + }, //policy 0, connection management operations + { _INIT_SECURITY_POLICY_C2( ECapabilityLocalServices, ECapabilityWriteDeviceData ), + CPolicyServer::EFailClient + } //policy 1, write HW settings + }; + +/** BTEng security policy package */ +const CPolicyServer::TPolicy KBTEngServerPolicy = + { + CPolicyServer::EAlwaysPass, // Connection attempts may pass + KBTEngRangeCount, // Number of ranges + KBTEngRanges, // Array of ranges + KBTEngElementsIndex, // Mapping of ranges to policies + KBTEngPolicyElements // Array of policies + }; + + +#endif // BTENGSECPOLICY_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,565 @@ +/* +* Copyright (c) 2006 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: BTEng server header definition +* +*/ + + +#ifndef BTENGSERVER_H +#define BTENGSERVER_H + +#include +#ifndef __WINS__ +#include +#endif //__WINS__ +#include +#include +#include +#include "btengdomaincrkeys.h" +#include "btengconstants.h" + +class CBTEngSrvState; +class CBTEngSrvPluginMgr; +class CBTEngPlugin; +class CBTEngSrvBBConnMgr; +class CBTEngSrvKeyWatcher; +class CBTEngSdpDbHandler; +class CBTEngPairMan; +class CPolicyServer; +class TEComResolverParams; +class CImplementationInformation; +class CDeltaTimer; + +/** + * Main function in which the server is running. + * + * @since S60 v3.2 + */ +static void RunServerL(); + +/** + * Utility to panic the client. + * + * @since S60 v3.2 + * @param aMessage Client message + * @param aPanic Panic reason code. + */ +void PanicClient( const RMessage2& aMessage, TInt aPanic ); + +/** + * Utility to panic the server. + * + * @since S60 v3.2 + * @param aPanic Panic reason code. + */ +void PanicServer( TInt aPanic ); + +/** Panic category */ +_LIT( KBTEngPanic, "BTEng panic" ); + +/** Panic codes */ +enum TBTEngServerPanic + { + EBTEngPanicMemoryLeak = 10000, + EBTEngPanicArgumentIsNull, + EBTEngPanicMemberVarIsNull, + EBTEngPanicCorrupt, + EBTEngPanicCorruptSettings + }; + + +/** + * Class CBTEngServer + * + * Core server class of BTEng. + * + * @lib bteng.lib + * @since S60 S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngServer ) : public CPolicyServer + { + + friend class CBTEngSrvSession; + friend class CBTEngSrvState; + friend class CBTEngSrvPluginMgr; + friend class CBTEngSrvKeyWatcher; + friend class CBTEngPairMan; + +public: + + static CBTEngServer* NewLC(); + + virtual ~CBTEngServer(); + + /** + * ?description + * + * @since S60 v3.2 + * @param aState The new power state. + * @param aTemp Turn BT off after use (ETrue) or not (EFalse). + */ + void SetPowerStateL( TBTPowerStateValue aState, TBool aTemporary ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void UpdateVisibilityModeL( TInt aStackScanMode ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void DisconnectAllL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetDutMode( TInt aDutMode ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void ScanModeTimerCompletedL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void DisconnectAllCompleted(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void DispatchPluginMessageL( const RMessage2& aMessage ); + + /** + * Increment the session count. + * + * @since S60 v3.2 + */ + void AddSession(); + + /** + * Decrement the session count. + * + * @since S60 v3.2 + * @param aAutoOff Indicator if this session had requested BT temporary on. + */ + void RemoveSession( TBool aAutoOff ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetUiIndicatorsL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetIndicatorStateL( const TInt aIndicator, const TInt aState ); + + /** + * Check whether BT should be turned off automatically. + * + * @since S60 v5.0 + */ + void CheckAutoPowerOffL(); + + /** + * Utility to get HW power state. + * + * @since S60 v5.1 + * @param aState On return, this will contain the current HW power state. + * @return KErrNone if successful, otherwise one of the system-wide error codes. + */ + TInt GetHwPowerState( TBTPowerStateValue& aState ); + + /** + * queue a timer if Simple Pairing debug mode has been enabled. + * + * @since S60 v3.2 + * @param aDebugMode State of Simple Pairing debug mode. + */ + void CheckSspDebugModeL( TBool aDebugMode ); + + /** + * Gets the access to pairing manager. Ownership is not transferred. + * @return the pairing manager + */ + CBTEngPairMan& PairManager(); + + /** + * Be informed when registry remote device table is changed + */ + void RemoteRegistryChangeDetected(); + + /** + * gets the reference of socket server session + */ + RSocketServ& SocketServ(); + + /** + * gets the reference of registry session. + */ + RBTRegServ& BTRegServ(); + + /** + * Returns the service (limited to services managed in bteng scope) + * level connection status of the specified device. + * + * @param aAddr the address of the device + * @return one of TBTEngConnectionStatus enums + */ + TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); + +// from base class CPolicyServer + + /** + * From CPolicyServer. + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual CSession2* NewSessionL( const TVersion& aVersion, + const RMessage2& aMessage ) const; + +// from base class MBTPowerManagerObserver + + BluetoothFeatures::TEnterpriseEnablementMode EnterpriseEnablementMode() const; + +private: + + CBTEngServer(); + + void ConstructL(); + + /** + * Checks if power is off and no session are connected, and + * starts a shutdown timer if so. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void CheckIdle(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + TInt SetPowerState( TBool aState ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + TInt SetLocalNameL(); + + TInt GetLocalNameFromRegistryL(TDes& aName); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetClassOfDeviceL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void InitBTStackL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void StopBTStackL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void UpdateCenRepPowerKeyL( TBTPowerStateValue aValue ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void LoadBTPowerManagerL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void ManageDIServiceL( TBool aState ); + + /** + * Reads the product-specific IDs for this phone from central repository. + * These values are used in the BT Device Information profile. + * + * @since S60 v3.2 + * @param aVendorId On return, holds the vendor ID for this phone. + * @param aProductId On return, holds the product ID for this phone. + */ + void GetProductIdsL( TInt& aVendorId, TInt& aProductId ); + + /** + * Checks if a client requests temporary power on/off, and keeps track + * of the number of clients requesting that. + * + * @since S60 v5.0 + * @param aCurrentState On return, will contain the current power state. + * @param aNewState The requested power state. + * @param aTemporary Indicates if this is about a tempororary state change. + */ + void CheckTemporaryPowerStateL( TBTPowerStateValue& aCurrentState, + TBTPowerStateValue aNewState, + TBool aTemporary ); + + /** + * Callback function for expiry of CDeltaTimer timer of temporary + * visibility mode. + * + * @since S60 v3.2 + * @param aPtr Pointer to ourselves. + * @return Result + */ + static TInt ScanModeTimerCallBack( TAny* aPtr ); + + /** + * Callback function for completion of disconnecting all + * Bluetoooth Baseband links. + * + * @since S60 v3.2 + * @param aPtr Pointer to ourselves. + * @return Result + */ + static TInt DisconnectAllCallBack( TAny* aPtr ); + + /** + * Callback function for expiriy CDeltaTimer timer of server idle timeout. + * + * @since S60 v3.2 + * @param aPtr Pointer to ourselves. + * @return Result + */ + static TInt IdleTimerCallBack( TAny* aPtr ); + + /** + * Callback function for expiriy CDeltaTimer timer of + * Simple Pairing Debug Mode. + * + * @since S60 v3.2 + * @param aPtr Pointer to ourselves. + * @return Result + */ + static TInt DebugModeTimerCallBack( TAny* aPtr ); + + /** + * Callback function for turning BT off automatically after all + * connections are gone. + * + * @since S60 v5.0 + * @param aPtr Pointer to ourselves. + * @return Result + */ + static TInt AutoPowerOffCallBack( TAny* aPtr ); + +private: // data + + /** + * Counter of the number of open sessions, which is used to + * stop the server when no session exists and Bluetooth is off. + */ + TInt iSessionCount; + + /** + * Handle to BT Power Manager library; this handle must exist + * for the lifetime of the loaded library. + */ + TUint32 iDiSdpRecHandle; + + /** + * Flag indicating if BT is going to be switched off automatically. + */ + TBool iAutoSwitchOff; + + /** + * Number of clients that are using BT temporarily. + * Note that this is equal or less than the active number of links. + */ + TInt iAutoOffClients; + + /** + * Flag indicating hidden mode has been set for temporary power on. + */ + TBool iRestoreVisibility; + + /** + * To decide wether DUT mode should be enabled in power mode + * change callback. + */ + TBool iEnableDutMode; + + /** + * Remember which timer has been queued. (CDeltaTimer does not + * provide this information). + */ + TUint32 iTimerQueued; + + /** + * Callback for expiry of temporary visibility mode timer. + */ + TDeltaTimerEntry iScanModeCallBack; + + /** + * Callback for expiry of temporary power on mode timer. + */ + TDeltaTimerEntry iPowerOffCallBack; + + /** + * Callback for expiry of idle timer. + */ + TDeltaTimerEntry iIdleCallBack; + /** + * Callback for expiry of Simple Pairing debug mode. + */ + TDeltaTimerEntry iDebugModeCallBack; + + /** + * Handle to BT Power Manager library; this handle must exist + * for the lifetime of the loaded library. + */ + RLibrary iPowerMgrLib; +#ifndef __WINS__ + /** + * Handle for DUT mode API + */ + RBluetoothDutMode iDutMode; +#endif //__WINS__ + + /** + * Pairing manager. + */ + CBTEngPairMan* iPairMan; + + /** + * Socket Server instance for this and other classes to access Bluetooth socket APIs. + */ + RSocketServ iSocketServ; + + + /** + * Registry Server instance for bteng to access Bluetooth registry APIs. + */ + RBTRegServ iBTRegServ; + + /** + * BT Power Manager. + * Own. + */ + CBTEngSrvState* iServerState; + + /** + * ECOM plugin manager. + * Own. + */ + CBTEngSrvPluginMgr* iPluginMgr; + + /** + * Bluetooth Baseband connection manager. + * Own. + */ + CBTEngSrvBBConnMgr* iBBConnMgr; + + /** + * Watcher for the relevant CenRep and PubSub keys. + * Own. + */ + CBTEngSrvKeyWatcher* iWatcher; + + /** + * BT Power Manager (HCIv2 version). + */ + RBTPowerControl iPowerMgr; + +#ifdef __WINS__ + /** + * Current BT power state (power manager is not used in emulator). + */ + TBTPowerState iPowerState; +#endif //__WINS__ + + /** + * SDP database handler. + * Own. + */ + CBTEngSdpDbHandler* iSdpDbHandler; + + /** + * Timer for setting various timeouts. + * Own. + */ + CDeltaTimer* iTimer; + + BluetoothFeatures::TEnterpriseEnablementMode iEnterpriseEnablementMode; + }; + + +#endif // BTENGSERVER diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsrvbbconnectionmgr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsrvbbconnectionmgr.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,241 @@ +/* +* Copyright (c) 2006 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: Helper class for handling Bluetooth Baseband-related +* connection management. +* +*/ + + + +#ifndef BTENGSRVBBCONNECTIONMGR_H +#define BTENGSRVBBCONNECTIONMGR_H + + +#include + +#include "btengactive.h" + +class CBTEngActive; + +/** ?description */ +//const ?type ?constant_var = ?constant; + + +/** + * ?one_line_short_description + * + * ?more_complete_description + * + * @lib ?library + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSrvBBConnMgr ) : public CBase, + public MBluetoothPhysicalLinksNotifier, + public MBTEngActiveObserver + { + +public: + + /** + * Two-phase constructor + */ + static CBTEngSrvBBConnMgr* NewL(RSocketServ& aSockServ); + + /** + * Destructor + */ + virtual ~CBTEngSrvBBConnMgr(); + + /** + * Subscribes to relevant events from BT Baseband, and also WLAN events. + * + * @since S60 v3.2 + */ + void Subscribe(); + + /** + * Stops listening to BT Baseband and WLAN events. + * + * @since S60 v3.2 + */ + void Unsubscribe(); + + /** + * Attempts to re-arrange the topology into a single piconet if necessary. + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + TInt ManageTopology( TBool aPrepDiscovery ); + + /** + * Gets the addresses of all connected Bluetooth devices. + * + * @since S60 v3.2 + * @param On return, holds the addresses of connected BT devices. + */ + void GetConnectedAddressesL( RBTDevAddrArray& aAddrArray ); + + /** + * Disconnect all Bluetooth baseband connections. + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + void DisconnectAllLinksL( TCallBack& aCallBack ); + + /** + * Indicate to turn off BT when idle. + * + * @since S60 v5.0 + * @param aEnable Enable or disable automatic power off. + * @param aCallBack re-use DisconnectAll callback. + */ + void SetAutoSwitchOff( TBool aEnable, TCallBack& aCallBack ); + +// from base class MBluetoothPhysicalLinksNotifier + + /** + * From MBluetoothPhysicalLinksNotifier. + * Notification of a requested connection coming up. Not used here. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void HandleCreateConnectionCompleteL( TInt aErr ); + + /** + * From MBluetoothPhysicalLinksNotifier. + * Notification of a requested disconnection having taken + * place. Not used here. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void HandleDisconnectCompleteL( TInt aErr ); + + /** + * From MBluetoothPhysicalLinksNotifier. + * Notification that all existing connections have been torn down. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void HandleDisconnectAllCompleteL( TInt aErr ); + +// from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Callback to notify that an outstanding request has completed. + * + * @since S60 v3.2 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Callback to notify that an error has occurred in RunL. + * + * @since S60 v3.2 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngSrvBBConnMgr(RSocketServ& aSockServ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * Gets the WLAN connection status, if activated. + * + * @since S60 v3.2 + * @return ETrue if a WLAN connection is active, otherwise EFalse. + */ + TBool GetWlanStatus(); + +private: // data + + /** + * Flag to indicate if we should monitor WLAN connection status. + */ + TBool iWlanSupported; + + /** + * Flag to indicate that BT is to be switched off when active. + */ + TBool iAutoSwitchOff; + + /** + * ?description_of_member + */ + RProperty iLinkCountProperty; + + /** + * ?description_of_member + */ + RProperty iWlanStatusProperty; + + /** + * Session with the socket server. Not own! + */ + RSocketServ& iSockServ; + + /** + * BT Link Manager socket. + * Own. + */ + CBluetoothPhysicalLinks* iPhyLinks; + + /** + * Active object for monitoring BT link count. + * Own. + */ + CBTEngActive* iLinkCountWatcher; + + /** + * Active object for monitoring BT link count. + * Own. + */ + CBTEngActive* iWlanWatcher; + + /** + * Callback function to call when disconnecting all links has completed. + * Not own. + */ + TCallBack iCallBack; + + }; + + +#endif // BTENGSRVBBCONNECTIONMGR_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsrvkeywatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsrvkeywatcher.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,237 @@ +/* +* Copyright (c) 2006 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: Watcher for BTEng server PubSub and CenRep keys. +* +*/ + + + +#ifndef BTENGSRVKEYWATCHER_H +#define BTENGSRVKEYWATCHER_H + + +#include + +#include "btengactive.h" + +class CBTEngServer; +class CRepository; + +/** + * ?one_line_short_description + * + * ?more_complete_description + * + * @lib ?library + * @since S60 v3.2 + */ +class CBTEngSrvKeyWatcher : public CBase, public MBTEngActiveObserver + { + +public: + + /** + * Two-phase constructor + */ + static CBTEngSrvKeyWatcher* NewL( CBTEngServer* aServer ); + + /** + * Destructor + */ + virtual ~CBTEngSrvKeyWatcher(); + +// from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Notification that a key value has changed. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Notification that a key value has changed. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + */ + CBTEngSrvKeyWatcher( CBTEngServer* aServer ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * Check if we checked the BD_ADDR before. + * + * @since S60 v3.2 + */ + void CheckBDAddrL(); + +private: // data + + /** + * Property contaning the BT Device Under Test (DUT) status. + * When enabled, we need inform the server. + */ + RProperty iDutModeKey; + + /** + * Property containing the phone lock status. + * We turn off BT when the phone is remotely locked. + */ + RProperty iPhoneLockKey; + + /** + * Property containing the system status. + * We disconnect BT links when the phone is shutting down. + */ + RProperty iSystemStateKey; + + /** + * Property containing count of physical BT connections. + * When physical connections exists, specific BT UI indicator is shown. + */ + RProperty iPHYCountKey; + + /** + * Property containing the BT connecting status. + * When connecting, specific BT UI indicator is shown. + */ + RProperty iBtConnectionKey; + + /** + * Property containing the BT stack scanning status. + * When changed, the UI indicators are updated + */ + RProperty iBtScanningKey; + + /** + * Property containing the emergency call status. + * We disconnect BT SAP when an emergency call is created. + */ + RProperty iEmergencyCallKey; + + /** + * Property containing the BT device address. + * We read it once to store it in CenRep. + */ + RProperty iBdaddrKey; + + /** + * Property containing the Simple Pairing debug mode status. + * We deactivate debug mode after 30 mins or BT power off. + */ + RProperty iSspDebugModeKey; + + /** + * Property containing the BT registry change monitoring key + */ + RProperty iBtRegistryKey; + + /** + * Session with the central repository for BT SAP mode setting. + * We load/unload BT SAP plugin. + * Own. + */ + CRepository* iSapKeyCenRep; + + /** + * Active object for subscribing to DUT mode property changes. + * Own. + */ + CBTEngActive* iDutModeWatcher; + + /** + * Active object for subscribing to phone lock property changes. + * Own. + */ + CBTEngActive* iPhoneLockWatcher; + + /** + * Active object for subscribing to system status property changes. + * Own. + */ + CBTEngActive* iSystemStateWatcher; + + /** + * Active object for subscribing to PHYCount property changes. + * Own. + */ + CBTEngActive* iPHYCountWatcher; + + /** + * Active object for subscribing to BT connection property changes. + * Own. + */ + CBTEngActive* iBtConnectionWatcher; + + /** + * Active object for subscribing to BT scanning state property changes. + * Own. + */ + CBTEngActive* iBtScanningWatcher; + + /** + * Active object for subscribing to emergency call property changes. + * Own. + */ + CBTEngActive* iEmergencyCallWatcher; + + /** + * Active object for subscribing to BT SAP mode setting changes. + * Own. + */ + CBTEngActive* iSapModeWatcher; + + /** + * Active object for subscribing to BD_Addr property changes. + * Own. + */ + CBTEngActive* iBdaddrWatcher; + + /** + * Active object for subscribing to SSP debug mode property changes. + * Own. + */ + CBTEngActive* iSspDebugModeWatcher; + + /** + * Active object for subscribing to BT registry property changes. + * Own. + */ + CBTEngActive* iBtRegistryWatcher; + + /** + * Pointer to our parent. + * Not own. + */ + CBTEngServer* iServer; + + }; + + +#endif // BTENGSRVKEYWATCHER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsrvpluginmgr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsrvpluginmgr.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,335 @@ +/* +* Copyright (c) 2006 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: Helper class for BTEng server to manage and interface with +* the profile plug-ins the profile plug-ins. +* +*/ + + + +#ifndef BTENGSRVPLUGINMGR_H +#define BTENGSRVPLUGINMGR_H + +#include "btengclientserver.h" +#include "btengplugin.h" + +class CBTEngServer; +class TEComResolverParams; +typedef RPointerArray RImplInfoPtrArray; +typedef RPointerArray RPluginPtrArray; + +/** ?description */ +//const ?type ?constant_var = ?constant; + + +/** + * ?one_line_short_description + * + * ?more_complete_description + * + * @lib ?library + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSrvPluginMgr ) : public CBase, + public MBTEngPluginObserver + { + +public: + + /** + * Two-phase constructor + */ + static CBTEngSrvPluginMgr* NewL( CBTEngServer* aServer ); + + /** + * Destructor + */ + virtual ~CBTEngSrvPluginMgr(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void ProcessCommandL( const RMessage2& aMessage ); + + /** + * ?description + * + * @since S60 v3.2 + */ + void DisconnectAllPlugins(); + + /** + * ?description + * + * @since S60 v3.2 + * @param aParams Selection parameters for loading a specific plugin. + * If it is empty (zero-length descriptor), + * all plug-ins are loaded. + */ + void LoadProfilePluginsL( const TEComResolverParams aParams ); + + /** + * ?description + * + * @since S60 v3.2 + * @return The number of ECom plug-ins still to load. + */ + TInt LoadPluginL(); + + /** + * ?description + * + * @since S60 v3.2 + */ + void UnloadProfilePlugins(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void LoadBTSapPluginL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void UnloadBTSapPlugin(); + + /** + * Disconnects the profile specified by aProfile + * Currently used only when emergency call is created for disconnecting SAP + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void DisconnectProfile( TBTProfile aProfile ); + + /** + * Checks if any audio connection is established + * + * @since S60 v5.0 + * @return ETrue if any audio connection is established + */ + TBool CheckAudioConnectionsL(); + + /** + * Returns the service (limited to services managed in bteng scope) + * level connection status of the specified device. + * + * @param aAddr the address of the device + * @return one of TBTEngConnectionStatus enums + */ + TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); + +// from base class MBTEngPluginObserver + + /** + * From MBTEngPluginObserver. + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void ConnectComplete( const TBTDevAddr& aAddr, + TBTProfile aProfile, TInt aErr, + RBTDevAddrArray* aConflicts = NULL ); + + /** + * From MBTEngPluginObserver. + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + virtual void DisconnectComplete( const TBTDevAddr& aAddr, + TBTProfile aProfile, TInt aErr ); + +private: + + /** + * C++ default constructor + */ + CBTEngSrvPluginMgr( CBTEngServer* aServer ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @return ?description + */ + TInt Connect( const TBTDevAddr& aAddr, const TBTDeviceClass& aDeviceClass ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @return ?description + */ + TInt CancelConnect( const TBTDevAddr& aAddr ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @return ?description + */ + TInt Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType ); + + + /** + * ?description + * + * @since S60 v5.1 + * @param aDeviceClass Device class of the remote device is used if + * no EIR data of this device exists. + * @param aAddr The address of remote device is used to get EIR data. + * Firstly use the service UUIDs in EIR data to determine if + * the remote device is connectable or not. + * @return The index of plugin in the plugin array, which supports the + * profiles via device class, + * . + */ + TInt GetConnectablePluginIndex( const TBTDeviceClass& aDeviceClass, const TBTDevAddr& aAddr = TBTDevAddr() ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @return ?description + */ + TInt GetConnectedAddresses( RBTDevAddrArray& aAddrArray, TBTProfile aProfile ); + + /** + * Checks from feature manager and central repository if the requested + * feature is supported and enabled. + * + * @since S60 v3.2 + * @param aProfile The profile to check if it is supported and enabled. + */ + TBool CheckFeatureEnabledL( TInt aProfile ); + + /** + * Maps a Clasee of Device to a profile identifier (UUID short form). + * + * @since S60 v3.2 + * @param aProfile The profile to map to a feature. + */ + static TBTProfile MapDeviceClassToProfile( const TBTDeviceClass& aDeviceClass ); + + /** + * Maps a profile identifier (UUID short form) to a feature + * to check from the feature manager. + * + * @since S60 v3.2 + * @param aProfile The profile to map to a feature. + */ + static TInt MapProfileToFeature( TInt aProfile ); + + /** + * Connectable if the UUID in Eir data is supported by plugins. + * + * @since S60 v5.1 + * @return The first index of plugin supporting specified UUID. + */ + TInt GetConnectablePluginIndexByEir(); + + /** + * Get Eir data of device in cache. + * + * @since S60 v5.1 + * @param aAddr The address of remote device + * @return Symbian error code + */ + TInt DoGetEirData( const TBTDevAddr& aAddr ); + + /** + * Utility function to check if profile supported by plugins. + * + * @param aProfile The profile to check + * @return The index of the first plugin in plugin array + * supporting this profile, KErrNotFound if not supported. + */ + TInt GetFirstPluginOfProfileSupported( TBTProfile aProfile ); + + /** + Returns ETrue if the specified plugin is to be loaded in the current + 'Enterprise Disabling of Bluetooth' mode, EFalse otherwise. + @param The implementation UID of the plugin we want to know whether should + be elided for Enterprise Disabling of Bluetooth reasons. + @return See description. + */ + TBool FilterByEnterpriseDisablementModeL(TUid aUid) const; + +private: // data + + /** + * Array of pointers to ECom plug-in information objects. + */ + RImplInfoPtrArray iPluginInfoArray; + + /** + * Array of pointers to the BTEng ECom plug-ins loaded by BTEng. + */ + RPluginPtrArray iPluginArray; + + /** + * The server instance. + * Not own. + */ + CBTEngServer* iServer; + + /** + * Hose Resolver to get cached EIR. + * Own. + */ + RHostResolver iHostResolver; + + /** + * used for getting cached EIR. + */ + TInquirySockAddr iInquirySockAddr; + + /** + * Entry to store inquiry result. + */ + TNameEntry iNameEntry; + + /** + * Container of UUIDs, gotten from Eir data. + * Own. + */ + RExtendedInquiryResponseUUIDContainer iUuidContainter; + }; + + +//#include "?include_file.inl" + + +#endif // BTENGSRVPLUGINMGR_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsrvsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsrvsession.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2006 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: BTEng server session header definition. +* +*/ + + + +#ifndef BTENGSRVSESSION_H +#define BTENGSRVSESSION_H + +#include +#include "btengclientserver.h" + +class CSession2; +class RMessage; +class CBTEngServer; +typedef RArray RBTDevAddrArray; + + +/** + * Class CBTEngSrvSession, server-side session class. + * + * An instance of this class is created for every client session, + * and handles client messages (commands). It also handles informing + * clients of connection events. + * + * @lib bteng.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSrvSession ): public CSession2 + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @return Pointer to the constructed CBTEngSrvSession object. + */ + static CBTEngSrvSession* NewL(); + + /** + * Destructor + */ + virtual ~CBTEngSrvSession(); + + /** + * Notify the client of the connection event. + * + * @since S60 v3.2 + * @param aAddr The address of the remote Bluetooth device + * @param aConnStatus Status of the connection. + * @param aArray Contains the bluetooth device addresses of the remote + * devices for which profile connections exist for an + * outgoing connection request. + * @param aErr The error code indicating the result of the connection + * request. + */ + void NotifyConnectionEvent( const TBTDevAddr aAddr, + TBTEngConnectionStatus aConnStatus, + RBTDevAddrArray* aArray, TInt aErr ); + + /** + * Completes client's pairing request. + * @param aResult the resultof pairing the client will receive. + */ + TInt CompletePairRequest( TInt aResult ); + +private: // from base class CSession2 + + /** + * From CSession2. + * Processes a message from a client. + * + * @since S60 v3.2 + * @param aMessage The message containing the details of the client request. + */ + virtual void ServiceL( const RMessage2& aMessage ); + + /** + * From CSession2. + * Completes construction of the session. + * + * @since S60 v3.2 + */ + virtual void CreateL(); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + */ + CBTEngSrvSession(); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + + /** + * Returns a handle to the server object. + * + * @since S60 v3.2 + * @return Pointer to the server object. + */ + CBTEngServer* Server(); + + /** + * Processes a message from a client. + * + * @since S60 v3.2 + * @param aMessage The message containing the details of the client request. + */ + void DispatchMessageL( const RMessage2& aMessage ); + + /** + * Cancels outstanding pairing request. + */ + void CancelPairRequest(); + +private: // data + /** + * Client-server message containing the thread handle of the client. + * For connection notifications. + */ + RMessage2 iNotifyConnMessage; + + /** + * For connection notifications. + * For outgoing pairing request. + */ + RMessage2 iPairMessage; + + /** + * Flag indicating if this client requested BT to be switched on temporarily. + */ + TBool iAutoSwitchOff; + + /** + * Required for queuing connection events to send to the client + */ + CDesC8ArraySeg* iConnectionEventQueue; + }; + +#endif // BTENGSRVSESSION diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengsrvstate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsrvstate.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine server state machine class declaration. +* +*/ + + + +#ifndef BTENGSRVSTATE_H +#define BTENGSRVSTATE_H + + +//#include + +#include "btengactive.h" +#include "btserversdkcrkeys.h" + +class MBTEngActiveObserver; +class CBTEngServer; + +/** ?description */ +//const ?type ?constant_var = ?constant; + + +/** + * Class CBTEngSrvState + * + * This class implements the state machine for BTEng server. + * The state machine is used for Bluetooth power on and power off operations. + * A state machine is needed because the required operations for loading and + * initalizing all required services is time-consuming and would be too long + * to handle in one operation. It also includes asynchronous operations. + * It is implemented in a separate class to make it easier extensible as well + * as to give a better overview of the state transitions and operations. + * + * The state machine is initialized in state Init, and ends in state Idle. Any + * state in between are temporary states (i.e. not accepting states). + * + * @lib bteng.lib + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( CBTEngSrvState ) : public CBase + { + +public: + + /** Enumeration of BTEng server states */ + enum TBTEngSrvState + { + EInit, + EInitBTStack, + ELoadDIService, + ELoadPlugins, + ELoadNextPlugin, + EIdle, + EWaitingForPowerOff, + EStopBTStack, + EUnloadDIService, + EUnloadPlugins, + EDisconnectPlugins, + }; + + /** Enumeration of BTEng server states */ + enum TBTEngSrvOperation + { + ESrvOpIdle, + EPowerOff, + EPowerOn + }; + + /** ?description */ +// typedef ?declaration + + /** + * Two-phase constructor + */ + static CBTEngSrvState* NewL( CBTEngServer* aServer ); + + /** + * Destructor + */ + virtual ~CBTEngSrvState(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + CBTEngSrvState::TBTEngSrvOperation CurrentOperation(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + void StartStateMachineL( TBool aState ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + * @param ?arg2 ?description + * @return ?description + */ + void ChangeState(); + +private: + + /** + * C++ default constructor + */ + CBTEngSrvState( CBTEngServer* aServer ); + + /** + * Symbian 2nd-phase constructor + */ + void ConstructL(); + + static TInt ChangeStateCb(TAny* aThis); + + void RequestCompletedL(); + + void HandleError(TInt aError); + +private: // data + + /** + * Our current state. + */ + TInt iState; + + /** + * The current command (power-on or power-off Bluetooth). + */ + TBTEngSrvOperation iOperation; + + /** + * The active object used for state transitions. + * Own. + */ + CAsyncCallBack* iAsyncCallback; + + /** + * The server instance. + * Not own. + */ + CBTEngServer* iServer; + + }; + + +#endif // BTENGSRVSTATE diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btengutil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengutil.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 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: Utilities that may be useful for components of +* Bluetooth Engine subsystem +* +*/ + +#ifndef BTENGUTIL_H +#define BTENGUTIL_H + +#include +#include + +/** + Tells if the given device has been paired regardless of user awareness. + (User aware paired devices are those seen in the paired device view of + Bluetooth application.) +*/ +inline TBool IsPaired( const TBTNamelessDevice &dev ) +{ + // IsValidPaired tells if the paired bit of dev is valid + // and IsPaired tells if the device is paired or not: + return dev.IsValidPaired() && + dev.IsPaired() && + // Authentication due to OBEX cases e.g. file transfer, is not + // considered as paired in Bluetooth engine scope: + dev.LinkKeyType() != ELinkKeyUnauthenticatedUpgradable; +} + +/** + Tells if the given device has been paired with Just Works model. +*/ +inline TBool IsJustWorksPaired( const TBTNamelessDevice &dev ) +{ + return IsPaired( dev ) && + dev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable; +} + +/** + Tells if the given device has been paired under user awareness. + (User aware paired devices are those seen in the paired device view of + Bluetooth application.) +*/ +inline TBool IsUserAwarePaired( const TBTNamelessDevice &dev ) +{ + if ( IsJustWorksPaired( dev ) ) + { + // Just Works paired devices can happen without user awareness. + // For example, paired due to an incoming service connection request + // from a device without IO. + // We use cookies to identify if this JW pairing is user aware or not: + TInt32 cookie = dev.IsValidUiCookie() ? dev.UiCookie() : EBTUiCookieUndefined; + return (cookie & EBTUiCookieJustWorksPaired ); + } + // Pairing in other mode than Just Works are always user-aware: + return IsPaired( dev ); +} + +#endif /*BTENGUTIL_H*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/btotgpairpub.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btotgpairpub.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2006 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: Implements getting/setting outgoing pair status +* from/to P&S KBTOutgoingPairing from btengprivatepskeys.h. +* +*/ + +#include "btengprivatepskeys.h" +#include + +// ---------------------------------------------------------- +// Get outgoing pair status from PS +// ---------------------------------------------------------- +// +inline void OutgoPairingProperty(RProperty& aProperty, + TBTDevAddr& aAddr, TBTOutgoingPairMode& aMode) + { + TBuf8 propDes; + TInt err = aProperty.Get( propDes ); + if ( !err && propDes.Length() == sizeof( TBTOutgoingPairProperty ) ) + { + TBTOutgoingPairProperty prop; + TPckgC tmpPckg( prop ); + tmpPckg.Set( propDes ); + aAddr = tmpPckg().iAddr; + aMode = tmpPckg().iMode; + } + else + { + aMode = EBTOutgoingPairNone; + } + } + +// ---------------------------------------------------------- +// Get outgoing pair status from PS +// ---------------------------------------------------------- +// +inline void OutgoPairingProperty(TBTDevAddr& aAddr, TBTOutgoingPairMode& aMode) + { + RProperty property; + TInt err = property.Attach( + KPSUidBluetoothEnginePrivateCategory, KBTOutgoingPairing ); + if ( !err ) + { + OutgoPairingProperty( property, aAddr, aMode ); + } + else + { + aMode = EBTOutgoingPairNone; + } + property.Close(); + } + +// ---------------------------------------------------------- +// Tells if another outgoing pairing is ongoing with a device +// other than the specified one. +// ---------------------------------------------------------- +// +inline TBool OtherOutgoPairing( const TBTDevAddr& aAddr ) + { + TBTDevAddr outpaddr; + TBTOutgoingPairMode mode; + OutgoPairingProperty( outpaddr, mode ); + return mode != EBTOutgoingPairNone && outpaddr != aAddr; + } + +// ---------------------------------------------------------- +// Gets the status of outgoing pair with the specified device. +// ---------------------------------------------------------- +// +inline TBTOutgoingPairMode OutgoPairingMode( + RProperty& aProperty, const TBTDevAddr& aAddr ) + { + TBTDevAddr addr; + TBTOutgoingPairMode mode; + OutgoPairingProperty(aProperty, addr, mode ); + return ( addr == aAddr ) ? mode : EBTOutgoingPairNone; + } + +// ---------------------------------------------------------- +// Gets the status of outgoing pair with the specified device. +// ---------------------------------------------------------- +// +inline TBTOutgoingPairMode OutgoPairingMode(const TBTDevAddr& aAddr) + { + TBTDevAddr addr; + TBTOutgoingPairMode mode; + OutgoPairingProperty( addr, mode ); + return ( addr == aAddr ) ? mode : EBTOutgoingPairNone; + } + +// ---------------------------------------------------------- +// publish outgoing pairing status to PS +// ---------------------------------------------------------- +// +inline void SetOutgoPairProperty(RProperty& aProperty, + const TBTDevAddr& aAddr, + TBTOutgoingPairMode aMode ) + { + if ( aMode == EBTOutgoingPairNone ) + { + (void) aProperty.Set( KNullDesC8 ); + return; + } + TPckgBuf tmpPckg; + tmpPckg().iAddr = aAddr; + tmpPckg().iMode = aMode; + (void) aProperty.Set( tmpPckg ); + } + +// ---------------------------------------------------------- +// Locally instantiate a RProperty and Set Outgoing Pair Property +// ---------------------------------------------------------- +// +inline void SetOutgoPairProperty(const TBTDevAddr& aAddr, + TBTOutgoingPairMode aMode ) + { + RProperty property; + TInt err = property.Attach( + KPSUidBluetoothEnginePrivateCategory, KBTOutgoingPairing ); + if ( !err ) + { + SetOutgoPairProperty( property, aAddr, aMode ); + } + property.Close(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2006 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: This file defines logging macros for bteng +* +*/ + + + +#ifndef BTENG_DEBUG_H +#define BTENG_DEBUG_H + + +#include "prjconfig.h" +#include +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else //PRJ_FILE_TRACE +#include +#endif PRJ_FILE_TRACE + + +/** + * Tracing levels definitions. + * This enables tracing of different levels of information. + */ +_LIT( KBTEngLogFile, "btenglog.txt" ); // Log file +_LIT( KBTEngLogDir, "bt" ); // Log file location + + +// Print options: +#define KPRINTERROR 0x00000001 // Print error +#define KPRINTFTRACE 0x00000002 // Print function trace +const TInt KBTEngDebugMask = 0x00000001 | 0x00000002; + + +/** + * Handlers below are used for formatting debug prints, + * to trucate rather than panic the caller. + */ +NONSHARABLE_CLASS( TBTEngOverflowTruncate8 ) : public TDes8Overflow + { +public: + void Overflow( TDes8& /*aDes*/ ) {} + }; + + +NONSHARABLE_CLASS( TBTEngOverflowTruncate16 ) : public TDes16Overflow + { +public: + void Overflow( TDes16& /*aDes*/ ) {} + }; + + +inline void DebugPrint( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat( KBTEngLogDir, KBTEngLogFile, EFileLoggingModeAppend, aFmt, list); +#ifdef MEMTRACE + TInt size; + User::Heap().AllocSize( size ); + RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[BTEng]\t Memory usage: %d; high: %d" ), size, User::Heap().Size() ); +#endif // MEMTRACE +#else // PRJ_FILE_TRACE + TBuf8<0x100> logString; + TBTEngOverflowTruncate8 overflow; + logString.AppendFormatList( aFmt, list, &overflow ); + TBuf16<0x100> buf16; + buf16.Copy( logString ); + TRefByValue tmpFmt( _L( "%S" ) ); + RDebug::Print( tmpFmt, &buf16 ); +#endif // PRJ_FILE_TRACE + } + + +inline void DebugPrint( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat( KBTEngLogDir, KBTEngLogFile, EFileLoggingModeAppend, aFmt, list ); +#ifdef MEMTRACE + TInt size; + User::Heap().AllocSize( size ); + RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[BTEng]\t Memory usage: %d; high: %d" ), size, User::Heap().Size() ); +#endif // MEMTRACE +#else // PRJ_FILE_TRACE + TBuf16<0x100> logString; + TBTEngOverflowTruncate16 overflow; + logString.AppendFormatList( aFmt, list, &overflow ); + RDebug::Print( logString ); +#endif // PRJ_FILE_TRACE + } + + +inline TBuf8<0x100> DebugFormat( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); + TBuf<0x100> buf; + TBTEngOverflowTruncate16 overflow; + buf.AppendFormatList( aFmt, list, &overflow ); + TBuf8<0x100> buf8; + buf8.Copy( buf ); + return buf8; + } + + +inline void DebugPrintToHex( const TDesC8& aDes ) + { + for( TInt i = 0; i < aDes.Length(); ++i ) + { + DebugPrint( _L( "[BTENG]\t %02x" ), aDes[i] ); + } + } + +inline void DebugPrintBDAddr(const TBTDevAddr& aAddr) + { + TBuf<16> addrdes; + aAddr.GetReadable(addrdes); + DebugPrint(_L("[BTENG]\t BD addr %S") , &addrdes); + } + +_LIT( KTracePrefix, "[BTENG]\t " ); +_LIT8( KFuncEntryFormat8, "[BTENG]\t %S >>" ); +_LIT8( KFuncEntryArgFormat8, "[BTENG]\t %S >> %S" ); +_LIT8( KFuncExitFormat8, "[BTENG]\t %S <<" ); +_LIT8( KFuncExitResFormat8, "[BTENG]\t %S << %S" ); + + +#define TRACE_INFO( a ) { if( KBTEngDebugMask & KPRINTFTRACE ) DebugPrint a; } + +#define TRACE_ERROR( a ) { if( KBTEngDebugMask & KPRINTERROR ) DebugPrint a; } + +#define TRACE_FUNC_ENTRY { if( KBTEngDebugMask & KPRINTFTRACE ) { \ + TPtrC8 ptr( (TUint8*) __PRETTY_FUNCTION__ ); \ + DebugPrint( KFuncEntryFormat8, &ptr ); } } + + +#define TRACE_FUNC_EXIT { if( KBTEngDebugMask & KPRINTFTRACE ) { \ + TPtrC8 ptr( (TUint8*) __PRETTY_FUNCTION__ ); \ + DebugPrint( KFuncExitFormat8, &ptr ); } } + + +#define TRACE_FUNC_ARG( a ) { if( KBTEngDebugMask & KPRINTFTRACE ) { \ + TPtrC8 func( (TUint8*) __PRETTY_FUNCTION__ ); \ + TPtrC8 arg( DebugFormat a ); \ + DebugPrint( KFuncEntryArgFormat8, &func, &arg ); } } + + +#define TRACE_FUNC_RES( a ) { if( KBTEngDebugMask & KPRINTFTRACE ) { \ + TPtrC8 func( (TUint8*) __PRETTY_FUNCTION__ ); \ + TPtrC8 res( DebugFormat a ); \ + DebugPrint( KFuncExitResFormat8, &func, &res ); } } + +#define TRACE_BDADDR( a ) { if( KBTEngDebugMask & KPRINTFTRACE ) DebugPrintBDAddr(a); } + +#else // PRJ_ENABLE_TRACE + +#define TRACE_INFO( a ) + +#define TRACE_ERROR( a ) + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_FUNC_ARG( a ) + +#define TRACE_FUNC_RES( a ) + +#define TRACE_BDADDR( a ) + +#endif // PRJ_ENABLE_TRACE + +#endif // BTENG_DEBUG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006 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: Debug configuration file. +* +*/ + + +#ifndef BTENG_DEBUGCONFIG_H +#define BTENG_DEBUGCONFIG_H + + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT( KLogFile, "bteng.txt" ); +_LIT( KLogDir, "bteng" ); +#endif + + +#ifdef PRJ_ENABLE_TRACE +_LIT( KTracePrefix16, "[BTEng] " ); +_LIT8( KTracePrefix8, "[BTEng] " ); +_LIT8( KFuncFormat8, "><%S" ); +_LIT8( KFuncThisFormat8, "><%S, [0x%08X]" ); +_LIT8( KFuncEntryFormat8, ">%S" ); +_LIT8( KFuncEntryThisFormat8, ">%S, [0x%08X]" ); +_LIT8( KFuncExitFormat8, "<%S" ); + +_LIT( KPanicCategory, "BT Engine" ); +_LIT8( KPanicPrefix8, "PANIC code " ); +_LIT8( KLeavePrefix8, "LEAVE code " ); +#endif + +#endif // BTENG_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef BTENG_PRJCONFIG_H +#define BTENG_PRJCONFIG_H + + +/** + * Traces are enabled via RDebug::Print() in UDEB build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * Traces will be written to file if this is defined. + */ +//#define PRJ_FILE_TRACE + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + +#endif // BTENG_PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/rom/bteng.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/rom/bteng.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2003-2006 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: Image description file for project bteng +* +*/ + + +#ifndef BTENG_IBY +#define BTENG_IBY + +#include + +#ifdef __BT +file=ABI_DIR\BUILD_DIR\btengsrv.exe PROGRAMS_DIR\btengsrv.exe +file=ABI_DIR\BUILD_DIR\bttoggle.exe PROGRAMS_DIR\bttoggle.exe +file=ABI_DIR\BUILD_DIR\btengconnman.dll SHARED_LIB_DIR\btengconnman.dll +file=ABI_DIR\BUILD_DIR\btengdevman.dll SHARED_LIB_DIR\btengdevman.dll +file=ABI_DIR\BUILD_DIR\btengdiscovery.dll SHARED_LIB_DIR\btengdiscovery.dll +file=ABI_DIR\BUILD_DIR\btfeatures.dll SHARED_LIB_DIR\btfeatures.dll +file=ABI_DIR\BUILD_DIR\btengsettings.dll SHARED_LIB_DIR\btengsettings.dll +data=ZPRIVATE\10005950\backup_registration.xml private\10005950\backup_registration.xml +data=ZPRIVATE\10003A3F\APPS\bttoggle_reg.rsc Private\10003a3f\apps\bttoggle_reg.rsc + +data=DATAZ_\RESOURCE_FILES_DIR\btengsdp.rsc RESOURCE_FILES_DIR\btengsdp.rsc +data=DATAZ_\RESOURCE_FILES_DIR\btrfs.txt RESOURCE_FILES_DIR\btrfs.txt + +ECOM_PLUGIN( btbearer.dll, btbearer.rsc ) +ECOM_PLUGIN( btrfsplugin.dll, btrfsplugin.rsc ) +ECOM_PLUGIN( btpsmplugin.dll, btpsmplugin.rsc ) + +#endif // __BT + +#endif // BTENG_IBY diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2006 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: Active object helper class. +* +*/ + + + +#include + +#include "btengactive.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngActive::CBTEngActive( MBTEngActiveObserver& aObserver, TInt aId, + TInt aPriority ) +: CActive( aPriority ), + iRequestId( aId ), + iObserver( aObserver ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngActive::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +CBTEngActive* CBTEngActive::NewL( MBTEngActiveObserver& aObserver, + TInt aId, TInt aPriority ) + { + CBTEngActive* self = new( ELeave ) CBTEngActive( aObserver, aId, aPriority ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngActive::~CBTEngActive() + { + Cancel(); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been cancelled. +// --------------------------------------------------------------------------- +// +void CBTEngActive::DoCancel() + { + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been completed. +// --------------------------------------------------------------------------- +// +void CBTEngActive::RunL() + { + iObserver.RequestCompletedL( this, iRequestId, iStatus.Int() ); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when an error in RunL has occurred. +// --------------------------------------------------------------------------- +// +TInt CBTEngActive::RunError( TInt aError ) + { + iObserver.HandleError( this, iRequestId, aError ); + return KErrNone; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengclient.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2006 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: Client-side implementation of BTEng +* +*/ + + + +#include +#include + +#include "btengclient.h" +#include "debug.h" + +/** Number of retries for connecting to BTEng server side */ +const TInt KBTEngConnectAttempts = 3; + + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// ?description +// --------------------------------------------------------------------------- +// +TInt ClientStart() + { + TRACE_FUNC_ENTRY + const TUidType serverUid( KNullUid, KNullUid, KBTEngServerUid3 ); + // Create a new server process. Simultaneous launching of two processes + // should be detected when the second one attempts to create the server + // object, failing with KErrAlreadyExists. + RProcess server; + TInt err = server.Create( KBTEngServerName, KNullDesC, serverUid ); + if( err != KErrNone ) + { + TRACE_INFO( ( _L( "[BTEng]\t Server process creation failed %d" ), err ) ); + return err; + } + TRequestStatus status; + server.Rendezvous( status ); + if( status != KRequestPending ) + { + TRACE_INFO( ( _L( "[BTEng]\t wrong status (%d), kill process"), + status.Int() ) ) + server.Kill( KErrCancel ); // Abort startup + } + else + { + TRACE_INFO( ( _L( "[BTEng]\t Server process launched") ) ) + server.Resume(); + } + User::WaitForRequest( status ); // Wait for start or death + err = status.Int(); + if( server.ExitType() == EExitPanic ) + { + // The server actually panicked; inform the client. + err = KErrDied; + } + server.Close(); + TRACE_FUNC_RES( ( _L( "result %d" ), err ) ) + return err; + } + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +RBTEng::RBTEng() +: RSessionBase() + { + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::Connect() + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + for( TInt i = 0; i < KBTEngConnectAttempts; i++ ) + { + err = CreateSession( KBTEngServerName, Version() ); + if( err == KErrNone ) + { + break; // Success + } + else if( err == KErrNotFound || err == KErrServerTerminated ) + { + // Session could not be created, + // first the server needs to be started. + err = ClientStart(); + } + if( err != KErrNone && err != KErrAlreadyExists ) + { + // If the server cannot be started for other reasons than + // KErrAlreadyExists, give up... + break; + } + } + TRACE_FUNC_RES( ( _L("result %d"), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TVersion RBTEng::Version() + { + return TVersion( KBTEngServerVersionMajor, KBTEngServerVersionMinor, + KBTEngServerVersionBuild ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::SetPowerState( const TBTPowerStateValue aState, const TBool aTemp ) + { + return SendReceive( EBTEngSetPowerState, TIpcArgs( aState, aTemp ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::SetVisibilityMode( const TBTVisibilityMode aMode, const TInt aTime ) + { + return SendReceive( EBTEngSetVisibilityMode, TIpcArgs( aMode, aTime ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::ConnectDevice( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ) + { + TRACE_BDADDR(aAddr); + TBTDevAddrPckgBuf addrPkg( aAddr ); + TBTEngDevClassPkg codPkg( aDeviceClass.DeviceClass() ); + return SendReceive( EBTEngConnectDevice, TIpcArgs( &addrPkg, &codPkg ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::CancelConnectDevice( const TBTDevAddr& aAddr ) + { + TRACE_BDADDR(aAddr); + TBTDevAddrPckgBuf addrPkg( aAddr ); + return SendReceive( EBTEngCancelConnectDevice, TIpcArgs( &addrPkg ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::DisconnectDevice( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ) + { + TRACE_BDADDR(aAddr); + TBTDevAddrPckgBuf addrPkg( aAddr ); + TBTEngParamPkg discPkg( aDiscType ); + return SendReceive( EBTEngDisconnectDevice, TIpcArgs( &addrPkg, &discPkg ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::IsDeviceConnected( const TBTDevAddr& aAddr, + TBTEngConnectionStatus& aConnected ) + { + TRACE_BDADDR(aAddr); + TBTDevAddrPckgBuf addrPkg( aAddr ); + TBTEngParamPkg connPkg( aConnected ); + TInt err = SendReceive( EBTEngIsDeviceConnected, TIpcArgs( &addrPkg, &connPkg ) ); + aConnected = (TBTEngConnectionStatus) connPkg(); + return err; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::IsDeviceConnectable( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ) + { + TRACE_BDADDR(aAddr); + TBTDevAddrPckgBuf addrPkg( aAddr ); + TBTEngDevClassPkg codPkg( aDeviceClass.DeviceClass() ); + TBTEngParamPkg connPkg( aConnectable ); + TInt err = SendReceive( EBTEngIsDeviceConnectable, TIpcArgs( &addrPkg, &codPkg, &connPkg ) ); + aConnectable = connPkg(); + return err; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::GetConnectedAddresses( TDes8& aArrayPkg, TBTEngParamPkg& aProfilePkg ) + { + return SendReceive( EBTEngGetConnectedAddresses, + TIpcArgs( &aArrayPkg, &aProfilePkg ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::NotifyConnectionEvents( TDes8& aEvent, TRequestStatus& aStatus ) + { + // Use the third slot for the event package. + SendReceive( EBTEngNotifyConnectionEvents, + TIpcArgs( NULL, NULL, &aEvent ), aStatus ); + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::CancelNotifyConnectionEvents() + { + return SendReceive( EBTEngCancelEventNotifier, TIpcArgs() ); + } + + +// --------------------------------------------------------------------------- +// Set a pairing observer in BTEngine. +// --------------------------------------------------------------------------- +// +TInt RBTEng::SetPairingObserver( const TBTDevAddr& aAddr, TBool aActivate ) + { + TBTDevAddrPckgBuf addrPkg( aAddr ); + return SendReceive( EBTEngSetPairingObserver, TIpcArgs( &addrPkg, aActivate ) ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt RBTEng::PrepareDiscovery() + { + return SendReceive( EBTEngPrepareDiscovery, TIpcArgs() ); + } + +// --------------------------------------------------------------------------- +// Start to pair a device in BTEngine. +// --------------------------------------------------------------------------- +// +void RBTEng::PairDevice( const TBTDevAddrPckgBuf& aAddr, + const TUint32& aDeviceClass, TRequestStatus& aStatus ) + { + SendReceive( EBTEngPairDevice, TIpcArgs( &aAddr, aDeviceClass ), aStatus ); + } + +// --------------------------------------------------------------------------- +// cancel pairing request +// --------------------------------------------------------------------------- +// +void RBTEng::CancelPairDevice( ) + { + (void) SendReceive( EBTEngCancelPairDevice); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengincpair.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengincpair.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,357 @@ +/* +* Copyright (c) 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: BT determines pairing status +* +*/ + +#include "btengincpair.h" +#include "btengpairman.h" +#include "btengotgpair.h" +#include "btengconstants.h" +#include "debug.h" + +const TInt KBTEngWaitingForPairingOkDelay = 500000; // 0.5s + +enum TPairingStageId + { + /** + * is monitoring physical link status + */ + EPhysicalLinkNotify = EDevicePairUserNotification + 1, + EWaitingForPairingOk, + }; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngIncPair::CBTEngIncPair( CBTEngPairMan& aParent, + const TBTDevAddr& aAddr) : CBTEngPairBase( aParent, aAddr ) + { + } + +// --------------------------------------------------------------------------- +// 2nd phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::ConstructL() + { + BaseConstructL(); + iActivePairingOk = CBTEngActive::NewL(*this, EWaitingForPairingOk, CActive::EPriorityStandard); + User::LeaveIfError( iPairingOkTimer.CreateLocal() ); + } + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngIncPair* CBTEngIncPair::NewL( CBTEngPairMan& aParent, + const TBTDevAddr& aAddr) + { + CBTEngIncPair* self = new (ELeave) CBTEngIncPair(aParent, aAddr); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngIncPair::~CBTEngIncPair() + { + TRACE_FUNC_ENTRY + // Cancel all outstanding requests + CancelPlaNotification(); + iPla.Close(); + iPairingOkTimer.Cancel(); + iPairingOkTimer.Close(); + iActivePairingOk->CancelRequest(); + delete iActivePairingOk; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Accept this message only if the specified device is the same as this is +// dealing with. +// --------------------------------------------------------------------------- +// +TInt CBTEngIncPair::ObserveIncomingPair( const TBTDevAddr& aAddr ) + { + TInt err( KErrServerBusy ); + if ( iAddr == aAddr ) + { + err = KErrNone; + if ( !iActive->IsActive() && !OpenPhysicalLinkAdaptor() ) + { + // If we are observing physical link, or showing user a note, + // we won't interrupt it. + UnSetPairResult(); + MonitorPhysicalLink(); + } + } + return err; + } + +// --------------------------------------------------------------------------- +// Assign the responsibility of outgoing pair handling to CBTEngOtgPair +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) + { + TRACE_FUNC_ENTRY + // Outgoing pairing always takes highest priority: + CBTEngPairBase* pairer = CBTEngOtgPair::NewL( iParent, aAddr ); + pairer->HandleOutgoingPairL( aAddr, aCod ); + iParent.RenewPairer( pairer ); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Accept this message only if the specified device is the same as this is +// dealing with. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::StopPairHandling( const TBTDevAddr& aAddr ) + { + if ( aAddr == iAddr ) + { + TRACE_FUNC_ENTRY + iParent.RenewPairer( NULL ); + TRACE_FUNC_EXIT + } + } + +// --------------------------------------------------------------------------- +// Notify user if pairing failed. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::DoHandlePairServerResult( TInt aResult ) + { + CancelPlaNotification(); + // For a successful pairing, we need wait for registry table change. + if( aResult != KErrNone && aResult != KHCIErrorBase ) + { + // Pair failure situation. + SetPairResult( aResult ); + ShowPairingNoteAndAuthorizeQuery(); + } + } + +// --------------------------------------------------------------------------- +// Kill this if the linkkey type indicates OBEX authentication. +// Otherwise notify user the pair result. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) + { + TRACE_FUNC_ENTRY + + // First of all cancel the iPairingOkTimer timer, if active + if (iActivePairingOk->IsActive()) + { + iPairingOkTimer.Cancel(); + iActivePairingOk->CancelRequest(); + UnSetPairResult(); // we might have set it before (if the link went down) so we want to reset it. + } + switch ( aDev.LinkKeyType() ) + { + case ELinkKeyUnauthenticatedNonUpgradable: + { + // If an application uses btengconnman API to connect a service of + // this device and JW pairing occurred as part of security enforcement, + // it shall be a user aware pairing, and we shall add this device in paired + // view. In this way, user is able to disconnect the device from our UI. + // Otherwise the link key has been created by a device without IO requesting + // a service connection with phone. We won't take any action (e.g. remove + // link key) in this case. As the result, this device can't be seen in our UI, + // however other applications are still freely to use its services. + TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with no IO device" ) ) + TBTEngConnectionStatus status = iParent.IsDeviceConnected( aDev.Address() ); + if ( status == EBTEngConnecting || status == EBTEngConnected ) + { + // the return error is ingore as we can not have other proper + // exception handling option: + (void) iParent.AddUiCookieJustWorksPaired( aDev ); + } + iParent.RenewPairer( NULL ); + break; + } + case ELinkKeyUnauthenticatedUpgradable: + { + // The linkkey has been created by an incoming OBEX service request + // which resulted a pairing event received from pair server. + TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with IO device" ) ) + iParent.RenewPairer( NULL ); + break; + } + default: + { + // Other pairing model than Just Works: + CancelPlaNotification(); + SetPairResult( KErrNone ); + ShowPairingNoteAndAuthorizeQuery(); + break; + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::RequestCompletedL( CBTEngActive* /*aActive*/, TInt aId, TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "aId: %d, aStatus: %d"), aId, aStatus ) ) + // Check which request completed. + switch( aId ) + { + case EPhysicalLinkNotify: + { + // Check if the link has disconnected. + HandlePhysicalLinkResultL( aStatus ); + break; + } + case EDevicePairUserNotification: + { + // the user has been informed of the result, kill this: + TRACE_INFO(_L("[BTENG]:CBTEngIncPair authorization notifier completed") ) + iParent.RenewPairer( NULL ); + break; + } + case EWaitingForPairingOk: + { + // pairing failed, inform user: + if (iPairResult == KErrNone) + { + // iPairResult must have been set as an error. if it's not it means somewhere else + // it has been reset. But we need to have it set to an error as we are notifying + // the "unable to pair" message. + SetPairResult(KErrGeneral); + } + ShowPairingNoteAndAuthorizeQuery(); + break; + } + default: + // Should not be possible, but no need for handling. + TRACE_INFO( (_L("[BTEng]: CBTEngIncPair::RequestCompletedL unhandled event!!") ) ) + break; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Handles a leave in RequestCompleted by simply self-destructing. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::HandleError( CBTEngActive* aActive, TInt aId, TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "request id: %d, error: %d" ), aId, aError ) ) + (void) aActive; + (void) aId; + (void) aError; + // Our error handling is to just stop observing. + // Nothing critical to be preserved herer, the user + // just won't get any notification of pairing result. + iParent.RenewPairer( NULL ); + } + +// --------------------------------------------------------------------------- +// Subscribe to physical link notifications. +// physical link must exist when calling this function. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::MonitorPhysicalLink() + { + TRACE_FUNC_ENTRY + iActive->SetRequestId( EPhysicalLinkNotify ); + // Subscribe to disconnect and error events. + iPla.NotifyNextBasebandChangeEvent( iBbEvent, + iActive->RequestStatus(), + ENotifyPhysicalLinkDown | ENotifyPhysicalLinkError ); + iActive->GoActive(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Opens the adaptor if physical link exists. +// --------------------------------------------------------------------------- +// +TInt CBTEngIncPair::OpenPhysicalLinkAdaptor() + { + TRACE_FUNC_ENTRY + TInt err ( KErrNone ); + if( !iPla.IsOpen() ) + { + // Try to open the adapter in case it failed earlier. + // This can happen for outgoing dedicated bonding with + // non-SSP device, as the PIN dialog can be kept open even + // though the link has dropped because of a time-out. + err = iPla.Open( iParent.SocketServ(), iAddr ); + } + TRACE_INFO( (_L("[BTEng]: CBTEngIncPair::HasPhysicalLink ? %d"), iPla.IsOpen() ) ) + return err; + } + +// --------------------------------------------------------------------------- +// Cancel outstanding physical link notification +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::CancelPlaNotification() + { + TRACE_FUNC_ENTRY + if( iActive && iActive->IsActive() && + iActive->RequestId() == EPhysicalLinkNotify ) + { + // cancel Baseband monitor + iPla.CancelNextBasebandChangeEventNotifier(); + iActive->Cancel(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Handle a physical link event. Notify pair failed if physical link is down. +// --------------------------------------------------------------------------- +// +void CBTEngIncPair::HandlePhysicalLinkResultL( TInt aResult ) + { + TRACE_FUNC_ARG( ( _L( " BBEvent 0x%08X, code %d"), + iBbEvent().EventType(), iBbEvent().SymbianErrorCode() ) ) + // Check if the connection is still alive. + TBool physicalLinkDown = + ( iBbEvent().EventType() == ENotifyPhysicalLinkDown | ENotifyPhysicalLinkError ); + + if( aResult || physicalLinkDown ) + { + // link went down. It might be because of pairing failed or the remote device disconnected the + // physical link after a successful pairing. + // we wait for 0.5 secs before notifying the "unable to pair" message as, if the pair is + // successful, we manage it to show the right confirmation message. + SetPairResult( (aResult == 0) ? KErrGeneral : aResult ); + iPairingOkTimer.After(iActivePairingOk->iStatus, KBTEngWaitingForPairingOkDelay); + iActivePairingOk->GoActive(); + } + else + { + // Uninteresting event, re-subscribe. + MonitorPhysicalLink(); + } + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengotgpair.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengotgpair.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,368 @@ +/* +* Copyright (c) 2006-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: Helper class for performing pairing (i.e. bonding) +* with another device. +* +*/ + +#include "btengotgpair.h" +#include +#include "btengpairman.h" +#include "btotgpairpub.inl" +#include "debug.h" + +enum TPairingStageId + { + /** + * no pairing operation ongoing + */ + ENoBonding = 0, + + /** + * pair with dedicated bonding method + */ + EDedicatedBonding = EDevicePairUserNotification + 1, + + /** + * pair with general bonding by establishing L2CAP connection. + */ + EGeneralBonding, + + /** + * delaying next pairing request for a while + */ + EGeneralBondingRetryTimer, + + /** + * The last pairing retry + */ + EGeneralBondingRetry + }; + +/** SDP PSM (used for pairing) */ +const TInt KSDPPSM = 0x0001; + +// Delay time to void Repeated Attempts on pairing +const TInt KBTEngGeneralBondingRetryDelayMicroSeconds = 5000000; // 5.0s + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngOtgPair::CBTEngOtgPair( CBTEngPairMan& aParent, const TBTDevAddr& aAddr) + : CBTEngPairBase( aParent, aAddr ) + { + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::ConstructL() + { + TRACE_FUNC_ENTRY + BaseConstructL(); + User::LeaveIfError( iOutgoProperty.Attach( KPSUidBluetoothEnginePrivateCategory, + KBTOutgoingPairing ) ); + User::LeaveIfError( iTimer.CreateLocal() ); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngPairBase* CBTEngOtgPair::NewL( CBTEngPairMan& aParent, + const TBTDevAddr& aAddr ) + { + CBTEngOtgPair* self = new( ELeave ) CBTEngOtgPair( aParent, aAddr ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngOtgPair::~CBTEngOtgPair() + { + TRACE_FUNC_ENTRY + SetOutgoPairProperty( iOutgoProperty, TBTDevAddr(), EBTOutgoingPairNone ); + CancelNotifier(); + DoCancelOutgoingPair(); + iBondingSession.Close(); + iSocket.Close(); + iTimer.Close(); + iOutgoProperty.Close(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Simply deny the request as this is handing outgoing pairing +// --------------------------------------------------------------------------- +// +TInt CBTEngOtgPair::ObserveIncomingPair( const TBTDevAddr& /*aAddr*/ ) + { + return KErrServerBusy; + } + +// --------------------------------------------------------------------------- +// Accept the request only this device is not busy with another pairing request. +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) + { + TRACE_FUNC_ARG( ( _L(" cod 0x%08x"), aCod ) ) + if ( iActive->IsActive() || aAddr != iAddr ) + { + // we don't allow another pairing request. + User::Leave( KErrServerBusy ); + } + + iAddr = aAddr; + iCod = aCod; + UnSetPairResult(); + iParent.UnpairDevice( iAddr ); + TBTDeviceClass decls( iCod ); + if ( decls.MajorDeviceClass() == EMajorDeviceAV && + decls.MinorDeviceClass() != EMinorDeviceAVHandsfree ) + { + // If the devie is a headset, set to 0000 pin auto pairing + iPairMode = EBTOutgoingHeadsetAutoPairing; + } + else + { + iPairMode = EBTOutgoingNoneHeadsetPairing; + } + SetOutgoPairProperty( iOutgoProperty, iAddr, iPairMode ); + DoPairingL(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels an outstanding pair request by self-destruct +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::CancelOutgoingPair() + { + TRACE_FUNC_ENTRY + iParent.RenewPairer( NULL ); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Abort pairing handling, request the owner to destroy this. +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::StopPairHandling( const TBTDevAddr& aAddr ) + { + if ( aAddr == iAddr ) + { + TRACE_FUNC_ENTRY + iParent.OutgoingPairCompleted( KErrCancel ); + iParent.RenewPairer( NULL ); + TRACE_FUNC_EXIT + } + } + +// --------------------------------------------------------------------------- +// Pairing result will be received when pairing operation completes. +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::DoHandlePairServerResult( TInt aResult ) + { + if (aResult == (KHCIErrorBase-EPairingNotAllowed)) + { + // if EPairingNotAllowed is recieved then any further pairing attempts will fail + // so don't attampt to pair + iPairMode = EBTOutgoingPairNone; + } + } + +// --------------------------------------------------------------------------- +// Cancels possible outstanding pairing and notify user pair success. +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) + { + TRACE_FUNC_ENTRY + if ( !IsNotifyingPairResult() ) + { + TInt err( KErrNone ); + // If pairing was performed using Just Works mode, we set a + // UICookie to indicate that the device is successfully + // bonded so that this device will be listed in paired device view of + // bluetooth application: + if ( aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable ) + { + TRACE_INFO( ( _L( "[BTENG] CBTEngOtgPair, Just Works pairing" ) ) ); + err = iParent.AddUiCookieJustWorksPaired( aDev ); + } + DoCancelOutgoingPair(); + SetPairResult( err ? err : KErrNone ); + ShowPairingNoteAndAuthorizeQuery(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Based on the result code, decides the next operation, either try pairing +// with another mode, or complete pair request. +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "reqid %d, status: %d, pair mode %d " ), aId, aStatus, iPairMode ) ) + (void) aActive; + (void) aId; + + if ( aId == EDevicePairUserNotification) + { + // user notification completes: + iParent.OutgoingPairCompleted( aStatus ? aStatus : iPairResult ); + iParent.RenewPairer( NULL ); + return; + } + + if( aId == EDedicatedBonding && + ( aStatus == KErrRemoteDeviceIndicatedNoBonding || + ( aStatus && iPairMode != EBTOutgoingNoneHeadsetPairing && iPairMode != EBTOutgoingPairNone ) ) ) + { + // try general pairing if the remote doesn't have dedicated bonding, or + // pairing fails with a headset. + DoPairingL(); + } + else if ( aStatus && iPairMode == EBTOutgoingHeadsetAutoPairing ) + { + iPairMode = EBTOutgoingHeadsetManualPairing; + // auto pairing with headset failed, try to pair again with manual pin: + ( void ) SetOutgoPairProperty( iOutgoProperty, iAddr, iPairMode ); + TRACE_INFO( _L( " auto pairing failed, switch to manual pairing") ); + DoPairingL(); + } + else if ( aStatus && aId == EGeneralBonding && + iPairMode == EBTOutgoingHeadsetManualPairing ) + { + // pairing headset with manual pin failed, wait for a while and try again: + iActive->SetRequestId( EGeneralBondingRetryTimer ); + iTimer.After( iActive->iStatus, KBTEngGeneralBondingRetryDelayMicroSeconds ); + iActive->GoActive(); + } + else if( aId == EGeneralBondingRetryTimer ) + { + // try to pair headset again with manual pin again: + DoPairingL(); + } + else if ( aStatus ) + { + // we only starts showing note if pairing failed. + // For a successful pair, we must wait until registry has been updated. + if ( !IsPairResultSet() ) + { + SetPairResult( aStatus ); + } + if ( aStatus ) + { + ShowPairingNoteAndAuthorizeQuery(); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Handles a leave in RequestCompleted by self-destructing. +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "error: %d" ), aError ) ) + // Our RunL can actually not leave, so we should never reach here. + (void) aActive; + (void) aId; + iParent.OutgoingPairCompleted( aError ); + iParent.RenewPairer( NULL ); + } + +// --------------------------------------------------------------------------- +// decide the next state and issue pair request +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::DoPairingL() + { + TRACE_FUNC_ENTRY + TPairingStageId currentMode = ( TPairingStageId ) iActive->RequestId(); + ASSERT( !iActive->IsActive() ); + TPairingStageId nextMode( EGeneralBonding ); + + // if running BTv2.0 stack, dedicated bonding method + // is not available. + if ( currentMode == ENoBonding && iParent.PairingServer() != NULL ) + { + nextMode = EDedicatedBonding; + } + else if(currentMode == EGeneralBondingRetryTimer) + { + nextMode = EGeneralBondingRetry; + } + + TRACE_INFO( ( _L( "[BTENG] CBTEngOtgPair::DoPairingL: bonding mode: pre %d, next %d"), currentMode, nextMode ) ); + + iActive->SetRequestId( nextMode ); + if ( nextMode == EDedicatedBonding ) + { + iBondingSession.Start( *iParent.PairingServer(), iAddr, iActive->RequestStatus() ); + } + else + { + TBTServiceSecurity sec; + sec.SetAuthentication( ETrue ); + iSockAddr.SetBTAddr( iAddr ); + iSockAddr.SetPort(KSDPPSM); + iSockAddr.SetSecurity( sec ); + iSocket.Close(); + User::LeaveIfError( iSocket.Open( iParent.SocketServ(), KL2CAPDesC ) ); + iSocket.Connect( iSockAddr, iActive->RequestStatus() ); + } + iActive->GoActive(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Make sure no outstanding pairing request is existing +// --------------------------------------------------------------------------- +// +void CBTEngOtgPair::DoCancelOutgoingPair() + { + TRACE_FUNC_ENTRY + if( iActive->IsActive() ) + { + iBondingSession.Close(); + if( iSocket.SubSessionHandle() ) + { + iSocket.CancelConnect(); + iSocket.Close(); + } + iTimer.Cancel(); + iActive->CancelRequest(); + } + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengpairbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengpairbase.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 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: the base class of pairing handling +* +*/ + +#include "btengpairman.h" +#include "btengpairbase.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngPairBase::CBTEngPairBase( CBTEngPairMan& aParent, const TBTDevAddr& aAddr) + : iAddr( aAddr ), iParent( aParent ) + { + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::BaseConstructL( ) + { + iActive = CBTEngActive::NewL(*this, 0, CActive::EPriorityStandard); + TRACE_BDADDR( iAddr ); + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngPairBase::~CBTEngPairBase() + { + CancelNotifier(); + iNotifier.Close(); + delete iActive; + } + +// --------------------------------------------------------------------------- +// Message passes through only if the result is for the same device this +// object is for. +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::HandlePairServerResult( const TBTDevAddr& aAddr, TInt aResult ) + { + if ( aAddr == iAddr ) + { + TRACE_FUNC_ENTRY + DoHandlePairServerResult( aResult ); + TRACE_FUNC_EXIT + } + } + +// --------------------------------------------------------------------------- +// Message passes through only if the result is for the same device this +// object is for. +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::HandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ) + { + if ( aDev.Address() == iAddr ) + { + TRACE_FUNC_ENTRY + DoHandleRegistryNewPairedEvent( aDev ); + TRACE_FUNC_EXIT + } + } + +// --------------------------------------------------------------------------- +// Default impl of virtual function. do nothing +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::CancelOutgoingPair() + { + } + +// --------------------------------------------------------------------------- +// Cancel outstanding notifier +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::CancelNotifier() + { + if( iActive && iActive->IsActive() && + iActive->RequestId() == EDevicePairUserNotification ) + { + TRACE_FUNC_ENTRY + iNotifier.CancelNotifier( KBTPairedDeviceSettingNotifierUid ); + iActive->Cancel(); + TRACE_FUNC_EXIT + } + } + +// --------------------------------------------------------------------------- +// Show the pairing result and ask the user to authorize the device. +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::ShowPairingNoteAndAuthorizeQuery() + { + TRACE_FUNC_ENTRY + if ( iActive->IsActive() ) + { + // In profress of showing note, won't interrupt it: + return; + } + TInt err ( KErrNone ); + if (!iNotifier.Handle()) + { + err = iNotifier.Connect(); + } + if ( !err ) + { + // Inform the user of the pairing status. + iActive->SetRequestId( EDevicePairUserNotification ); + iAuthoPckg().iPairingStatus = iPairResult; + iAuthoPckg().iRemoteAddr = iAddr; + iNotifier.StartNotifierAndGetResponse( iActive->RequestStatus(), + KBTPairedDeviceSettingNotifierUid, + iAuthoPckg, iAuthoPckg ); + iActive->GoActive(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Invalidate iPairResultSet +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::UnSetPairResult() + { + iPairResultSet = EFalse; + } + +// --------------------------------------------------------------------------- +// Save the result and validate the flag +// --------------------------------------------------------------------------- +// +void CBTEngPairBase::SetPairResult( TInt aResult ) + { + iPairResult = aResult; + iPairResultSet = ETrue; + } + +// --------------------------------------------------------------------------- +// Returns the flag +// --------------------------------------------------------------------------- +// +TBool CBTEngPairBase::IsPairResultSet() + { + return iPairResultSet; + } + +// --------------------------------------------------------------------------- +// check AO validity and its request information +// --------------------------------------------------------------------------- +// +TBool CBTEngPairBase::IsNotifyingPairResult() + { + return iActive && iActive->IsActive() && + iActive->RequestId() == EDevicePairUserNotification ; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengpairman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengpairman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,733 @@ +/* +* Copyright (c) 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: Pairing result receiver in Bluetooth engine subsystem +* +*/ + +#include "btengpairman.h" +#include "btengserver.h" +#include "btengsrvsession.h" +#include "btengotgpair.h" +#include "btengincpair.h" +#include "btengclientserver.h" +#include "debug.h" +#include + +/** Identification for active object */ +enum TPairManActiveRequestId + { + ESimplePairingResult, + EAuthenticationResult, + ERegistryInitiatePairedDevicesView, + ERegistryPairedDevicesNewView, + ERegistryInitiatePairedDevicesList, + ERegistryGetPairedDevices, + }; + +/** The message argument which holds the Bluetooth address. */ +const TInt KBTEngAddrSlot = 0; + +// --------------------------------------------------------------------------- +// Tells if two TBTNamelessDevice instances are for the same remote device +// --------------------------------------------------------------------------- +// +TBool CompareDeviceByAddress( const TBTNamelessDevice& aDevA, const TBTNamelessDevice& aDevB ) + { + return aDevA.Address() == aDevB.Address(); + } + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngPairMan::CBTEngPairMan( CBTEngServer& aServer ) + : iServer( aServer ) + { + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::ConstructL() + { + TRACE_FUNC_ENTRY + // Connect to pairing server for authentication & simple pairing + // results directly from the BT stack. + // Pairing server doesn't exist if we run BT 2.0 stack: + iPairingServ = new (ELeave) RBluetoothPairingServer; + TInt err = iPairingServ->Connect(); + if ( err) + { + delete iPairingServ; + iPairingServ = NULL; + } + else + { + User::LeaveIfError( iPairingResult.Open( *iPairingServ ) ); + User::LeaveIfError( iAuthenResult.Open( *iPairingServ ) ); + iSSPResultActive = CBTEngActive::NewL( *this, ESimplePairingResult, CActive::EPriorityStandard ); + iAuthenResultActive = CBTEngActive::NewL( *this, EAuthenticationResult, CActive::EPriorityStandard ); + SubscribeSspPairingResult(); + SubscribeAuthenticateResult(); + } + + // connect to registry + User::LeaveIfError( iBTRegistry.Open( BTRegServ() ) ); + iRegistryActive = CBTEngActive::NewL( *this, ERegistryInitiatePairedDevicesView, CActive::EPriorityStandard ); + // Start to get the list of all paired devices. + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + iPairedDevices = new (ELeave) RArray; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngPairMan* CBTEngPairMan::NewL( CBTEngServer& aServer ) + { + CBTEngPairMan* self = NULL; + self = new CBTEngPairMan( aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngPairMan::~CBTEngPairMan() + { + TRACE_FUNC_ENTRY + CancelSubscribe(); + delete iSSPResultActive; + delete iAuthenResultActive; + delete iRegistryActive; + delete iPairedDevicesResp; + delete iPairer; + if ( iPairedDevices ) + { + iPairedDevices->Close(); + delete iPairedDevices; + } + iBTRegistry.Close(); + iPairingResult.Close(); + iAuthenResult.Close(); + if ( iPairingServ ) + { + iPairingServ->Close(); + delete iPairingServ; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Handles pairing related commands from BTEng clients. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::ProcessCommandL( const RMessage2& aMessage ) + { + TRACE_FUNC_ENTRY + TInt opcode = aMessage.Function(); + TBTDevAddrPckgBuf addrPkg; + switch( opcode ) + { + case EBTEngSetPairingObserver: + { + aMessage.ReadL( KBTEngAddrSlot, addrPkg ); + SetPairObserver( addrPkg(), aMessage.Int1() ); + break; + } + case EBTEngPairDevice: + { + TBTDevAddrPckgBuf addrPkg; + aMessage.ReadL( KBTEngAddrSlot, addrPkg ); + PairDeviceL( addrPkg(), aMessage.Int1() ); + break; + } + case EBTEngCancelPairDevice: + { + CancelCommand( opcode ); + break; + } + default: + { + TRACE_INFO( ( _L( "CBTEngPairMan ProcessCommandL: bad request (%d)" ), + aMessage.Function() ) ) + User::Leave( KErrArgument ); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels outgoing pairing requests +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::CancelCommand( TInt aOpCode ) + { + switch( aOpCode ) + { + case EBTEngPairDevice: + { + TRACE_FUNC_ENTRY + if ( iPairer ) + { + iPairer->CancelOutgoingPair(); + } + TRACE_FUNC_EXIT + break; + } + } + } + +// --------------------------------------------------------------------------- +// Handle a change in BTRegistry remote devices table. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::RemoteRegistryChangeDetected() + { + if ( !iRegistryActive->IsActive() ) + { + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else + { + iNotHandledRegEventCounter++; + } + } + +// --------------------------------------------------------------------------- +// Returns the RBluetoothPairingServer instance. +// --------------------------------------------------------------------------- +// +RBluetoothPairingServer* CBTEngPairMan::PairingServer() + { + return iPairingServ; + } + +// --------------------------------------------------------------------------- +// Access the reference of RSockServ +// --------------------------------------------------------------------------- +// +RSocketServ& CBTEngPairMan::SocketServ() + { + return iServer.SocketServ(); + } + +// --------------------------------------------------------------------------- +// Access the reference of RBTRegSrv +// --------------------------------------------------------------------------- +// +RBTRegServ& CBTEngPairMan::BTRegServ() + { + return iServer.BTRegServ(); + } + +// --------------------------------------------------------------------------- +// Deletes the current pairing handler and transfer the responsibility +// to the specified. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::RenewPairer( CBTEngPairBase* aPairer ) + { + delete iPairer; + iPairer = aPairer; + } + +// --------------------------------------------------------------------------- +// Find the session who requested this and completes its request. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::OutgoingPairCompleted( TInt aErr ) + { + TRACE_FUNC_ENTRY + // the meaning of KHCIErrorBase equals KErrNone. Hide this specific BT stack + // detail from clients: + if ( aErr == KHCIErrorBase ) + { + aErr = KErrNone; + } + // we must complete client's pairing request: + iServer.iSessionIter.SetToLast(); + CBTEngSrvSession* session = (CBTEngSrvSession*) iServer.iSessionIter--; + TInt ret( KErrNotFound ); + while( session && ret ) + { + ret = session->CompletePairRequest( aErr ); + session = (CBTEngSrvSession*) iServer.iSessionIter--; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Unpair the device from registry +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::UnpairDevice( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + TIdentityRelation addrComp( CompareDeviceByAddress ); + TBTNamelessDevice dev; + dev.SetAddress( aAddr ); + // only do unpairing if the we have a link key with it. + TInt index = iPairedDevices->Find( dev, addrComp ); + if ( index > KErrNotFound ) + { + dev = (*iPairedDevices)[index]; + TBTDeviceSecurity security = dev.GlobalSecurity(); + // Clear trust setting so that correct icon will be shown in ui applications. + security.SetNoAuthenticate(EFalse ); + security.SetNoAuthorise(EFalse ); + dev.SetGlobalSecurity(security); + dev.DeleteLinkKey(); + if ( dev.IsValidUiCookie() && + ( dev.UiCookie() & EBTUiCookieJustWorksPaired ) ) + { + // Remove the UI cookie bit for Just Works pairing. + TInt32 cookie = dev.UiCookie() & ~EBTUiCookieJustWorksPaired; + dev.SetUiCookie( cookie ); + TRACE_INFO( ( _L( "UI cookie %x cleared"), EBTUiCookieJustWorksPaired ) ); + } + // modify the device in registry synchronously + // status.Int() could be -1 if the device is not in registry + // which is totally fine for us. + (void) UpdateRegDevice( dev ); + } + TRACE_FUNC_EXIT + } + +TInt CBTEngPairMan::AddUiCookieJustWorksPaired( const TBTNamelessDevice& aDev ) + { + TInt err( KErrNone ); + // There might be UI cookies used by other applications, + // we should not overwrite them. + TInt32 cookie = aDev.IsValidUiCookie() ? aDev.UiCookie() : EBTUiCookieUndefined; + if ( !( cookie & EBTUiCookieJustWorksPaired ) ) + { + // Only update the cookie if the wanted one is not in registry yet + // to keep minimal operations with registry. + TBTNamelessDevice dev = aDev; + cookie |= EBTUiCookieJustWorksPaired; + dev.SetUiCookie( cookie ); + err = UpdateRegDevice( dev ); + TRACE_INFO( ( _L( "[BTENG] CBTEngOtgPair write Ui cookie ret %d"), err ) ); + } + return err; + } + +// --------------------------------------------------------------------------- +// update a nameless device in registry +// --------------------------------------------------------------------------- +// +TInt CBTEngPairMan::UpdateRegDevice( const TBTNamelessDevice& aDev ) + { + TRequestStatus status( KRequestPending ); + // update the device in registry synchronously + iBTRegistry.ModifyDevice( aDev, status ); + User::WaitForRequest( status ); + TRACE_INFO( ( _L( "UpdateRegDevice, ret %d"), status.Int() ) ) + return status.Int(); + } + +// --------------------------------------------------------------------------- +// Ask server class the connection status of the specified device +// --------------------------------------------------------------------------- +// +TBTEngConnectionStatus CBTEngPairMan::IsDeviceConnected( const TBTDevAddr& aAddr ) + { + return iServer.IsDeviceConnected( aAddr ); + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Checks if there is an authentication result. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::RequestCompletedL( CBTEngActive* /*aActive*/, TInt aId, TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "aId: %d, aStatus: %d"), aId, aStatus ) ) + // Check which request completed. + switch( aId ) + { + case ESimplePairingResult: + { + TBTDevAddr tmpAddr = iSimplePairingRemote; + if (aStatus != KErrServerTerminated) + { + SubscribeSspPairingResult(); + } + HandlePairingResultL( tmpAddr, aStatus ); + break; + } + case EAuthenticationResult: + { + TBTDevAddr tmpAddr = iAuthenticateRemote; + if (aStatus != KErrServerTerminated) + { + SubscribeAuthenticateResult(); + } + HandlePairingResultL( tmpAddr, aStatus ); + break; + } + case ERegistryInitiatePairedDevicesView: + case ERegistryPairedDevicesNewView: + { + HandleCreatePairedDevicesViewCompletedL( aStatus, aId ); + break; + } + case ERegistryInitiatePairedDevicesList: + case ERegistryGetPairedDevices: + { + HandleGetPairedDevicesCompletedL( aStatus, aId ); + break; + } + default: + // Should not be possible, but no need for handling. + TRACE_INFO( (_L("[BTEng]: CBTEngPairMan::RequestCompletedL unhandled event!!") ) ) + break; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::HandleError( CBTEngActive* aActive, TInt aId, TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "request id: %d, error: %d" ), aId, aError ) ) + (void) aActive; + (void) aError; + if ( aId == ERegistryInitiatePairedDevicesList || + aId == ERegistryGetPairedDevices ) + {// leave happened in registry operation, delete registry response: + delete iPairedDevicesResp; + iPairedDevicesResp = NULL; + } + } + +// --------------------------------------------------------------------------- +// Activate or deactivate a pairing handler +// --------------------------------------------------------------------------- +// +TInt CBTEngPairMan::SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate) + { + TRACE_FUNC_ARG( ( _L( "%d" ), aActivate ) ) + TRACE_BDADDR( aAddr ) + TInt err( KErrNone ); + if ( !aActivate ) + { + if ( iPairer ) + { + iPairer->StopPairHandling( aAddr ); + } + return err; + } + + if ( !iPairer) + { + // This is an incoming pair, unpair it from registry and + // create the handler: + UnpairDevice( aAddr ); + TRAP( err, iPairer = CBTEngIncPair::NewL( *this, aAddr )); + } + if ( iPairer) + { + // let the handler decide what to do: + err = iPairer->ObserveIncomingPair( aAddr ); + } + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Delegates the request to current pair handler +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod ) + { + if ( !iPairer) + { + // no existing pair handling, create one: + iPairer = CBTEngOtgPair::NewL( *this, aAddr ); + } + // let pair handler decide what to do: + iPairer->HandleOutgoingPairL( aAddr, aCod ); + } + +// --------------------------------------------------------------------------- +// cancel Subscribings to simple pairing result and authentication result from +// Pairing Server +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::CancelSubscribe() + { + TRACE_FUNC_ENTRY + if( iSSPResultActive && iSSPResultActive->IsActive() ) + { + // Cancel listening Simple pairing result + iPairingResult.CancelSimplePairingResult(); + iSSPResultActive->Cancel(); + } + if( iAuthenResultActive && iAuthenResultActive->IsActive() ) + { + // Cancel listening authentication result + iAuthenResult.CancelAuthenticationResult(); + iAuthenResultActive->Cancel(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Subscribes to simple pairing result from Pairing Server +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::SubscribeSspPairingResult() + { + TRACE_FUNC_ENTRY + iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() ); + iSSPResultActive->GoActive(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Subscribes to authentication result from Pairing Server +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::SubscribeAuthenticateResult() + { + TRACE_FUNC_ENTRY + // Subscribe authentication result (which requires pairing for unpaired devices) + iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() ); + iAuthenResultActive->GoActive(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Handle a pairing result from the pairing server. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::HandlePairingResultL( const TBTDevAddr& aAddr, TInt aResult ) + { + TRACE_FUNC_ARG( (_L("result %d"), aResult ) ) + TRACE_BDADDR( aAddr ); + if ( !iPairer && ( aResult == KErrNone || aResult == KHCIErrorBase ) ) + { + // we only create new handler if incoming pairing succeeds. + // Pairing failure could be caused by user local cancellation, as the + // result, the handler was destroyed by notifier. We shall not + // instantiate the handler again. + // If a pairing failed due to other reasons than user local cancelling, + // it will be catched by the already started handler + // (except Just Works pairing - no handler for it at all until we receive + // registry change event. Thus if incoming JWs pairing failed, no user + // notification will be shown.) + TBTNamelessDevice dev; + dev.SetAddress( aAddr ); + TIdentityRelation addrComp( CompareDeviceByAddress ); + TInt index = iPairedDevices->Find( dev, addrComp ); + + // If the device is not found in the old paired device list, it is a new + // paired device: + if ( index == KErrNotFound) + { + // No handler yet, create incoming pairing handler: + iPairer = CBTEngIncPair::NewL( *this, aAddr ); + } + } + if ( iPairer ) + { + iPairer->HandlePairServerResult( aAddr, aResult ); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// issue creating a bonded devices view +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::CreatePairedDevicesView( TInt aReqId ) + { + TRACE_FUNC_ENTRY + iNotHandledRegEventCounter = 0; + TBTRegistrySearch searchPattern; + searchPattern.FindBonded(); + iRegistryActive->SetRequestId( aReqId ); + iBTRegistry.CreateView( searchPattern, iRegistryActive->iStatus ); + iRegistryActive->GoActive(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// gets the paired devices from the view created by CreatePairedDevicesView +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::GetPairedDevices( TInt aReqId ) + { + TRACE_FUNC_ENTRY + delete iPairedDevicesResp; + iPairedDevicesResp = NULL; + TRAP_IGNORE( iPairedDevicesResp = CBTRegistryResponse::NewL( iBTRegistry ) ); + if ( iPairedDevicesResp ) + { + iRegistryActive->SetRequestId( aReqId ); + iPairedDevicesResp->Start( iRegistryActive->iStatus ); + iRegistryActive->GoActive(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// re-create a paired device view if registry was changed during the previous +// operation. otherwise if the view is not empty, get the paired devices. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::HandleCreatePairedDevicesViewCompletedL( TInt aStatus, TInt aReqId ) + { + TRACE_FUNC_ENTRY + + if ( aReqId == ERegistryInitiatePairedDevicesView ) + {// Initialization phase, list paired devices if there are. + if ( aStatus > KErrNone ) + { + GetPairedDevices( ERegistryInitiatePairedDevicesList ); + } + else + {//no paired device, close the view. + (void) iBTRegistry.CloseView(); + } + } + else + { + if (iNotHandledRegEventCounter) + { // more registry change detected, create paired device view again: + (void) iBTRegistry.CloseView(); + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else if ( aStatus > KErrNone ) + { // paired device available, get them: + GetPairedDevices( ERegistryGetPairedDevices ); + } + else + { + // No paired devices in registry, empty local db: + (void) iBTRegistry.CloseView(); + iPairedDevices->Reset(); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// update paired device list. if registry was changed, create a new view. +// otherwise check for new pairing event. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::HandleGetPairedDevicesCompletedL( TInt /*aStatus*/, TInt aReqId ) + { + TRACE_FUNC_ENTRY + (void) iBTRegistry.CloseView(); + if ( aReqId == ERegistryInitiatePairedDevicesList ) + { + // We completed the initialization of paired device list, + // move all paired devices to the array: + UpdatePairedDeviceListL(); + } + + if (iNotHandledRegEventCounter) + { // more registry change detected, create paired device view again: + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else if ( aReqId == ERegistryGetPairedDevices) + { + // no more registry change detected, find new pairings: + CheckPairEventL(); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// copy the nameless devices to local array +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::UpdatePairedDeviceListL() + { + TRACE_FUNC_ENTRY + iPairedDevices->Reset(); + for ( TInt i = 0; i < iPairedDevicesResp->Results().Count(); i++ ) + { + TRACE_BDADDR( iPairedDevicesResp->Results()[i]->BDAddr() ); + TRACE_INFO((_L("[BTENG]\t linkkeytype %d"), + iPairedDevicesResp->Results()[i]->LinkKeyType())) + iPairedDevices->AppendL( iPairedDevicesResp->Results()[i]->AsNamelessDevice() ); + } + delete iPairedDevicesResp; + iPairedDevicesResp = NULL; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// find new paired devices. for each, delegate the information to +// current pair handler. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::CheckPairEventL() + { + TRACE_FUNC_ENTRY + RArray* pairedDevicesOld; + pairedDevicesOld = iPairedDevices; + CleanupStack::PushL( pairedDevicesOld ); + CleanupClosePushL( *pairedDevicesOld ); + iPairedDevices = NULL; + iPairedDevices = new (ELeave) RArray; + UpdatePairedDeviceListL(); + + TIdentityRelation addrComp( CompareDeviceByAddress ); + for ( TInt i = 0; i < iPairedDevices->Count(); i++ ) + { + TBTNamelessDevice& dev = (*iPairedDevices)[i]; + TInt index = pairedDevicesOld->Find( dev, addrComp ); + + // If the device is not found in the old paired device list or + // the link key type has been changed from + // ELinkKeyUnauthenticatedUpgradable, the device is a new + // paired device: + TBool newPaired = dev.LinkKeyType() != ELinkKeyUnauthenticatedUpgradable && + ( index == KErrNotFound || + ( index > KErrNotFound && + dev.LinkKeyType() != (*pairedDevicesOld)[index].LinkKeyType() ) ); + TRACE_BDADDR( dev.Address() ); + if ( newPaired && !iPairer) + { + iPairer = CBTEngIncPair::NewL( *this, dev.Address() ); + } + if ( iPairer ) + { + // Ask pair handler to decide what to do: + iPairer->HandleRegistryNewPairedEvent( dev ); + } + } + // Free old paired device list resource: + CleanupStack::PopAndDestroy( 2 ); + TRACE_FUNC_EXIT + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengsdpdbhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsdpdbhandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,398 @@ +/* +* Copyright (c) 2006 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: Helper class for SDP database management. +* +*/ + + + +#include +#include +#include +#include +#include + +#include "btengsdpdbhandler.h" +#include "btengsdp.hrh" +#include "debug.h" + +_LIT( KBTEngSdpResourceFile, "btengsdp.rsc"); +_LIT( KDriveZ, "z:"); +_LIT8( KHex, "0x"); +const TInt KMaxServiceDesLength = 64; +const TInt KNumberOfChars = 8; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSdpDbHandler::CBTEngSdpDbHandler() + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::ConstructL() + { + TRACE_FUNC_ENTRY + User::LeaveIfError( iSdp.Connect() ); + User::LeaveIfError( iDb.Open( iSdp ) ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSdpDbHandler* CBTEngSdpDbHandler::NewL() + { + CBTEngSdpDbHandler* self = new( ELeave ) CBTEngSdpDbHandler(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSdpDbHandler::~CBTEngSdpDbHandler() + { + iDb.Close(); // This should have no effect if the handle is null. + iSdp.Close(); + } + + +// --------------------------------------------------------------------------- +// Register SDP record for the specified service containing the specified +// protocol channel in the protocol descriptor list. +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::RegisterSdpRecordL( const TUUID& aService, + TInt aChannel, TSdpServRecordHandle& aHandle ) + { + TRACE_FUNC_ARG( ( _L( "channel: %d" ), aChannel ) ) + iChannel = aChannel; + RegisterSdpRecordL( aService, aHandle ); + } + + +// --------------------------------------------------------------------------- +// Register SDP record for the specified service containing the specified +// VendorID and ProductID for the relevant attributes (mainly for DI profile). +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::RegisterSdpRecordL( const TUUID& aService, + TInt aVendorId, TInt aProductId, TSdpServRecordHandle& aHandle ) + { + TRACE_FUNC_ARG( ( _L( "vendor ID: %d: product ID: %d" ), + aVendorId, aProductId ) ) + iVendorId = aVendorId; + iProductId = aProductId; + RegisterSdpRecordL( aService, aHandle ); + } + + +// --------------------------------------------------------------------------- +// Register SDP record for the specified service. +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::RegisterSdpRecordL( const TUUID& aService, + TSdpServRecordHandle& aHandle ) + { + TResourceReader reader; + HBufC8* record = NULL; + TBuf8 serviceBuf( KHex ); + TPtrC8 ptr = aService.ShortestForm(); + if( ptr.Length() <= 4 ) + { + // Short form UUID (16 or 32 bytes). + TUint service = SdpUtil::GetUint( ptr ); + serviceBuf.AppendNum( service, EHex ); + } + else + { + // Long form UUID (128 bytes). + TUint64 serviceLo = 0; + TUint64 serviceHi = 0; + SdpUtil::GetUint128( ptr, serviceLo, serviceHi ); + // The numbers need to have a fixed width (including leading zeros) + // and AppendNumFixedWidth is only avaliable with TUint32. + serviceBuf.AppendNumFixedWidth( I64HIGH(serviceHi), EHex, KNumberOfChars ); + serviceBuf.AppendNumFixedWidth( I64LOW(serviceHi), EHex, KNumberOfChars ); + serviceBuf.AppendNumFixedWidth( I64HIGH(serviceLo), EHex, KNumberOfChars ); + serviceBuf.AppendNumFixedWidth( I64LOW(serviceLo), EHex, KNumberOfChars ); + } + + // Read the record from resource file. + ReadRecordResourceL( serviceBuf, reader, record ); + CleanupStack::PushL( record ); + + iDb.CreateServiceRecordL( TUUID( 0 ), aHandle ); + CSdpAttrValue* attrVal = NULL; + TUint attrCount = reader.ReadUint16(); + for( TInt i = 0; i < attrCount; i++ ) + { + TUint16 attrId = reader.ReadUint16(); + BuildAttributeLC( attrVal, reader, attrId ); + if( attrVal ) + { + iDb.UpdateAttributeL( aHandle, attrId, *attrVal ); + CleanupStack::PopAndDestroy( attrVal ); + attrVal = NULL; + } + } + + CleanupStack::PopAndDestroy( record ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Delete the SDP record for the specified record handle. +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::DeleteSdpRecordL( const TSdpServRecordHandle aHandle ) + { + TRACE_FUNC_ENTRY + if( aHandle ) + { + iDb.DeleteRecordL( aHandle ); + } + else + { + User::Leave( KErrBadHandle ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Build an SDP attribute. +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::BuildAttributeLC( CSdpAttrValue*& aAttrVal, + TResourceReader& aReader, TInt aAttrId ) + { + // Read the attribute type and ID + TUint attrType = aReader.ReadUint8(); + if( attrType == EElemTypeList ) + { + BuildAttrDesLC( aAttrVal, aReader, aAttrId ); + } + else + { + BuildAttrValueLC( aAttrVal, aReader, attrType, aAttrId ); + } + } + + +// --------------------------------------------------------------------------- +// Build an SDP attribute for a concrete attribute type. +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::BuildAttrValueLC( CSdpAttrValue*& aAttrVal, + TResourceReader& aReader, TUint aAttrType, TInt aAttrId ) + { + TRACE_FUNC_ENTRY + switch( aAttrType ) + { + case EElemTypeWord: + { + TSdpIntBuf buf( aReader.ReadUint16() ); + if( iVendorId && aAttrId == EVendorID ) + { + buf = TSdpIntBuf( iVendorId ); + iVendorId = 0; // Reset vendor ID + } + if( iProductId && aAttrId == EProductID ) + { + buf = TSdpIntBuf( iProductId ); + iProductId = 0; // Reset vendor ID + } + aAttrVal = CSdpAttrValueUint::NewUintL( buf ); + } + break; + case EElemTypeLong: + { + TSdpIntBuf buf( aReader.ReadUint32() ); + aAttrVal = CSdpAttrValueUint::NewUintL( buf ); + } + break; + case EElemTypeUUID: + { + TUUID uuid( aReader.ReadUint32() ); + aAttrVal = CSdpAttrValueUUID::NewUUIDL( uuid ); + } + break; + case EElemTypeUUID128: + { + TUUID uuid; + uuid.SetL( aReader.ReadTPtrC8() ); + aAttrVal = CSdpAttrValueUUID::NewUUIDL( uuid ); + } + break; + case EElemTypeText: + { + TPtrC8 ptr = aReader.ReadTPtrC8(); + aAttrVal = CSdpAttrValueString::NewStringL( ptr ); + } + break; + case EElemTypeByte: + { + TSdpIntBuf buf( aReader.ReadUint8() ); + if( iChannel && aAttrId == EProtocolDescriptorList ) + { + buf = TSdpIntBuf( iChannel ); + iChannel = 0; // Reset channel number + } + aAttrVal = CSdpAttrValueUint::NewUintL( buf ); + } + break; + case EElemTypeList: + { + BuildAttrDesLC( aAttrVal, aReader, aAttrId ); + } + break; + case EElemTypeLong64: + { + TPtrC8 ptr = aReader.ReadTPtrC8(); + aAttrVal = CSdpAttrValueUint::NewUintL(ptr); + break; + } + case EElemTypeBool: + { + TBool boolVal = (TBool) aReader.ReadUint8(); + aAttrVal = CSdpAttrValueBoolean::NewBoolL( boolVal ); + break; + } + case EElemTypeLink: + default: + break; + } + if( aAttrVal ) + { + CleanupStack::PushL( aAttrVal ); + } + } + + +// --------------------------------------------------------------------------- +// Build an SDP Data Elelement Sequence attribute (i.e. a sequence of +// concrete attributes or lists). +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::BuildAttrDesLC( CSdpAttrValue*& aAttrVal, + TResourceReader& aReader, TInt aAttrId ) + { + TRACE_FUNC_ENTRY + TUint elementCount = aReader.ReadUint16(); + MSdpElementBuilder* builder = NULL; + if( !aAttrVal ) + { + // This is the first element of the attribute. + aAttrVal = CSdpAttrValueDES::NewDESL( NULL ); + builder = ( (CSdpAttrValueDES*) aAttrVal )->StartListL(); + } + else + { + // This is a nested DES. This means that the parent element is + // also a DES. Append this DES to the parent. + builder = ( (CSdpAttrValueDES*) aAttrVal )->BuildDESL(); + builder = builder->StartListL(); + } + + CleanupStack::PushL( aAttrVal ); + while( elementCount > 0 ) + { + // Build the list; this can result in another call to this function + // to build a nested list. + CSdpAttrValue* element = NULL; + BuildAttributeLC( element, aReader, aAttrId ); + if( element ) + { + CleanupStack::Pop( element ); // Ownership will be passed to DES. + CSdpAttrValueDES* list = (CSdpAttrValueDES*) builder; + list->AppendValueL( element ); + } + elementCount--; + } + builder = builder->EndListL(); + } + + +// --------------------------------------------------------------------------- +// Read the service record from the resource file containing all BT Engine's +// service record definitions. +// --------------------------------------------------------------------------- +// +void CBTEngSdpDbHandler::ReadRecordResourceL( const TDesC8& aService, + TResourceReader& aReader, HBufC8*& aRecordBuf ) + { + TRACE_FUNC_ENTRY + // Find and open resource file + TFileName fileName( KDriveZ ); + fileName.Append( KDC_RESOURCE_FILES_DIR ); + fileName.Append( KBTEngSdpResourceFile ); + RFs fsSession; + User::LeaveIfError( fsSession.Connect() ); + CleanupClosePushL( fsSession ); + RResourceFile resourceFile; + resourceFile.OpenL( fsSession, fileName ); + CleanupClosePushL( resourceFile ); + + // Read the array containing the mappings of UUID to resource definitions. + HBufC8* buf = resourceFile.AllocReadLC( R_SERVICE_RECORD_LIST ); + aReader.SetBuffer( buf ); + CDesC8ArrayFlat* serviceIdArray = aReader.ReadDesC8ArrayL(); + CleanupStack::PushL( serviceIdArray ); + + // Find the requested service record. + TInt pos = KErrNotFound; + for( TInt i = 0; i < serviceIdArray->Count(); i++ ) + { + // CompareF is case insensitive comparison + if( aService.CompareF( (*serviceIdArray)[i] ) == 0 ) + { + pos = i; + break; + } + } + if( pos < 0 ) + { + // The record is not found from the resource file. + User::Leave( pos ); + } + + // Read the service record resource in a buffer to pass back. + aReader.Advance( 2 * pos + 2 ); // 16bit LINK + TUint resourceId = aReader.ReadUint16(); + aRecordBuf = resourceFile.AllocReadL( resourceId ); + aReader.SetBuffer( aRecordBuf ); + + CleanupStack::PopAndDestroy( serviceIdArray ); + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( &resourceFile ); + CleanupStack::PopAndDestroy( &fsSession ); + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1414 @@ +/* +* Copyright (c) 2006-2008 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: Server-side implementation of BTEng +* +*/ + + + +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "btengserver.h" +#include "btengsrvstate.h" +#include "btengsrvsession.h" +#include "btengsrvpluginmgr.h" +#include "btengsrvbbconnectionmgr.h" +#include "btengsrvkeywatcher.h" +#include "btengsdpdbhandler.h" +#include "btengclientserver.h" +#include "btengsecpolicy.h" +#include "btengprivatecrkeys.h" +#include "btengprivatepskeys.h" +#include "btengplugin.h" +#include "btengpairman.h" +#include "debug.h" + +/** Bluetooth Engine server thread name */ +_LIT( KBTEngThreadName, "BTEngine" ); + +/** Constant for converting minutes to microseconds */ +const TInt64 KMinutesInMicroSecs = MAKE_TINT64( 0, 60000000 ); + +/** Idle timeout for shutting down the server (when power is off, + * and no clients are connected). The value is 3 seconds. + */ +const TInt KBTEngSrvIdleTimeout = 3000000; + +/** Timeout for disabling Simple Pairing debug mode. The value is 30 minutes. */ +const TInt KBTEngSspDebugModeTimeout = 1800000000; + +/** Timeout for determining that BT is not turned off automatically. + * The value is 10.5 seconds. + */ +const TInt KBTEngBtAutoOffTimeout = 10500000; + +/** Enumeration of bitmask for keeping track of different timers. */ +enum TTimerQueued + { + ENone = 0x00, + EScanModeTimer = 0x01, + EIdleTimer = 0x02, + EAutoPowerOffTimer = 0x04, + ESspDebugModeTimer = 0x08 + }; + +/** PubSub key read and write policies */ +_LIT_SECURITY_POLICY_C2( KBTEngPSKeyReadPolicy, + ECapabilityLocalServices, ECapabilityReadDeviceData ); +_LIT_SECURITY_POLICY_C2( KBTEngPSKeyWritePolicy, + ECapabilityLocalServices, ECapabilityWriteDeviceData ); + +// Default values for Major and Minor Device Class +const TUint16 KCoDDefaultServiceClass = EMajorServiceTelephony | EMajorServiceObjectTransfer | EMajorServiceNetworking; +const TUint8 KCoDDefaultMajorDeviceClass = EMajorDevicePhone; +const TUint8 KCoDDefaultMinorDeviceClass = EMinorDevicePhoneSmartPhone; + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Constructs and returns an application object. +// --------------------------------------------------------------------------- +// +void RunServerL() + { + TRACE_FUNC_ENTRY + User::RenameThread( KBTEngThreadName ); + // Create and install the active scheduler for this thread. + CActiveScheduler* scheduler = new( ELeave ) CActiveScheduler(); + CleanupStack::PushL( scheduler ); + CActiveScheduler::Install( scheduler ); + // create the server (leave it on the cleanup stack) + CBTEngServer* btServer = CBTEngServer::NewLC(); + // Initialisation complete, now signal the client + RProcess::Rendezvous( KErrNone ); + // The server is not up and running. + TRACE_INFO( ( _L( "[BTENG]\t BTEng server now up and running" ) ) ) + // The active scheduler runs during the lifetime of this thread. + CActiveScheduler::Start(); + // Cleanup the server and scheduler. + CleanupStack::PopAndDestroy( btServer ); + CleanupStack::PopAndDestroy( scheduler ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Completes the message and panics the client. +// --------------------------------------------------------------------------- +// +void PanicClient( const RMessage2& aMessage, TInt aPanic ) + { + TRACE_INFO( ( _L( "[BTENG]\t PanicClient: Reason %d" ), aPanic ) ) + aMessage.Panic( KBTEngPanic, aPanic ); + } + + +// --------------------------------------------------------------------------- +// Panic the server. +// --------------------------------------------------------------------------- +// +void PanicServer( TInt aPanic ) + { + TRACE_INFO( ( _L( "[BTENG]\t PanicClient: Reason %d" ), aPanic ) ) + User::Panic( KBTEngPanic, aPanic ); + } + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// (Priority is not as high as in prev. architecture, but should be enough) +// --------------------------------------------------------------------------- +// +CBTEngServer::CBTEngServer() +: CPolicyServer( EPriorityHigh, KBTEngServerPolicy ) + { + iEnableDutMode = EFalse; + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngServer::ConstructL() + { + TRACE_FUNC_ENTRY + // No need to check _BT flag here, as the server can + // only be started by BTEng components. + + // Add the server to the active scheduler (from CServer2): + StartL( KBTEngServerName ); + User::LeaveIfError( RProperty::Define( KPSUidBluetoothTestingMode, KBTDutEnabled, + RProperty::EInt, KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy ) ); + User::LeaveIfError( RProperty::Define( KPSUidBluetoothTestingMode, KBTSspDebugmode, + RProperty::EInt, KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy ) ); + User::LeaveIfError( RProperty::Define( KPSUidBluetoothEnginePrivateCategory, + KBTBlockDevAddr, RProperty::EText, + KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy ) ); + User::LeaveIfError( RProperty::Define( KPSUidBluetoothEnginePrivateCategory, + KBTOutgoingPairing, + RProperty::EByteArray, + KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy) ); + User::LeaveIfError( RProperty::Define( KPSUidBluetoothEnginePrivateCategory, + KBTConnectionTimeStamp, + RProperty::EByteArray, + KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy) ); + User::LeaveIfError( RProperty::Define( KPSUidBluetoothEnginePrivateCategory, + KBTTurnBTOffQueryOn, + RProperty::EInt, + KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy) ); + + User::LeaveIfError( RProperty::Define( KPSUidBluetoothEnginePrivateCategory, + KBTNotifierLocks, + RProperty::EByteArray, + KBTEngPSKeyReadPolicy, + KBTEngPSKeyWritePolicy) ); + + User::LeaveIfError( iSocketServ.Connect() ); + LoadBTPowerManagerL(); + // The server is only started by its client, so leave the state + // machine in Init state. A request to turn power on will follow + // usually immediately. + iServerState = CBTEngSrvState::NewL( this ); + iWatcher = CBTEngSrvKeyWatcher::NewL( this ); + iPluginMgr = CBTEngSrvPluginMgr::NewL( this ); + iBBConnMgr = CBTEngSrvBBConnMgr::NewL( iSocketServ ); + + User::LeaveIfError( iBTRegServ.Connect() ); + iPairMan = CBTEngPairMan::NewL( *this ); + + TCallBack idleCb( IdleTimerCallBack, this ); + iIdleCallBack.Set( idleCb ); + TCallBack sspCb( DebugModeTimerCallBack, this ); + iDebugModeCallBack.Set( sspCb ); + TCallBack scanModeCb( ScanModeTimerCallBack, this ); + iScanModeCallBack.Set( scanModeCb ); + TCallBack powerOffCb( AutoPowerOffCallBack, this ); + iPowerOffCallBack.Set( powerOffCb ); + iTimer = CDeltaTimer::NewL(CActive::EPriorityLow); + + iEnterpriseEnablementMode = BluetoothFeatures::EnterpriseEnablementL(); + TRACE_INFO( ( _L( "iEnterpriseEnablementMode = %d" ), iEnterpriseEnablementMode) ) + if ( iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) + { + SetVisibilityModeL( EBTVisibilityModeNoScans, 0 ); + } + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngServer* CBTEngServer::NewLC() + { + CBTEngServer* self = new( ELeave ) CBTEngServer(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngServer::~CBTEngServer() + { + TRACE_FUNC_ENTRY + if( iTimer ) + { + iTimerQueued = ENone; + iTimer->Remove( iScanModeCallBack ); + iTimer->Remove( iPowerOffCallBack ); + iTimer->Remove( iIdleCallBack); + iTimer->Remove( iDebugModeCallBack ); + } + RProperty::Delete( KPSUidBluetoothTestingMode, KBTDutEnabled ); + RProperty::Delete( KPSUidBluetoothTestingMode, KBTSspDebugmode ); + RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr ); + RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTOutgoingPairing ); + RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTConnectionTimeStamp ); + RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTTurnBTOffQueryOn ); + RProperty::Delete( KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks ); + delete iTimer; + delete iSdpDbHandler; + delete iWatcher; + delete iPluginMgr; + delete iBBConnMgr; + delete iServerState; + delete iPairMan; + iPowerMgr.Close(); + iSocketServ.Close(); + iBTRegServ.Close(); + } + + +// --------------------------------------------------------------------------- +// Turn BT on or off. +// --------------------------------------------------------------------------- +// +void CBTEngServer::SetPowerStateL( TBTPowerStateValue aState, TBool aTemporary ) + { + TRACE_FUNC_ARG( ( _L( "setting power state %d" ), (TInt) aState ) ) + if ( aState == EBTPowerOn && iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) + { + TRACE_INFO( ( _L( "\tno we're not... Bluetooth is enterprise-IT-disabled" ) ) ) + User::Leave(KErrNotSupported); + } + + TBTPowerStateValue currentState = EBTPowerOff; + CheckTemporaryPowerStateL( currentState, aState, aTemporary ); + + if( ( currentState == aState || ( aTemporary && aState == EBTPowerOff ) ) && iServerState->CurrentOperation() == CBTEngSrvState::ESrvOpIdle ) + { + // The requested power state is already active, ignore silently. + // We don't return an error here, as there is no error situation. + TRACE_INFO( ( _L( "SetPowerStateL: nothing to do" ) ) ) + if(currentState == aState) + { + // Make sure that the CenRep key is in sync. + // During boot-up, the pwoer is set from the CenRep key, so we could + // end up out-of-sync. + TRACE_INFO( ( _L( "SetPowerStateL: currentState == aState" ) ) ) + UpdateCenRepPowerKeyL( aState ); + } + return; + } + if( aState ) + { + // Hardware power on is the first step. + User::LeaveIfError( SetPowerState( aState ) ); + } + else + { + //Prevent BT visibility in the situation when we turn OFF BT Engine + //but FM Radio is still alive + SetVisibilityModeL( EBTVisibilityModeNoScans, 0 ); + // Hardware power off is the last step. + // First disconnect all plug-ins. + iPluginMgr->DisconnectAllPlugins(); + } + // We only signal that BT is on after everything has completed (through + // the CenRep power state key), so that all services are initialized. + // We signal that BT is off immediately though, so that our clients will + // not try to use BT during power down. + iServerState->StartStateMachineL( (TBool) aState ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ) + { + TRACE_FUNC_ENTRY + + if ( aMode != EBTVisibilityModeNoScans && iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) + { + TRACE_INFO( ( _L( "\tnot changing anything... Bluetooth is enterprise-IT-disabled" ) ) ) + User::Leave(KErrNotSupported); + } + + TInt err = KErrNone; + iTimerQueued &= ~EScanModeTimer; + iTimer->Remove( iScanModeCallBack ); + if( aMode != EBTVisibilityModeNoScans ) + { + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + err = cenRep->Set( KBTDiscoverable, aMode ); + delete cenRep; + } + if( !err && aMode == EBTVisibilityModeTemporary ) + { + // We need TInt64 here, as the max. time in microseconds for the + // max. value (1 hour) is larger than KMaxTInt32. + TInt64 timeMicroSec = MAKE_TINT64( 0, aTime ); + timeMicroSec = timeMicroSec * KMinutesInMicroSecs; + TTimeIntervalMicroSeconds interval( timeMicroSec ); + // Queue callback to set the visibility back to hidden. + err = iTimer->QueueLong( interval, iScanModeCallBack ); + iTimerQueued |= EScanModeTimer; + aMode = EBTVisibilityModeGeneral; + } + else if( !err && iRestoreVisibility ) + { + // The user overrides, do not restore visibility mode anymore. + iRestoreVisibility = EFalse; + } + if( !err ) + { + err = RProperty::Set( KUidSystemCategory, + KPropertyKeyBluetoothSetScanningStatus, aMode ); + } + TBool hiddenMode = ( aMode == EBTVisibilityModeHidden ); + if( !err && aMode != EBTVisibilityModeNoScans ) + { + // In hidden mode, we only accept connections from paired devices. + err = RProperty::Set( KUidSystemCategory, + KPropertyKeyBluetoothSetAcceptPairedOnlyMode, + hiddenMode ); + } + + User::LeaveIfError( err ); // To communicate the result to the client. + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// The method is called when BT stack scanning mode P&S key is changed +// --------------------------------------------------------------------------- +// +void CBTEngServer::UpdateVisibilityModeL( TInt aStackScanMode ) + { + TRACE_FUNC_ENTRY + TRACE_INFO( ( _L( "[BTEng]\t aStackScanMode: %d" ), aStackScanMode ) ) + TBTVisibilityMode currentMode; + + CRepository* cenRep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); + User::LeaveIfError( cenRep->Get( KBTDiscoverable, (TInt&) currentMode ) ); + + // In case we are in temp visibility mode, we cannot always know whether the BT stack + // scan mode key was set by some external party or by us in SetVisibilityModeL above. + // Therefore we cannot stop the timer in case aMode is EBTVisibilityModeGeneral and + // currentmode is EBTVisibilityModeTemporary + if( !( currentMode == EBTVisibilityModeTemporary && aStackScanMode == EBTVisibilityModeGeneral ) ) + { + // Cancel the timer and queue it again if needed. + iTimerQueued &= ~EScanModeTimer; + iTimer->Remove( iScanModeCallBack ); + if( currentMode != aStackScanMode ) + { + if( aStackScanMode == EPageScanOnly || aStackScanMode == EInquiryAndPageScan ) + { + User::LeaveIfError( cenRep->Set( KBTDiscoverable, aStackScanMode ) ); + } + else if( aStackScanMode == EInquiryScanOnly ) + { + // We don't support ENoScansEnabled nor EInquiryScanOnly mode + // -> Consider these as same as Hidden + User::LeaveIfError( cenRep->Set( KBTDiscoverable, EBTVisibilityModeHidden ) ); + } + else if( aStackScanMode == ENoScansEnabled ) + { + //We don't change KBTDiscoverable here, because ENoScansEnabled + //indicates BT/SYSTEM shutdown is happening + } + } + } + SetUiIndicatorsL(); + CleanupStack::PopAndDestroy( cenRep ); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::DisconnectAllL() + { + TRACE_FUNC_ENTRY + iPluginMgr->DisconnectAllPlugins(); + TCallBack cb( DisconnectAllCallBack, this ); + iBBConnMgr->DisconnectAllLinksL( cb ); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::SetDutMode( TInt aDutMode ) + { + TRACE_FUNC_ARG( ( _L( "DUT mode %d" ), aDutMode ) ) + + if (aDutMode == EBTDutOff) + { + return; + } + + TInt powerState = EBTPowerOff; + CRepository* cenrep = NULL; + + TRAPD(err, cenrep = CRepository::NewL(KCRUidBluetoothPowerState)); + + if (!err && cenrep) + { + cenrep->Get(KBTPowerState, powerState); + delete cenrep; + cenrep = NULL; + } + else + { + return; + } + + if (powerState == EBTPowerOn) + { + +#ifndef __WINS__ + + TInt err = iDutMode.Open(); + TRACE_FUNC_ARG( ( _L( "Open DUT mode handle err %d" ), err) ) + if(!err) + { + iDutMode.ActivateDutMode(); + iDutMode.Close(); + } +#endif //__WINS__ + } + iEnableDutMode = EFalse; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::ScanModeTimerCompletedL() + { + TRACE_FUNC_ENTRY + // The timer has completed, so remove our reference as well. + iTimerQueued &= ~EScanModeTimer; + iTimer->Remove( iScanModeCallBack ); + SetVisibilityModeL( EBTVisibilityModeHidden, 0 ); + TBTPowerStateValue power = EBTPowerOff; + TInt err = GetHwPowerState( (TBTPowerStateValue&) power ); + if( !err && power ) + { + // Show a notification to the user + TBTGenericInfoNotiferParamsPckg pckg; + pckg().iMessageType = EBTVisibilityTimeout; + + RNotifier notifier; + TInt err = notifier.Connect(); + if( !err ) + { + err = notifier.StartNotifier( KBTGenericInfoNotifierUid, pckg ); + notifier.Close(); + } + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::DisconnectAllCompleted() + { + // Check if we are powering off. Otherwise we have just been + // requested to disconnect all, e.g. for system shutdown. + if( iServerState->CurrentOperation() == CBTEngSrvState::EPowerOff ) + { + (void) SetPowerState( EFalse ); + // Put the state machine into idle state. + iServerState->ChangeState(); + } + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::DispatchPluginMessageL( const RMessage2& aMessage ) + { + iPluginMgr->ProcessCommandL( aMessage ); + } + + +// --------------------------------------------------------------------------- +// A new session has been added, update the session count. +// --------------------------------------------------------------------------- +// +void CBTEngServer::AddSession() + { + iSessionCount++; + // Remove the idle timer. + iTimerQueued &= ~EIdleTimer; + iTimer->Remove( iIdleCallBack ); + } + + +// --------------------------------------------------------------------------- +// A session has been ended, update the session count. +// --------------------------------------------------------------------------- +// +void CBTEngServer::RemoveSession( TBool aAutoOff ) + { + TRACE_FUNC_ENTRY + TRACE_INFO( ( _L( "[CBTEngServer]\t aAutoOff %d"), aAutoOff )) + TRACE_INFO( ( _L( "[CBTEngServer]\t iSessionCount %d"), iSessionCount )) + iSessionCount--; + if( aAutoOff ) + { + TRAP_IGNORE( SetPowerStateL( EBTPowerOff, ETrue ) ); + } + else + { + CheckIdle(); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class CPolicyServer. +// Checks version compatibility and constructs a new session object. +// --------------------------------------------------------------------------- +// +CSession2* CBTEngServer::NewSessionL( const TVersion& aVersion, + const RMessage2& aMessage ) const + { + TRACE_FUNC_ENTRY + (void) aMessage; + // Compare our version with client-side version, CServer2 requires that + // we leave if they are not compatible. + // Compatible is interpreted here as equal or greater than our version. + TVersion srvVersion( KBTEngServerVersionMajor, KBTEngServerVersionMinor, + KBTEngServerVersionBuild ); + + if( !User::QueryVersionSupported( aVersion, srvVersion ) ) + { + // EFalse is returned if our version is not less than or + // equal to the client version. + User::Leave( KErrNotSupported ); + } + return CBTEngSrvSession::NewL(); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::CheckIdle() + { + TRACE_FUNC_ENTRY + __ASSERT_DEBUG( iTimer, PanicServer( EBTEngPanicMemberVarIsNull ) ); + iTimerQueued &= ~EIdleTimer; + iTimer->Remove( iIdleCallBack ); + if( iSessionCount <= 0 ) + { + // No more sessions, check the power state. + TBTPowerStateValue pwr = EBTPowerOff; + TInt err = GetHwPowerState( pwr ); + TRACE_INFO( ( _L( "[BTEng]\t No sessions; power state: %d" ), pwr ) ) + if( !err &&!pwr + && iServerState->CurrentOperation() == CBTEngSrvState::ESrvOpIdle ) + { + TRACE_INFO( ( _L( "[BTEng]\t Power off; starting shutdown timer" ) ) ) + // power is off, start the shutdown timer. + TTimeIntervalMicroSeconds32 interval = KBTEngSrvIdleTimeout; + iTimer->Queue( interval, iIdleCallBack ); + iTimerQueued |= EIdleTimer; + } + } + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::SetPowerState( TBool aState ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + // HCIv2 power state type is inverted from BTPM-defined type... + TBTPowerState powerState = (TBTPowerState) !aState; + TRequestStatus status; + +#ifndef __WINS__ + iPowerMgr.SetPower( powerState, NULL, status ); + User::WaitForRequest( status ); + err = status.Int(); +#else //__WINS__ + iPowerState = powerState; + err = KErrNone; +#endif //__WINS__ + + if( !err && aState ) + { + TInt dutMode; + err = RProperty::Get( KPSUidBluetoothTestingMode, KBTDutEnabled, dutMode ); + if( !err && dutMode == EBTDutOn ) + { + // Set the DUT mode key to OFF since DUT mode is disabled at this point + err = RProperty::Set( KPSUidBluetoothTestingMode, KBTDutEnabled, EBTDutOff ); + } + // Set the local name straight away, so that an error + // in the loading of the BT stack will be detected here. + // Note that the HCIv2 power manager already loads the BT stack, + // so we do not need to do that here. + TRAP(err,SetLocalNameL()); + } + if( err ) + { + // Power off if an error occurred during power on sequence. +#ifndef __WINS__ + // This cannot happen in emulator environment. + iPowerMgr.SetPower( EBTOff, NULL, status ); + User::WaitForRequest( status ); +#endif //__WINS__ + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::SetLocalNameL() + { + TRACE_FUNC_ENTRY + RHostResolver hostResolver; + TBuf name; + name.Zero(); + TBuf tmpName; + + TInt err = RProperty::Get(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetDeviceName, name); + if(err == KErrNone) + { + err = RProperty::Get(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetDeviceName, tmpName); + if (tmpName.Compare(name)) + { + // The name has not yet been updated. Use the new one. + name.Copy(tmpName); + } + } + // if name hasn't been set, check whats in the registry + if (err || !name.Length()) + { + GetLocalNameFromRegistryL(name); + } + + TRACE_INFO( ( _L( "[CBTEngServer]\t localDev.DeviceName(): '%S'" ), &name)) + + CleanupClosePushL(hostResolver); + User::LeaveIfError(hostResolver.Open(iSocketServ, KBTAddrFamily, KBTLinkManager)); + User::LeaveIfError(hostResolver.SetHostName(name)); + CleanupStack::PopAndDestroy(&hostResolver); + + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// Checks whats written in the registry in order to set host name +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::GetLocalNameFromRegistryL(TDes& aName) + { + TRACE_FUNC_ENTRY + RBTRegServ btRegServ; + RBTLocalDevice btReg; + TBTLocalDevice localDev; + + CleanupClosePushL(btRegServ); + CleanupClosePushL(btReg); + + // In case of error, read local name from registry + aName.Zero(); + User::LeaveIfError(btRegServ.Connect()); + User::LeaveIfError(btReg.Open(btRegServ)); + + // Read the BT local name from BT Registry. + User::LeaveIfError(btReg.Get(localDev)); + + CleanupStack::PopAndDestroy(2,&btRegServ); + + // BT registry keeps the device name in UTF-8 format, convert to unicode. + // The error can be > 0 if there are unconverted characters. + TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(aName, localDev.DeviceName()); + if (err != KErrNone) + User::Leave(err); + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::SetClassOfDeviceL() + { + TRACE_FUNC_ENTRY + TUint16 serviceClass = KCoDDefaultServiceClass; + // Check from feature manager if stereo audio is enabled. + FeatureManager::InitializeLibL(); + TBool supported = FeatureManager::FeatureSupported( KFeatureIdBtStereoAudio ); + FeatureManager::UnInitializeLib(); + if( supported ) + { + // A2DP spec says we should set this bit as we are a SRC + serviceClass |= EMajorServiceCapturing; + } + // These values may nayway be overridden by HCI + TBTDeviceClass cod( serviceClass, KCoDDefaultMajorDeviceClass, + KCoDDefaultMinorDeviceClass ); + // Ignore error, it is non-critical + (void) RProperty::Set( KPropertyUidBluetoothControlCategory, + KPropertyKeyBluetoothSetDeviceClass, cod.DeviceClass() ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::InitBTStackL() + { + TRACE_FUNC_ENTRY + iBBConnMgr->Subscribe(); + TBTVisibilityMode visibility = EBTVisibilityModeHidden; + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + TInt err = cenRep->Get( KBTDiscoverable, (TInt&) visibility ); + delete cenRep; + if (iRestoreVisibility == EFalse) + { + if( err || visibility == EBTVisibilityModeTemporary && !( iTimerQueued & EScanModeTimer ) ) + { + visibility = EBTVisibilityModeHidden; + } + SetVisibilityModeL( visibility, 0 ); + } + SetClassOfDeviceL(); + TBool sspDebugMode = EFalse; + (void) RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetSimplePairingDebugMode, + (TInt&) sspDebugMode ); + // Only set debug mode to off if it is on, to prevent a loop notifications. + if( sspDebugMode ) + { + sspDebugMode = EFalse; + // Add LeaveIfError if unsuccessful + (void) RProperty::Set(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) sspDebugMode ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::StopBTStackL() + { + TRACE_FUNC_ENTRY + TBTVisibilityMode visibility = EBTVisibilityModeHidden; + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + // Ignore error here; if we can't read it, likely we can't set it either. + (void) cenRep->Get( KBTDiscoverable, (TInt&) visibility ); + delete cenRep; + if( visibility == EBTVisibilityModeTemporary ) + { + visibility = EBTVisibilityModeHidden; + SetVisibilityModeL( visibility, 0 ); // Also cancels scan mode timer. + } + + // Stop listening to events + iBBConnMgr->Unsubscribe(); + // Disconnect all links + TCallBack cb( DisconnectAllCallBack, this ); + iBBConnMgr->DisconnectAllLinksL( cb ); + // Results in a callback (which is called directly when there are no links). + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Update the power state CenRep key. +// --------------------------------------------------------------------------- +// +void CBTEngServer::UpdateCenRepPowerKeyL( TBTPowerStateValue aState ) + { + TRACE_FUNC_ENTRY + CRepository* cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); + User::LeaveIfError( cenrep->Set( KBTPowerState, (TInt) aState ) ); + CleanupStack::PopAndDestroy( cenrep ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Loads the BT Power Manager; leaves if it cannot be loaded. +// --------------------------------------------------------------------------- +// +void CBTEngServer::LoadBTPowerManagerL() + { + TRACE_FUNC_ENTRY + TRACE_INFO( ( _L( "[CBTEngServer]\t Using HCI API v2 power manager" ) ) ) + User::LeaveIfError( iPowerMgr.Open() ); +#ifndef __WINS__ + TRequestStatus status( KRequestPending ); + iPowerMgr.SetPower( EBTOff, NULL, status ); + User::WaitForRequest( status ); + status = ( status.Int() == KErrAlreadyExists ? KErrNone : status.Int() ); + User::LeaveIfError( status.Int() ); +#else //__WINS__ + iPowerState = EBTOff; +#endif //__WINS__ + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::ManageDIServiceL( TBool aState ) + { + TRACE_FUNC_ENTRY + // The session with the SDP database is kept open during the + // lifetime of BTEng server. This ensures that the database server + // will not destroy itself (and the SDP record) when there are no + // sessions anymore (which it would do). This also ensures that other + // sessions (of BT Engine Discovery API) can be closed without the SDP + // database being destroyed, and so saving memory. + TInt err = KErrNone; + if( !iSdpDbHandler ) + { + iSdpDbHandler = CBTEngSdpDbHandler::NewL(); + } + if( aState && !iDiSdpRecHandle ) + { + // Use TRAP here, because the function will leave if + // the required CenRep keys are not available. + TInt vendorId = 0; + TInt productId = 0; + TRAP( err, GetProductIdsL( vendorId, productId ) ); +#ifdef __WINS__ + err = KErrNone; // Ignore error and load with S60 RnD default values. +#endif //__WINS__ + if( !err ) + { + TUUID uuid( EBTProfileDI ); + iSdpDbHandler->RegisterSdpRecordL( uuid, vendorId, productId, + iDiSdpRecHandle ); + } + } + if( ( !aState || err ) && iDiSdpRecHandle ) + { + // Either we are shutting down, or we did not manage + // to fill the record with required data -> delete it. + iSdpDbHandler->DeleteSdpRecordL( iDiSdpRecHandle ); + iDiSdpRecHandle = 0; + delete iSdpDbHandler; + iSdpDbHandler = NULL; + } + User::LeaveIfError( err ); // To pass back the result of the operation. + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::GetProductIdsL( TInt& aVendorId, TInt& aProductId ) + { + TRACE_FUNC_ENTRY + CRepository* cenRep = CRepository::NewLC( KCRUidBluetoothEngine ); + User::LeaveIfError( cenRep->Get( KBTVendorID, aVendorId ) ); + User::LeaveIfError( cenRep->Get( KBTProductID, aProductId ) ); + CleanupStack::PopAndDestroy( cenRep ); //cenRep + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::SetUiIndicatorsL() + { + TRACE_FUNC_ENTRY + TInt powerState = EBTPowerOff; + TBTVisibilityMode visibilityMode = EBTVisibilityModeHidden; + CRepository* cenrep = NULL; + TInt phys = 0; + TInt connecting = 0; + + cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); + User::LeaveIfError( cenrep->Get( KBTPowerState, powerState ) ); + CleanupStack::PopAndDestroy( cenrep ); + + if( powerState == EBTPowerOff ) + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); + } + else if( powerState == EBTPowerOn ) + { + RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, phys ); + RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); + + cenrep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); + User::LeaveIfError( cenrep->Get( KBTDiscoverable, (TInt&) visibilityMode ) ); + CleanupStack::PopAndDestroy( cenrep ); + + if( visibilityMode == EBTVisibilityModeHidden ) + { + if ( connecting ) // BT connecting and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateAnimate ); + } + else if ( phys > 0 ) // BT connection active and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOn ); + } + else // BT connection not active and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOn ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + } + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); + } + else if( visibilityMode == EBTVisibilityModeGeneral || visibilityMode == EBTVisibilityModeTemporary ) + { + if ( connecting ) // BT connecting and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateAnimate ); + } + else if ( phys > 0 ) // BT connection active and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOn ); + } + else // BT connection not active and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOn ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); + } + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) + { + CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) ); + indicator->SetIndicatorStateL( aState ); + CleanupStack::PopAndDestroy( indicator ); //indicator + } + +// --------------------------------------------------------------------------- +// Gets the current HW power state. +// For now this is a separate method to isolate the different variations. +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::GetHwPowerState( TBTPowerStateValue& aState ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + +#ifndef __WINS__ + err = iPowerMgr.GetPower( (TBTPowerState&) aState, NULL ); +#else //__WINS__ + aState = (TBTPowerStateValue) iPowerState; +#endif //__WINS__ + + // HCIv2 power state type is inverted from BTPM-defined type... + aState = (TBTPowerStateValue) !aState; + TRACE_FUNC_ARG( ( _L( "Power state is %d, result %d" ), (TInt) aState, err ) ) + return err; + } + +// --------------------------------------------------------------------------- +// Check the power state and if BT gets turned off automatically. +// --------------------------------------------------------------------------- +// +void CBTEngServer::CheckTemporaryPowerStateL( TBTPowerStateValue& aCurrentState, + TBTPowerStateValue aNewState, TBool aTemporary ) + { + TRACE_FUNC_ENTRY + User::LeaveIfError( GetHwPowerState( aCurrentState ) ); + if( !aTemporary ) + { + // Force the new power state, so clear all auto switch off flags. + // If power is off, this will anyway be ignored. + iAutoOffClients = 0; + iAutoSwitchOff = EFalse; + TCallBack cb; + iBBConnMgr->SetAutoSwitchOff( EFalse, cb ); + if( iRestoreVisibility && aCurrentState == EBTPowerOn ) + { + // Set visibility mode back to the value selected by the user. + SetVisibilityModeL( EBTVisibilityModeGeneral, 0 ); + iRestoreVisibility = EFalse; + } + } + else + { + if( aCurrentState == aNewState ) + { + if( iAutoSwitchOff && aNewState == EBTPowerOn ) + { + iAutoOffClients++; + if( iTimerQueued & EAutoPowerOffTimer ) + { + iTimer->Remove( iPowerOffCallBack ); + iTimerQueued &= ~EAutoPowerOffTimer; + } + } + } + else if( iAutoSwitchOff || aNewState == EBTPowerOn ) + { + aNewState == EBTPowerOff ? iAutoOffClients-- : iAutoOffClients++; + iAutoSwitchOff = ETrue; + if( aNewState == EBTPowerOff && iAutoOffClients <= 0 ) + { + TCallBack powerOffCb( AutoPowerOffCallBack, this ); + iBBConnMgr->SetAutoSwitchOff( ETrue, powerOffCb ); + iTimer->Queue( KBTEngBtAutoOffTimeout, iPowerOffCallBack ); + iTimerQueued |= EAutoPowerOffTimer; + } + else if( aNewState == EBTPowerOn ) + { + CRepository* cenRep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); + TBTVisibilityMode visibility = EBTVisibilityModeGeneral; + TInt err = cenRep->Get( KBTDiscoverable, (TInt&) visibility ); + CleanupStack::PopAndDestroy( cenRep ); + if( !err && visibility == EBTVisibilityModeGeneral ) + { + SetVisibilityModeL( EBTVisibilityModeHidden, 0 ); + iRestoreVisibility = ETrue; + } + if( iTimerQueued & EAutoPowerOffTimer ) + { + iTimer->Remove( iPowerOffCallBack ); + iTimerQueued &= ~EAutoPowerOffTimer; + } + } + } + } + if( iAutoOffClients < 0 ) + { + iAutoOffClients = 0; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Check the power state and if BT gets turned off automatically. +// This method is invoked either when the timer has expired, or +// if there are no more connections while the timer was running. +// --------------------------------------------------------------------------- +// +void CBTEngServer::CheckAutoPowerOffL() + { + TRACE_FUNC_ENTRY + if ( iAutoOffClients > 0 ) + { + TRACE_INFO( ( _L( "[CBTEngServer]\t iAutoOffClients %d"), iAutoOffClients )) + return; + } + TInt linkCount = 0; + TInt err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount, linkCount ); + if( !err && !linkCount ) + { + TRACE_INFO( ( _L( "[CBTEngServer]\t SetPowerStateL( EBTPowerOff, EFalse );"))) + SetPowerStateL( EBTPowerOff, EFalse ); + } + else + { + if( iRestoreVisibility ) + { + // Set visibility mode back to the value selected by the user. + SetVisibilityModeL( EBTVisibilityModeGeneral, 0 ); + iRestoreVisibility = EFalse; + } + // show note if non-audio connection exists + if ( !iPluginMgr->CheckAudioConnectionsL() ) + { + RNotifier notifier; + TInt err = notifier.Connect(); + if( !err ) + { + TRequestStatus status; + TBTGenericInfoNotiferParamsPckg pckg; + pckg().iMessageType = EBTStayPowerOn; + TBuf8 result; + //notifier.StartNotifier( KBTGenericInfoNotifierUid, pckg, result ); + notifier.StartNotifierAndGetResponse( status, + KBTGenericInfoNotifierUid, + pckg, result ); // Reply buffer not used. + User::WaitForRequest( status ); + notifier.Close(); + } + } + iAutoOffClients = 0; + iAutoSwitchOff = EFalse; + TCallBack cb; + iBBConnMgr->SetAutoSwitchOff( EFalse, cb ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngServer::CheckSspDebugModeL( TBool aDebugMode ) + { + TRACE_FUNC_ARG( ( _L( "SSP debug mode state %d" ), (TInt) aDebugMode ) ) + TBTPowerState pwr = EBTOff; + TBool currentMode = EFalse; + TInt err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetSimplePairingDebugMode, + (TInt&) currentMode ); +#ifndef __WINS__ + err = iPowerMgr.GetPower( pwr, NULL ); // Treat error as power off. +#else //__WINS__ + pwr = iPowerState; +#endif //__WINS__ + if( err || pwr == EBTOff ) + { + iTimerQueued &= ~ESspDebugModeTimer; + iTimer->Remove( iDebugModeCallBack ); + // Only set debug mode to off if it is on, to prevent a loop notifications. + if( currentMode ) + { + (void) RProperty::Set( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) aDebugMode ); + } + // In case of an error in getting the power state, turn BT off. + // If BT is already off, this call will be ignored. + SetPowerStateL( EBTPowerOff, EFalse ); + } + else if( aDebugMode ) + { + // Ignore if there already is a timer queued. + if( !( iTimerQueued & ESspDebugModeTimer ) ) + { + iTimer->Queue( TTimeIntervalMicroSeconds32( KBTEngSspDebugModeTimeout ), + iDebugModeCallBack ); + iTimerQueued &= ESspDebugModeTimer; + err = RProperty::Set(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) aDebugMode ); + } + } + else + { + // Power is on, and debug mode is set to off. + TInt linkCount = 0; + err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount, linkCount ); + if( err || !linkCount ) + { + (void) RProperty::Set(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) aDebugMode ); + SetPowerStateL( EBTPowerOff, EFalse ); + } + else + { + // There are still existing connections, queue the + // timer again for half the period. + iTimer->Queue( TTimeIntervalMicroSeconds32( KBTEngSspDebugModeTimeout / 2 ), + iDebugModeCallBack ); + iTimerQueued &= ESspDebugModeTimer; + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// returns the reference of pairing manager +// --------------------------------------------------------------------------- +// +CBTEngPairMan& CBTEngServer::PairManager() + { + return *iPairMan; + } + +// --------------------------------------------------------------------------- +// Delegate the information to pairing manager +// --------------------------------------------------------------------------- +// +void CBTEngServer::RemoteRegistryChangeDetected() + { + iPairMan->RemoteRegistryChangeDetected(); + } + +// --------------------------------------------------------------------------- +// Access the reference of RSockServ +// --------------------------------------------------------------------------- +// +RSocketServ& CBTEngServer::SocketServ() + { + return iSocketServ; + } + +// --------------------------------------------------------------------------- +// Access the reference of RBTRegSrv +// --------------------------------------------------------------------------- +// +RBTRegServ& CBTEngServer::BTRegServ() + { + return iBTRegServ; + } + +// --------------------------------------------------------------------------- +// Ask plugin manager the connection status of the specified device +// --------------------------------------------------------------------------- +// +TBTEngConnectionStatus CBTEngServer::IsDeviceConnected( const TBTDevAddr& aAddr ) + { + TBTEngConnectionStatus status = EBTEngNotConnected; + if ( iPluginMgr ) + { + status = iPluginMgr->IsDeviceConnected( aAddr ); + } + return status; + } + +// --------------------------------------------------------------------------- +// Static callback for temporary visibility mode. +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::ScanModeTimerCallBack( TAny* aPtr ) + { + __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); + TRAPD( err, ( (CBTEngServer*) aPtr )->ScanModeTimerCompletedL() ); + return err; + } + +// --------------------------------------------------------------------------- +// Static callback for disconnecting all Baseband connections. +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::DisconnectAllCallBack( TAny* aPtr ) + { + __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); + ( (CBTEngServer*) aPtr )->DisconnectAllCompleted(); + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// Static callback for idle timer timeout. We are shutting down ourselves. +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::IdleTimerCallBack( TAny* aPtr ) + { + (void) aPtr; + CActiveScheduler::Stop(); // Will destroy CBTEngServer + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Static callback for idle timer timeout. Turn off BT to get it out of +// debug mode. If there are existing connections, queue the timer again. +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::DebugModeTimerCallBack( TAny* aPtr ) + { + // Set our internal debug mode key to off. Ignore error, not critical here. + (void) RProperty::Set( KPSUidBluetoothTestingMode, KBTSspDebugmode, EFalse ); + + __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); + + TRAP_IGNORE( ( (CBTEngServer*) aPtr )->CheckSspDebugModeL( EFalse ) ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Static callback for auto power off. +// --------------------------------------------------------------------------- +// +TInt CBTEngServer::AutoPowerOffCallBack( TAny* aPtr ) + { + TRACE_FUNC_ENTRY + + __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); + + CBTEngServer* server = (CBTEngServer*) aPtr; + server->iTimerQueued &= ~EAutoPowerOffTimer; + TRAPD( err, server->CheckAutoPowerOffL() ); + return err; + } + +BluetoothFeatures::TEnterpriseEnablementMode CBTEngServer::EnterpriseEnablementMode() const + { + return iEnterpriseEnablementMode; + } + +// ======== GLOBAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Main function of the executable. +// --------------------------------------------------------------------------- +// +GLDEF_C TInt E32Main() + { + __UHEAP_MARK; + TRACE_FUNC_ENTRY + CTrapCleanup* cleanup = CTrapCleanup::New(); + TInt err = KErrNoMemory; + if ( cleanup ) + { + TRAP( err, RunServerL() ); + delete cleanup; + } + __UHEAP_MARKEND; + return err; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengsrvbbconnectionmgr.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsrvbbconnectionmgr.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,390 @@ +/* +* Copyright (c) 2006 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: Helper class for handling Bluetooth Baseband-related +* connection management. +* +*/ + + + +#include +#include + +#include "btengsrvbbconnectionmgr.h" +#include "debug.h" + +/** ?description */ +const TInt KBTEngSrvBBConnId = 11; +/** ?description */ +const TInt KBTEngSrvWlanStatusId = 12; +/** ?description */ +const TInt KBTEngMaxAddrArraySize = 10; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSrvBBConnMgr::CBTEngSrvBBConnMgr(RSocketServ& aSockServ) + : iSockServ(aSockServ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::ConstructL() + { + iLinkCountWatcher = CBTEngActive::NewL( *this, KBTEngSrvBBConnId, + CActive::EPriorityStandard ); + // Subscribe to the BT Baseband link count. + User::LeaveIfError( iLinkCountProperty.Attach( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount ) ); + // Check if we need to monitor WLAN + FeatureManager::InitializeLibL(); + iWlanSupported = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ); + FeatureManager::UnInitializeLib(); + if( iWlanSupported ) + { + iWlanWatcher = CBTEngActive::NewL( *this, KBTEngSrvWlanStatusId, + CActive::EPriorityStandard ); + User::LeaveIfError( iWlanStatusProperty.Attach( KPSUidWlan, + KPSWlanIndicator ) ); + } + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSrvBBConnMgr* CBTEngSrvBBConnMgr::NewL(RSocketServ& aSockServ) + { + CBTEngSrvBBConnMgr* self = new( ELeave ) CBTEngSrvBBConnMgr(aSockServ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSrvBBConnMgr::~CBTEngSrvBBConnMgr() + { + Unsubscribe(); + iLinkCountProperty.Close(); + iWlanStatusProperty.Close(); + delete iLinkCountWatcher; + delete iWlanWatcher; + delete iPhyLinks; + } + + +// --------------------------------------------------------------------------- +// Start listening to the relevant properties. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::Subscribe() + { + if( !iLinkCountWatcher->IsActive() ) + { + iLinkCountProperty.Subscribe( iLinkCountWatcher->RequestStatus() ); + iLinkCountWatcher->GoActive(); + } + if( iWlanSupported && !iWlanWatcher->IsActive() ) + { + iWlanStatusProperty.Subscribe( iWlanWatcher->RequestStatus() ); + iWlanWatcher->GoActive(); + } + } + + +// --------------------------------------------------------------------------- +// Stop listening to the subscribed properties. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::Unsubscribe() + { + if( iLinkCountWatcher->IsActive() ) + { + iLinkCountProperty.Cancel(); + iLinkCountWatcher->CancelRequest(); + } + if( iWlanWatcher && iWlanWatcher->IsActive() ) + { + iWlanStatusProperty.Cancel(); + iWlanWatcher->CancelRequest(); + } + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvBBConnMgr::ManageTopology( TBool aPrepDiscovery ) + { + TInt linkCount = 0; + TBool closeSock = ETrue; // To check if we can close the handle again. + TInt err = iLinkCountProperty.Get( linkCount ); + if( !err && !linkCount && iAutoSwitchOff ) + { + // Inform server that there are no active connections anymore. + iAutoSwitchOff = EFalse; + iCallBack.CallBack(); + } + RBTDevAddrArray addrArray; + TInt minLinks = 1; // We don't care about our role if we have only one link. + if( aPrepDiscovery || GetWlanStatus() ) + { + // If we are performing discovery shortly, or we have an active WLAN + // connection, then request master role on all links. + minLinks = 0; + } + if( !err && linkCount > minLinks ) + { + if( iPhyLinks ) + { + // If we have an open handle with the socket server (because we + // are disconnecting all links), then don't close the socket. + closeSock = EFalse; + } + // There are existing links; get the addresses. + TRAP( err, GetConnectedAddressesL( addrArray ) ); + } + if( !err && addrArray.Count() > minLinks ) + { + // Try to become master on all the links. + RBTPhysicalLinkAdapter btLink; + for( TInt i = 0; i < addrArray.Count(); i++ ) + { + // At this point, the results of the operations do not matter + // too much. If an error is returned, then that only affects + // further operations on the same link, and they should not be + // passed back to the caller. + TUint32 basebandState = 0; + err = btLink.Open( iSockServ, addrArray[ i ] ); + if( !err ) + { + // Mostly for logging purposes, check the current role (the + // request will anyway be ignored if we're already master). + err = btLink.PhysicalLinkState( basebandState ); + TRACE_INFO( ( + _L( "[BTEng]\t ManageTopology: Current role: %d; status: %d" ), + (TInt) ( basebandState & ENotifyAnyRole ), err ) ) + } + if( !err && ( basebandState & ENotifySlave ) ) + { + // Try to become master of this link. This request could + // be issued without checking the current role, and would + // just be ignored if we are already master. The return + // value is also ignored later on, at this stage it is + // not important if the call succeeds. + err = btLink.RequestMasterRole(); + TRACE_INFO( ( + _L( "[BTEng]\t Requesting master role; result: %d" ), err ) ) + } + // Reset the result, so that it is not passed up + // (in case this was the last one in the loop). + err = KErrNone; + btLink.Close(); + } + } + addrArray.Close(); + if( closeSock ) + { + delete iPhyLinks; + iPhyLinks = NULL; + } + return err; + } + + +// --------------------------------------------------------------------------- +// Gets an array of addresses of remote devices for all Baseband connections. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::GetConnectedAddressesL( RBTDevAddrArray& aAddrArray ) + { + TInt err = KErrNone; + if( !iPhyLinks ) + { + iPhyLinks = CBluetoothPhysicalLinks::NewL( *this, iSockServ ); + } + if( !err ) + { + err = iPhyLinks->Enumerate( aAddrArray, KBTEngMaxAddrArraySize ); + } + User::LeaveIfError( err ); + } + + +// --------------------------------------------------------------------------- +// Request to disconnect all Bluetooth baseband connections. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::DisconnectAllLinksL( TCallBack& aCallBack ) + { + TRACE_FUNC_ENTRY + iCallBack = aCallBack; + RBTDevAddrArray addrArray; + GetConnectedAddressesL( addrArray ); + TInt err = KErrNone; + if( addrArray.Count() > 0 ) + { + err = iPhyLinks->DisconnectAll(); + } + else + { + err = KErrNotFound; + } + addrArray.Close(); + if( err && err != KErrInUse ) + { + // No connections, or something went wrong; just clean up + // and inform our client. + HandleDisconnectAllCompleteL( err ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Request to disconnect all Bluetooth baseband connections. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::SetAutoSwitchOff( TBool aEnable, TCallBack& aCallBack ) + { + iAutoSwitchOff = aEnable; + iCallBack = aCallBack; + if( aEnable ) + { + TInt linkCount = 0; + TInt err = iLinkCountProperty.Get( linkCount ); + if( !err && !linkCount ) + { + iCallBack.CallBack(); + } + } + } + + +// --------------------------------------------------------------------------- +// From class MBluetoothPhysicalLinksNotifier. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::HandleCreateConnectionCompleteL( TInt aErr ) + { + (void) aErr; + } + + +// --------------------------------------------------------------------------- +// From class MBluetoothPhysicalLinksNotifier. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::HandleDisconnectCompleteL( TInt aErr ) + { + (void) aErr; + } + + +// --------------------------------------------------------------------------- +// From class MBluetoothPhysicalLinksNotifier. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::HandleDisconnectAllCompleteL( TInt aErr ) + { + TRACE_FUNC_ARG( ( _L( "error: %d" ), aErr ) ) + delete iPhyLinks; + iPhyLinks = NULL; + iCallBack.CallBack(); // Inform our client. + (void) aErr; // There is no way to pass the error code; + // anyway our client is not interested.. + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "id: %d; status: %d" ), aId, aStatus ) ) + ASSERT( aId == KBTEngSrvBBConnId || aId == KBTEngSrvWlanStatusId ); + (void) aActive; + (void) aId; + if( aStatus != KErrPermissionDenied ) + { + // Ignore any other errors. + // First subscribe again, so that we don't miss any updates. + Subscribe(); + } + (void) ManageTopology( EFalse ); // Ignore result; nothing to do + // about it here. + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Handles an error in RunL( i.e. RequestCompletedL). Does nothing, since our +// RunL cannot actually leave. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "id: %d; status: %d" ), aId, aError ) ) + (void) aActive; + (void) aId; + (void) aError; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TBool CBTEngSrvBBConnMgr::GetWlanStatus() + { + TInt wlanStatus = 0; + TBool connected = EFalse; + if( iWlanSupported ) + { + TInt err = iWlanStatusProperty.Get( wlanStatus ); + if( err ) + { + wlanStatus = 0; // Reset just to be sure. + } + } + if( wlanStatus == EPSWlanIndicatorActive || + wlanStatus == EPSWlanIndicatorActiveSecure ) + { + connected = ETrue; + } + return connected; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengsrvkeywatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,559 @@ +/* +* Copyright (c) 2006 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: Watcher for BTEng server PubSub and CenRep keys. +* +*/ + + + +#include +#include +#include +#include +#include + +#include "btengsrvkeywatcher.h" +#include "btengserver.h" +#include "btengsrvpluginmgr.h" +#include "btengprivatepskeys.h" +#include "btengprivatecrkeys.h" +#include "debug.h" + +/** Identification for active object */ +const TInt KBTEngDutWatcher = 15; +/** Identification for active object */ +const TInt KBTEngLockWatcher = 16; +/** Identification for active object */ +const TInt KBTEngSysWatcher = 17; +/** Identification for active object */ +const TInt KBTEngPHYCountWatcher = 18; +/** Identification for active object */ +const TInt KBTEngBtConnectionWatcher = 19; +/** Identification for active object */ +const TInt KBTEngScanningWatcher = 20; +/** Identification for active object */ +const TInt KBTEngEmergencyWatcher = 21; +/** Identification for active object */ +const TInt KBTEngSapWatcher = 22; +/** Identification for active object */ +const TInt KBTEngAddrWatcher = 23; +/** Identification for active object */ +const TInt KBTEngRegistryWatcher = 24; +/** Identification for active object */ +const TInt KBTEngSspDebugWatcher = 25; +/** Buffer size for BT device address as stored in CenRep */ +const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSrvKeyWatcher::CBTEngSrvKeyWatcher( CBTEngServer* aServer ) +: iServer( aServer ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSrvKeyWatcher::ConstructL() + { + TRACE_FUNC_ENTRY + TInt err = iDutModeKey.Attach( KPSUidBluetoothTestingMode, KBTDutEnabled ); + if( !err ) + { + iDutModeWatcher = CBTEngActive::NewL( *this, KBTEngDutWatcher, + CActive::EPriorityStandard ); + iDutModeKey.Subscribe( iDutModeWatcher->RequestStatus() ); + iDutModeWatcher->GoActive(); + } +#ifdef RD_REMOTELOCK + err = iPhoneLockKey.Attach( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus ); + if( !err ) + { + iPhoneLockWatcher = CBTEngActive::NewL( *this, KBTEngLockWatcher, + CActive::EPriorityStandard ); + iPhoneLockKey.Subscribe( iPhoneLockWatcher->RequestStatus() ); + iPhoneLockWatcher->GoActive(); + } +#endif //RD_REMOTELOCK + + err = iSystemStateKey.Attach( KPSUidStartup, KPSGlobalSystemState ); + if( !err ) + { + iSystemStateWatcher = CBTEngActive::NewL( *this, KBTEngSysWatcher, + CActive::EPriorityStandard ); + iSystemStateKey.Subscribe( iSystemStateWatcher->RequestStatus() ); + iSystemStateWatcher->GoActive(); + } + + err = iPHYCountKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount ); + if( !err ) + { + iPHYCountWatcher = CBTEngActive::NewL( *this, KBTEngPHYCountWatcher, + CActive::EPriorityStandard ); + iPHYCountKey.Subscribe( iPHYCountWatcher->RequestStatus() ); + iPHYCountWatcher->GoActive(); + } + + err = iBtConnectionKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting ); + if( !err ) + { + iBtConnectionWatcher = CBTEngActive::NewL( *this, KBTEngBtConnectionWatcher, + CActive::EPriorityStandard ); + iBtConnectionKey.Subscribe( iBtConnectionWatcher->RequestStatus() ); + iBtConnectionWatcher->GoActive(); + } + + err = iBtScanningKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothSetScanningStatus ); + if( !err ) + { + iBtScanningWatcher = CBTEngActive::NewL( *this, KBTEngScanningWatcher, + CActive::EPriorityStandard ); + iBtScanningKey.Subscribe( iBtScanningWatcher->RequestStatus() ); + iBtScanningWatcher->GoActive(); + } + + err = iEmergencyCallKey.Attach( KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo ); + if( !err ) + { + iEmergencyCallWatcher = CBTEngActive::NewL( *this, KBTEngEmergencyWatcher, + CActive::EPriorityStandard ); + iEmergencyCallKey.Subscribe( iEmergencyCallWatcher->RequestStatus() ); + iEmergencyCallWatcher->GoActive(); + } + + err = iBtRegistryKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetRegistryTableChange ); + if( !err ) + { + iBtRegistryWatcher = CBTEngActive::NewL( *this, KBTEngRegistryWatcher, + CActive::EPriorityStandard ); + iBtRegistryKey.Subscribe( iBtRegistryWatcher->RequestStatus() ); + iBtRegistryWatcher->GoActive(); + } + + err = iSspDebugModeKey.Attach( KPSUidBluetoothTestingMode, KBTSspDebugmode ); + if( !err ) + { + iSspDebugModeWatcher = CBTEngActive::NewL( *this, KBTEngSspDebugWatcher, + CActive::EPriorityStandard ); + iSspDebugModeKey.Subscribe( iSspDebugModeWatcher->RequestStatus() ); + iSspDebugModeWatcher->GoActive(); + } + + // Use TRAP here, because it leaves if the key does not exist. + TRAP( err, iSapKeyCenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ) ); + if( !err ) + { + iSapModeWatcher = CBTEngActive::NewL( *this, KBTEngSapWatcher, + CActive::EPriorityStandard ); + err = iSapKeyCenRep->NotifyRequest( KBTSapEnabled, + iSapModeWatcher->RequestStatus() ); + } + if( !err ) + { + iSapModeWatcher->GoActive(); + } + err = iBdaddrKey.Attach( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetLocalDeviceAddress ); + + if( !err ) + { + CheckBDAddrL(); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSrvKeyWatcher* CBTEngSrvKeyWatcher::NewL( CBTEngServer* aServer ) + { + CBTEngSrvKeyWatcher* self = new( ELeave ) CBTEngSrvKeyWatcher( aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSrvKeyWatcher::~CBTEngSrvKeyWatcher() + { + if( iDutModeKey.Handle() ) + { + iDutModeKey.Cancel(); + } + delete iDutModeWatcher; + iDutModeKey.Close(); + +#ifdef RD_REMOTELOCK + if( iPhoneLockKey.Handle() ) + { + iPhoneLockKey.Cancel(); + } + delete iPhoneLockWatcher; + iPhoneLockKey.Close(); +#endif //RD_REMOTELOCK + + if( iSystemStateKey.Handle() ) + { + iSystemStateKey.Cancel(); + } + delete iSystemStateWatcher; + iSystemStateKey.Close(); + + if( iPHYCountKey.Handle() ) + { + iPHYCountKey.Cancel(); + } + delete iPHYCountWatcher; + iPHYCountKey.Close(); + + if( iBtConnectionKey.Handle() ) + { + iBtConnectionKey.Cancel(); + } + delete iBtConnectionWatcher; + iBtConnectionKey.Close(); + + if( iBtScanningKey.Handle() ) + { + iBtScanningKey.Cancel(); + } + delete iBtScanningWatcher; + iBtScanningKey.Close(); + + if( iEmergencyCallKey.Handle() ) + { + iEmergencyCallKey.Cancel(); + } + delete iEmergencyCallWatcher; + iEmergencyCallKey.Close(); + + if( iSspDebugModeKey.Handle() ) + { + iSspDebugModeKey.Cancel(); + } + delete iSspDebugModeWatcher; + iSspDebugModeKey.Close(); + + if( iBtRegistryKey.Handle() ) + { + iBtRegistryKey.Cancel(); + } + delete iBtRegistryWatcher; + iBtRegistryKey.Close(); + + if( iSapKeyCenRep ) + { + iSapKeyCenRep->NotifyCancel( KBTSapEnabled ); + } + delete iSapModeWatcher; + delete iSapKeyCenRep; + + if( iBdaddrKey.Handle() ) + { + iBdaddrKey.Cancel(); + } + delete iBdaddrWatcher; + iBdaddrKey.Close(); + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Processes a changed key value. +// --------------------------------------------------------------------------- +// +void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_FUNC_ARG( ( _L( "status %d" ), aStatus ) ) + ASSERT( aStatus != KErrPermissionDenied ); + TInt val = 0; + switch( aId ) + { + case KBTEngDutWatcher: + { + TRACE_INFO( ( _L( "DUT mode key changed" ) ) ) + iDutModeKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + if( !aStatus && !iDutModeKey.Get( val ) ) + { + iServer->SetDutMode( val ); + } + } + break; + case KBTEngLockWatcher: + { + TRACE_INFO( ( _L( "phone lock key changed" ) ) ) +#ifdef RD_REMOTELOCK + iPhoneLockKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + TInt remoteLockVal = 0; + remoteLockVal = ERemoteLocked; + if( !aStatus && !iPhoneLockKey.Get( val ) && val == remoteLockVal ) + { + iServer->SetPowerStateL( EBTPowerOff, EFalse ); + } +#endif //RD_REMOTELOCK + } + break; + case KBTEngSysWatcher: + { + TRACE_INFO( ( _L( "System state key changed" ) ) ) + iSystemStateKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + if( !aStatus && !iSystemStateKey.Get( val ) && + val == ESwStateShuttingDown ) + { + iServer->SetVisibilityModeL( EBTVisibilityModeNoScans , 0 ); + iServer->DisconnectAllL(); + } + } + break; + case KBTEngPHYCountWatcher: + { + TRACE_INFO( ( _L( "PHY count key changed" ) ) ) + iPHYCountKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + iServer->SetUiIndicatorsL(); + } + break; + case KBTEngBtConnectionWatcher: + { + TRACE_INFO( ( _L( "BT connection key changed" ) ) ) + iBtConnectionKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + iServer->SetUiIndicatorsL(); + } + break; + case KBTEngScanningWatcher: + { + TRACE_INFO( ( _L( "BT stack scanning key changed" ) ) ) + iBtScanningKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + if ( !iBtScanningKey.Get( val ) ) + { + iServer->UpdateVisibilityModeL( val ); + } + } + break; + case KBTEngEmergencyWatcher: + { + TRACE_INFO( ( _L( "Emergency call key changed" ) ) ) + iEmergencyCallKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + if( !aStatus && !iEmergencyCallKey.Get( val ) && val ) + { + // An emergency call initiated -> Close SAP connection if it's active + iServer->iPluginMgr->DisconnectProfile( EBTProfileSAP ); + } + } + break; + case KBTEngSspDebugWatcher: + { + TRACE_INFO( ( _L( "Simple pairing debug mode key changed" ) ) ) + iSspDebugModeKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + if( !aStatus && !iSspDebugModeKey.Get( val ) ) + { + iServer->CheckSspDebugModeL( (TBool) val ); + } + break; + } + case KBTEngRegistryWatcher: + { + TRACE_INFO( ( _L( "BT Registry key changed" ) ) ) + TInt myChangedTable; + + iBtRegistryKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + + TInt err = iBtRegistryKey.Get( myChangedTable ); + if( !err && myChangedTable == KRegistryChangeRemoteTable ) + { + TRACE_INFO( ( _L("BT Remote registry key changed") ) ) + iServer->RemoteRegistryChangeDetected(); + } + break; + } + case KBTEngSapWatcher: + { + TRACE_INFO( ( _L( "SAP mode key changed" ) ) ) + iSapKeyCenRep->NotifyRequest( KBTSapEnabled, aActive->RequestStatus() ); + aActive->GoActive(); + iSapKeyCenRep->Get( KBTSapEnabled, val ); + + TBTPowerStateValue powerState = EBTPowerOff; + User::LeaveIfError( iServer->GetHwPowerState( (TBTPowerStateValue&) powerState ) ); + if( aStatus >= 0 && powerState ) + { + // Relevant only if BT is on + if( val == EBTSapEnabled ) + { + iServer->iPluginMgr->LoadBTSapPluginL(); + } + else + { + iServer->iPluginMgr->UnloadBTSapPlugin(); + } + } + } + break; + case KBTEngAddrWatcher: + { + TBuf8 addrPubSub; + iBdaddrKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + + if( !aStatus && !iBdaddrKey.Get( addrPubSub ) && + addrPubSub.Length() == KBTDevAddrSize ) + { + iBdaddrKey.Cancel(); + + TBTDevAddr addr( addrPubSub ); + TBuf addrCenRep; + addr.GetReadable( addrCenRep ); + // Write the key to CenRep and stop listening. + CRepository* cenRep = CRepository::NewL( + KCRUidBluetoothLocalDeviceAddress ); + cenRep->Set( KBTLocalDeviceAddress, addrCenRep ); + if ( iBdaddrWatcher ) + { + delete iBdaddrWatcher; + iBdaddrWatcher = NULL; + } + iBdaddrKey.Close(); + } + } + break; + default: + { + TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aId ) ) + } + break; + + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Handles a leave in RunL/RequestCompletedL by checking that all +// the subscriptions are active. +// --------------------------------------------------------------------------- +// +void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, TInt aId, + TInt aError ) + { + TRACE_FUNC_ARG( ( _L( "status %d" ), aError ) ) + (void) aError; + if( !aActive->IsActive() ) + { + switch( aId ) + { + case KBTEngDutWatcher: + { + iDutModeKey.Subscribe( aActive->RequestStatus() ); + } + break; + case KBTEngLockWatcher: + { +#ifdef RD_REMOTELOCK + iPhoneLockKey.Subscribe( aActive->RequestStatus() ); +#else + return; // we don't want to go active without subscribing +#endif //RD_REMOTELOCK + } + break; + case KBTEngSysWatcher: + { + iSystemStateKey.Subscribe( aActive->RequestStatus() ); + } + break; + case KBTEngSspDebugWatcher: + { + iSspDebugModeKey.Subscribe( aActive->RequestStatus() ); + } + break; + case KBTEngSapWatcher: + { + iSapKeyCenRep->NotifyRequest( KBTSapEnabled, aActive->RequestStatus() ); + } + break; + default: + { + TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aId ) ) + } + return; // we don't want to go active without subscribing + } + aActive->GoActive(); + } + } + + +// --------------------------------------------------------------------------- +// Checks if we have already stored the BD_ADDR in CenRep; if not, we get it +// from PubSub. If not available from PubSub yet, we subscribe to the key. +// --------------------------------------------------------------------------- +// +void CBTEngSrvKeyWatcher::CheckBDAddrL() + { + TBuf addrCenRep; + CRepository* cenRep = NULL; + // Use TRAP to catch a leave if the CenRep key does not exist. + TRAPD( err, cenRep = CRepository::NewL( KCRUidBluetoothLocalDeviceAddress ) ); + CleanupStack::PushL( cenRep ); + if( !err ) + { + err = cenRep->Get( KBTLocalDeviceAddress, addrCenRep ); + } + if( err || addrCenRep.Length() != KCenRepAddrBufSize ) + { + TBuf8 addrPubSub; + err = iBdaddrKey.Get( addrPubSub ); + if( !err && addrPubSub.Length() == KBTDevAddrSize ) + { + TBTDevAddr addr( addrPubSub ); // For easy conversion + addr.GetReadable( addrCenRep ); + cenRep->Set( KBTLocalDeviceAddress, addrCenRep ); + iBdaddrKey.Close(); + } + else + { + iBdaddrWatcher = CBTEngActive::NewL( *this, KBTEngAddrWatcher, + CActive::EPriorityStandard ); + iBdaddrKey.Subscribe( iBdaddrWatcher->RequestStatus() ); + iBdaddrWatcher->GoActive(); + } + } + else + { + iBdaddrKey.Close(); + } + CleanupStack::PopAndDestroy( cenRep ); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengsrvpluginmgr.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsrvpluginmgr.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,843 @@ +/* +* Copyright (c) 2006 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: Helper class for BTEng server to manage and interface with +* the profile plug-ins the profile plug-ins. +* +*/ + + + +#include +#include +#include +#include + +#include "btengsrvpluginmgr.h" +#include "btengserver.h" +#include "btengsrvsession.h" +#include "btengsrvbbconnectionmgr.h" +#include "btengprivatecrkeys.h" +#include "debug.h" +#include + +/** UID for BTEng plug-ins */ +const TUid KBTEngPluginUid = { 0x2000277B }; +/** ECOM registration info for BTSAP plugin */ +_LIT8( KEComBTSapPlugin, "112D" ); +/** The message argument which holds the Bluetooth address. */ +const TInt KBTEngAddrSlot = 0; +/** The message argument which holds the connection status parameter. */ +const TInt KBTEngParamSlot = 1; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSrvPluginMgr::CBTEngSrvPluginMgr( CBTEngServer* aServer ) +: iServer( aServer ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSrvPluginMgr* CBTEngSrvPluginMgr::NewL( CBTEngServer* aServer ) + { + CBTEngSrvPluginMgr* self = new( ELeave ) CBTEngSrvPluginMgr( aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSrvPluginMgr::~CBTEngSrvPluginMgr() + { + iPluginInfoArray.Close(); + iPluginArray.ResetAndDestroy(); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::ProcessCommandL( const RMessage2& aMessage ) + { + TRACE_FUNC_ENTRY + TInt opcode = aMessage.Function(); + TInt err = KErrNone; + TBTDevAddrPckgBuf addr; + switch( opcode ) + { + case EBTEngConnectDevice: + { + aMessage.ReadL( KBTEngAddrSlot, addr ); + TBTEngDevClassPkg cod; + aMessage.ReadL( KBTEngParamSlot, cod ); + err = Connect( addr(), TBTDeviceClass( cod() ) ); + } + break; + case EBTEngCancelConnectDevice: + { + aMessage.ReadL( KBTEngAddrSlot, addr ); + err = CancelConnect( addr() ); + } + break; + case EBTEngDisconnectDevice: + { + aMessage.ReadL( KBTEngAddrSlot, addr ); + TPckgBuf discType; + aMessage.ReadL( KBTEngParamSlot, discType ); + err = Disconnect( addr(), (TBTDisconnectType) discType() ); + } + break; + case EBTEngIsDeviceConnected: + { + aMessage.ReadL( KBTEngAddrSlot, addr ); + TBTEngConnectionStatus connectStatus = EBTEngNotConnected; + connectStatus = IsDeviceConnected( addr() ); + TBTEngParamPkg statusPkg( connectStatus ); + aMessage.WriteL( KBTEngParamSlot, statusPkg ); + } + break; + case EBTEngIsDeviceConnectable: + { + aMessage.ReadL( KBTEngAddrSlot, addr ); + TBTEngDevClassPkg cod; + aMessage.ReadL( KBTEngParamSlot, cod ); + TBool connectable = ( GetConnectablePluginIndex(cod(), addr() ) != KErrNotFound ) ; + TPckgBuf connPkg( connectable ); + aMessage.WriteL( 2, connPkg ); + } + break; + case EBTEngGetConnectedAddresses: + { + TPckgBuf profile; + aMessage.ReadL( KBTEngParamSlot, profile ); + RBTDevAddrArray addrArray; + if( profile() == EBTProfileUndefined ) + { + // Get all baseband connections + iServer->iBBConnMgr->GetConnectedAddressesL( addrArray ); + } + else + { + err = GetConnectedAddresses( addrArray, profile() ); + } + HBufC8* buf = HBufC8::NewLC( aMessage.GetDesMaxLengthL( KBTEngAddrSlot ) ); + TPtr8 ptr = buf->Des(); + aMessage.ReadL( KBTEngAddrSlot, ptr ); + ptr.Zero(); + for( TInt i = 0; i < addrArray.Count(); i++ ) + { + addr = addrArray[ i ]; + ptr.Append( addr ); + } + aMessage.WriteL( KBTEngAddrSlot, ptr ); + CleanupStack::PopAndDestroy( buf ); + } + break; + default: + { + TRACE_INFO( ( _L( "ProcessCommandL: bad request (%d)" ), + aMessage.Function() ) ) + err = KErrArgument; + } + break; + } + User::LeaveIfError( err ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::DisconnectAllPlugins() + { + TRACE_FUNC_ENTRY + TBTDevAddr nullAddr; + for( TInt i = 0; i < iPluginArray.Count(); i++ ) + { + (void) iPluginArray[ i ]->Disconnect( nullAddr, EBTDiscImmediate ); + } + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::LoadProfilePluginsL( const TEComResolverParams aParams ) + { + TRACE_FUNC_ENTRY + if( aParams.DataType().Length() ) + { + // This is a request to enable a specific service, e.g. BT SAP. + REComSession::ListImplementationsL( KBTEngPluginUid, aParams, + iPluginInfoArray ); + } + else + { + if( iPluginArray.Count() > 0 || iPluginInfoArray.Count() > 0 ) + { + // Could be the case if we received a command to turn BT on + // halfway through a power down sequence. Just ignore. + return; + } + iPluginInfoArray.Reset(); + iPluginArray.Reset(); + REComSession::ListImplementationsL( KBTEngPluginUid, iPluginInfoArray ); + } + // Ignore the number of plug-ins left to load; the server state machine + // will handle this at a later stage. + (void) LoadPluginL(); + TRACE_FUNC_EXIT + } + +TBool CBTEngSrvPluginMgr::FilterByEnterpriseDisablementModeL(TUid aUid) const + { + TRACE_FUNC_ENTRY + TBool want = EFalse; + switch ( iServer->EnterpriseEnablementMode() ) + { + case BluetoothFeatures::EDisabled: + // In Disabled mode all plugins are filtered out. + break; + case BluetoothFeatures::EDataProfilesDisabled: + // In 'privileged profiles only' mode we only allow the following. + if ( aUid == TUid::Uid(0x1020897B) // audio (i.e. allow HSP, HFP and A2DP) + || aUid == TUid::Uid(0x10208979) // remote control (i.e. allow AVRCP) ) + || aUid == TUid::Uid(0x2001E309) // HID + ) + { + want = ETrue; + } + break; + case BluetoothFeatures::EEnabled: + // In Enabled mode we do not filter plugins. + want = ETrue; + break; + default: + __ASSERT_DEBUG( NULL, PanicServer( EBTEngPanicCorruptSettings ) ); + break; + } + TRACE_INFO( ( _L( "[BTENG]\t returning want = %d" ), want ) ) + TRACE_FUNC_EXIT + return want; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::LoadPluginL() + { + TRACE_FUNC_ENTRY + if( !iPluginInfoArray.Count() ) + { + // All plug-ins have been loaded. + return KErrNotFound; + } + + // Simply pop the first info object, process it, and delete it. + // There is no need to keep it after the plug-in has been constructed. + CImplementationInformation* implInfo = iPluginInfoArray[ 0 ]; + iPluginInfoArray.Remove( 0 ); + CleanupStack::PushL( implInfo ); + TLex8 lex( implInfo->DataType() ); + TUint profile = (TInt) EBTProfileUndefined; + TInt err = lex.Val( profile, EHex ); + // Check if the feature is allowed to be loaded + if( !err && CheckFeatureEnabledL( profile ) && FilterByEnterpriseDisablementModeL(implInfo->ImplementationUid()) ) + { + TRACE_INFO( ( _L( "[BTENG]\t loading profile 0x%04x" ), profile ) ) + TUid implUid = implInfo->ImplementationUid(); + CBTEngPlugin* plugin = CBTEngPlugin::NewL( implUid ); + CleanupStack::PushL( plugin ); + plugin->SetObserver( ( MBTEngPluginObserver* ) this ); + User::LeaveIfError( iPluginArray.Append( plugin ) ); + CleanupStack::Pop( plugin ); + } + CleanupStack::PopAndDestroy( implInfo ); + TRACE_FUNC_RES( ( _L( "%d plug-ins left to load" ), iPluginInfoArray.Count() ) ) + return iPluginInfoArray.Count(); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::UnloadProfilePlugins() + { + TRACE_FUNC_ARG( ( _L( "[BTENG]\t unloading %d plug-ins" ), iPluginArray.Count() ) ) + + // All plug-ins need to be unloaded at once. Otherwise it gets too + // difficult to keep track in case of a power-on command during a + // power-off sequence. + iPluginArray.ResetAndDestroy(); + + REComSession::FinalClose(); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::LoadBTSapPluginL() + { + TRACE_FUNC_ENTRY + + // SAP is supported in neither Data Profiles Disabled nor Disabled mode. + if ( iServer->EnterpriseEnablementMode() != BluetoothFeatures::EEnabled ) + { + TRACE_INFO( ( _L( "\tno we're not... Bluetooth is enterprise-IT-disabled" ) ) ) + User::Leave(KErrNotSupported); + } + + if( CheckFeatureEnabledL( EBTProfileSAP ) ) + { + TEComResolverParams params; + TPtrC8 ptr( KEComBTSapPlugin ); + params.SetDataType( ptr ); + LoadProfilePluginsL( params ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::UnloadBTSapPlugin() + { + TRACE_FUNC_ENTRY + TInt ret = GetFirstPluginOfProfileSupported( EBTProfileSAP ); + if( ret != KErrNotFound ) + { + CBTEngPlugin* plugin = iPluginArray[ ret ]; + iPluginArray.Remove( ret ); + delete plugin; + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::DisconnectProfile( TBTProfile aProfile ) + { + TRACE_FUNC_ENTRY + RBTDevAddrArray addrArray; + TInt count = iPluginArray.Count(); + while( count ) + { + count--; + if( iPluginArray[ count ]->IsProfileSupported( aProfile ) ) + { + iPluginArray[ count ]->GetConnections( addrArray, aProfile ); + for ( TInt i = 0; i < addrArray.Count(); i++ ) + { + iPluginArray[ count ]->Disconnect( addrArray[i], EBTDiscImmediate ); + } + break; + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngPluginObserver. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::ConnectComplete( const TBTDevAddr& aAddr, + TBTProfile aProfile, TInt aErr, RBTDevAddrArray* aConflicts ) + { + TRACE_FUNC_ENTRY + // Inform listeners of this event. + (void) aProfile; + iServer->iSessionIter.SetToFirst(); + CBTEngSrvSession* session = (CBTEngSrvSession*) iServer->iSessionIter++; + while( session ) + { + TRACE_INFO( ( _L( "[BTEng]\t Notifying session %d" ), (TInt) session ) ) + session->NotifyConnectionEvent( aAddr, EBTEngConnected, aConflicts, aErr ); + session = (CBTEngSrvSession*) iServer->iSessionIter++; + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngPluginObserver. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvPluginMgr::DisconnectComplete( const TBTDevAddr& aAddr, + TBTProfile aProfile, TInt aErr ) + { + TRACE_FUNC_ENTRY + // Inform listeners of this event. + (void) aProfile; + iServer->iSessionIter.SetToFirst(); + CBTEngSrvSession* session = (CBTEngSrvSession*) iServer->iSessionIter++; + while( session ) + { + TRACE_INFO( ( _L( "[BTEng]\t Notifying session %d" ), (TInt) session ) ) + session->NotifyConnectionEvent( aAddr, EBTEngNotConnected, NULL, aErr ); + session = (CBTEngSrvSession*) iServer->iSessionIter++; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::Connect( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ) + { + TRACE_FUNC_ENTRY + TRACE_BDADDR ( aAddr ) + TInt pindex = GetConnectablePluginIndex( aDeviceClass ); + TRACE_INFO( ( _L( "[BTEng]\t The %dth of plugin in plugarray to connect" ), pindex ) ) + TInt err (KErrNotFound); + if( pindex != KErrNotFound && iPluginArray.Count()) + { + err = iPluginArray[ pindex ]->Connect( aAddr ); + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::CancelConnect( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNotFound; + TRACE_BDADDR(aAddr); + for( TInt i = 0; i < iPluginArray.Count(); i++ ) + { + TBTEngConnectionStatus status = iPluginArray[ i ]->IsConnected( aAddr ); + if( status == EBTEngConnecting || status == EBTEngConnected ) + { + (void) iPluginArray[ i ]->CancelConnect( aAddr ); + err = KErrNone; + break; + } + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::Disconnect( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ) + { + TRACE_FUNC_ENTRY + TRACE_BDADDR(aAddr); + TInt err = KErrNotFound; + for( TInt i = 0; i < iPluginArray.Count(); i++ ) + { + // Should be ignored if the plug-in does not have + // a connection to the address. + err = iPluginArray[ i ]->Disconnect( aAddr, aDiscType ); + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TBTEngConnectionStatus CBTEngSrvPluginMgr::IsDeviceConnected( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + TRACE_BDADDR(aAddr); + TBTEngConnectionStatus status = EBTEngNotConnected; + for( TInt i = 0; i < iPluginArray.Count(); i++ ) + { + status = iPluginArray[ i ]->IsConnected( aAddr ); + if( status == EBTEngConnecting || status == EBTEngConnected ) + { + break; // Just exit the loop here, we have a connection status. + } + } + TRACE_FUNC_RES( ( _L( "result: %d" ), (TInt) status ) ) + return status; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::GetConnectablePluginIndex( const TBTDeviceClass& aDeviceClass, const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + TInt plugindex( KErrNotFound ); + TRACE_BDADDR(aAddr); + TRACE_INFO ( (_L("[BTENG] cod %b"), aDeviceClass.DeviceClass())) + if( aAddr != TBTDevAddr() ) + { + DoGetEirData( aAddr ); + } + + if( iUuidContainter.UUIDs().Count() > 0) + { + plugindex = GetConnectablePluginIndexByEir(); + } + + if ( plugindex == KErrNotFound ) + { + TBTProfile profile = MapDeviceClassToProfile( aDeviceClass ); + if( profile == EBTProfileUndefined ) + { + return plugindex; + } + + plugindex = GetFirstPluginOfProfileSupported( profile ); + + if ( !iPluginArray.Count() ) + { + // In case BT is off and plugins are not loaded + if ( profile == EBTProfileHFP || profile == EBTProfileA2DP ) + { + plugindex = KErrNone; + } + } + } + + TRACE_FUNC_RES( ( _L( "result: %d" ), plugindex ) ) + return plugindex; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::GetConnectedAddresses( RBTDevAddrArray& aAddrArray, + TBTProfile aProfile ) + { + TRACE_FUNC_ENTRY + TInt ret = GetFirstPluginOfProfileSupported( aProfile ); + if( ret != KErrNotFound ) + { + iPluginArray[ ret ]->GetConnections( aAddrArray, aProfile ); + ret = KErrNone; + } + TRACE_FUNC_RES( ( _L( "result: %d" ), ret ) ) + return ret; + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TBool CBTEngSrvPluginMgr::CheckFeatureEnabledL( TInt aProfile ) + { + TRACE_FUNC_ARG( ( _L( "requested feature: 0x%04x" ), aProfile ) ) + // By default, a feature is supported. This allowd features that do not + // have a related feature flag to be loaded too. + TBool supported = ETrue; + if( aProfile == EBTProfileSAP ) + { + // First check from central repository. + CRepository* cenrep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + TInt enabled = 0; + TInt err = cenrep->Get( KBTSapEnabled, enabled ); + delete cenrep; + if( err || !enabled ) + { + return EFalse; + } + } + + TInt feature = MapProfileToFeature( aProfile ); + if( feature ) + { + // Check from feature manager if this phone enables this feature. + FeatureManager::InitializeLibL(); + supported = FeatureManager::FeatureSupported( feature ); + FeatureManager::UnInitializeLib(); + } + TRACE_FUNC_RES( ( _L ( "result: %d" ), supported ) ) + return supported; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TBTProfile CBTEngSrvPluginMgr::MapDeviceClassToProfile( + const TBTDeviceClass& aDeviceClass ) + { + TRACE_FUNC_ARG( ( _L( "Mapping CoD %b ..." ), aDeviceClass.DeviceClass() ) ) + // Could (should?) be done more dynamically or with some header file definition. + // Right now these are the only known/possible ECOM plug-ins. + TBTProfile profile = EBTProfileUndefined; + if( aDeviceClass.MajorServiceClass() & EMajorServiceAudio ) + { + profile = EBTProfileHFP; + } + else if( aDeviceClass.MajorServiceClass() & EMajorServiceRendering && + ( aDeviceClass.MajorDeviceClass() != EMajorDeviceImaging ) ) + // Printer or camera or other imaging device may set EMajorServiceRendering bit + // as well as stereo audio device, so check EMajorDeviceImaging too. + { + profile = EBTProfileA2DP; + } + else if( aDeviceClass.MajorDeviceClass() == EMajorDevicePeripheral && + ( (aDeviceClass.MinorDeviceClass() & EMinorDevicePeripheralKeyboard) || + (aDeviceClass.MinorDeviceClass() & EMinorDevicePeripheralPointer) ) ) + { + profile = EBTProfileHID; + } + else if( aDeviceClass.MajorDeviceClass() == EMajorDeviceLanAccessPoint ) + { + // Mainly for testing now; PAN profile is a personal favorite. + profile = EBTProfilePANU; + } + + TRACE_FUNC_RES( ( _L( "... to profile 0x%04x." ), profile ) ) + return profile; + } + + +// --------------------------------------------------------------------------- +// Maps a profile UUID to any Bluetooth-related pflatfom feature flag. +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::MapProfileToFeature( TInt aProfile ) + { + TInt feature = 0; + switch( aProfile ) + { + case EBTProfileHSP: + case EBTProfileHFP: + { + feature = KFeatureIdBtAudio; + } + break; + case EBTProfileA2DP: + { + feature = KFeatureIdBtStereoAudio; + } + break; + case EBTProfileSAP: + { + feature = KFeatureIdBtSap; + } + break; + case EBTProfileDUN: + { + feature = KFeatureIdDialupNetworking; + } + break; + case EBTProfileFAX: + { + feature = KFeatureIdBtFaxProfile; + } + break; + case EBTProfilePANU: + case EBTProfileNAP: + case EBTProfileGN: + { + //feature = KFeatureIdBtPanProfile; + feature = 0;// Testin' + } + break; + case EBTProfileBIP: + { + feature = KFeatureIdBtImagingProfile; + } + break; + case EBTProfileBPP: + { + feature = KFeatureIdBtPrintingProfile; + } + break; + default: + break; + } + TRACE_FUNC_RES( ( _L( "selected feature %d" ), feature ) ) + return feature; + } + +// --------------------------------------------------------------------------- +// Get Eir Data by hostResolver in Cache +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::DoGetEirData( const TBTDevAddr& aAddr ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + iUuidContainter.Close(); + + if( !iServer->iSocketServ.Handle() ) + { + err = iServer->iSocketServ.Connect(); + } + + TProtocolDesc pInfo; + if(err == KErrNone) + { + _LIT(KBTLinkManagerProtocol, "BTLinkManager"); + err = iServer->iSocketServ.FindProtocol( KBTLinkManagerProtocol(), pInfo ); + } + if (err == KErrNone) + { + err = iHostResolver.Open(iServer->iSocketServ, pInfo.iAddrFamily, pInfo.iProtocol); + } + if(err == KErrNone) + { + iInquirySockAddr = TInquirySockAddr(); + iInquirySockAddr.SetBTAddr(aAddr); + iInquirySockAddr.SetAction(KHostResCache | KHostResEir); + + TRequestStatus status; + iHostResolver.GetByAddress(iInquirySockAddr, iNameEntry, status); + User::WaitForRequest(status); + err = status.Int(); + TRACE_FUNC_RES(( _L( "HostResolver GetByAddress status: %d" ), err)) + iHostResolver.Close(); + } + if(err == KErrNone) + { + TBluetoothNameRecordWrapper eirWrapper( iNameEntry() ); + err = eirWrapper.GetServiceClassUuids( iUuidContainter ); + } + + TRACE_FUNC_EXIT + return err; + } + +// --------------------------------------------------------------------------- +// Check if Service UUID is supported by some plugin. +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::GetConnectablePluginIndexByEir() + { + CBTEngPlugin::RProfileArray profiles; + TInt count = iUuidContainter.UUIDs().Count(); + + for( TInt u = 0; u < count; u++) + { + for( TInt i = 0; i < iPluginArray.Count(); i++ ) + { + profiles.Reset(); + iPluginArray[ i ]->GetSupportedProfiles( profiles ); + for (TInt x = 0; x < profiles.Count(); x++) + { + if (iUuidContainter.UUIDs().At(u) == TUUID(profiles[x])) + { + profiles.Close(); + TRACE_INFO( ( _L( "connectable plugin index %d" ), i ) ) + return i; + } + } + } + } + profiles.Close(); + return KErrNotFound; + } + +// --------------------------------------------------------------------------- +// Internal utility function +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvPluginMgr::GetFirstPluginOfProfileSupported(TBTProfile aProfile ) + { + TRACE_FUNC_ENTRY + for( TInt i = 0; i < iPluginArray.Count(); i++ ) + { + if( iPluginArray[ i ]->IsProfileSupported( aProfile ) ) + { + return i; + } + } + return KErrNotFound; + } + +// --------------------------------------------------------------------------- +// Check if any audio connection exists. +// --------------------------------------------------------------------------- +// + +TBool CBTEngSrvPluginMgr::CheckAudioConnectionsL() + { + TRACE_FUNC_ENTRY + TBool result = EFalse; + RArray profiles; + CleanupClosePushL( profiles ); + profiles.AppendL( EBTProfileHSP ); + profiles.AppendL( EBTProfileHFP ); + profiles.AppendL( EBTProfileA2DP ); + profiles.AppendL( EBTProfileAVRCP ); + + RBTDevAddrArray addrArray; + for ( TInt i = 0; i < profiles.Count(); i++ ) + { + GetConnectedAddresses( addrArray, profiles[i] ); + if ( addrArray.Count() > 0 ) + { + result = ETrue; + break; + } + addrArray.Reset(); + } + addrArray.Close(); + + CleanupStack::PopAndDestroy( &profiles ); + TRACE_FUNC_RES( ( _L( "result: %d" ), result ) ) + return result; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengsrvsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsrvsession.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,335 @@ +/* +* Copyright (c) 2006 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: Implementation of BTEng server session handling +* +*/ + + + +#include +#include "btengsrvsession.h" +#include "btengserver.h" +#include "btengsrvbbconnectionmgr.h" +#include "btengpairman.h" +#include "btengclientserver.h" +#include "debug.h" + + +/** The message argument which holds the client event package. */ +const TInt KBTEngEventSlot = 2; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSrvSession::CBTEngSrvSession() +: CSession2() + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSrvSession::ConstructL() + { + TRACE_FUNC_ENTRY + + //create queue for storing multiple connection events + iConnectionEventQueue = new (ELeave) CDesC8ArraySeg(1); + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSrvSession* CBTEngSrvSession::NewL() + { + CBTEngSrvSession* self = new( ELeave ) CBTEngSrvSession(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSrvSession::~CBTEngSrvSession() + { + TRACE_FUNC_ENTRY + if( !iNotifyConnMessage.IsNull() ) + { + iNotifyConnMessage.Complete( KErrCancel ); + } + CancelPairRequest(); + if( Server() ) + { + Server()->RemoveSession( iAutoSwitchOff ); + } + + delete iConnectionEventQueue; + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Complete the construction of the session. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSession::CreateL() + { + TRACE_FUNC_ENTRY + Server()->AddSession(); + } + + +// --------------------------------------------------------------------------- +// Notify the client of the connection event. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSession::NotifyConnectionEvent(const TBTDevAddr aAddr, + TBTEngConnectionStatus aConnStatus, RBTDevAddrArray* aArray, TInt aErr) + { + TRACE_FUNC_ENTRY + + TRACE_INFO((_L("[BTEng]\t Informing client %d"), iNotifyConnMessage.Handle())); + + //package up connection event to send to the client + TBTEngEventPkg pkg; + pkg().iAddr = aAddr; + pkg().iConnEvent = aConnStatus; + pkg().iConflictsBuf.Zero(); + if (aArray) + { + TBTDevAddrPckgBuf addr; + + for (TInt i = 0; i < aArray->Count(); i++) + { + addr = (*aArray)[i]; + pkg().iConflictsBuf.Append(addr); + } + } + + TInt err = KErrNotFound; + + //if a client message is outstanding + if (!iNotifyConnMessage.IsNull()) + { + //complete the message prioritising the main error + err = iNotifyConnMessage.Write(KBTEngEventSlot, pkg); + aErr = (aErr != KErrNone) ? aErr : err; + iNotifyConnMessage.Complete(aErr); + } + + //if there is no client message outstanding or the write failed + if (err != KErrNone) + { + //if the append fails we can't do anything with the error so ignore + //it and let the event get dropped + TRAP_IGNORE(iConnectionEventQueue->AppendL(pkg)); + } + } + +// --------------------------------------------------------------------------- +// Comfirm the caller if pairing request is completed in this invoke. +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvSession::CompletePairRequest( TInt aResult ) + { + if ( !iPairMessage.IsNull()) + { + iPairMessage.Complete( aResult ); + return KErrNone; + } + return KErrNotFound; + } + +// --------------------------------------------------------------------------- +// From class CSession2 +// Handles servicing of a client request that has been passed to the server. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSession::ServiceL( const RMessage2& aMessage ) + { + TRAPD( err, DispatchMessageL( aMessage ) ); + + if( !aMessage.IsNull() && + ( err || + ( aMessage.Function() != EBTEngNotifyConnectionEvents && + aMessage.Function() != EBTEngPairDevice ) ) ) + { + // Return the error code to the client. + aMessage.Complete( err ); + } + } + + +// --------------------------------------------------------------------------- +// Returns a handle to CBTEngServer. +// --------------------------------------------------------------------------- +// +CBTEngServer* CBTEngSrvSession::Server() + { + return (CBTEngServer*) CSession2::Server(); + } + + +// --------------------------------------------------------------------------- +// Handles a client request that has been passed to the server. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSession::DispatchMessageL( const RMessage2& aMessage ) + { + TRACE_FUNC_ENTRY + TInt opcode = aMessage.Function(); + + switch( opcode ) + { + case EBTEngSetPowerState: + { + iAutoSwitchOff = (TBool) aMessage.Int1(); + Server()->SetPowerStateL( (TBTPowerStateValue) aMessage.Int0(), + iAutoSwitchOff ); + } + break; + case EBTEngSetVisibilityMode: + { + Server()->SetVisibilityModeL( (TBTVisibilityMode) aMessage.Int0(), + aMessage.Int1() ); + } + break; + case EBTEngNotifyConnectionEvents: + { + //ensure the message contains the correctly sized descriptor + if (aMessage.GetDesMaxLengthL(KBTEngEventSlot) != sizeof(TBTEngEventMsg)) + { + User::Leave(KErrBadDescriptor); + } + + if(!iNotifyConnMessage.IsNull()) + { + User::Leave(KErrInUse); + } + + //save the client message + iNotifyConnMessage = RMessage2(aMessage); + + //if there is an existing connection event that the client does + //not yet know about + if (iConnectionEventQueue->Count() > 0) + { + //complete straight away with package from queue + TInt err = iNotifyConnMessage.Write(KBTEngEventSlot, (*iConnectionEventQueue)[0]); + if (err == KErrNone) + { + iConnectionEventQueue->Delete(0); + } + iNotifyConnMessage.Complete(err); + } + } + break; + case EBTEngCancelEventNotifier: + { + if( !iNotifyConnMessage.IsNull() ) + { + iNotifyConnMessage.Complete( KErrCancel ); + } + } + break; + case EBTEngConnectDevice: + case EBTEngCancelConnectDevice: + case EBTEngDisconnectDevice: + case EBTEngIsDeviceConnected: + case EBTEngGetConnectedAddresses: + { + TBTPowerStateValue pwr = EBTPowerOff; + Server()->GetHwPowerState( pwr ); + if( pwr ) + { + // Simply forward it to the plug-in manager + Server()->DispatchPluginMessageL( aMessage ); + } + else + { + User::Leave( KErrNotReady ); + } + } + break; + case EBTEngIsDeviceConnectable: + { + Server()->DispatchPluginMessageL( aMessage ); + } + break; + case EBTEngPrepareDiscovery: + { + aMessage.Complete( KErrNone ); // Client does not have to wait. + Server()->iBBConnMgr->ManageTopology( ETrue ); + } + break; + case EBTEngSetPairingObserver: + case EBTEngPairDevice: + { + TBTPowerStateValue pwr = EBTPowerOff; + (void) Server()->GetHwPowerState( pwr ); + if( pwr ) + { + // Simply forward it to the pairing manager + Server()->PairManager().ProcessCommandL( aMessage ); + if ( opcode == EBTEngPairDevice ) + { + iPairMessage = RMessage2( aMessage ); + } + } + else + { + User::Leave( KErrNotReady ); + } + break; + } + case EBTEngCancelPairDevice: + { + CancelPairRequest(); + break; + } + default: + { + TRACE_INFO( ( _L( "[BTENG]\t DispatchMessageL: bad request (%d)" ), + aMessage.Function() ) ) + User::Leave( KErrArgument ); + } + break; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Only the originator of pairing can cancel the pairing request. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSession::CancelPairRequest() + { + if ( !iPairMessage.IsNull() ) + { + Server()->PairManager().CancelCommand( iPairMessage.Function() ); + iPairMessage.Complete( KErrCancel ); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bteng/src/btengsrvstate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsrvstate.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,251 @@ +/* +* Copyright (c) 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: Bluetooth Engine server state machine class implementation. +* +*/ + + + +#include + +#include "btengsrvstate.h" +#include "btengserver.h" +#include "btengsrvpluginmgr.h" +#include "debug.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSrvState::CBTEngSrvState( CBTEngServer* aServer ) +: iState( EInit ), + iOperation( ESrvOpIdle ), + iServer( aServer ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSrvState::ConstructL() + { + TRACE_FUNC_ENTRY + // Create the active object handling asynchronous state transitions. + // The state transitions need to be done fast, as it can be initiated + // through user interaction (i.e. the user is waiting). + const TCallBack cb(&ChangeStateCb, this); + iAsyncCallback = new(ELeave) CAsyncCallBack(cb, CActive::EPriorityHigh); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSrvState* CBTEngSrvState::NewL( CBTEngServer* aServer ) + { + CBTEngSrvState* self = new( ELeave ) CBTEngSrvState( aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSrvState::~CBTEngSrvState() + { + delete iAsyncCallback; + } + + +// --------------------------------------------------------------------------- +// Returns the current state machine operation. +// --------------------------------------------------------------------------- +// +CBTEngSrvState::TBTEngSrvOperation CBTEngSrvState::CurrentOperation() + { + return iOperation; + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvState::StartStateMachineL( TBool aState ) + { + TRACE_FUNC_ENTRY + if( aState ) + { + // Power on; starting state is initializing the stack + iState = EInitBTStack; + iOperation = EPowerOn; + } + else + { + // Power off, starting state is to disconnect the plug-ins + iState = EDisconnectPlugins; + iOperation = EPowerOff; + iServer->UpdateCenRepPowerKeyL( EBTPowerOff ); + iServer->SetUiIndicatorsL(); + } + ChangeState(); + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvState::ChangeState() + { + TRACE_FUNC_ENTRY + if(!iAsyncCallback->IsActive()) + { + iAsyncCallback->CallBack(); + } + } + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvState::ChangeStateCb(TAny* aThis) + { + TRAPD(err, static_cast(aThis)->RequestCompletedL()); + if(err != KErrNone) + { + static_cast(aThis)->HandleError(err); + } + return KErrNone; + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvState::RequestCompletedL() + { + switch( iState ) + { + case EInitBTStack: + { + iState = ELoadDIService; + iServer->InitBTStackL(); + } + break; + case ELoadDIService: + { + iState = ELoadPlugins; + iServer->ManageDIServiceL( ETrue ); + } + break; + case ELoadPlugins: + { + iState = ELoadNextPlugin; + TEComResolverParams params; + iServer->iPluginMgr->LoadProfilePluginsL( params ); + } + break; + case ELoadNextPlugin: + { + // Only change the state when all plug-ins are loaded + if( iServer->iPluginMgr->LoadPluginL() <= 0 ) + { + iState = EIdle; + } + } + break; + case EStopBTStack: + { + iState = EWaitingForPowerOff; + iServer->StopBTStackL(); + } + break; + case EUnloadDIService: + { + iState = EStopBTStack; + iServer->ManageDIServiceL( EFalse ); + } + break; + case EUnloadPlugins: + { + iState = EUnloadDIService; + iServer->iPluginMgr->UnloadProfilePlugins(); + } + break; + case EDisconnectPlugins: + { + iState = EUnloadPlugins; + // This is the starting state; the disconnect command has + // already been sent. Just one more loop to give more time + // for disconnecting. + } + break; + case EWaitingForPowerOff: + { + // Disconnecting all connections completed and + // called us back; we are done. + iState = EIdle; + } // Fall through + case EIdle: + { + if( iOperation == EPowerOn ) + { + iServer->UpdateCenRepPowerKeyL( EBTPowerOn ); + iServer->SetUiIndicatorsL(); + } + iOperation = ESrvOpIdle; + iServer->CheckIdle(); + } + case EInit: + default: + break; + } + // In state EWaitingForPowerOff, we change the state + // through a callback in the server. + if( iOperation != ESrvOpIdle && iState != EWaitingForPowerOff ) + { + ChangeState(); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Handles a leave in RunL/RequestCompletedL. +// --------------------------------------------------------------------------- +// +void CBTEngSrvState::HandleError(TInt aError) + { + TRACE_FUNC_ARG( ( _L( "error: %d" ), aError ) ) + + (void) aError; + // All critical operations are done in turning power on; all other + // operations are recoverable i.e. we can do without loading/unloading + // of services. So simply change the state to handle next state change. + ChangeState(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidclient/bwins/bthidclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidclient/bwins/bthidclientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,12 @@ +EXPORTS + ?CancelConnectDevice@RBTHidClient@@QBEXXZ @ 1 NONAME ; void RBTHidClient::CancelConnectDevice(void) const + ?CancelNotifyStatusChange@RBTHidClient@@QBEXXZ @ 2 NONAME ; void RBTHidClient::CancelNotifyStatusChange(void) const + ?Connect@RBTHidClient@@QAEHXZ @ 3 NONAME ; int RBTHidClient::Connect(void) + ?ConnectDevice@RBTHidClient@@QAEXABV?$TPckgBuf@VTBTDevAddr@@@@AAVTDes8@@AAVTRequestStatus@@@Z @ 4 NONAME ; void RBTHidClient::ConnectDevice(class TPckgBuf const &, class TDes8 &, class TRequestStatus &) + ?DisconnectAllGracefully@RBTHidClient@@QAEXAAVTRequestStatus@@@Z @ 5 NONAME ; void RBTHidClient::DisconnectAllGracefully(class TRequestStatus &) + ?DisconnectDevice@RBTHidClient@@QAEXABV?$TPckgBuf@VTBTDevAddr@@@@W4TBTDisconnectType@@AAVTRequestStatus@@@Z @ 6 NONAME ; void RBTHidClient::DisconnectDevice(class TPckgBuf const &, enum TBTDisconnectType, class TRequestStatus &) + ?GetConnections@RBTHidClient@@QAEXAAVTDes8@@H@Z @ 7 NONAME ; void RBTHidClient::GetConnections(class TDes8 &, int) + ?IsConnected@RBTHidClient@@QAEHABVTBTDevAddr@@@Z @ 8 NONAME ; int RBTHidClient::IsConnected(class TBTDevAddr const &) + ?NotifyStatusChange@RBTHidClient@@QAEXAAV?$TPckgBuf@VTHIDStateUpdate@@@@AAVTDes8@@AAVTRequestStatus@@@Z @ 9 NONAME ; void RBTHidClient::NotifyStatusChange(class TPckgBuf &, class TDes8 &, class TRequestStatus &) + ?Version@RBTHidClient@@QBE?AVTVersion@@XZ @ 10 NONAME ; class TVersion RBTHidClient::Version(void) const + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidclient/eabi/bthidclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidclient/eabi/bthidclientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,11 @@ +EXPORTS + _ZN12RBTHidClient11IsConnectedERK10TBTDevAddr @ 1 NONAME + _ZN12RBTHidClient13ConnectDeviceERK8TPckgBufI10TBTDevAddrER5TDes8R14TRequestStatus @ 2 NONAME + _ZN12RBTHidClient14GetConnectionsER5TDes8i @ 3 NONAME + _ZN12RBTHidClient16DisconnectDeviceERK8TPckgBufI10TBTDevAddrE17TBTDisconnectTypeR14TRequestStatus @ 4 NONAME + _ZN12RBTHidClient18NotifyStatusChangeER8TPckgBufI15THIDStateUpdateER5TDes8R14TRequestStatus @ 5 NONAME + _ZN12RBTHidClient23DisconnectAllGracefullyER14TRequestStatus @ 6 NONAME + _ZN12RBTHidClient7ConnectEv @ 7 NONAME + _ZNK12RBTHidClient19CancelConnectDeviceEv @ 8 NONAME + _ZNK12RBTHidClient24CancelNotifyStatusChangeEv @ 9 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidclient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidclient/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +PRJ_MMPFILES +bthidclient.mmp + + +PRJ_PLATFORMS +WINSCW ARMV5 diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidclient/group/bthidclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidclient/group/bthidclient.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2008 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: project file +* +*/ + +#include + +TARGET bthidclient.dll +TARGETTYPE DLL +VENDORID VID_DEFAULT + +CAPABILITY CAP_CLIENT_DLL + +UID 0x1000008d 0x2001E307 + +SOURCEPATH ../src +SOURCE bthidclient.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../bthidserver/inc +USERINCLUDE ../../common/inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY ecom.lib +LIBRARY euser.lib // Kernel API +LIBRARY esock.lib // socket API +LIBRARY bluetooth.lib // BTDevAddr, BTSockAddr + +LIBRARY flogger.lib +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidclient/inc/bthidclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidclient/inc/bthidclient.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2008 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: BTHID Server client API + * +*/ + + +#ifndef BTHIDCLIENT_H +#define BTHIDCLIENT_H + +#include +#include +#include +#include "bthidtypes.h" +#include "btengconstants.h" + +/*! + State changes of a Bluetooth HID connection + */ +enum TBTHidConnState + { + EBTDeviceConnected, /*!< Device connected */ + EBTDeviceLinkLost, /*!< Device link lost */ + EBTDeviceLinkRestored, /*!< Device link restored */ + EBTDeviceDisconnected, /*!< Device disconnected */ + EBTDeviceUnplugged, /*!< Device unplugged */ + EBTDeviceAnotherExist + /*!< Another Device Connection already exist */ + }; + +/*! + BT HID Device connection state details. + */ +class THIDStateUpdate + { +public: + /*! HID Device Bluetooth Address. */ + TBTDevAddr iDeviceAddress; + + /*! New Connection State. */ + TBTHidConnState iState; + }; +typedef TPckgBuf THIDStateUpdateBuf; + +/*! + Provides the client-side interface to the server session. + */ + +NONSHARABLE_CLASS( RBTHidClient ) : public RSessionBase + { +public: + /*! + Connect to the server and create a session. + @result System error code. + */ + IMPORT_C TInt Connect(); + + /*! + Get the version number. + @result The client version. + */ + IMPORT_C TVersion Version() const; + + /*! + Issue a connect request to the server. + @param aParams The connection parameters. + @param aDiagnostic Returned BT device address in case of conflict. + @param aStatus A TRequestStatus object to be used for async comms. + */ + IMPORT_C void ConnectDevice(const TBTDevAddrPckgBuf& aAddrBuf, + TDes8& aDiagnostic, TRequestStatus& aStatus); + + /*! + Issue an update request to the server. + @param aUpdateParams Update buffer to be filled by the server. + @param aDiagnostic Returned BT device address in case of conflict. + @param aStatus A TRequestStatus object to be used for async comms. + */ + IMPORT_C void NotifyStatusChange(THIDStateUpdateBuf& aUpdateParams, + TDes8& aDiagnostic, TRequestStatus& aStatus); + + /*! + Issue a disconnect request to the server. + @param aAddress The BT address of the device to disconnect. + @param aStatus A TRequestStatus object to be used for async comms. + */ + IMPORT_C void DisconnectDevice(const TBTDevAddrPckgBuf& aAddrBuf, + TBTDisconnectType aDiscType, TRequestStatus& aStatus); + + /*! + Cancels an outstanding connect request with the server. + */ + IMPORT_C void CancelConnectDevice() const; + + /*! + Cancels an outstanding update request with the server. + */ + IMPORT_C void CancelNotifyStatusChange() const; + + /*! + Issue a disconnect request to the server. + Release all the HID connections. + @param aStatus A TRequestStatus object to be used for async comms. + */ + IMPORT_C void DisconnectAllGracefully(TRequestStatus& aStatus); + + /*! + Return HID device connection status in service level + @param aBDaddr BT address of the device to retrieve. + */ + IMPORT_C TInt IsConnected(const TBTDevAddr& aBDaddr); + + /*! + Return HID device connection status in service level + @param aAddrs Descriptor of BT addresses of connected devices + @param aProfile Profile for connection + */ + IMPORT_C void GetConnections(TDes8& aAddrs, TInt aProfile); + + }; + +#endif // BTHIDCLIENT_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidclient/src/bthidclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidclient/src/bthidclient.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2007 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: BT HID client implementation + * +*/ + + +#include +#include "bthidclient.h" +#include "bthidclientsrv.h" +#include "debug.h" +#include "hiduids.h" + +static TInt StartServer(); + +// --------------------------------------------------------- +// Connect +// Handles connection to server(creates session) +// --------------------------------------------------------- +// +EXPORT_C TInt RBTHidClient::Connect() + { + TRACE_FUNC + + TInt retVal = CreateSession(KBTHidSrvName, Version()); + if (retVal != KErrNone && retVal != KErrAlreadyExists) + { + retVal = StartServer(); + if (retVal == KErrNone || retVal == KErrAlreadyExists) + { + retVal = CreateSession(KBTHidSrvName, Version()); + } + } + TRACE_INFO((_L("[BTHID] ret %d "), retVal)) + + if (retVal != KErrNone) + { + Close(); + } + + return retVal; + } + +// --------------------------------------------------------- +// Version +// Defines server version number +// --------------------------------------------------------- +// +TVersion RBTHidClient::Version() const + { + return (TVersion(KBTHIDServMajorVersionNumber, + KBTHIDServMinorVersionNumber, KBTHIDServBuildVersionNumber)); + } + +// --------------------------------------------------------- +// ConnectToHID +// Establishes a Bluetooth HID connection +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::ConnectDevice(const TBTDevAddrPckgBuf& aAddrBuf, + TDes8& aDiagnostic, TRequestStatus& aStatus) + { + SendReceive(EBTHIDServConnectDevice, TIpcArgs(&aAddrBuf, &aDiagnostic), + aStatus); + } + +// --------------------------------------------------------- +// CancelConnectDevice +// Cancel Connection attempt +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::CancelConnectDevice() const + { + SendReceive(EBTHIDServCancelConnect); + } + +// --------------------------------------------------------- +// NotifyStatusChange +// Request for a notify for change of connection status +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::NotifyStatusChange( + THIDStateUpdateBuf& aUpdateParams, TDes8& aDiagnostic, + TRequestStatus& aStatus) + { + SendReceive(EBTHIDServNotifyConnectionChange, TIpcArgs(&aUpdateParams, + &aDiagnostic), aStatus); + } + +// --------------------------------------------------------- +// CancelNotifyStatusChange +// Cancel a outstanding request for a notify for change of connection status +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::CancelNotifyStatusChange() const + { + SendReceive(EBTHIDServCancelNotify); + } + +// --------------------------------------------------------- +// DisconnectDevice +// Disconnect from the selected HID device +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::DisconnectDevice( + const TBTDevAddrPckgBuf& aAddrBuf, TBTDisconnectType aDiscType, + TRequestStatus& aStatus) + { + TBTHidParamPkg discPkg(aDiscType); + SendReceive(EBTHIDServDisconnectDevice, TIpcArgs(&aAddrBuf, &discPkg), + aStatus); + } + +// --------------------------------------------------------- +// DisconnectAllGracefully +// Disconnect from the all HID devices +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::DisconnectAllGracefully(TRequestStatus& aStatus) + { + TRACE_FUNC + SendReceive(EBTHidSrvDisconnectAllGracefully, aStatus); + } + +// --------------------------------------------------------- +// IsConnected +// Request for the connection status for a specified device +// --------------------------------------------------------- +// +EXPORT_C TInt RBTHidClient::IsConnected(const TBTDevAddr& aBTaddr) + { + TPckgC addrPck(aBTaddr); + return SendReceive(EBTHIDServIsConnected, TIpcArgs(&addrPck)); + } + +// --------------------------------------------------------- +// GetConnections +// Request for a list of current connected HID device addresses +// --------------------------------------------------------- +// +EXPORT_C void RBTHidClient::GetConnections(TDes8& aAddrs, TInt aProfile) + { + TRACE_FUNC + SendReceive(EBTHIDGetConnections, TIpcArgs(&aAddrs, aProfile)); + } + +TInt StartServer() + { + TRACE_STATIC_FUNC + const TUid KKBTHIDSrvUid3 = + { + BTHID_SRV_UID + }; + const TUidType serverUid(KNullUid,KNullUid, KKBTHIDSrvUid3); + RProcess server; + TInt r = server.Create(KBTHidServerFilename, KNullDesC, serverUid); + if (r != KErrNone) + return r; + server.SetPriority(EPriorityHigh); + + TRequestStatus stat; + server.Rendezvous(stat); + if (stat != KRequestPending) + { + server.Kill(0); + } + else + { + server.Resume(); + } + + User::WaitForRequest(stat); + TRACE_INFO((_L("[BTHID] Server started, code %d"), stat.Int())) + r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); + server.Close(); + return r; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/data/2001E308.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/data/2001E308.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2008 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: ECom resource definition Declares +* +*/ + + + +// INCLUDES +#include +#include +#include "hiduids.h" + +RESOURCE REGISTRY_INFO BTHIDPluginResource + { + resource_format_version = RESOURCE_FORMAT_VERSION_2; + dll_uid = KBD_ENGPLUGIN_UID; + interfaces = + { + INTERFACE_INFO + { + // BTEng plugin interface + interface_uid = 0x2000277B; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = KBD_ENGPLUGIN_IMP; + version_no = 1; + display_name = "bthidsrv"; + default_data = "1124"; + opaque_data = ""; + rom_only = 1; + } + }; + } + }; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2008 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: Project build file +* +*/ + +#include + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +// backup registration +../../common/btkeyboard_backup_registration.xml /epoc32/data/z/private/10201d2a/backup_registration.xml + +PRJ_MMPFILES +bthidengplugin.mmp + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/group/bthidengplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/group/bthidengplugin.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2008 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: Project definition +* +*/ + + +#include + +VENDORID VID_DEFAULT + +CAPABILITY CAP_ECOM_PLUGIN + +TARGET bthidengplugin.dll +TARGETTYPE PLUGIN + +UID 0x10009d8d 0x2001E308 + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../common/inc +USERINCLUDE ../../bthidclient/inc +USERINCLUDE ../../bthidserver/inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc + +START RESOURCE ../data/2001E308.rss + TARGET bthidengplugin.rsc +END + +LIBRARY ecom.lib +LIBRARY euser.lib // Kernel API +LIBRARY esock.lib // socket API +LIBRARY bluetooth.lib // BTDevAddr, BTSockAddr +LIBRARY bthidclient.lib + +LIBRARY flogger.lib + +SOURCEPATH ../src +SOURCE bthidengplugin.cpp bthidproxy.cpp genericactive.cpp + +//End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/inc/bthidengplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/inc/bthidengplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,222 @@ +/* +* Copyright (c) 2008 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: Bluetooth HID ECom plug-in class declaration. + * +*/ + + +#ifndef BTHIDPLUGIN_H +#define BTHIDPLUGIN_H + +#include +#include +#include +#include +#include +#include "bthidclient.h" +#include "genericactive.h" +#include "bthidclientsrv.h" + +/** + * BTEng plug-in base class. + * + * + * @lib + * @since S60 v5.0 + */ +class RBTHidClient; + +class CBTHidPlugin : public CBTEngPlugin, public MGenericActiveObserver + { + +public: + + /** + * Constructor; loads the plug-in through the ECom framework. + * + * @since S60 v5.0 + * @param aImplementationUid The UID of the interface implementation + * to be loaded. + * @return Pointer to the constructed CBTHidPlugin object. + */ + static CBTHidPlugin* NewL(); + + /** + * Destructor; destroys the plug-in through the ECom framework. + */ + virtual ~CBTHidPlugin(); + + /** + * Gets the list of profiles implemented by this plug-in. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v5.0 + * @param aProfiles Array of integers identifying the BT profiles + * implemented by this plug-in. + */ + void GetSupportedProfiles(RProfileArray& aProfiles); + + /** + * Sets the observer for receiving connection events through the + * MBTEngPluginObserver interface. This method MUST be called + * before any command is given to the plug-in + * + * @since S60 v5.0 + * @param aObserver The observer of connection events. + */ + void SetObserver(MBTEngPluginObserver* aObserver); + + /** + * Indicates if this plug-in implements the specified profiles. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v5.0 + * @param aProfile Integer identifying the BT profile. + * @return ETrue if the plug-in implements the requested profile, + * otherwise EFalse. + */ + TBool IsProfileSupported(const TBTProfile aProfile) const; + + /** + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::ConnectComplete with + * the appropriate error code. + * + * @since S60 v5.0 + * @param aAddr The BT device address identifying a remote device. + * @return KErrNone on success, otherwise an appropriate error code. + */ + TInt Connect(const TBTDevAddr& aAddr); + + /** + * Instructs the plug-in to cancel the creation a service-level + * connection with the specified Bluetooth address. + * + * In addition, as this is part of an asynchronous operation, the plug-in + * completes the outstanding asyncronous request status with KErrCancel. + * + * @since S60 v5.0 + * @param aAddr The BT device address identifying a remote device. + */ + void CancelConnect(const TBTDevAddr& aAddr); + + /** + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::DisconnectComplete with + * the appropriate error code. + * + * + * @since S60 v5.0 + * @param aAddr The BT device address identifying a remote device. + * In case the address is the NULL address, the plug-in is + * expected to disconnect all its connections. + * @param aDiscType The type of disconnection; + * EGraceful for graceful (normal) disconnection, + * EImmediate for immediate (forced) disconnection. + * @return KErrNone on success, otherwise an appropriate error code. + */ + TInt Disconnect(const TBTDevAddr& aAddr, TBTDisconnectType aDiscType); + + /** + * Gets the addresses of the connected devices for the specified profile. + * + * @since S60 v5.0 + * @param aAddrArray On return, holds the Bluetooth device addresses + * of the connected Bluetooth devices for the + * requested profile. + * @param aConnectedProfile The profile for which the existing + * connections are requested. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + void GetConnections(RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile); + + /** + * Indicates if this plug-in has a service-level connection + * with the specified Bluetooth address. + * + * @since S60 v5.0 + * @param aAddr The BT device address identifying a remote device. + * @return The status of the connection according to the TConnectionStatus + * enumeration. EConnecting is interpreted that at least one + * incoming connection request has been completed, but that not + * all service-level connections have been fully established. + */ + TBTEngConnectionStatus IsConnected(const TBTDevAddr& aAddr); + +private: + //From MGenericActiveObserver + void RequestCompletedL(CGenericActive& aActive); + + void CancelRequest(CGenericActive& aActive); + +private: + + CBTHidPlugin(); + + void ConstructL(); + + //Handle async requests + TInt HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId); + + //Report the Profile connection event to BTEng + void ReportProfileConnectionEvents(const TBTDevAddr& aAddr, + TBool aConnected); + + //Handle the complete of request for NotifyProfileStatusChange + void HandleNotifyProfileStatusChange(CGenericActive& aActive); + + //Handle the complete of request for RequestConnect + void HandelRequestConnectComplete(); + + //Handle the complete of request for RequestDisconnect + void HandelRequestDisconnectComplete(); + +private: + // data + + MBTEngPluginObserver* iObserver; // not own + + //Client API for BTHID Server + RBTHidClient iClient; + + //Active Object for async request Connect/Disconnect + CGenericActive* iActive4ClientReq; + + //Packagebuf of TBTDevAddr + TBTDevAddrPckgBuf iBTDevAddrPckgBuf; + + //BT address buf for conflict address, when connecting to HID device + TBuf8 iDiagnostic; + + //BT address buf for conflict address, when HID device reconnect + TBuf8 iDiagnosticAddress; + + //Active Object for async request profile status update + CGenericActive* iActive4ProfileStatus; + + //Packagebuf of HID status update + THIDStateUpdateBuf iHIDStateUpdatePckg; + }; + +#endif // BTHIDPLUGIN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/inc/genericactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/inc/genericactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,154 @@ +/* +* Copyright (c) 2008 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: An Active Object offering its request status for any + * asynchronous request handling. + * +*/ + + +#ifndef C_GENERICACTIVE_H +#define C_GENERICACTIVE_H + +// INCLUDES +#include + +class CGenericActive; + +/** + * The observer of CGenericActive's request events + * + * This class defines the interface to handle request events from CGenericActive. + * + * @since S60 v3.1 + */ +class MGenericActiveObserver + { + +public: + + /** + * Called by CGenericActive::RunL() to handle the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CGenericActive& aActive) = 0; + + /** + * alled by CGenericActive::RunL() to handle the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CGenericActive& aActive) = 0; + + }; + +/** + * + * CGenericActive provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CGenericActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CGenericActive : public CActive + { + +public: + + static CGenericActive* New(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + static CGenericActive* NewL(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + virtual ~CGenericActive(); + +public: + + /** + * Calls SetActive(). + * + * @since S60 v3.1 + */ + virtual void GoActive(); + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @return the request identifier + */ + TInt RequestId() const; + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @param the request identifier + */ + void SetRequestId(TInt aRequestId); + + TRequestStatus& RequestStatus(); + +protected: + + /** + * From CActive. + * cancels the outstanding request. + * + * @since S60 v3.1 + */ + virtual void DoCancel(); + + /** + * From CActive. + * Handles the request completion event. + * + * @since S60 v3.1 + */ + virtual void RunL(); + + /** + * From CActive. + * Handles the leave from RunL(). + * + * @since S60 v3.1 + * @param aError the leave code in RunL() + * @return the error code to Active Scheduler + */ + virtual TInt RunError(TInt aError); + +protected: + + CGenericActive(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + +private: + + /** + * The observer which is interested in the request handling events. + * Not own. + */ + MGenericActiveObserver& iObserver; + + /** + * The request identifier assigned to this active object. + */ + TInt iRequestId; + + }; + +#endif // C_GENERICACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,373 @@ +/* +* Copyright (c) 2006 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: Bluetooth Hid ECom plug-in class definition. + * +*/ + + +#include +#include +#include +#include "bthidengplugin.h" +#include "bthidclient.h" + +#include "debug.h" + +//Used to identify the type of request to the AO +enum TRequestId + { + ERequestConnect = 1, + ERequestDisconnect = 2, + ENotifyProfileStatusChange = 3, + ERequestDisconnectAll, + }; + +CBTHidPlugin::CBTHidPlugin() + { + } + +CBTHidPlugin* CBTHidPlugin::NewL() + { + CBTHidPlugin* self = new (ELeave) CBTHidPlugin(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CBTHidPlugin::ConstructL() + { + TRACE_FUNC + LEAVE_IF_ERROR( iClient.Connect() ); + + iActive4ProfileStatus = CGenericActive::NewL(*this, + CActive::EPriorityStandard, ENotifyProfileStatusChange); + iDiagnosticAddress.Zero(); + iClient.NotifyStatusChange(iHIDStateUpdatePckg, iDiagnosticAddress, + iActive4ProfileStatus->iStatus); + iActive4ProfileStatus->GoActive(); + + TRACE_FUNC_EXIT + } + +CBTHidPlugin::~CBTHidPlugin() + { + delete iActive4ClientReq; + delete iActive4ProfileStatus; + if (iClient.Handle()) + { + TRequestStatus req = KRequestPending; + iClient.DisconnectAllGracefully(req); + User::WaitForRequest(req); + } + iClient.Close(); + TRACE_FUNC + } + +void CBTHidPlugin::SetObserver(MBTEngPluginObserver* aObserver) + { + iObserver = aObserver; + } + +void CBTHidPlugin::GetSupportedProfiles(RProfileArray& aProfiles) + { + aProfiles.Reset(); + aProfiles.Append(EBTProfileHID); + } + +TBool CBTHidPlugin::IsProfileSupported(const TBTProfile aProfile) const + { + return (aProfile == EBTProfileHID); + } + +TInt CBTHidPlugin::Connect(const TBTDevAddr& aAddr) + { + TRACE_FUNC + return HandleAsyncRequest(aAddr, ERequestConnect); + } + +void CBTHidPlugin::CancelConnect(const TBTDevAddr& aAddr) + { + TRACE_FUNC + (void) aAddr; + iClient.CancelConnectDevice(); + } + +TInt CBTHidPlugin::Disconnect(const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType) + { + TRACE_FUNC + (void) aDiscType; + return HandleAsyncRequest(aAddr, ERequestDisconnect); + } + +void CBTHidPlugin::GetConnections(RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile) + { + if (aConnectedProfile == EBTProfileHID) + { + TBuf8 addrbuf; + iClient.GetConnections(addrbuf, aConnectedProfile); + TPtrC8 ptr(addrbuf); + while (ptr.Length() >= KBTDevAddrSize) + { + aAddrArray.Append(TBTDevAddr(ptr.Left(KBTDevAddrSize))); + ptr.Set(ptr.Mid(KBTDevAddrSize)); + } + } + } + +void CBTHidPlugin::HandleNotifyProfileStatusChange(CGenericActive& aActive) + { + if (aActive.iStatus.Int() == KErrNone && iObserver) + { + TBool retStatus = EFalse; + + THIDStateUpdate& HIDStateUpdate = iHIDStateUpdatePckg(); + + if (HIDStateUpdate.iState == EBTDeviceConnected + || HIDStateUpdate.iState == EBTDeviceLinkRestored) + { + retStatus = ETrue; + ReportProfileConnectionEvents(HIDStateUpdate.iDeviceAddress, + retStatus); + } + + if (HIDStateUpdate.iState == EBTDeviceDisconnected + || HIDStateUpdate.iState == EBTDeviceLinkLost + || HIDStateUpdate.iState == EBTDeviceUnplugged) + { + retStatus = EFalse; + ReportProfileConnectionEvents(HIDStateUpdate.iDeviceAddress, + retStatus); + } + iDiagnosticAddress.Zero(); + iClient.NotifyStatusChange(iHIDStateUpdatePckg, iDiagnosticAddress, + aActive.iStatus); + aActive.GoActive(); + } + else + { + if (aActive.iStatus.Int() != KErrNone) + { + THIDStateUpdate& HIDStateUpdate = iHIDStateUpdatePckg(); + if (iDiagnosticAddress.Length() >= KBTDevAddrSize) + { + RBTDevAddrArray array; + TPtrC8 ptr(iDiagnosticAddress); + while (ptr.Length() >= KBTDevAddrSize) + { + TRAP_IGNORE(array.AppendL(TBTDevAddr(ptr.Left(KBTDevAddrSize)));); +#ifdef _DEBUG + const TPtrC8 myPtr(array[array.Count() - 1].Des()); +#endif + TRACE_INFO((_L8("conflict <%S>"), &myPtr)) + ptr.Set(ptr.Mid(KBTDevAddrSize)); + } + + iBTDevAddrPckgBuf() = HIDStateUpdate.iDeviceAddress; + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), + EBTProfileHID, aActive.iStatus.Int(), &array); + array.Close(); + } + else + { + iObserver->ConnectComplete(HIDStateUpdate.iDeviceAddress, + EBTProfileHID, aActive.iStatus.Int()); + } + iClient.NotifyStatusChange(iHIDStateUpdatePckg, + iDiagnosticAddress, aActive.iStatus); + aActive.GoActive(); + } + } + } + +void CBTHidPlugin::HandelRequestConnectComplete() + { + if (iActive4ClientReq->iStatus.Int() != KErrNone) // might have conflicts, decode iDiagnostic + { + if (iDiagnostic.Length() >= KBTDevAddrSize) + { + RBTDevAddrArray array; + TPtrC8 ptr(iDiagnostic); + while (ptr.Length() >= KBTDevAddrSize) + { + TRAP_IGNORE(array.AppendL(TBTDevAddr(ptr.Left(KBTDevAddrSize)));); +#ifdef _DEBUG + const TPtrC8 myPtr(array[array.Count() - 1].Des()); +#endif + TRACE_INFO((_L8("conflict <%S>"), &myPtr)) + ptr.Set(ptr.Mid(KBTDevAddrSize)); + } + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), EBTProfileHID, + iActive4ClientReq->iStatus.Int(), &array); + array.Close(); + } + else + { + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), EBTProfileHID, + iActive4ClientReq->iStatus.Int()); + } + } + else + { + TInt profile = 0; + if (iDiagnostic.Length() >= sizeof(TInt)) + { + TPckg pckg(profile); + pckg.Copy(iDiagnostic.Mid(0, sizeof(TInt))); + } + ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), ETrue); + } + delete iActive4ClientReq; + iActive4ClientReq = NULL; + } + +void CBTHidPlugin::HandelRequestDisconnectComplete() + { + if (iActive4ClientReq->iStatus.Int() != KErrNone) + { + iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), EBTProfileHID, + iActive4ClientReq->iStatus.Int()); + } + else + { + TInt profile = 0; + if (iDiagnostic.Length() >= sizeof(TInt)) + { + TPckg pckg(profile); + pckg.Copy(iDiagnostic.Mid(0, sizeof(TInt))); + } + ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), EFalse); + } + delete iActive4ClientReq; + iActive4ClientReq = NULL; + } + +void CBTHidPlugin::RequestCompletedL(CGenericActive& aActive) + { + TRACE_FUNC + switch (aActive.RequestId()) + { + case ENotifyProfileStatusChange: + { + HandleNotifyProfileStatusChange(aActive); + break; + } + case ERequestConnect: + { + HandelRequestConnectComplete(); + break; + } + case ERequestDisconnect: + { + HandelRequestDisconnectComplete(); + break; + } + case ERequestDisconnectAll: + { + iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), EBTProfileHID, + iActive4ClientReq->iStatus.Int()); + break; + } + } + } + +TBTEngConnectionStatus CBTHidPlugin::IsConnected(const TBTDevAddr& aAddr) + { + TInt stat = 0; + stat = iClient.IsConnected(aAddr); + TRACE_INFO((_L("CBTHidPlugin::IsConnected() = %d"), stat)) + return ((TBTEngConnectionStatus) stat); + } + +void CBTHidPlugin::CancelRequest(CGenericActive& aActive) + { + if (aActive.RequestId() == ENotifyProfileStatusChange) + { + iClient.CancelNotifyStatusChange(); + } + else + { + if (aActive.RequestId() == ERequestConnect) + { + iClient.CancelConnectDevice(); + } + } + } + +TInt CBTHidPlugin::HandleAsyncRequest(const TBTDevAddr& aAddr, + TInt aRequestId) + { + TInt err = KErrNone; + if (!iClient.Handle()) + { + err = iClient.Connect(); + } + if (err) + { + return err; + } + if (iActive4ClientReq) + { + err = KErrServerBusy; + } + if (!err) + { + iActive4ClientReq = CGenericActive::New(*this, + CActive::EPriorityStandard, aRequestId); + if (iActive4ClientReq) + { + iBTDevAddrPckgBuf() = aAddr; + if (aRequestId == ERequestConnect) + { + iDiagnostic.Zero(); + iClient.ConnectDevice(iBTDevAddrPckgBuf, iDiagnostic, + iActive4ClientReq->iStatus); + } + else + { + iClient.DisconnectDevice(iBTDevAddrPckgBuf, EBTDiscImmediate, + iActive4ClientReq->iStatus); + } + iActive4ClientReq->GoActive(); + } + else + { + err = KErrNoMemory; + } + } + return err; + } + +void CBTHidPlugin::ReportProfileConnectionEvents(const TBTDevAddr& aAddr, + TBool aConnected) + { + TRACE_FUNC + TRACE_INFO((_L("CBTHidPlugin::ReportProfileConnectionEvents() == %d"), aConnected)) + + if (iObserver) + { + if (aConnected) + { + iObserver->ConnectComplete(aAddr, EBTProfileHID, KErrNone); + } + else + { + iObserver->DisconnectComplete(aAddr, EBTProfileHID, KErrNone); + } + } + } + +//End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/src/bthidproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/src/bthidproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2005-2006 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: the Plugin entry. + * +*/ + + +#ifndef BTHIDPROXY_H +#define BTHIDPROXY_H + +#include + +#include +#include "bthidengplugin.h" +#include "hiduids.h" + +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KBD_ENGPLUGIN_IMP, CBTHidPlugin::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( + TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif // BTHIDPROXY_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidengplugin/src/genericactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidengplugin/src/genericactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2007 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 "genericactive.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CGenericActive* CGenericActive::New(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + return new CGenericActive(aObserver, aPriority, aRequestId); + } + +CGenericActive* CGenericActive::NewL(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CGenericActive* self = new (ELeave) CGenericActive(aObserver, aPriority, + aRequestId); + return self; + } + +CGenericActive::~CGenericActive() + { + Cancel(); + TRACE_FUNC + } + +void CGenericActive::GoActive() + { + TRACE_ASSERT(!IsActive(), -2); + SetActive(); + TRACE_INFO((_L("CGenericActive: Service %d starts"), iRequestId)) + } + +TInt CGenericActive::RequestId() const + { + return iRequestId; + } + +void CGenericActive::SetRequestId(TInt aRequestId) + { + iRequestId = aRequestId; + } + +TRequestStatus& CGenericActive::RequestStatus() + { + return iStatus; + } + +void CGenericActive::DoCancel() + { + iObserver.CancelRequest(*this); + TRACE_INFO((_L("Service %d cancelled"), iRequestId)) + } + +void CGenericActive::RunL() + { + TRACE_INFO((_L("Service %d completed with %d"), iRequestId, iStatus.Int())) + iObserver.RequestCompletedL(*this); + } + +TInt CGenericActive::RunError(TInt aError) + { + TRACE_INFO((_L("Service %d RunError with %d"), iRequestId, aError)) + (void) aError; + return KErrNone; + } + +CGenericActive::CGenericActive(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) : + CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) + { + CActiveScheduler::Add(this); + TRACE_FUNC + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/aif/qgn_wka_cxt.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/aif/qgn_wka_cxt.svg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,540 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/bwins/bthidsettingsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/bwins/bthidsettingsu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,9 @@ +EXPORTS + ??1CBtHidSettings@@UAE@XZ @ 1 NONAME ; CBtHidSettings::~CBtHidSettings(void) + ??0CBtHidSettings@@QAE@XZ @ 2 NONAME ; CBtHidSettings::CBtHidSettings(void) + ?NewLC@CBtHidSettings@@SAPAV1@XZ @ 3 NONAME ; class CBtHidSettings * CBtHidSettings::NewLC(void) + ?NewL@CBtHidSettings@@SAPAV1@XZ @ 4 NONAME ; class CBtHidSettings * CBtHidSettings::NewL(void) + ?ConstructL@CBtHidSettings@@AAEXXZ @ 5 NONAME ; void CBtHidSettings::ConstructL(void) + ?LoadLayoutSetting@CBtHidSettings@@QAE?AW4THidKeyboardLayoutId@@XZ @ 6 NONAME ; enum THidKeyboardLayoutId CBtHidSettings::LoadLayoutSetting(void) + ?SaveLayoutSettingL@CBtHidSettings@@QBEXW4THidKeyboardLayoutId@@@Z @ 7 NONAME ; void CBtHidSettings::SaveLayoutSettingL(enum THidKeyboardLayoutId) const + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/data/BthidResource.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/data/BthidResource.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,450 @@ +/* +* Copyright (c) 2008 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: +* +*/ + +NAME HSTR // 4 letter ID + +// INCLUDES +#include +#include + +#include +#include "btkeyboard.hrh" +#include +#include +#include +#include +#include +#include + +// RESOURCE DEFINITIONS + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf="BTHidKBDSettings"; } + +RESOURCE EIK_APP_INFO +{ +} + +//---------------------------------------------------- +// +// r_btkeyboard_softkeys_options_back__change +// +//---------------------------------------------------- +// + +RESOURCE CBA r_btkeyboard_softkeys_options_back__change + { + buttons = + { + CBA_BUTTON {id=EAknSoftkeyOptions; txt = qtn_hid_options;}, + CBA_BUTTON {id=EAknSoftkeyBack; txt = qtn_hid_back;}, + CBA_BUTTON {id=EAknSoftkeyChange; txt = qtn_options_change;} + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_setting_view +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_btkeyboard_setting_view + { + menubar = r_btkeyboard_menubar_setting_view; + cba = r_btkeyboard_softkeys_options_back__change; + } + +//---------------------------------------------------- +// +// r_btkeyboard_menubar_setting_view +// +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_btkeyboard_menubar_setting_view + { + titles= + { + MENU_TITLE { menu_pane=r_btkeyboard_setting_menu; txt=""; } + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_setting_menu +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_btkeyboard_setting_menu + { + items= + { + MENU_ITEM + { + command=EBTKeyCmdAppChange; + txt = qtn_hid_change; + }, + MENU_ITEM + { + command=EBTKeyCmdAppHelp; + txt = qtn_hid_help; + }, + MENU_ITEM + { + command=EEikCmdExit; + txt = qtn_options_exit; + } + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_nokia_layout_item_array +// +//---------------------------------------------------- +// +RESOURCE TBUF r_string_connected{ buf=qtn_hid_connected; } +RESOURCE ARRAY r_btkeyboard_nokia_layout_item_array + { + items = + { + LBUF + { + txt = qtn_hid_layout_english_su8; + }, + LBUF + { + txt = qtn_hid_layout_finnish_swedish; + }, + LBUF + { + txt = qtn_hid_layout_german; + }, + LBUF + { + txt = qtn_hid_layout_norwegian_danish_su8; + }, + LBUF + { + txt = qtn_hid_layout_russian; + } + + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_nokia_layout_page_list +// +//---------------------------------------------------- +// +// Ensure these values match the current Enum in layoutmgr.h +RESOURCE ARRAY r_btkeyboard_nokia_layout_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 1; + text = qtn_hid_layout_english_su8; + }, + AVKON_ENUMERATED_TEXT + { + value = 3; + text = qtn_hid_layout_finnish_swedish; + }, + AVKON_ENUMERATED_TEXT + { + value = 2; + text = qtn_hid_layout_german; + }, + AVKON_ENUMERATED_TEXT + { + value = 4; + text = qtn_hid_layout_norwegian_danish_su8; + }, + AVKON_ENUMERATED_TEXT + { + value = 5; + text = qtn_hid_layout_russian; + } + + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_nokia_layout_popup_setting_list +// +//---------------------------------------------------- +// +RESOURCE AVKON_POPUP_SETTING_TEXTS r_btkeyboard_nokia_layout_popup_setting_list + { + setting_texts_resource = r_btkeyboard_nokia_layout_page_list; + popped_up_texts_resource = r_btkeyboard_nokia_layout_item_array; + } + + +//---------------------------------------------------- +// +// r_btkeyboard_layout_popup_setting_list_new_entry +// +//---------------------------------------------------- +// +RESOURCE POPUP_SETTING_LIST r_btkeyboard_layout_popup_setting_list_new_entry + { + flags = EAknPopupSettingListFlagInitialised; + } + +//---------------------------------------------------- +// +// r_btkeyboard_layout_setting_page +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_btkeyboard_layout_setting_page + { + number = EAknSettingPageNoOrdinalDisplayed; + label= qtn_hid_layout; + type = EAknCtPopupSettingList; + editor_resource_id = r_btkeyboard_layout_popup_setting_list_new_entry; + } + +//---------------------------------------------------- +// +// r_btkeyboard_nokia_setting_list +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_ITEM_LIST r_btkeyboard_nokia_setting_list + { + flags= EAknSettingItemIncludeHiddenInOrdinal; + title = qtn_hid_settings; + initial_number = 1; + items = + { + AVKON_SETTING_ITEM + { + identifier = EBTKeySettingLayout; + setting_page_resource = r_btkeyboard_layout_setting_page; + associated_resource = r_btkeyboard_nokia_layout_popup_setting_list; + name = qtn_hid_layout; + } + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_standard_layout_page_list +// +//---------------------------------------------------- +// +RESOURCE AVKON_POPUP_SETTING_TEXTS r_btkeyboard_standard_layout_popup_setting_list + { + setting_texts_resource = r_btkeyboard_standard_layout_page_list; + popped_up_texts_resource = r_btkeyboard_standard_layout_item_array; + } + +//---------------------------------------------------- +// +// r_btkeyboard_standard_layout_page_list +// +//---------------------------------------------------- +// +// Ensure these values match the current Enum in layoutmgr.h +RESOURCE ARRAY r_btkeyboard_standard_layout_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 6; + text = qtn_hid_layout_uk; + }, + AVKON_ENUMERATED_TEXT + { + value = 7; + text = qtn_hid_layout_us; + }, + AVKON_ENUMERATED_TEXT + { + value = 8; + text = qtn_hid_layout_us_int; + }, + AVKON_ENUMERATED_TEXT + { + value = 9; + text = qtn_hid_layout_belgian; + }, + AVKON_ENUMERATED_TEXT + { + value = 10; + text = qtn_hid_layout_danish; + }, + AVKON_ENUMERATED_TEXT + { + value = 11; + text = qtn_hid_layout_dutch; + }, + AVKON_ENUMERATED_TEXT + { + value = 12; + text = qtn_hid_layout_finnish_swedish; + }, + AVKON_ENUMERATED_TEXT + { + value = 13; + text = qtn_hid_layout_french; + }, + AVKON_ENUMERATED_TEXT + { + value = 14; + text = qtn_hid_layout_german; + }, + AVKON_ENUMERATED_TEXT + { + value = 15; + text = qtn_hid_layout_italian; + }, + AVKON_ENUMERATED_TEXT + { + value = 16; + text = qtn_hid_layout_norwegian; + }, + AVKON_ENUMERATED_TEXT + { + value = 17; + text = qtn_hid_layout_portuguese; + }, + AVKON_ENUMERATED_TEXT + { + value = 18; + text = qtn_hid_layout_spanish; + }, + AVKON_ENUMERATED_TEXT + { + value = 19; + text = qtn_hid_layout_us_dvorak; + } + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_standard_layout_item_array +// +//---------------------------------------------------- +// +RESOURCE ARRAY r_btkeyboard_standard_layout_item_array + { + items = + { + LBUF + { + txt = qtn_hid_layout_uk; + }, + LBUF + { + txt = qtn_hid_layout_us; + }, + LBUF + { + txt = qtn_hid_layout_us_int; + }, + LBUF + { + txt = qtn_hid_layout_belgian; + }, + LBUF + { + txt = qtn_hid_layout_danish; + }, + LBUF + { + txt = qtn_hid_layout_dutch; + }, + LBUF + { + txt = qtn_hid_layout_finnish_swedish; + }, + LBUF + { + txt = qtn_hid_layout_french; + }, + LBUF + { + txt = qtn_hid_layout_german; + }, + LBUF + { + txt = qtn_hid_layout_italian; + }, + LBUF + { + txt = qtn_hid_layout_norwegian; + }, + LBUF + { + txt = qtn_hid_layout_portuguese; + }, + LBUF + { + txt = qtn_hid_layout_spanish; + }, + LBUF + { + txt = qtn_hid_layout_us_dvorak; + } + }; + } + +//---------------------------------------------------- +// +// r_btkeyboard_nokia_setting_list +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_ITEM_LIST r_btkeyboard_standard_setting_list + { + flags= EAknSettingItemIncludeHiddenInOrdinal; + title = qtn_hid_settings; + initial_number = 1; + items = + { + AVKON_SETTING_ITEM + { + identifier = EBTKeySettingLayout; + setting_page_resource = r_btkeyboard_layout_setting_page; + associated_resource = r_btkeyboard_standard_layout_popup_setting_list; + name = qtn_hid_layout; + } + }; + } + +RESOURCE TBUF256 r_btkeyboard_settings_status_pane_title + { + buf = qtn_hid_settings; + } + +RESOURCE CONTEXT_PANE r_statusapp_context_pane_image + { + bmpfile = "z:\\resource\\apps\\btkeyboard_aif.mif"; + bmpid = EMbmBtkeyboardQgn_wka_cxt; + bmpmask = EMbmBtkeyboardQgn_wka_cxt_mask; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/data/bthidkbdsettings.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/data/bthidkbdsettings.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2003-2008 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: ECOM plugin resource file for BTHid plugin. +* +*/ + +#include +#include "hiduids.h" + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = KBDSETTINGS_UIPLUGIN_UID; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x1020745F; //UID for CBtuiPluginInterface + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = KBDSETTINGS_UIPLUGIN_IMP; + version_no = 1; + display_name = "BTHid Btui-plugin"; + default_data = "5 10"; // MajorDeviceClass MinorDeviceClass defined in btdevice.h + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/eabi/bthidsettingsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/eabi/bthidsettingsu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,14 @@ +EXPORTS + _ZN14CBtHidSettings10ConstructLEv @ 1 NONAME + _ZN14CBtHidSettings17LoadLayoutSettingEv @ 2 NONAME + _ZN14CBtHidSettings4NewLEv @ 3 NONAME + _ZN14CBtHidSettings5NewLCEv @ 4 NONAME + _ZN14CBtHidSettingsC1Ev @ 5 NONAME + _ZN14CBtHidSettingsC2Ev @ 6 NONAME + _ZN14CBtHidSettingsD0Ev @ 7 NONAME + _ZN14CBtHidSettingsD1Ev @ 8 NONAME + _ZN14CBtHidSettingsD2Ev @ 9 NONAME + _ZNK14CBtHidSettings18SaveLayoutSettingLE20THidKeyboardLayoutId @ 10 NONAME + _ZTI14CBtHidSettings @ 11 NONAME ; ## + _ZTV14CBtHidSettings @ 12 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2004-2008 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: Project build file +* +*/ + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS + +PRJ_EXTENSIONS +START EXTENSION s60/mifconv +OPTION TARGETFILE btkeyboard.mif +OPTION TARGETFILE btkeyboard_aif.mif +OPTION HEADERFILE btkeyboard.mbg +OPTION SOURCEDIR ../aif +OPTION SOURCES -c8,8 qgn_wka_cxt +END + +PRJ_MMPFILES +bthidsettings.mmp +bthidkbdsettings.mmp + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/group/bthidkbdsettings.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/group/bthidkbdsettings.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2008 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: BTHid settings plugin project definition +* +*/ + + +#include +#include +#include + +TARGET bthidkbdsettings.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2001E30B +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +//********* UIDs ************* +//0x10201D2C //DLL UID +//0x10201D2D //Impl1. UID +//0x10201D2E //impl2. UID +//0x10201D2F //impl3. UID +//****************************' + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../common/inc +USERINCLUDE ../../manager/inc +USERINCLUDE ../../loc + +SOURCEPATH ../../common/src +SOURCE bthidcenrepwatcher.cpp +SOURCE layoututils.cpp + +SOURCEPATH ../src +SOURCE bthidsettingcontainer.cpp +SOURCE bthidsettingview.cpp +SOURCE bthidpluginimplementationtable.cpp btkeysettinglist.cpp btkeyenumtextsettingitem.cpp + +APP_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc ../../../inc + +//***********ECOM resource definition****************** +//--Ecom resource TARGET name must be same as DLL name, +//--otherwise Ecom won't recognise it. +//***************************************************** +START RESOURCE ../data/bthidkbdsettings.rss +HEADER +TARGET bthidkbdsettings.rsc +END // RESOURCE + +//plugin resource definition +START RESOURCE ../data/BthidResource.rss +HEADER +TARGETPATH RESOURCE_FILES_DIR +LANGUAGE_IDS +END + +LIBRARY aknlayout.lib +LIBRARY aknskins.lib +LIBRARY avkon.lib +LIBRARY bafl.lib +LIBRARY bluetooth.lib +LIBRARY btdevice.lib + +LIBRARY cone.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY egul.lib // CGulIcon +LIBRARY etext.lib +LIBRARY eikdlg.lib +LIBRARY eikcore.lib +LIBRARY eikcoctl.lib +LIBRARY eikctl.lib +LIBRARY estor.lib +LIBRARY euser.lib +LIBRARY commonengine.lib + +LIBRARY gdi.lib +LIBRARY gsframework.lib +LIBRARY gsecomplugin.lib +LIBRARY ws32.lib +LIBRARY bthidsettings.lib +LIBRARY kbdclient.lib +LIBRARY centralrepository.lib +LIBRARY cenrepnotifhandler.lib +DEBUGLIBRARY flogger.lib + +#ifdef __SERIES60_HELP +LIBRARY hlplch.lib // Help library +#endif + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/group/bthidsettings.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/group/bthidsettings.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2008 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: Access to layout settings for BTUI hid plugin +* +*/ + + +#include + +TARGET bthidsettings.dll +TARGETTYPE dll +UID 0x1000008d 0x2001E320 +CAPABILITY CAP_CLIENT_DLL +VENDORID VID_DEFAULT + + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../layouts/inc +USERINCLUDE ../../common/inc + + + + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc ../../../inc + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY centralrepository.lib + +DEBUGLIBRARY flogger.lib + +SOURCEPATH ../src +SOURCE bthidsettings.cpp diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettingcontainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettingcontainer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2008 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: Declares setting container class. + * +*/ + + +#ifndef BTHIDSETTINGCONTAINER_H +#define BTHIDSETTINGCONTAINER_H + +/** + * CBTHidSettingContainer + * container control class. + */ +class CBTHidSettingContainer : public CCoeControl, public MCoeControlObserver + { +public: + // Constructors and destructor + + /** + * EPOC default constructor. + * @param aRect Frame rectangle for container. + */ + void ConstructL(const TRect& aRect); + + /** + * Constructs common parts of the container. + * @param aRect control's rect. + */ + void BaseConstructL(const TRect& aRect); + + /** + * Destructor. + */ + ~CBTHidSettingContainer(); + +private: + // Functions from base classes + + /** + * From CCoeControl,Draw. + */ + void Draw(const TRect& aRect) const; + + /** + * From CCoeControl + */ + void HandleResourceChange(TInt aType); + + /** + * From CoeControl,SizeChanged. + */ + void SizeChanged(); + + /** + * From CoeControl,CountComponentControls. + */ + TInt CountComponentControls() const; + + /** + * From CCoeControl,ComponentControl. + */ + CCoeControl* ComponentControl(TInt aIndex) const; + + /** + * From MCoeControlObserver + */ + void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType); + + /** + * Pass skin information if needed. + */ + TTypeUid::Ptr MopSupplyObject(TTypeUid aId); + + /** + * From CCoeControl + */ + //void GetHelpContext(TCoeHelpContext& aContext) const; + +private: + //data + CAknsBasicBackgroundControlContext* iBackGround; //for skins support + + + }; + +#endif // BTHIDSETTINGCONTAINER_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettinglist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettinglist.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2008 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: Declares settings list class. + * +*/ + + +#ifndef __BTHIDSETTINGLIST_H__ +#define __BTHIDSETTINGLIST_H__ + +#include + +class CBtHidSettings; +class CBtHidSettingView; + +class CBTKeySettingList : public CAknSettingItemList + { +public: + CBTKeySettingList(CBtHidSettings& aSettings, + CBtHidSettingView* aBtHidSettingView); + + CAknSettingItem* CreateSettingItemL(TInt identifier); + + // handles the listbox events + virtual void HandleListBoxEventL(CEikListBox* aListBox, + TListBoxEvent aEventType); + + void EditCurrentItemL(TInt aCommand); + +private: + void SizeChanged(); + +private: + // From CCoeControl + +private: + /*! A reference to the BtHidSettings object */ + CBtHidSettings& iSettings; + + /*! Temporary layout code variable */ + TInt iLayoutCode; + + CBtHidSettingView* iBtHidSettingView; + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettings.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2008 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: BT HID settings header + * +*/ + +#ifndef BTHIDSETTINGS_H +#define BTHIDSETTINGS_H + +// INCLUDES +#include +#include "layoututils.h" + +// CLASS DECLARATION +/** + * BT HID settings CenRep handler. + * + * @lib btkeyboard.exe + */ +class CBtHidSettings : public CBase + { +public: + // Constructors and destructor + /** + * Two-phased constructor. + */ + IMPORT_C static CBtHidSettings* NewL(); + + /** + * Two-phased constructor. Leaves object in cleanup stack. + */ + IMPORT_C static CBtHidSettings* NewLC(); + + /** + * Destructor. + */ + virtual ~CBtHidSettings(); + +public: + // Functions from base classes + + +public: + // New functions + + + /** + * C++ default constructor. + */ + CBtHidSettings(); + + /*! + Retrieve the current keyboard layout value. + */ + IMPORT_C THidKeyboardLayoutId LoadLayoutSetting(); + + /*! + Set the layout value. + @param aNewValue The new layout value + */ + IMPORT_C void SaveLayoutSettingL(THidKeyboardLayoutId aNewValue) const; + + +private: + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + +private: + // New functions + /** + * Set value to CenRep + * @since + * @param aKey CenRep key + * @param aValue Integer value. + * @return status + */ + TInt SetValue(const TUint32 aKey, const TInt aValue) const; + + /** + * Get value from CenRep + * @since + * @param aKey CenRep key + * @param aValue Integer value. + * @return status + */ + TInt GetValue(const TUint32 aKey, TInt& aValue); + +private: + // Data + + + }; +#endif // BTHIDSETTINGS_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettingview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/inc/bthidsettingview.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2008 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: Declares the setting view for keyboard device. + * +*/ + + +#ifndef BTHIDSETTINGVIEW_H +#define BTHIDSETTINGVIEW_H + +// INCLUDES + +#include // AVKON components +#include +#include // Menu pane definitions +#include +#include +#include "BtuiPluginInterface.h" +#include "bthidsettings.h" +#include "bthidsettinglist.h" +#include "bthidcenrepwatcher.h" +// FORWARD DECLARATIONS +class CBTHidSettingContainer; +class CBTKeySettingList; +#include "bthidsettings.h" +#include "layoutmgr.h" +#include "hidlayoutids.h" +// CONSTANTS +_LIT(KFileDrive,"z:"); +_LIT(KResourceFileName, "BthidResource.rsc"); + +// CLASS DECLARATION + +/** + * Main view of the application. Handles view activation, + * deactivation, commands and dynamic options menus. + */ +class CBtHidSettingView : public CBtuiPluginInterface, + public MBtHidCenRepObserver + { +public: + // Constructors and destructor + + /** + * ECOM implementation instantiation function of + * interface "CBtuiPluginInterface", to be used by BtuiPairedView. + */ + static CBtHidSettingView* NewBtuiPluginL( /* TAny* aAppUi */); + + /** + * Destructor. + */ + virtual ~CBtHidSettingView(); + +protected: + + /** + * C++ default constructor. + */ + CBtHidSettingView(/* CAknViewAppUi* aAppUi */); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + +public: + // Functions from base classes + + /** + * From CAknView Returns view id. + * @param None. + * @return View id. + */ + TUid Id() const; + + /** + * From CAknView Handles user commands. + * @param aCommand A command id. + * @return None. + */ + void HandleCommandL(TInt aCommand); + void CenRepDataChanged(TUid& aUid, TUint32 aKey); + +private: + // Functions from base classes + + /** + * From CAknView Activates view. + * @param aPrevViewId Id of previous view. + * @param aCustomMessageId Custom message id. + * @param aCustomMessage Custom message. + * @return None. + */ + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, + const TDesC8& aCustomMessage); + + /** + * From CAknView Deactivates view. + * @param None. + * @return None. + */ + void DoDeactivate(); + + /** + * From CAknView Dynamically initialises options menu. + * @param aResourceId Id identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + * @return None. + */ + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); + +public: + // New functions + + +private: + + /** + * Creates List Box + */ + void CreateSettingListL(); + THidKeyboardLayoutId CurrentLayoutL() const; + + void SetNavipaneTextL(const TDesC8& aDeviceName); + +public: + void SetCurrentLayoutL(THidKeyboardLayoutId aLayoutValue); + +private: + // Data + CBTHidSettingContainer* iContainer; + CBtHidSettings* iSettings; // Settings handler class + CBTKeySettingList* iSettingList; // The settings-list list view + + //CIdle* iIdle; // Idle time class (for doing operation delayed) + TVwsViewId iPrevViewId; // Previous view of GS app. + TInt iResourceFileFlag; // Flag for eikon env. + CEikonEnv* iEikEnv; + + /*! The Layout Manager Server session */ + RLayoutManager iLayoutSession; + + /*! The last keyboard layout selected by the user */ + THidKeyboardLayoutId iLastSelectedLayout; + TBool iIsNokiaKeyboard; + /** + * Needed when creating navipane text + * Own this pointer + */ + CAknNavigationDecorator* iNaviDecorator; + CAknContextPane* iContextPane; + CBtHidCenRepWatcher* iCenRepWatcher; + + }; + +#endif // BTHIDSETTINGVIEW_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/inc/btkeyboard.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/inc/btkeyboard.hrh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +#ifndef BTKEYBOARD_HRH +#define BTKEYBOARD_HRH + +enum TBTKeyboardCommandIds + { + EBTKeyCmdAppFindKbd = 1, + EBTKeyCmdAppDiscKbd, + EBTKeyCmdAppSettings, + EBTKeyCmdAppChange, + EBTKeyCmdAppAbout, + EBTKeyCmdAppHelp, + EBTKeyCmdExit + }; + +enum TBTKeyboardSettingItems + { + EBTKeySettingLayout, EBTKeySettingAutostart, EBTKeySettingNotify + }; + +#endif // BTKEYBOARD_HRH diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/inc/btkeyenumtextsettingitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/inc/btkeyenumtextsettingitem.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2008 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: Declares the setting view for keyboard device. + * +*/ + + +#ifndef __BTKEYENUMTEXTSETTINGITEM_H__ +#define __BTKEYENUMTEXTSETTINGITEM_H__ + +#include + +class CBtHidSettings; +class CBtHidSettingView; + +class CBTKeyEnumTextSettingItem : public CAknEnumeratedTextPopupSettingItem + { +public: + + /*! + Constructs this object + */ + CBTKeyEnumTextSettingItem(TInt aResourceId, TInt& aValue, + CBtHidSettings& aSettings, CBtHidSettingView* aBtHidSettingView); + + /*! + Destroy the object and release all memory objects + */ + ~CBTKeyEnumTextSettingItem(); + +public: + // from CAknSettingItem + void HandleSettingPageEventL(CAknSettingPage *aSettingPage, + TAknSettingPageEvent aEventType); + +private: + CBtHidSettings& iSettings; + CBtHidSettingView* iBtHidSettingView; + }; + +#endif // __BTKEYENUMTEXTSETTINGITEM_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/src/bthidpluginimplementationtable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/src/bthidpluginimplementationtable.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 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: +* ECOM proxy table for this plugin +* +*/ + + +// System includes +// +#include +#include + +// User includes +// +#include "bthidsettingview.h" +#include "hiduids.h" + +// Constants +// +const TImplementationProxy KBtHidPluginImplementationTable[] = + { + // UPDATE THIS - Uid for plugin implementation: + + //This impl is for BtuiPluginInterface. + IMPLEMENTATION_PROXY_ENTRY( KBDSETTINGS_UIPLUGIN_IMP, CBtHidSettingView::NewBtuiPluginL ), + }; + + +// --------------------------------------------------------------------------- +// ImplementationGroupProxy +// Gate/factory function +// +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KBtHidPluginImplementationTable) + / sizeof(TImplementationProxy); + return KBtHidPluginImplementationTable; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/src/bthidsettingcontainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/src/bthidsettingcontainer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2006 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: This is the implementation of setting container class +* +*/ + + +// INCLUDE FILES +#include // for font +#include // skin +#include //skin +#include +#include "bthidsettingcontainer.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTHidSettingContainer::ConstructL(const TRect& aRect) +// EPOC two phased constructor +// --------------------------------------------------------- +// +void CBTHidSettingContainer::ConstructL(const TRect& aRect) + { + CreateWindowL(); //makes the control a window-owning control + BaseConstructL( aRect ); + } + +// --------------------------------------------------------- +// CBTHidBaseContainer::BaseConstructL() +// --------------------------------------------------------- +// +void CBTHidSettingContainer::BaseConstructL( const TRect& aRect ) + { + SetRect(aRect); + iBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse ); + ActivateL(); + } + + +// Destructor +CBTHidSettingContainer::~CBTHidSettingContainer() + { + delete iBackGround; + } + + +// --------------------------------------------------------------------------- +// CBTHidSettingContainer::SizeChanged +// called by framwork when the view size is changed +// +// --------------------------------------------------------------------------- +// +void CBTHidSettingContainer::SizeChanged() + { + TRACE_INFO( (_L("[BTHID]\t CBTHidBaseContainer::SizeChanged(); Width %d Height %d "),Rect().Height(), Rect().Width())); + + //Handle SizeChanged for Skin + TRect parentRect(Rect()); + if (iBackGround) + iBackGround->SetRect(parentRect); + } + +// --------------------------------------------------------------------------- +// CBTHidSettingContainer::CountComponentControls +// +// +// --------------------------------------------------------------------------- +// +TInt CBTHidSettingContainer::CountComponentControls() const + { + return 0; + } + +// --------------------------------------------------------------------------- +// CBTHidSettingContainer::ComponentControl +// +// +// --------------------------------------------------------------------------- +// +CCoeControl* CBTHidSettingContainer::ComponentControl(TInt /*aIndex*/) const + { + return NULL; + } + +void CBTHidSettingContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) + { + // TODO: Add your control event handler code here + } + +// --------------------------------------------------------- +// CBTHidBaseContainer::HandleResourceChange +// --------------------------------------------------------- +// + +void CBTHidSettingContainer::HandleResourceChange( TInt aType ) + { + + //Handle change in layout orientation + if (aType == KEikDynamicLayoutVariantSwitch) + { + + //TRect rect = iAvkonAppUi->ClientRect(); + // The line above provides to big rectangle in the bottom causing cba's overdrawn by by blank area. + // Correct way to do this is below. + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); + SetRect(mainPaneRect); + DrawNow(); + } + + else + { + CCoeControl::HandleResourceChange(aType); + } + } + +// --------------------------------------------------------- +// CBTHidBaseContainer::Draw(const TRect& aRect) const +// --------------------------------------------------------- +// +void CBTHidSettingContainer::Draw(const TRect& aRect) const + { + TRACE_FUNC(_L("[BTHID]\t CBTHidSettingContainer::Draw()")); + TRgb color; + + CWindowGc& gc = SystemGc(); + + // draw background + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + + // get skin text color + AknsUtils::GetCachedColor( skin, color , KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); + gc.SetPenColor( color ); + + MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); + AknsDrawUtils::Background( skin, cc, this, gc, aRect ); + } + +// --------------------------------------------------------- +// CBTHidBaseContainer::MopSupplyObject() +// Pass skin information if needed. +// --------------------------------------------------------- +// +TTypeUid::Ptr CBTHidSettingContainer::MopSupplyObject(TTypeUid aId) + { + if(aId.iUid == MAknsControlContext::ETypeId && iBackGround) + { + return MAknsControlContext::SupplyMopObject( aId, iBackGround); + } + + return CCoeControl::MopSupplyObject( aId ); + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/src/bthidsettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/src/bthidsettings.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2006 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: +* BT HID settings manager +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include "btengprivatecrkeys.h" +#include "bthidsettings.h" +#include "debug.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtHidSettings::CBtHidSettings +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C CBtHidSettings::CBtHidSettings() + {} + +// ----------------------------------------------------------------------------- +// CBtHidSettings::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CBtHidSettings::ConstructL() + {} + +// ----------------------------------------------------------------------------- +// CBtHidSettings::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CBtHidSettings* CBtHidSettings::NewL() + { + CBtHidSettings* self = CBtHidSettings::NewLC(); + CleanupStack::Pop(); + + return self; + } + + +// ----------------------------------------------------------------------------- +// CBtHidSettings::NewLC +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CBtHidSettings* CBtHidSettings::NewLC() + { + CBtHidSettings* self = new( ELeave ) CBtHidSettings; + + CleanupStack::PushL( self ); + self->ConstructL(); + + return self; + } + + +// Destructor +EXPORT_C CBtHidSettings::~CBtHidSettings() + {} + +// ---------------------------------------------------- +// CBtHidSettings::LoadLayoutSetting() +// ---------------------------------------------------- +// +EXPORT_C THidKeyboardLayoutId CBtHidSettings::LoadLayoutSetting() + { + TInt layout; + + TInt err = GetValue( KBtHidKeyboardLayout, layout ); + if( KErrNone != err) + { + TRACE_INFO( (_L("[HID]\tGetValue() error (%d)\n"), err)); + layout = 0; + } + + // Convert the Int to the enum. + THidKeyboardLayoutId layoutID = + static_cast(layout); + + TRACE_INFO( (_L("[HID]\tCBtHidSettings::LoadLayoutSetting()(%d)\n"), + layoutID)); + return layoutID; + } + +// ---------------------------------------------------- +// CBtHidSettings::SaveLayoutSettingL +// ---------------------------------------------------- +// +EXPORT_C void CBtHidSettings::SaveLayoutSettingL(THidKeyboardLayoutId aNewValue) const + { + User::LeaveIfError( SetValue( KBtHidKeyboardLayout, aNewValue ) ); + } + +// ----------------------------------------------------------------------------- +// CBtHidSettings::SetValue +// Sets integer value to CenRep +// ----------------------------------------------------------------------------- +// +TInt CBtHidSettings::SetValue( const TUint32 aKey, const TInt aValue ) const + { + TRACE_INFO(_L("[BTHID]\t CBtHidSettings::SetValue")); + CRepository* cenrep = NULL; + TRAPD(status, cenrep = CRepository::NewL(KCRUidBTEngPrivateSettings)); + if( status == KErrNone) + { + status = cenrep->Set( aKey, aValue ); + delete cenrep; + } + if( status != KErrNone) + { + TRACE_INFO(_L("Cenrep fail")); + } + return status; + } + + +// ----------------------------------------------------------------------------- +// CBtHidSettings::GetValue +// Gets integer value from CenRep +// ----------------------------------------------------------------------------- +// +TInt CBtHidSettings::GetValue( const TUint32 aKey, TInt& aValue ) + { + TRACE_INFO(_L("[BTHID]\t CBtHidSettings::GetValue")); + CRepository* cenrep = NULL; + TRAPD( status , cenrep = CRepository::NewL(KCRUidBTEngPrivateSettings)); + if( status == KErrNone) + { + status = cenrep->Get( aKey, aValue ); + delete cenrep; + } + if( status != KErrNone) + { + TRACE_INFO(_L("Cenrep fail")); + } + + TRACE_FUNC_EXIT + return status; + } + +// End of File + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/src/bthidsettingview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/src/bthidsettingview.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,436 @@ +/* +* Copyright (c) 2006 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: This is the implementation of setting view class +* +*/ + +#include +#include +#include +#include +#include +#include // Help launcher +#include +#include +#include +#include // Help IDs +#include +#include +#include "bthidsettingview.h" +#include "bthidsettingcontainer.h" +#include "bthidsettings.h" +#include "bthidsettinglist.h" +#include "btkeyboard.hrh" +#include +#include "btengprivatecrkeys.h" +#include "layoutmgr.h" +#include "hidlayoutids.h" +#include "debug.h" + +const TUid KBtHidSettingViewId = + { + 0x2001E30B + } + ; // UID of HID device setting view. +// --------------------------------------------------------- +// CBtHidSettingView::NewNewGsPluginL +// Two phased constructor +// --------------------------------------------------------- +// +CBtHidSettingView* CBtHidSettingView::NewBtuiPluginL() + { + //TRACE_FUNC(_L("[BTHID]\t CBtHidSettingView::NewBtuiPluginL(), BEGIN")); + + CBtHidSettingView* self = new (ELeave) CBtHidSettingView(); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + //TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::NewBtuiPluginL, END"),self) ); + + return self; + } + + +// ---------------------------------------------------- +// CBtHidSettingView::CBtHidSettingView +// default constructor +// ---------------------------------------------------- +// +CBtHidSettingView::CBtHidSettingView() + {} + +// ---------------------------------------------------- +// CBtHidSettingView::ConstructL +// ---------------------------------------------------- +// +void CBtHidSettingView::ConstructL() + { + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]:ConstructL(), BEGIN"),this) ); + + User::LeaveIfError(iLayoutSession.Connect()); + + // Check to see what type of layout code the layout manager will return + // us. (i.e nokia or standard) + // This is used to know which settings page to display. + TBool ignore; + TRACE_INFO(_L("[BTHID]\t CBtHidMainView::ConstructL(), get layout info...")); + User::LeaveIfError(iLayoutSession.GetDeviceInfo(iIsNokiaKeyboard, ignore)); + + iEikEnv = CEikonEnv::Static(); + TFileName filename; + filename += KFileDrive; + filename += KDC_RESOURCE_FILES_DIR; + filename += KResourceFileName; + BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); + iResourceFileFlag=iEikEnv->AddResourceFileL(filename); + BaseConstructL( R_BTKEYBOARD_SETTING_VIEW ); + + CEikStatusPane *sp = ((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane(); + // Fetch pointer to the default title pane control + iContextPane = (CAknContextPane *)sp->ControlL(TUid::Uid(EEikStatusPaneUidContext)); + + iSettings = CBtHidSettings::NewL(); + + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]:ConstructL(), END"),this) ); + } +// ---------------------------------------------------- +// CBtHidSettingView::~CBtHidSettingView() +// Destructor +// Frees reserved resources +// ---------------------------------------------------- +// +CBtHidSettingView::~CBtHidSettingView() + { + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::~CBtHidSettingView()"), this) ); + iLayoutSession.Close(); + + delete iNaviDecorator; + iEikEnv->DeleteResourceFile(iResourceFileFlag); + + if ( iSettingList ) + { + AppUi()->RemoveFromStack( (CCoeControl*) iSettingList ); + delete iSettingList; + } + if ( iContainer ) + { + AppUi()->RemoveFromStack(iContainer ); + delete iContainer; + } + if( iCenRepWatcher ) + delete iCenRepWatcher; + + if (iSettings ) + delete iSettings; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// TUid CBtHidSettingView::Id +// --------------------------------------------------------- +// +TUid CBtHidSettingView::Id() const + { + TUid id = KBtHidSettingViewId; //view id + return id; + } + +// ---------------------------------------------------- +// CBtHidSettingView::HandleCommandL(TInt aCommand) +// takes care of command handling +// ---------------------------------------------------- +// +void CBtHidSettingView::HandleCommandL(TInt aCommand) + { + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::HandleCommandL(%d)"),this, aCommand) ); + switch ( aCommand ) + { + case EEikCmdExit: // fall-through, handled similarily + case EAknSoftkeyExit: // fall-through, handled similarily + //case EBTKeyCmdExit: + { + AppUi()->HandleCommandL( EEikCmdExit); + } + case EAknSoftkeyChange: + case EBTKeyCmdAppChange: + { + if( iSettingList ) + { + iCenRepWatcher->DisableNotifications(); + iSettingList->EditCurrentItemL( aCommand ); + iCenRepWatcher->EnableNotifications(); + } + break; + } + case EAknSoftkeyBack: + { + AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid ); + break; + } + +#ifdef __SERIES60_HELP + case EBTKeyCmdAppHelp: + { + HlpLauncher::LaunchHelpApplicationL( + iEikEnv->WsSession(), AppUi()->AppHelpContextL()); + break; + } + +#endif + default: + { + AppUi()->HandleCommandL( aCommand ); + break; + } + } + } + +// --------------------------------------------------------------------------- +// CBtHidSettingView::DoActivateL() +// --------------------------------------------------------------------------- +// +void CBtHidSettingView::DoActivateL( const TVwsViewId& aPrevViewId, + TUid aCustomMessageId, + const TDesC8& aCustomMessage ) + { + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoActivateL, BEGIN"),this) ); + iPrevViewId = aPrevViewId; + (void) aCustomMessageId; + + // Setup the title + HBufC* title; + title = iCoeEnv->AllocReadResourceLC(R_BTKEYBOARD_SETTINGS_STATUS_PANE_TITLE); + + CEikStatusPane* statusPane = StatusPane(); + CAknTitlePane* titlePane; + titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); + titlePane->SetTextL(title->Des()); + CleanupStack::PopAndDestroy(); // title + title = NULL; + + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoActivateL(), Creating container..."),this) ); + iContainer = new (ELeave) CBTHidSettingContainer; + iContainer->SetMopParent(this); + iContainer->ConstructL( ClientRect()); + iContainer->MakeVisible( ETrue ); + iContainer->ActivateL(); + AppUi()->AddToStackL(iContainer); + + CreateSettingListL(); + iCenRepWatcher = CBtHidCenRepWatcher::NewL( KCRUidBTEngPrivateSettings, *this ); // create listener for cenrep events. + SetNavipaneTextL(aCustomMessage); + + TRACE_INFO((_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoActivateL, END"),this) ); + } + + +// --------------------------------------------------------------------------- +// CBtHidSettingView::DoDeactivate +// +// Deactivate the settings view. +// --------------------------------------------------------------------------- +// +void CBtHidSettingView::DoDeactivate() + { + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::DoDeactivate, BEGIN"),this) ); + if ( iSettingList ) + { + AppUi()->RemoveFromStack( (CCoeControl*) iSettingList ); + delete iSettingList; + iSettingList = NULL; + } + if( iContainer ) + { + iContainer->MakeVisible(EFalse); + AppUi()->RemoveFromStack( iContainer ); + delete iContainer; + iContainer = NULL; + } + + if (iNaviDecorator) + { + delete iNaviDecorator; + iNaviDecorator = NULL; + } + iLastSelectedLayout = iSettings->LoadLayoutSetting(); + iLayoutSession.SetLayout(iLastSelectedLayout); + delete iCenRepWatcher; + iCenRepWatcher = NULL; + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------- +// CBtHidSettingView::DynInitMenuPaneL +// ---------------------------------------------------- +// +void CBtHidSettingView::DynInitMenuPaneL( + TInt aResourceId, CEikMenuPane* aMenuPane) + { + if (aResourceId == R_BTKEYBOARD_SETTING_MENU ) + { + aMenuPane->SetItemDimmed(EBTKeyCmdAppChange, ETrue); + } + + + } + +// ---------------------------------------------------- +// CBtHidSettingView::CreateSettingListL +// ---------------------------------------------------- +// +void CBtHidSettingView::CreateSettingListL() + { + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::CreateSettingListL, BEGIN"),this) ); + + TInt resourceId = R_BTKEYBOARD_STANDARD_SETTING_LIST; + + TBool foundLayout; + User::LeaveIfError(iLayoutSession.GetDeviceInfo(iIsNokiaKeyboard, foundLayout)); + + if(iIsNokiaKeyboard) + { + resourceId = R_BTKEYBOARD_NOKIA_SETTING_LIST; + } + else + { + resourceId = R_BTKEYBOARD_STANDARD_SETTING_LIST; + } + + TInt layoutCode; + if ( !foundLayout ) + { + //No layout found, find an appropriate one. + layoutCode = CurrentLayoutL(); + SetCurrentLayoutL(static_cast(layoutCode)); + } + else + { + //Layout found, load it as default + iLayoutSession.GetLayout(layoutCode); + SetCurrentLayoutL(static_cast(layoutCode)); + } + + if ( iSettingList ) + { + AppUi()->RemoveFromStack( (CCoeControl*) iSettingList ); + } + delete iSettingList; + iSettingList = NULL; + + iSettingList = new (ELeave) CBTKeySettingList( *iSettings, this); + iSettingList->SetMopParent(this); + iSettingList->ConstructFromResourceL(resourceId); + AppUi()->AddToStackL( (CCoeControl*) iSettingList ); + iSettingList->MakeVisible(ETrue); + iSettingList->SetRect(ClientRect()); + iSettingList->ActivateL(); + iSettingList->DrawNow(); + TRACE_INFO( (_L("[BTHID]\t CBtHidSettingView[0x%08x]::CreateSettingListL, END"),this) ); + } + +// ---------------------------------------------------- +// CBtHidSettingView::SetCurrentLayoutL +// ---------------------------------------------------- +// +void CBtHidSettingView::SetCurrentLayoutL(THidKeyboardLayoutId aLayoutValue) + { + // Ask the layout manager to change layout. + // Use the leaving version so we the user can't confirm a selection + // if an error occurs. + iLayoutSession.SetLayoutL(aLayoutValue); + + iSettings->SaveLayoutSettingL( aLayoutValue ); + } + +THidKeyboardLayoutId CBtHidSettingView::CurrentLayoutL() const + { + // Ask the layout manager for the current layout. + // Use the leaving version. + TInt layoutCode = iLayoutSession.GetLayoutL(); + + // Convert the Int to the enum. + THidKeyboardLayoutId layoutID = + static_cast(layoutCode); + + // If we believe this to be a Nokia keyboard then the layout settings + // page will contain the list of Nokia Su8 items. + // Conversly if we think this is a Standard keyboard the layout settings + // page will contain the list of Standard layouts. + // We must pass a valid value to the Settings page or it will panic. + // Validate the code from the Layout Manager before returning it. + if ( iIsNokiaKeyboard ) + { + CLayoutUtils::ValidateNokiaSU8Layout(layoutID); + } + else + { + CLayoutUtils::ValidateStandardLayout(layoutID); + } + + return layoutID; + } + +void CBtHidSettingView::SetNavipaneTextL(const TDesC8& aDeviceName) + { + TRACE_INFO(_L("[BTHID]\t CBtHidSettingView::SetNavipaneTextL Start")); + CEikStatusPane* sp = + iEikonEnv->AppUiFactory()->StatusPane(); + + CAknNavigationControlContainer* np = + static_cast( + sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); + + delete iNaviDecorator; + iNaviDecorator = NULL; + + TInt blank(1); + if (aDeviceName.Length()>0 ) + { + HBufC* stringHolder = HBufC::NewLC(aDeviceName.Length() + blank); + stringHolder->Des().Copy(aDeviceName); + stringHolder->Des().Append(_L(" ")); + iNaviDecorator = np->CreateNavigationLabelL( *stringHolder ); + np->PushL( *iNaviDecorator ); + sp->DrawNow(); + CleanupStack::PopAndDestroy(stringHolder); // stringHolder + } + else + { + HBufC* temp = HBufC::NewLC(aDeviceName.Length()); + temp->Des().Copy(aDeviceName); + iNaviDecorator = np->CreateNavigationLabelL( *temp ); + np->PushL( *iNaviDecorator ); + sp->DrawNow(); + CleanupStack::PopAndDestroy(temp); // temp + } + TRACE_INFO(_L("[BTHID]\t CBtHidSettingView::SetNavipaneTextL End")); + } +// ---------------------------------------------------- +// CBtHidSettingView::CenRepDataChanged +// ---------------------------------------------------- +// +void CBtHidSettingView::CenRepDataChanged(TUid& aUid, TUint32 aKey) + { + // just recreate the setting list + TRACE_INFO((_L("[BTHID]\t CBtHidSettingView[0x%08x]::CenRepDataChanged"),this)); + (void) aUid; + if ( aKey == KBtHidKeyboardLayout ) + { + TRAPD( err, CreateSettingListL()); + err = err; + } + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/src/btkeyenumtextsettingitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/src/btkeyenumtextsettingitem.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2004 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 "btkeyenumtextsettingitem.h" +#include "btkeyboard.hrh" +#include "bthidsettingview.h" +#include "bthidsettings.h" +#include "debug.h" + +//----------------------------------------------------------------------------- +// CBTKeyEnumTextSettingItem::CBTKeyEnumTextSettingItem +//----------------------------------------------------------------------------- +// +CBTKeyEnumTextSettingItem::CBTKeyEnumTextSettingItem( + TInt aResourceId, TInt& aValue, CBtHidSettings& aSettings, CBtHidSettingView* aBtHidSettingView) : + CAknEnumeratedTextPopupSettingItem ( aResourceId, aValue ), + iSettings(aSettings), + iBtHidSettingView(aBtHidSettingView) + {} + + +//----------------------------------------------------------------------------- +// CBTKeyEnumTextSettingItem::~CBTKeyEnumTextSettingItem +//----------------------------------------------------------------------------- +// +CBTKeyEnumTextSettingItem::~CBTKeyEnumTextSettingItem() + {} + +//----------------------------------------------------------------------------- +// CBTKeyEnumTextSettingItem::HandleSettingPageEventL +//----------------------------------------------------------------------------- +// +void CBTKeyEnumTextSettingItem::HandleSettingPageEventL( + CAknSettingPage *aSettingPage, TAknSettingPageEvent aEventType) + { + switch( aEventType ) + { + case EEventSettingOked: + { + TRACE_INFO(_L("[BTHID]\t CBTKeyEnumTextSettingItem::HandleSettingPageEventL: OK")); + // Get the new index and new value + TInt newIndex = QueryValue()->CurrentValueIndex(); + TInt newValue = EnumeratedTextArray()->At(newIndex)->EnumerationValue(); + + // Reset the index to the initial value, so if we leave when + // trying to use the new value and the user then selects cancel + // the setting item won't set the new value on the display. + QueryValue()->SetCurrentValueIndex(IndexFromValue(InternalValue())); + + switch ( Identifier() ) + { + case EBTKeySettingLayout: + { + THidKeyboardLayoutId newLayout = + static_cast(newValue); + iSettings.SaveLayoutSettingL(newLayout); + iBtHidSettingView->SetCurrentLayoutL(newLayout); + } + break; + + default: + break; + } + + // We have finished using the new value. Set the index to the new + // value so the UI is updated when this function exits + QueryValue()->SetCurrentValueIndex(newIndex); + + // store the setting page internal value to the external variable + StoreL(); + break; + } + case EEventSettingCancelled: + { + TRACE_INFO(_L("[BTHID]\t CBTKeyEnumTextSettingItem::HandleSettingPageEventL: Cancel")); + // Reset the index to the initial value + QueryValue()->SetCurrentValueIndex(IndexFromValue(InternalValue())); + break; + } + case EEventSettingChanged: + { + TRACE_INFO(_L("[BTHID]\t CBTKeyEnumTextSettingItem::HandleSettingPageEventL: Changed")); + // Flow through + } + default: + { + //do nothing + break; + } + } + // call the base class handler to take care of other event types + CAknSettingItem::HandleSettingPageEventL(aSettingPage, aEventType); + } + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidkbdsettings/src/btkeysettinglist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidkbdsettings/src/btkeysettinglist.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2004 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 "bthidsettingview.h" +#include "bthidsettings.h" +#include "bthidsettinglist.h" +#include "btkeyenumtextsettingitem.h" +#include "btkeyboard.hrh" + +//----------------------------------------------------------------------------- +// CBTKeySettingList::CBTKeySettingList +//----------------------------------------------------------------------------- +// +CBTKeySettingList::CBTKeySettingList(CBtHidSettings& aSettings, CBtHidSettingView* aBtHidSettingView): + CAknSettingItemList(), iSettings(aSettings), iBtHidSettingView(aBtHidSettingView) + { + } + +//----------------------------------------------------------------------------- +// CBTKeySettingList::CreateSettingItemL +//----------------------------------------------------------------------------- +// +CAknSettingItem* CBTKeySettingList::CreateSettingItemL( TInt aIdentifier ) + { + CAknSettingItem* settingItem = 0; + switch ( aIdentifier ) + { + case EBTKeySettingLayout: + iLayoutCode = iSettings.LoadLayoutSetting(); + settingItem = new (ELeave) CBTKeyEnumTextSettingItem( + aIdentifier, iLayoutCode, iSettings, iBtHidSettingView); + break; + default: + break; + } + + return settingItem; + } + +//----------------------------------------------------------------------------- +// CBTKeySettingList::HandleListBoxEventL +//----------------------------------------------------------------------------- +// +void CBTKeySettingList::HandleListBoxEventL( + CEikListBox* aListBox, TListBoxEvent aEventType) + { + // call the base classes handler to handle this event. + CAknSettingItemList::HandleListBoxEventL(aListBox, aEventType); + + // store the values from all setting items to their external variables + StoreSettingsL(); + } + +//----------------------------------------------------------------------------- +// CBTKeySettingList::SizeChanged +//----------------------------------------------------------------------------- +// +void CBTKeySettingList::SizeChanged() + { + if ( ListBox() ) + { + ListBox()->SetRect(Rect()); + } + } + +//----------------------------------------------------------------------------- +// CBTKeySettingList::EditCurrentItemL +//----------------------------------------------------------------------------- +// +void CBTKeySettingList::EditCurrentItemL( TInt aCommand ) + { + if ( ListBox() ) + { + TInt index = ListBox()->CurrentItemIndex(); + EditItemL(index, EBTKeyCmdAppChange == aCommand); + StoreSettingsL(); + } + } +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +PRJ_MMPFILES + +bthidserver.mmp + +PRJ_PLATFORMS +WINSCW ARMV5 diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/group/bthidserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/group/bthidserver.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2008 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 "../../inc/hiduids.h" + +TARGET bthidserver.exe +TARGETTYPE exe +UID 0x1000008d 0x2001E301 + +CAPABILITY CAP_APPLICATION +VENDORID VID_DEFAULT //=0x101FB657 + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../common/inc +USERINCLUDE ../../bthidclient/inc +USERINCLUDE ../../mouse/Sesame_client/inc +USERINCLUDE ../../bthidkbdsettings/inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc + +SOURCEPATH ../../common/src +SOURCE genericserver.cpp +SOURCE timeouttimer.cpp +SOURCE genericclient.cpp + +SOURCEPATH ../src +SOURCE socketinitiator.cpp +SOURCE hidsdpclient.cpp +SOURCE bthidsession.cpp +SOURCE bthidserver.cpp +SOURCE bthiddevice.cpp +SOURCE socketlistener.cpp +SOURCE socketreader.cpp +SOURCE socketwriter.cpp +SOURCE bthidconnection.cpp +SOURCE descriptorlistparser.cpp +SOURCE hiddescriptor.cpp +SOURCE hiddescriptorlist.cpp +SOURCE datasegmenter.cpp +SOURCE genericactive.cpp + + +LIBRARY ecom.lib +LIBRARY euser.lib //All +LIBRARY esock.lib //?? +LIBRARY bluetooth.lib //All -Tcb +//LIBRARY btmanclient.lib //All -Tcb +LIBRARY estor.lib +LIBRARY efsrv.lib +LIBRARY sdpagent.lib //All -Tcb +LIBRARY sdpdatabase.lib //All -Tcb +LIBRARY btdevice.lib //All -Tcb +LIBRARY sysutil.lib //?? +LIBRARY generichid.lib //CAP_GENERAL_DLL -AllFiles +//LIBRARY hal.lib //ALL +LIBRARY flogger.lib //?? +LIBRARY kbdclient.lib +LIBRARY bthidsettings.lib + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __BTCONNECTIONOBSERVER_H__ +#define __BTCONNECTIONOBSERVER_H__ + +/*! + This class specifies the connection observer interface + Used in conjunction with CBTHidConnection class + */ + +class MBTConnectionObserver + { +public: + + /*! + Reports control data received from the HID device + @param aConnID connection id + @param aBuffer the data buffer + */ + virtual void HandleControlData(TInt aConnID, const TDesC8& aBuffer) = 0; + + /*! + Reports completion of a Set/Get command to the HID device for commands that + do not have a data response + @param aConnID connection id + @param aStatus command ack status code. + */ + virtual void HandleCommandAck(TInt aConnID, TInt aStatus) = 0; + + /*! + Reports interrupt data received from the HID device + @param aConnID connection id + @param aBuffer the data buffer + */ + virtual void HandleInterruptData(TInt aConnID, const TDesC8& aBuffer) = 0; + + /*! + Report a change in the connection status + @param aConnID connection id + @param aStatus KErrNone, or system error code. + */ + virtual void FirstTimeConnectionComplete(TInt aConnID, TInt aStatus) = 0; + + /*! + Reports that a connection has entered the link loss state + @param aConnID connection id + */ + virtual void LinkLost(TInt aConnID) = 0; + + /*! + Reports that a connection has been re-established + @param aConnID connection id + */ + virtual void LinkRestored(TInt aConnID) = 0; + + /*! + Reports that the Bluetooth Link has been intentionally disconnected + @param aConnID connection id + */ + virtual void Disconnected(TInt aConnID) = 0; + + /*! + Reports that a connection has been unplugged + @param aConnID connection id + */ + virtual void Unplugged(TInt aConnID) = 0; + }; + +#endif // __BTCONNECTIONOBSERVER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/bthidconnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidconnection.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,435 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __BTCONNECTION_H__ +#define __BTCONNECTION_H__ + +#include +#include +#include "socketobserver.h" +#include "sockinitnotifier.h" +#include "timeoutnotifier.h" + +const TUint KCommandBufferSize = 2; + +enum + { + EControlSocketID, EInterruptSocketID + }; + +const TUint KL2CAPDefaultMTU = 672; + +/*! 5 Minute -10 sec Inactivity Timeout (-10 sec due to Nokia Su8W*/ +const TUint KInactivityTimeout = (5 * 60 * 1000000) - 10000000; + +class CSocketReader; +class CSocketWriter; +class CSocketInitiator; +class CDataSegmenter; +class CTimeOutTimer; +class CBTHidDevice; +class MBTConnectionObserver; + +/*! + Tracks the current state of the connection + */ +enum TBTConnectionState + { + ENotConnected, /*!< No connection has been established. */ + EFirstConnection, /*!< A first-time connection is in progress. */ + ELinkLost, /*!< The connection is in link loss. */ + EConnected, /*!< The connection is active */ + EHostReconnecting, /*!< Host is reconnecting to the device */ + EHIDReconnecting, /*!< The device is reconnection to the host */ + EDisconnecting, /*!< The connection is being closed */ + EConnecting + }; + +/*! + This class represents a single connection to a bluetooth HID device. + It creates instances of separate active objects to perform reading from, + and writing to, the sockets. + */ +class CBTHidConnection : public CObject, + public MSocketObserver, + public MSockInitNotifier, + public MTimeOutNotifier + { +public: + /*! + Create a CBTHidConnection object. + @param aSocketServ The socket server session. + @param aObserver An observer of this object. + @result A pointer to the created instance of CBTHidConnection. + */ + static CBTHidConnection* NewL(RSocketServ& aSocketServ, + MBTConnectionObserver& aObserver, + TBTConnectionState aConnectionState); + + /*! + Create a CBTHidConnection object. + @param aSocketServ The socket server session. + @param aObserver An observer of this object. + @result A pointer to the created instance of CBTHidConnection. + */ + static CBTHidConnection* NewLC(RSocketServ& aSocketServ, + MBTConnectionObserver& aObserver, + TBTConnectionState aConnectionState); + + /*! + Destroy the object and release all memory objects. + */ + ~CBTHidConnection(); + + /*! + Gets the id for this connection. + @return A connection ID. + */ + TInt ConnID(); + + /*! + Sets the id for this connection. + @param aConnID The new id for this connection. + */ + void SetConnID(TInt aConnID); + + /*! + Starts a first time connection to the HID device. + */ + void ConnectL(); + + /*! + The connection should restart. either by connecting to the device or waiting + for a connection. + */ + void ReconnectL(); + + /*! + Perform a deliberate disconnection from the device. + Includes sending the Virtual-Cable-Unplug message if needed. + */ + void Disconnect(); + + /*! + Drops the Bluetooth connection to a device + */ + void DropConnection(); + + /*! + Starts the reading process on the sockets. + */ + void StartMonitoringChannelsL(); + + /*! + Get access to the connections device details object. + @result A reference to a device details object. + */ + CBTHidDevice& DeviceDetails(); + + /*! + Current status of a connection after initial connection has been performed. + @result ETrue device is connected. + @result EFalse device is in link loss. + */ + TBool IsConnected() const; + + TBTConnectionState ConnectStatus() const; + + /*! + Asks to accept an incoming connection on the control channel. + @param aAddress address of the connecting device. + @param aSocket the socket for the connection. This will be set to NULL + if the connection accepts the socket. + */ + void OfferControlSocket(const TBTDevAddr& aAddress, RSocket*& aSocket); + + /*! + Asks to accept an incoming connection on the interrupt channel. + @param aAddress address of the connecting device. + @param aSocket the socket for the connection. This will be set to NULL + if the connection accepts the socket. + */ + void OfferInterruptSocket(const TBTDevAddr& aAddress, RSocket*& aSocket); + + /*! + Issues the Get Protocol Command over the control channel.. + */ + void GetProtocolL(); + + /*! + Issues the Set Protocol Command over the control channel. + @param aValue the protocol setting. 0 = Boot, 1 = Report. + */ + void SetProtocolL(TUint16 aValue); + + /*! + Issues the Get Report Command over the control channel. + @param aReportType the type of the report. + @param aReportID the report ID. + @param aLength the length of the report we are asking for. + */ + void GetReportL(TUint8 aReportType, TUint8 aReportID, TUint16 aLength); + + /*! + Issues the Set Report Command over the control channel. + @param aReportType the type of the report. + @param aReportID the report ID. + @param aReport the report. + */ + void SetReportL(TUint8 aReportType, TUint8 aReportID, + const TDesC8& aReport); + + /*! + Issues the DATA Out command over the Interrupt channel. This is similar to + SetReport which uses ReportType Output. Therefore you may use SetReport + to do data transfers from Host to device as well. + @param aReportID + @param aReport reference to the report buffer + */ + void DataOutL(TUint8 aReportID, const TDesC8& aReport); + + /*! + Issues the Get Idle Command over the control channel. + */ + void GetIdleL(); + + /*! + Issues the Set Idle Command over the control channel. + @param aDuration the idle duration. + */ + void SetIdleL(TUint8 aDuration); + +public: + // from MSocketObserver + + void HandleSocketError(TUint aSocketID, TBool aConnectionLost, + TInt aErrorCode); + + TBool HandleDataReceived(TUint aSocketID, const TDesC8& aBuffer); + + void HandleWriteComplete(TUint aSocketID); + +public: + // from MSockInitNotifier + + void SocketsConnected(); + + void SocketsConnFailed(TInt aStatus); + +public: + // from MTimeOutNotifier + void TimerExpired(); + +private: + /*! + Perform the first phase of two phase construction. + @param aSocketServ the socket server session. + @param aObserver an observer of this object. + */ + CBTHidConnection(RSocketServ& aSocketServ, + MBTConnectionObserver& aObserver, + TBTConnectionState aConnectionState); + + /*! + Perform the second phase construction of a CBTHidConnection object. + */ + void ConstructL(); + + /*! + The BT HID Transaction Header based upon Bluetooth HID Spec Sec. 7.3 + */ + enum TBTTransaction + { + // Handshake commands + EHandshakeSuccess = 0, + EHandshakeNotReady = 1, + EHandshakeInvalidRepID = 2, + EHandshakeUnsupported = 3, + EHandshakeInvalidParam = 4, + EHandshakeUnknown = 14, + EHandshakeFatal = 15, + // Control Commands + EHIDControlNOP = 16, + EHIDControlHardReset = 17, + EHIDControlSoftReset = 18, + EHIDControlSuspend = 19, + EHIDControlExitSuspend = 20, + EHIDControlVCUnplug = 21, + // Get Report Commands + EGetReportFullBufReserved = 64, + // Set Report Commands + ESetReportReserved = 80, + // Get/Set Protocol Commands + EGetProtocol = 96, + ESetProtocol = 112, + // Get/Set Idle Commands + EGetIdle = 128, + ESetIdle = 144, + // DATA Commands + EDATAOther = 160, + EDATAInput = 161, + EDATAOutput = 162, + EDATAFeature = 163, + // DATC Commands + EDATCOther = 176, + EDATCInput = 177, + EDATCOutput = 178, + EDATCFeature = 179 + }; + + /** + * Prepare the newly-connected sockets for reading and writing. + */ + void PrepareSocketsL(); + + /*! + Perform a change in the connection status + @param aNewStatus new connection status + */ + void ChangeState(TBTConnectionState aNewStatus); + + /*! + Handle the situation when the link to a device is lost. + */ + void ConnectionLost(); + + /*! + The HID device has sent the virtual cable unplug command. + */ + void ReceivedVirtualCableUnplug(); + + /*! + Checks to see if the connections is in a state able to service a set/get + command. + */ + void LeaveIfCommandNotReadyL() const; + + /*! + Closes the L2CAP Control and Interrupt channels + */ + void CloseChannels(); + + /*! + Handle data received on the control channel. + @param aBuffer the data buffer. + @result ETrue to continue reading. + @result EFalse to stop reading. + */ + TBool ProcessControlData(const TDesC8& aBuffer); + + /*! + Append as much data to a buffer as can be handled. + @param aDest the destination buffer. + @param aSource the source buffer. + */ + void AppendData(TDes8& aDest, const TDesC8& aSource); + + /*! + Handle data received on the interrupt channel. + @param aBuffer the data buffer. + @result ETrue to continue reading. + @result EFalse to stop reading. + */ + TBool ProcessInterruptData(const TDesC8& aBuffer); + + void HandleEDATCFeature(const TDesC8& aBuffer); + + /*! + Begin handling a new multiple interrupt packet transaction + @param aBuffer the data buffer + */ + void StartSegmentedInterruptDataL(const TDesC8& aBuffer); + + /*! + Handle a Continuation data packet on the interrupt channel + @param aBuffer the data buffer + @param aFinalSegment ETrue if this is the final segment, EFalse otherwise + */ + void ContinueSegmentedInterruptData(const TDesC8& aBuffer, + TBool aFinalSegment); + +private: + + /*! The socket server */ + RSocketServ& iSocketServ; + + /*! An observer for status reporting */ + MBTConnectionObserver& iObserver; + + /*! The ID given to this connection */ + TInt iConnID; + + /*! The HID device details */ + CBTHidDevice* iDevice; + + /*! Current connection status */ + TBTConnectionState iConnectionState; + + /*! Control channel socket */ + RSocket* iControlSocket; + + /*! Interrupt channel socket */ + RSocket* iInterruptSocket; + + /*! Active object to control connecting sockets */ + CSocketInitiator* iSocketInitiator; + + /*! Active object to control reads from the socket */ + CSocketReader* iControlSocketReader; + + /*! Active object to control writes to the socket */ + CSocketWriter* iControlSocketWriter; + + /*! Active object to control reads from the socket */ + CSocketReader* iInterruptSocketReader; + + /*! Active object to control writes to the socket */ + CSocketWriter* iInterruptSocketWriter; + + /*! Set/Get command is outstanding with the device */ + TBool iCommandIssued; + + /*! Fixed buffer used for all Set/Get commands except SetReport*/ + TBuf8 iCommandBuffer; + + /*! Utility object to provide individual packets for large data */ + CDataSegmenter* iCommandSegmenter; + + /*! Dynamic buffer used for control data larger than the incoming MTU */ + HBufC8* iControlDataBuffer; + + /*! Dynamic buffer used for interrupt data larger than the incoming MTU */ + HBufC8* iInterruptDataBuffer; + + /*! Size of data host can send in a packet on the control channel*/ + TInt iControlOutMTU; + + /*! Size of data the device sends in a packet on the control channel*/ + TInt iControlInMTU; + + /*! Size of data host can send in a packet on the interrupt channel*/ + TInt iInterruptOutMTU; + + /*! Size of data the device sends in a packet on the interrupt channel*/ + TInt iInterruptInMTU; + + /*! A timer to track inactivity on the Bluetooth Connection */ + CTimeOutTimer* iInactivityTimer; + }; + +#endif // __BTCONNECTION_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/bthiddevice.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/bthiddevice.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __BTHIDDEVICE_H__ +#define __BTHIDDEVICE_H__ + +#include +#include +#include + +class CHidDescriptorList; + +/*! + A bluetooth hid device.details + */ + +class CBTHidDevice : public CBase + { +public: + /*! + Create a CBTHidDevice object using two phase construction, + and return a pointer to the created object + @result Pointer to created CBTHidDevice object + */ + static CBTHidDevice* NewL(); + + /*! + Create a CBTHidDevice object using two phase construction, + and return a pointer to the created object, leaving a pointer to the + object on the cleanup stack. + @result Pointer to created CBTHidDevice object. + */ + static CBTHidDevice* NewLC(); + + /*! + Destroy the object and release all memory objects. + */ + ~CBTHidDevice(); + + /*! + Determine the number of bytes this object will take up when + externalised to disk + @return The size required to externalise. + */ + TInt DiskSize() const; + + /*! + Externalize data from a stream. + @param aStream stream object. + */ + void ExternalizeL(RWriteStream& aStream) const; + + /*! + Internalize data to a stream. + @param aStream stream object . + */ + void InternalizeL(RReadStream& aStream); + +private: + /*! + Constructs this object. + */ + CBTHidDevice(); + + /*! + Performs second phase construction of this object + */ + void ConstructL(); + +public: + /*! Bluetooth Address */ + TBTDevAddr iAddress; + + /*! Bluetooth Name */ + TBTDeviceName iDeviceName; + + /*! Bluetooth Class of Device (Cod) */ + TBTDeviceClass iDeviceClass; + + /*! Use security on connection */ + TBool iUseSecurity; + + // HID Service Attributes + + /*! Vendor assigned device release number */ + TUint iDeviceReleaseNumber; + + /*! Device SubClass */ + TUint iDeviceSubClass; + + /*! Device Country Code */ + TUint iCountryCode; + + /*! Indicated if the device supports the virtual cable feature */ + TBool iVirtuallyCabled; + + /*! Device initiates reconnection process */ + TBool iReconnectInit; + + /*! The device BT HID Descriptor List */ + CHidDescriptorList* iDescList; + + /*! Device remains connectable */ + TBool iNormallyConnectable; + + /*! Device Profile Version */ + TUint iProfileVersion; + + //Bluetooth PNP Device Identification + + /*! Vendor ID */ + TUint iVendorID; + + /*! Product ID */ + TUint iProductID; + + }; + +#endif // __BTHIDDEVICE_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/bthidserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,403 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __BTHIDSERVER_H__ +#define __BTHIDSERVER_H__ + +#include +#include +#include +#include +#include +#include +#include +#include //linkkey +#include + + +#include "hidinterfaces.h" +#include "bthidclient.h" +#include "btconnectionobserver.h" +#include "listenerobserver.h" +#include "genericserver.h" +#include "hidlayoutids.h" +#include "genericactive.h" + +class CBTConnection; +class CSocketListener; +class CBTHidConnection; +class CBTHidDevice; +class CGenericHid; +class CBTHidNotifierHelper; + +/** + * An instance of class CBTHidServer is the main server class. + * + * @since Series 60 2.6 + */ +class CBTHidServer : public CGenericServer, + public MBTConnectionObserver, + public MListenerObserver, + public MTransportLayer + { +public: + + /*! + Create a CBTHidServer object using two phase construction, + and return a pointer to the created object + @result Pointer to created CBTHidServer object + */ + static CBTHidServer* NewL(); + + /*! + Create a CBTHidServer object using two phase construction, + and return a pointer to the created object, leaving a pointer to the + object on the cleanup stack. + @result Pointer to created CBTHidServer object. + */ + static CBTHidServer* NewLC(); + + /*! + Destroy the object and release all memory objects. + */ + ~CBTHidServer(); + + /*! + Panic the client. + @param aMessage the message channel to the client + @param aReason the reason code for the panic. + */ + static void PanicClient(const RMessage2& aMessage, TInt aReason); + + void StartShutdownTimerIfNoSession(); + + void CancelShutdownTimer(); + + /*! + Increments the count of the active sessions for this server. + */ + void IncrementSessions(); + + /*! + Decrements the count of the active sessions for this server. . + If no more sessions are in use the server terminates. + */ + void DecrementSessions(); + + /*! + Returns a count of the BT HID connections the server is managing. + @result Number of connections + */ + TUint ConnectionCount(); + + /*! + Gives access to the device details for a numbered connection. + @param aConnID connection ID. + @result Reference to a device details object + */ + CBTHidDevice& ConnectionDetailsL(TInt aConnID); + + void CleanOldConnection(TInt aConnID); + /*! + Asks the server to create a new connection object. + @result ID for the connection + */ + TInt NewConnectionL(); + + /*! + Asks the server to do a first-time connection to a device. + @param aConnID ID of the connection returned from NewConnectionL + */ + void DoFirstConnectionL(TInt aConnID); + + /*! + Asks the server to delete a new connection object + @param aConnID ID of the connection returned from NewConnectionL + */ + void DeleteNewConnection(TInt aConnID); + + /* + * Keep the connection alive, initial reconnect from HID device available... + */ + void DisconnectDeviceL(const TBTDevAddr& aAddress); + void DisconnectAllDeviceL(); + + /** + * Asks the server to disconnect (virtual cable unplug) a device totally, + * remove the connection entry from the connection container. + @param aAddress bluetooth address of the device to disconnect. + */ + void CloseBluetoothConnection(const TBTDevAddr& aAddress); + void CloseAllBluetoothConnection(); + + /*! + Finds out the connection status for a given Bluetooth address connected with HID profile + @param aBDAddr reference to TBTAddr that is checked from Bluetooth registry + @result TBTEngConnectionStatus + */ + TBTEngConnectionStatus ConnectStatus(const TBTDevAddr& aAddress); + + /*! + Panic the server. + @param aPanic panic code + */ + static void PanicServer(TInt aPanic); + + TBool GetConnectionAddress(TDes8& aAddressBuf); + + TBool IsAllowToConnectFromServerSide(TUint aDeviceSubClass); + TBool IsAllowToConnectFromClientSide(TBTDevAddr devAddr); + TUint GetDeviceSubClass(TBTDevAddr aDevAddr); + TBool IsKeyboard(TUint aDeviceSubClass); + TBool IsPointer(TUint aDeviceSubClass); + + TBTDevAddr ConflictAddress(); + +public: + // from MBTConnectionObserver + void HandleControlData(TInt aConnID, const TDesC8& aBuffer); + + void HandleCommandAck(TInt aConnID, TInt aStatus); + + void HandleInterruptData(TInt aConnID, const TDesC8& aBuffer); + + void FirstTimeConnectionComplete(TInt aConnID, TInt aStatus); + + void LinkLost(TInt aConnID); + + void LinkRestored(TInt aConnID); + + void Disconnected(TInt aConnID); + + void Unplugged(TInt aConnID); + +public: + //from MListenerObserver + void SocketAccepted(TUint aPort, TInt aErrorCode); + +public: + //from MTransportLayer + TUint CountryCodeL(TInt aConnID); + + TUint VendorIdL(TInt aConnID); + + TUint ProductIdL(TInt aConnID); + + void GetProtocolL(TInt aConnID, TUint16 aInterface); + + void SetProtocolL(TInt aConnID, TUint16 aValue, TUint16 aInterface); + + void GetReportL(TInt aConnID, TUint8 aReportType, TUint8 aReportID, + TUint16 aInterface, TUint16 aLength); + + void SetReportL(TInt aConnID, TUint8 aReportType, TUint8 aReportID, + TUint16 aInterface, const TDesC8& aReport); + + void DataOutL(TInt aConnID, TUint8 aReportID, TUint16 aInterface, + const TDesC8& aReport); + + void GetIdleL(TInt aConnID, TUint8 aReportID, TUint16 aInterface); + + void SetIdleL(TInt aConnID, TUint8 aDuration, TUint8 aReportID, + TUint16 aInterface); + + void NotifierRequestCompleted(); + +protected: + // From CActive + /*! + Process any errors + @param aError the leave code reported. + */ + TInt RunError(TInt aError); + static TInt TimerFired(TAny* aThis); + +private: + + /*! + Perform the first phase of two phase construction + */ + CBTHidServer(); + + /*! + Perform the second phase construction of a CBTHidServer object + */ + void ConstructL(); + + /*! + Shuts down socket listeners on error and inform user + @param aError The error which caused the shutdown. + */ + void ShutdownListeners(TInt aError); + + /*! + Retrieve the Connection object for a given ID. + @param aConnID The connection ID. + @return A pointer to a CBTHidConnection object. + */ + CBTHidConnection* IdentifyConnectionL(TInt aConnID) const; + + /*! + Loads virtually-cabled device details from the filestore. + @param aStoreName file to load from. + */ + void LoadVirtuallyCabledDevicesL(const TDesC& aStoreName); + + /*! + Stores virtually-cabled device details from the filestore. + @param aStoreName file to write to. + */ + void StoreVirtuallyCabledDevicesL(const TDesC& aStoreName); + + /*! + Stores virtually-cabled device details from the filestore. + (Non-Leaving Version) + @param aStoreName file to write to. + */ + void StoreVirtuallyCabledDevices(const TDesC& aStoreName); + + /*! + Updates all current sessions with the current status of a connection + @param aDeviceDetails details of the device whose status has changed + @param aState new state of the connection + */ + void InformClientsOfStatusChange(const CBTHidDevice& aDeviceDetails, + TBTHidConnState aState); + + void GlobalNotify(const TBTDevAddr& aDeviceAddr, TBTHidConnState aState); + + TInt HandleAsyncRequest(const TBTDevAddr& aDeviceAddr, TInt note); + + void HandleAsyncRequestL(const TBTDevAddr& aDeviceAddr, TInt aNote); + + void InformStatusChange(const TBTDevAddr& aAddress, + TBTHidConnState aState); + /*! + Inform the Generic HID of a new connection (and start the driver if required) + @param aConnection a CBTHidConnection object for the device connected. + @param aStartDriver ETrue to start the driver, EFalse otherwise. + */ + void + GenericHIDConnectL(CBTHidConnection* aConnection, + TBool aStartDriver); + +private: + // From CServer2 + + /*! + Create a time server session, and return a pointer to the created object + @param aVersion version + @result Pointer to new session + */ + CSession2* NewSessionL(const TVersion &aVersion, + const RMessage2& aMessage) const; + +private: + /* Internal function to override the security settings of Control channel + * listener. Used if we are listening for unauthenticated/unauthorised device. + * For example: Microsoft keyboard with Nokia 6630 PR#1 needs this. + */ + void CheckAndSetControlListenerSecurityL(TBool aSec); + + /*! The active session count */ + TInt iSessionCount; + + /*! The file server session */ + RFs iFs; + + /*! The socket server session */ + RSocketServ iSocketServ; + + /*! A temporary socket to accept a connection on the control channel */ + RSocket* iTempControl; + + /*! A temporary socket to accept a connection on the interrupt channel */ + RSocket* iTempInterrupt; + + /*! Flag indicating the Autorisation setting on incoming connections */ + TBool iAuthorisationFlag; + + /*! Socket listener for the control channel */ + CSocketListener* iControlListener; + + /*! Socket listener for the interrupt channel */ + CSocketListener* iInterruptListener; + + /*! The Generic HID object */ + CGenericHid* iGenHID; + + /*! Main container index for the server */ + CObjectConIx* iMasterContIndex; + + /*! Container for BT Connection Objects */ + CObjectCon* iBTConnContainer; + + /*! Index for the BT Connection container */ + CObjectIx* iBTConnIndex; + + /*! BT address of a Bluetooth device currently connected in conflict*/ + TBTDevAddr iConflictAddr; + + /*! BT address of a Bluetooth device last used */ + TBTDevAddr iLastUsedAddr; + TBool iActiveState; + + //Shutdown Timer + CPeriodic* iShutDownTimer; + + RNotifier iNotifier; + + RPointerArray iReqs; + + }; + + +/** + * This wraps up a UI Notification for the BTHidServer + */ + +class CBTHidNotifierHelper : public CActive + { +public: + + static CBTHidNotifierHelper* NewL(CBTHidServer& aHidServer, TInt aNote, const TBTDevAddr& aDeviceAddr); + + ~CBTHidNotifierHelper(); + + void Start(); + +private: + + CBTHidNotifierHelper(CBTHidServer& aHidServer, TInt aNote, const TBTDevAddr& aDeviceAddr); + + void ConstructL(); + void RunL(); + void DoCancel(); + +private: + + CBTHidServer& iHidServer; + + RNotifier iNotifier; + + TPckgBuf iNoResult; + + TBTGenericInfoNotiferParamsPckg iGenericInfoNotifierType; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/bthidserver.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidserver.pan Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2004-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: BT HID Server Panic codes + * +*/ + +#ifndef __BTHIDSERVER_PAN__ +#define __BTHIDSERVER_PAN__ + +//Panic Category +_LIT(KBTHIDServer, "BTHIDServer"); + +/*! Server panic codes */ +enum TBTHIDServPanic + { + EBadRequest = 1, + EBadDescriptor = 2, + ESrvCreateServer = 3, + EMainSchedulerError = 4, + ECreateTrapCleanup = 5, + ESrvSessCreateTimer = 6, + EReqAlreadyPending = 7, + EInvalidHandle = 8, + EBadState = 9, + ENotifierAlreadyActive = 10, + }; + +#endif // __BTHIDSERVER_PAN__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/bthidsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidsession.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __BTHIDSESSION_H__ +#define __BTHIDSESSION_H__ + +#include +#include "hidsdpobserver.h" +#include "bthidclient.h" + +class CBTHidServer; +class CHidSdpClient; + +/*! + An instance of class CBTHidServerSession is created for each client + */ +class CBTHidServerSession : public CSession2, public MHidSdpObserver + { + +public: + + /*! + Create a CBTHidServerSession object using two phase construction, + and return a pointer to the created object. + @param aClient client's thread. + @param aServer the server. + @result Pointer to new session. + */ + static CBTHidServerSession* NewL(CBTHidServer& aServer); + + /*! + Create a CBTHidServerSession object using two phase construction, + and return a pointer to the created object + (leaving a pointer to the object on the cleanup stack) + @param aClient client's thread + @param aServer the server + @result Pointer to new session + */ + static CBTHidServerSession* NewLC(CBTHidServer& aServer); + + /*! + Destroy the object and release all memory objects + */ + ~CBTHidServerSession(); + + /*! + Updates the client of this session with the new status of a + connection, if it has an outstanding update request. + @param aUpdateParams details of the bluetooth device that has changed. + */ + void InformStatusChange(const THIDStateUpdateBuf& aUpdateParams); + /*! + Informs the session of the result of a first-time connection. + @param aConnID id given to the connection when it was created + @param aResult result of the connection attempt + */ + void InformConnectionResult(TInt aConnID, TInt aResult); + +public: + // from CSession + /*! + Service request from client + @param aMessage client message (containing requested operation and any data) + */ + void ServiceL(const RMessage2& aMessage); + +public: + // from MHidSdpObserver + + void HidSdpSearchComplete(TInt aResult); + +private: + + /*! + Perform the first phase of two phase construction + @param aClient client's thread + */ + CBTHidServerSession(CBTHidServer& aServer); + + /*! + Perform the second phase construction of a CBTHidServerSession object + */ + void ConstructL(); + + void DispatchMessageL(const RMessage2& aMessage); + + /*! + Handle the connection message. + @param aMessage message for request + */ + void RequestConnectionL(const RMessage2& aMessage); + + /*! + Handle the disconnection message. + @param aMessage message for request + */ + void RequestDisconnectionL(const RMessage2& aMessage); + + void IsConnectedL(const RMessage2& aMessage); + + void GetConnections(const RMessage2& aMessage); + +private: + // Member variables + + /*! The hid server */ + CBTHidServer& iServer; + + /*! ID of the connection being established */ + TInt iConnectingID; + + /*! A hid sdp client */ + CHidSdpClient* iHidSdpClient; + + TBool iSearchingSDP; + + /*! An outstanding connect message */ + RMessage2 iConnectionMessage; + + RMessagePtr2 iDisconnectMsg; + + /*! Session has an outstanding update message */ + RMessage2 iUpdateMessage; + + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/bthidtypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidtypes.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __BTHIDTYPES_H__ +#define __BTHIDTYPES_H__ + +#include +#include + +// HID Profile Service +const TInt KHidPServiceUUID = 0x0011; +// Plug and Play Information +const TInt KPnPServiceUUID = 0x1200; + +// Values for the attributes for the HID P Service +const TSdpAttributeID KHIDAttrDevRelNum = 0x0200; +const TSdpAttributeID KHIDAttrDevSubClass = 0x0202; +const TSdpAttributeID KHIDAttrCountryCode = 0x0203; +const TSdpAttributeID KHIDAttrVirtuallyCabled = 0x0204; +const TSdpAttributeID KHIDAttrReconnectInitiate = 0x0205; +const TSdpAttributeID KHIDAttrDescriptorList = 0x0206; +const TSdpAttributeID KHIDAttrProfileVersion = 0x020b; +const TSdpAttributeID KHIDAttrNormallyConnectable = 0x020d; + +// Values for the attributes for the PNP Service +const TSdpAttributeID KPnPAttrVendorID = 0x0201; +const TSdpAttributeID KPnPAttrProductID = 0x0202; + +const TInt KL2CAPHidControl = 0x0011; +const TInt KL2CAPHidInterrupt = 0x0013; + +#endif // __BTHIDTYPES_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/datasegmenter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/datasegmenter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __CMDSEGMENTER_H__ +#define __CMDSEGMENTER_H__ + +#include + +/*! + This utility class segments large commands into MTU size packets + */ +class CDataSegmenter : public CBase + { +public: + + /*! + Create a CDataSegmenter object + @result a pointer to the created instance of CDataSegmenter + */ + static CDataSegmenter* NewL(); + + /*! + Create a CDataSegmenter object + @result a pointer to the created instance of CDataSegmenter + */ + static CDataSegmenter* NewLC(); + + /*! + Destroy the object and release all memory objects + */ + ~CDataSegmenter(); + + /*! + Prepares buffers for sending a large command, possibly in separate packets. + @param aInitialHeader the header to use in the first packet. + @param aPayload the payload section of the packet. + @param aAdditionalHeader the header byte to use on continuation packets. + @param aMTU the current MTU for a packet. + */ + void SegmentDataL(const TDesC8& aInitialHeader, const TDesC8& aPayload, + TChar aAdditionalHeaderByte, TInt aMTU); + + /*! + Retrieves the first packet in a sequence. + Function will leave if there is no data packet to return. + @result a pointer to the data packet + */ + const HBufC8* FirstPacketL() const; + + /*! + Retrieves the next packet in a sequence. + @result a pointer to the data packet + @result 0 if there are no more packets + */ + const HBufC8* NextPacket(); + + /*! + Resets the state of the object + */ + void Reset(); + +private: + + /*! + Constructs this object + */ + CDataSegmenter(); + + /*! + Performs second phase construction of this object + */ + void ConstructL(); + +private: + /*! Dynamic buffer to hold a command packet */ + HBufC8* iPacket; + + /*! Dynamic buffer used to hold payload not sent in first packet */ + HBufC8* iPayloadBuf; + + /*! Pointer to the current remaining payload */ + TPtrC8 iPayloadBufPtr; + + /*! The current maximum size of a packet */ + TInt iMTU; + + /*! The header byte to use on continuation packets */ + TChar iAdditionalHeaderByte; + }; + +#endif // __CMDSEGMENTER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/descriptorlistparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/descriptorlistparser.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __CDESCRIPTORLISTPARSER_H__ +#define __CDESCRIPTORLISTPARSER_H__ + +#include +#include + +class CHidDescriptor; +class CHidDescriptorList; + +/*! + This class parses a HID Descriptor List DES, extracting its HID Descriptors. + BT HID Spec. 1.0 Sec. 7.11.6 + */ +class CDescriptorListParser : public CBase, public MSdpAttributeValueVisitor + { +public: + + /*! + Constructs this object + @param aDescriptorList the descriptor list to populate + */ + CDescriptorListParser(CHidDescriptorList& aDescriptorList); + + /*! + Destroy the object and release all memory objects + */ + ~CDescriptorListParser(); + +public: + // from MSdpAttributeValueVisitor + /*! + Handle attribute value. + @param aValue Attribute value + @param aType Attribute type + */ + void VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType); + + /*! + Indicates that a new Data Element Sequence (DES) has started. + @param aList Attribute value list + */ + void StartListL(CSdpAttrValueList& aList); + + /*! + Indicates that a Data Element Sequence (DES) has ended. + */ + void EndListL(); + +private: + // Member variables + + /*! The current indentation when parsing Data Element Sequences */ + TInt iIndentationLevel; + + /*! The descriptor list to populate */ + CHidDescriptorList& iDescriptorList; + + /*! The descriptor currently being created */ + CHidDescriptor* iCurrentDescriptor; + }; + +#endif // __CDESCRIPTORLISTPARSER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/genericactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/genericactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,161 @@ +/* +* Copyright (c) 2008 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: An Active Object offering its request status for any + * asynchronous request handling. + * +*/ + + +#ifndef C_GENERICACTIVE_H +#define C_GENERICACTIVE_H + +// INCLUDES +#include + +class CGenericActive; + +/** + * The observer of CGenericActive's request events + * + * This class defines the interface to handle request events from CGenericActive. + * + * @since S60 v3.1 + */ +class MGenericActiveObserver + { + +public: + + /** + * Called by CGenericActive::RunL() to handle the request completion event. + * + * @since S60 v5.0 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CGenericActive& aActive) = 0; + + /** + * alled by CGenericActive::RunL() to handle the cancellation of an outstanding request. + * + * @since S60 v5.0 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CGenericActive& aActive) = 0; + + /** + * Callback to notify that an error has occurred in RunL. + * + * @since S60 v5.0 + * @param ?arg1 ?description + */ + virtual void HandleError(TInt aId, TInt aError) = 0; + }; + +/** + * + * CGenericActive provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CGenericActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CGenericActive : public CActive + { + +public: + + static CGenericActive* New(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + static CGenericActive* NewL(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + virtual ~CGenericActive(); + +public: + + /** + * Calls SetActive(). + * + * @since S60 v3.1 + */ + virtual void GoActive(); + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @return the request identifier + */ + TInt RequestId() const; + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @param the request identifier + */ + void SetRequestId(TInt aRequestId); + + TRequestStatus& RequestStatus(); + +protected: + + /** + * From CActive. + * cancels the outstanding request. + * + * @since S60 v3.1 + */ + virtual void DoCancel(); + + /** + * From CActive. + * Handles the request completion event. + * + * @since S60 v3.1 + */ + virtual void RunL(); + + /** + * From CActive. + * Handles the leave from RunL(). + * + * @since S60 v3.1 + * @param aError the leave code in RunL() + * @return the error code to Active Scheduler + */ + virtual TInt RunError(TInt aError); + +protected: + + CGenericActive(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + +private: + + /** + * The observer which is interested in the request handling events. + * Not own. + */ + MGenericActiveObserver& iObserver; + + /** + * The request identifier assigned to this active object. + */ + TInt iRequestId; + + }; + +#endif // C_GENERICACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/hiddescriptor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/hiddescriptor.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __HIDDESCRIPTOR_H__ +#define __HIDDESCRIPTOR_H__ + +#include +#include + +/*! + This class represents an individual BT HID Descriptor + */ +class CHidDescriptor : public CBase + { +public: + /*! The type of this HID descriptor */ + enum TDescType + { + EReportDescriptor = 0x22, /*!< Report Descriptor */ + EPhysicalDescriptor = 0x23, + /*!< Physical Descriptor */ + }; +public: + + /*! + Create a CHidDescriptor object + @result a pointer to the created instance of CHidDescriptor + */ + static CHidDescriptor* NewL(); + + /*! + Create a CHidDescriptor object + (object is left on the cleanup stack) + @result a pointer to the created instance of CHidDescriptor + */ + static CHidDescriptor* NewLC(); + + /*! + Create a CHidDescriptor object from a stream. + @param aStream a stream to create the object from + @result a pointer to the created instance of CHidDescriptor + */ + static CHidDescriptor* NewL(RReadStream& aStream); + + /*! + Create a CHidDescriptor object from a stream. + (object is left on the cleanup stack) + @param aStream a stream to create the object from + @result a pointer to the created instance of CHidDescriptor + */ + static CHidDescriptor* NewLC(RReadStream& aStream); + + /*! + Destroy the object and release all memory objects + */ + ~CHidDescriptor(); + + /*! + Sets the type of this HID descriptor + @param aType The type of this descriptor. + */ + inline void SetDescriptorType(TDescType aType); + + /*! + Sets the contents of the member buffer + @param aBuf new buffer to copy. + */ + inline void SetRawDataL(const TDesC8& aBuf); + + /*! + Gets the type of this HID descriptor + @return The type of this descriptor. + */ + inline TDescType DescriptorType() const; + + /*! + Gets the contents of the member buffer + @return A TDesC8 reference to the member data buffer + */ + inline const TDesC8& RawData() const; + + /*! + Determine the number of bytes this object will take up when + externalised to disk + @return The size required to externalise. + */ + TInt DiskSize() const; + + /*! + Externalize data to a stream + @param aStream stream object + */ + void ExternalizeL(RWriteStream& aStream) const; + +private: + + /*! + Constructs this object + */ + CHidDescriptor(); + + /*! + Performs second phase construction of this object + */ + void ConstructL(); + + /*! + Performs second phase construction of this object from a filestore + @param aStream a stream to create the object from + */ + void ConstructL(RReadStream& aStream); + +private: + // Member variables + /*! The type of this descriptor */ + TDescType iType; + + /*! The raw descriptor */ + HBufC8* iRawData; + }; + +inline void CHidDescriptor::SetDescriptorType(TDescType aType) + { + iType = aType; + } + +inline void CHidDescriptor::SetRawDataL(const TDesC8& aText) + { + // Copy the buffer + delete iRawData; + iRawData = 0; + iRawData = aText.AllocL(); + } + +inline CHidDescriptor::TDescType CHidDescriptor::DescriptorType() const + { + return iType; + } + +inline const TDesC8& CHidDescriptor::RawData() const + { + if (!iRawData) + { + return KNullDesC8; + } + else + { + return *iRawData; + } + } + +#endif // __HIDDESCRIPTOR_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/hiddescriptorlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/hiddescriptorlist.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __HIDDESCRIPTORLIST_H__ +#define __HIDDESCRIPTORLIST_H__ + +#include +#include + +class CHidDescriptor; + +/*! + This class contains a set of BT HID Descriptors + */ +class CHidDescriptorList : public CBase + { +public: + + /*! + Constructs this object + */ + CHidDescriptorList(); + + /*! + Destroy the object and release all memory objects + */ + ~CHidDescriptorList(); + + /*! + Get a count of the number of HID descriptors + @result The number of descriptors. + */ + TInt DescriptorCount() const; + + /*! + Get access to an individual HID descriptor by index. + @param aIndex the index of the HID descriptor + @result A HID descriptor object + */ + const CHidDescriptor& operator[](TInt aIndex) const; + + /*! + Add a new descriptor to the list + @param aDesc a HID descriptor object + */ + void AddDescriptorL(const CHidDescriptor* aDesc); + + /*! + Determine the number of bytes this object will take up when + externalised to disk + @return The size required to externalise. + */ + TInt DiskSize() const; + + /*! + Externalize data to a stream + @param aStream stream object + */ + void ExternalizeL(RWriteStream& aStream) const; + + /*! + Internalize data from a stream + @param aStream stream object + */ + void InternalizeL(RReadStream& aStream); + +private: + // Member variables + /*! A list of descriptors */ + CArrayPtrFlat* iDescriptorList; + }; + +#endif // __HIDDESCRIPTORLIST_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/hidsdpclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/hidsdpclient.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __HIDSDPCLIENT_H__ +#define __HIDSDPCLIENT_H__ + +#include +#include + +class CBTHidDevice; +class MHidSdpObserver; + +/*! + This class queries the SDP database of a HID device in order to populate an + instance of the CBTHidDevice class + */ +class CHidSdpClient : public CActive, public MSdpAgentNotifier + { +public: + + /*! + Create a CHidSdpClient object + @param aDevice device details object to populate + @param aObserver observer to report to. + @result A pointer to the created instance of CHidSdpClient + */ + static CHidSdpClient* NewL(CBTHidDevice& aDevice, + MHidSdpObserver& aObserver); + + /*! + Create a CHidSdpClient object + @param aDevice device details object to populate + @param aObserver observer to report to. + @result A pointer to the created instance of CHidSdpClient + */ + static CHidSdpClient* NewLC(CBTHidDevice& aDevice, + MHidSdpObserver& aObserver); + + /*! + Destroy the object and release all memory objects + */ + ~CHidSdpClient(); + + /*! + Start the SDP inquiry. + */ + void StartL(); + + /*! + Ask the object to destroy itself when its conventient. + */ + void Kill(); + +public: + // From CActive + void RunL() + { + delete this; + } + ; + void DoCancel() + { + } + ; + +public: + // From MSdpAgentNotifier + /*! + Called when an service record request + (CSdpAgent::NextRecordRequestComplete()) operation completes. + @param aError KErrNone, or an SDP error + @param aHandle Service record for which the query was made + @param aTotalRecordsCount Total number of matching records + */ + + void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, + TInt aTotalRecordsCount); + /*! + Called by the attribute request function + (CSdpAgent::AttributeRequestL()) to pass the results of a successful + attribute request. + @param aHandle Service record for which the query was made + @param aAttrID ID of the attribute obtained + @param aAttrValue Attribute value obtained + */ + + void AttributeRequestResult(TSdpServRecordHandle aHandle, + TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue); + + /*! + Called when an service record request + (CSdpAgent::NextRecordRequestComplete()) operation completes. + @param aHandle Service record for which the query was made + @param aError KErrNone, or an SDP error + */ + + void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError); + +private: + + /*! + Constructs this object + @param aDevice device details object to populate + @param aObserver observer to report to. + */ + CHidSdpClient(CBTHidDevice& aDevice, MHidSdpObserver& aObserver); + + /*! + Performs second phase construction of this object + */ + void ConstructL(); + + /* + Reset the object and inform the observer of the result + @param aError KErrNone if successful, or an SDP error + */ + void Finish(TInt aError); + +private: + // Member variables + /*! Current Parser State */ + enum TParserState + { + EIdle, /*!< Parser is idle */ + EHIDService, /*!< Parser is retrieving the HID Service Record */ + EBTPnPService + /*!< Parser is retrieving the PnP Service Record */ + }; + + /*! Device details object to fill from sdp query */ + CBTHidDevice& iDevice; + + /*! Observer to inform of results */ + MHidSdpObserver& iObserver; + + /*! Current state of the parser */ + TParserState iParserState; + + /*! SDP Agent used to search the SDP database */ + CSdpAgent* iAgent; + + /*! UUID pattern to filter the SDP database search */ + CSdpSearchPattern* iSdpSearchPattern; + + /*! HID Service record attribute filter */ + CSdpAttrIdMatchList* iHIDMatchList; + + /*! BT PnP Service record attribute filter */ + CSdpAttrIdMatchList* iPNPMatchList; + + /*! A bitmask of the mandatory attributes found */ + TUint iMandAttrValue; + }; + +#endif // __HIDSDPCLIENT_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/hidsdpobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/hidsdpobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __HIDSDPOBSERVER_H__ +#define __HIDSDPOBSERVER_H__ + +/*! + This class specifies the hid parser observer interface + Used in conjunction with CHidSdpClient class + */ + +class MHidSdpObserver + { +public: + + /*! + Reports that the hid device sdp query has finished. + @param aResult System error code. + */ + virtual void HidSdpSearchComplete(TInt aResult) = 0; + + }; + +#endif // __HIDSDPOBSERVER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/listenerobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/listenerobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __LISTENEROBSERVER_H__ +#define __LISTENEROBSERVER_H__ + +/*! + This class specifies the listener observer interface + Used in conjunction with CSocketListener class + */ + +class MListenerObserver + { +public: + + /*! + Informs the observer that a connection has been accepted by a listener into + the blank socket provided. + @param aPort BT L2CAP channel the listener is working on + @param aErrorCode KErrNone, or system error code + */ + virtual void SocketAccepted(TUint aPort, TInt aErrorCode) = 0; + + }; + +#endif // __LISTENEROBSERVER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/socketinitiator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/socketinitiator.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SOCKETINITIATOR_H__ +#define __SOCKETINITIATOR_H__ + +#include +#include +#include +#include "timeoutnotifier.h" + +class CTimeOutTimer; +class MSockInitNotifier; + +/*! + Controls connection of the L2CAP control and interrupt channels to a BT + HID device. Performs authorisation and encryption if required. + */ +class CSocketInitiator : public CActive, public MTimeOutNotifier + { +public: + + /*! + Create a CSocketInitiator object + @param aSocketServ the socket server session + @param aNotifier a notifier to report to. + @result A pointer to the created instance of CSocketInitiator + */ + static CSocketInitiator* NewL(RSocketServ& aSocketServ, + MSockInitNotifier& aNotifier); + + /*! + Create a CSocketInitiator object + (object is left on the cleanup stack) + @param aSocketServ the socket server session + @param aNotifier a notifier to report to. + @result A pointer to the created instance of CSocketInitiator + */ + static CSocketInitiator* NewLC(RSocketServ& aSocketServ, + MSockInitNotifier& aNotifier); + + /*! + Destroy the object and release all memory objects + */ + ~CSocketInitiator(); + + /*! + Perform a connection to a BT HID device + @param aAddress the bluetooth address of the device to connect + @param aUseSecurity whether to use security on the connection + @param aControlSocket the socket to use to connect the control channel + @param aInterruptSocket the socket to use to connect the interrupt channel + */ + void ConnectSocketsL(const TBTDevAddr& aAddress, TBool aUseSecurity, + RSocket* aControlSocket, RSocket* aInterruptSocket); + +public: + // from MTimeOutNotifier + + void TimerExpired(); + +protected: + // from CActive + + /*! + Cancel any outstanding requests + */ + void DoCancel(); + + /*! + Respond to an event + */ + void RunL(); + +private: + + /*! + Constructs this object + @param aSocketServ the socket server session + @param aNotifier a notifier to report to. + */ + CSocketInitiator(RSocketServ& aSocketServ, MSockInitNotifier& aNotifier); + + /*! + Performs second phase construction of this object + */ + void ConstructL(); + + /*! + Tracks the progress of host initiated connection + */ + enum TConnectState + { + EIdle, /*!< Initial State */ + EConnectingControl, /*!< Control channel is being connected */ + EConnectingInterrupt, /*!< Interrupt channel is being connected */ + EAuthenticateLink, /*!< Forcing authentication of the device. */ + EEncryptLink + /*!< Forcing encryption of the connection */ + }; + + /*! + Connect the L2CAP Interrupt Channel + */ + void ConnectInterruptSocket(); + +private: + /*! The maximum time allowed for connection requests to complete */ + static const TInt KTimeOut; + + /*! The socket server session */ + RSocketServ& iSocketServ; + + /*! A notifier to inform of connection results*/ + MSockInitNotifier& iNotifier; + + /*! Current connect process state */ + TConnectState iState; + + /*! Use security on the sockets */ + TBool iUseSecurity; + + /*! BT Socket address used to connect */ + TBTSockAddr iSockAddress; + + /*! Control channel socket */ + RSocket* iControlSocket; + + /*! Interrupt channel socket */ + RSocket* iInterruptSocket; + + /*! Timer active object */ + CTimeOutTimer* iTimer; + + /*! Encryption buffer to use with the encrypt IOCTL */ + THCISetEncryptionBuf iEncryptBuf; + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/socketlistener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/socketlistener.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2008 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: + * +*/ + + +#ifndef __SOCKETLISTENER_H__ +#define __SOCKETLISTENER_H__ + +#include +#include + +#include + +class MListenerObserver; + +/*! + This class listens for incoming connection attempts on a BT L2CAP channel + */ + +class CSocketListener : public CActive + { +public: + + /*! + Create a CSocketListener object + @param aSocketServ the socket server session + @param aPort port to listen on + @param aObserver an observer of this object + @result A pointer to the created instance of CSocketListener + */ + static CSocketListener* NewL(RSocketServ& aSocketServ, TUint aPort, + MListenerObserver& aObserver, TBool aAuthorisation); + + /*! + Create a CSocketListener object + @param aSocketServ the socket server session + @param aPort port to listen on + @param aObserver an observer of this object + @result A pointer to the created instance of CSocketListener + */ + static CSocketListener* NewLC(RSocketServ& aSocketServ, TUint aPort, + MListenerObserver& aObserver, TBool aAuthorisation); + + /*! + Destroy the object and release all memory objects + */ + ~CSocketListener(); + + /*! + Accept the next connection into a blank socket + @param aSocket blank socket to accept into + @return KErrNone if successful, or one of the system-wide error codes. + */ + TInt AcceptConnection(RSocket& aSocket); + +protected: + // from CActive + + /*! + Cancel any outstanding requests + */ + void DoCancel(); + + /*! + Respond to an event + */ + void RunL(); + +private: + + /*! + Perform the first phase of two phase construction + @param aSocketServ the socket server session + @param aPort port to listen on + @param aObserver an observer of this object + */ + CSocketListener(RSocketServ& aSocketServ, TUint aPort, + MListenerObserver& aObserver, TBool aAuthorisation); + + /*! + Perform the second phase of two phase construction + */ + void ConstructL(); + +private: + // Member variables + + /*! The socket server session */ + RSocketServ& iSocketServer; + + /*! Socket port to listen on */ + TUint iPort; + + /*! An observer for status reporting */ + MListenerObserver& iObserver; + + /*! Listening Socket */ + RSocket iListeningSocket; + + /*! The socket to accept into. Not owned */ + RSocket* iAcceptSocket; + + /*! Whether to use authorisation in incoming connections when constructed */ + TBool iAuthorisationAskedFlag; + + }; + +#endif // __SOCKETLISTENER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/socketobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/socketobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SOCKETOBSERVER_H__ +#define __SOCKETOBSERVER_H__ + +/*! + This class specifies the socket observer interface + Used in conjunction with CSocketReader & CSocketWriter classes + */ +class MSocketObserver + { +public: + /*! + Report a communication error. + @param aSocketID socket being observed. + @param aConnectionLost True if the error is a failure to read. + @param aErrorCode associated error code. + */ + virtual void HandleSocketError(TUint aSocketID, TBool aConnectionLost, + TInt aErrorCode) = 0; + + /*! + Data has been received on the socket and read into a buffer. + @param aSocketID socket being observed. + @param aBuffer the data buffer. + @result ETrue to continue reading. + @result EFalse to stop reading. + */ + virtual TBool + HandleDataReceived(TUint aSocketID, const TDesC8& aBuffer) = 0; + + /*! + Data has been sent on the socket. + @param aSocketID socket being observed + */ + virtual void HandleWriteComplete(TUint aSocketID) = 0; + + }; + +#endif // __SOCKETOBSERVER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/socketreader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/socketreader.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SOCKETSREADER_H__ +#define __SOCKETSREADER_H__ + +#include + +class MSocketObserver; + +/*! + This class handles reading data from a socket. + Any data read is simply passed back to the observer. + */ +class CSocketReader : public CActive + { +public: + /*! + Create a CSocketReader object + @param aSocketID ID given to the socket. Used when reporting back. + @param aObserver an observer for status reporting + @param aInitialBufSize the initial size to use for the read buffer + @result A pointer to the created instance of CSocketReader + */ + static CSocketReader* NewL(TUint aSocketID, MSocketObserver& aObserver, + TInt aInitialBufSize); + + /*! + Create a CSocketReader object + @param aSocketID ID given to the socket. Used when reporting back. + @param aObserver an observer for status reporting + @param aInitialBufSize the initial size to use for the read buffer + @result A pointer to the created instance of CSocketReader + */ + static CSocketReader* NewLC(TUint aSocketID, MSocketObserver& aObserver, + TInt aInitialBufSize); + + /*! + Destroy the object and release all memory objects + */ + ~CSocketReader(); + + /*! + Initiate reading from a socket + @param aSocket socket to read from + @param aMTU the bluetooth maximum transmission unit for the given socket. + */ + void StartReadingL(RSocket* aSocket, TInt aMTU); + +protected: + // from CActive + /*! + Cancel any outstanding operation + */ + void DoCancel(); + + /*! + Called when operation complete + */ + void RunL(); + +private: + /*! + Perform the first phase of two phase construction + @param aSocketID ID given to the socket. Used when reporting back. + @param aObserver an observer for status reporting + */ + CSocketReader(TUint aSocketID, MSocketObserver& aObserver); + + /*! + Perform the second phase construction of a CSocketReader + @param aInitialBufSize the initial size to use for the read buffer + */ + void ConstructL(TInt aInitialBufSize); + + /*! + Initiate a read from the socket. + */ + void IssueRead(); + +private: + // Member variables + /*! The ID of the socket being read from */ + TUint iSocketID; + + /*! An observer for reporting data to */ + MSocketObserver& iObserver; + + /*! Socket to read data from */ + RSocket* iSocket; + + /*! Buffer for receiving data */ + HBufC8* iBuffer; + + /*! Pointer to the buffer to be used when reading */ + TPtr8 iBufferPtr; + }; + +#endif // __SOCKETSREADER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/sockets.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/sockets.pan Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2004-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: BT HID Sockets Panic codes + * +*/ + +#ifndef __SOCKETS_PAN__ +#define __SOCKETS_PAN__ +#include +_LIT(KPanicBTConnection, "BTConnection"); +_LIT(KPanicSocketsEngineWrite, "SocketsEngineWrite"); +_LIT(KPanicSocketsEngineRead, "SocketsEngineRead"); + +/*! Sockets panic codes */ +enum TSocketsPanics + { + ESocketsBasicUi = 1, + ESocketsBadStatus, + ESocketsAppView, + ESocketsBadState, + ESocketsUnknownID + }; + +#endif // __SOCKETS_PAN__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/socketwriter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/socketwriter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SOCKETSWRITER_H__ +#define __SOCKETSWRITER_H__ + +#include +#include "timeoutnotifier.h" + +class CTimeOutTimer; +class MSocketObserver; + +/*! + This class handles writing data to a socket. + */ +class CSocketWriter : public CActive, public MTimeOutNotifier + { +public: + /*! + Create a CSocketWriter object + @param aSocketID ID given to the socket. Used when reporting back. + @param aObserver an observer for status reporting + @result A pointer to the created instance of CSocketWriter + */ + static CSocketWriter* NewL(TUint aSocketID, MSocketObserver& aObserver); + + /*! + Create a CSocketWriter object + @param aSocketID ID given to the socket. Used when reporting back. + @param aObserver an observer for status reporting + @result A pointer to the created instance of CSocketWriter + */ + static CSocketWriter* NewLC(TUint aSocketID, MSocketObserver& aObserver); + + /*! + Destroy the object and release all memory objects + */ + ~CSocketWriter(); + + /*! + Write the data to the socket + @param aData the data to be written + */ + void IssueWriteL(const TDesC8& aData); + + /*! + Initialise the writer with a socket + @param aSocket socket to write to. + */ + void Initialise(RSocket* aSocket); + +public: + // From MTimeOutNotifier + + void TimerExpired(); + +protected: + // from CActive + /*! + Cancel any outstanding operation + */ + void DoCancel(); + + /*! + Called when operation complete + */ + void RunL(); + +private: + /*! + Perform the first phase of two phase construction + @param aSocketID ID given to the socket. Used when reporting back. + @param aObserver an observer for status reporting + */ + CSocketWriter(TUint aSocketID, MSocketObserver& aObserver); + + /*! + Perform the second phase construction of a CSocketWriter + */ + void ConstructL(); + + /** + * Write the data from the current buffer to the socket. + */ + void DoWrite(); + /** + * Store data to be written in the specified buffer. + * @param aData Data to be written. + * @param aBuffer Which buffer to use. + */ + void StoreDataL(const TDesC8& aData, TInt aBuffer); + +private: + // Member variables + + /*! The maximum time allowed for a write to complete */ + static const TInt KTimeOut; + + /*! The ID of the RSocket we are working on */ + TUint iSocketID; + + /*! An observer for status reporting */ + MSocketObserver& iObserver; + + /*! The socket to write to */ + RSocket* iSocket; + + /*! Timer used to cancel a write after a predefined timeout */ + CTimeOutTimer* iTimer; + + /** Buffers to hold the data being written */ + HBufC8* iWriteBuffer[2]; + + /** The buffer whose contents are currently being written */ + TInt iCurrentBuffer; + }; + +#endif // __SOCKETSWRITER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/inc/sockinitnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/inc/sockinitnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SOCKINITNOTIFIER_H__ +#define __SOCKINITNOTIFIER_H__ + +/*! + This class specifies the socket initiator notifier interface + Used in conjunction with CSocketInitiator class + */ + +class MSockInitNotifier + { +public: + + /*! + Reports that control and interrupt sockets have been established. + */ + virtual void SocketsConnected() = 0; + + /*! + Reports that a failure occurred connecting the sockets. + @param aStatus system error code. + */ + virtual void SocketsConnFailed(TInt aStatus) = 0; + }; + +#endif // __SOCKINITNOTIFIER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1173 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include +#include "hiddebug.h" +#include "bthidconnection.h" +#include "btconnectionobserver.h" +#include "sockets.pan" +#include "socketinitiator.h" +#include "socketreader.h" +#include "socketwriter.h" +#include "datasegmenter.h" +#include "timeouttimer.h" +#include "bthidtypes.h" +#include "bthiddevice.h" +#include "hidinterfaces.h" +#include "debug.h" + +CBTHidConnection* CBTHidConnection::NewL(RSocketServ& aSocketServ, + MBTConnectionObserver& aObserver, TBTConnectionState aConnectionState) + { + CBTHidConnection* self = CBTHidConnection::NewLC(aSocketServ, aObserver, + aConnectionState); + CleanupStack::Pop(self); + return self; + } + +CBTHidConnection* CBTHidConnection::NewLC(RSocketServ& aSocketServ, + MBTConnectionObserver& aObserver, TBTConnectionState aConnectionState) + { + CBTHidConnection* self = new (ELeave) CBTHidConnection(aSocketServ, + aObserver, aConnectionState); + // This is a CObject derived class so must be closed to destroy it. + CleanupClosePushL(*self); + self->ConstructL(); + return self; + } + +CBTHidConnection::CBTHidConnection(RSocketServ& aSocketServ, + MBTConnectionObserver& aObserver, TBTConnectionState aConnectionState) : + iSocketServ(aSocketServ), iObserver(aObserver) + { + ChangeState(aConnectionState); + } + +CBTHidConnection::~CBTHidConnection() + { + delete iControlSocketReader; + + delete iControlSocketWriter; + + delete iInterruptSocketReader; + + delete iInterruptSocketWriter; + + delete iSocketInitiator; + + delete iCommandSegmenter; + + delete iControlDataBuffer; + + delete iInterruptDataBuffer; + + delete iInactivityTimer; + + delete iDevice; + + // Close connections in the reverse order to when they were opened + if (iInterruptSocket) + { + iInterruptSocket->Close(); + delete iInterruptSocket; + } + + if (iControlSocket) + { + iControlSocket->Close(); + delete iControlSocket; + } + } + +TInt CBTHidConnection::ConnID() + { + return iConnID; + } + +void CBTHidConnection::SetConnID(TInt aConnID) + { + // We shouldn't be trying to set the id for this connection + // after it is connected. + __ASSERT_DEBUG(iConnectionState == ENotConnected || iConnectionState == EConnecting, + User::Panic(KPanicBTConnection, ESocketsBadState)); + + iConnID = aConnID; + } + +void CBTHidConnection::ConstructL() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ConstructL")); + //ChangeState(ENotConnected); + + // A new hid device information object. + iDevice = CBTHidDevice::NewL(); + + // Socket readers and writer objects to perform asynchronous requests + iControlSocketReader = CSocketReader::NewL(EControlSocketID, *this, + KL2CAPDefaultMTU); + + iControlSocketWriter = CSocketWriter::NewL(EControlSocketID, *this); + + iInterruptSocketReader = CSocketReader::NewL(EInterruptSocketID, *this, + KL2CAPDefaultMTU); + + iInterruptSocketWriter = CSocketWriter::NewL(EInterruptSocketID, *this); + + // Socket initiator to perform socket connections + iSocketInitiator = CSocketInitiator::NewL(iSocketServ, *this); + + // Create a timeout timer + iInactivityTimer = CTimeOutTimer::NewL(EPriorityHigh, *this); + } + +void CBTHidConnection::ConnectL() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ConnectL")); + // If we aren't in the correct stiDeviceate for an initial connection Panic. + __ASSERT_DEBUG(iConnectionState == ENotConnected || iConnectionState == EConnecting, + User::Panic(KPanicBTConnection, ESocketsBadState)); + + // Create the two sockets. + + delete iControlSocket; + iControlSocket = 0; + iControlSocket = new (ELeave) RSocket; + + // If we leave after this iControlSocket will not be NULL. + // This is ok since any place where it can be set will delete it first + // or it will be finally deleted in the destructor + delete iInterruptSocket; + iInterruptSocket = 0; + iInterruptSocket = new (ELeave) RSocket; + + // If we leave after this iControlSocket & iInterruptSocket will not + // be NULL. + // This is ok since any place where they can be set will delete first + // or they will be finally deleted in the destructor + + // Ask the socket initiator to connect these sockets, + // giving it the bluetooth address of the device and a security flag. + iSocketInitiator->ConnectSocketsL(iDevice->iAddress, + iDevice->iUseSecurity, iControlSocket, iInterruptSocket); + ChangeState(EFirstConnection); + } + +void CBTHidConnection::ReconnectL() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ReconnectL")); + // If we aren't in the correct state for an reconnection Panic. + __ASSERT_DEBUG(iConnectionState == ENotConnected, + User::Panic(KPanicBTConnection, ESocketsBadState)); + + // Expect the device to reconnect for now + ChangeState(ELinkLost); + } + +void CBTHidConnection::Disconnect() //Virtual Cable Unplug. (this is not Bluetooth disconnect) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::Disconnect (Virtual Cable Unplug)")); + if (iConnectionState == EConnected) + { + //First Send VCUnplug + iCommandBuffer.Zero(); + iCommandBuffer.Append(EHIDControlVCUnplug); + + TRequestStatus status; + iControlSocket->Write(iCommandBuffer, status); + User::WaitForRequest(status); + + //Then wait for a reply from Su-8W on L2CAP channel(s). If not waited, Su-8W will go mad. + User::After(500000); //0.5 sec + + //but we never handle that acknowledgement (because it is not required by BT HID + //specification, but Su-8W needs to send something.) + iControlSocketWriter->Cancel(); + iControlSocketReader->Cancel(); + iInterruptSocketReader->Cancel(); + iInterruptSocketWriter->Cancel(); + } + } + +void CBTHidConnection::OfferControlSocket(const TBTDevAddr& aAddress, + RSocket*& aSocket) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::OfferControlSocket")); + if (aAddress == iDevice->iAddress) + { + __ASSERT_DEBUG((iConnectionState == ELinkLost) || + (iConnectionState == EHIDReconnecting), + User::Panic(KPanicBTConnection, ESocketsBadState)); + + // Take ownership of this socket + delete iControlSocket; + iControlSocket = aSocket; + aSocket = 0; + + // Mark that the HID Device is reconnecting to us. + ChangeState(EHIDReconnecting); + } + } + +void CBTHidConnection::OfferInterruptSocket(const TBTDevAddr& aAddress, + RSocket*& aSocket) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::OfferInterruptSocket")); + + if (aAddress == iDevice->iAddress) + { + __ASSERT_DEBUG((iConnectionState == EHIDReconnecting), //||(iConnectionState == ELinkLost) , + User::Panic(KPanicBTConnection, ESocketsBadState)); + + // Take ownership of this socket + delete iInterruptSocket; + iInterruptSocket = aSocket; + aSocket = 0; + TRAPD(error, PrepareSocketsL()); + + if (KErrNone == error) + { + // Mark that we are now reconnected. + + ChangeState(EConnected); + + // Inform the observer that the connection has been restored. + iObserver.LinkRestored(iConnID); + + } + else + { + // Close the sockets as they can't be used + CloseChannels(); + ChangeState(ELinkLost); + } + } + } + +CBTHidDevice& CBTHidConnection::DeviceDetails() + { + return (*iDevice); + } + +TBool CBTHidConnection::IsConnected() const + { + TRACE_INFO( (_L("[BTHID]\tCBTHidConnection::IsConnected: connection state = %d"), iConnectionState) ); + return (EConnected == iConnectionState); + } + +TBTConnectionState CBTHidConnection::ConnectStatus() const + { + TRACE_INFO( (_L("[BTHID]\tCBTHidConnection::ConnectStatus: connection state = %d"), iConnectionState) ); + return (iConnectionState); + } + +void CBTHidConnection::StartMonitoringChannelsL() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::StartMonitoringChannelsL")); + __ASSERT_DEBUG(iConnectionState == EConnected, + User::Panic(KPanicBTConnection, ESocketsBadState)); + + iControlSocketReader->StartReadingL(iControlSocket, iControlInMTU); + iInterruptSocketReader->StartReadingL(iInterruptSocket, iInterruptInMTU); + + // If the device will reconnect to us we are ok to drop the link + // after a period of inactivity. + if (iDevice->iReconnectInit) + { + iInactivityTimer->Cancel(); + iInactivityTimer->After(KInactivityTimeout); + } + } + +void CBTHidConnection::DropConnection() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::DropConnection")); + // Close the Bluetooth Channels. + CloseChannels(); + + // Update the connection state. + ChangeState(ELinkLost); + + // If a command is outstanding + if (iCommandIssued) + { + // Generate an error to the parent. + iObserver.HandleCommandAck(iConnID, KErrNotReady); + // Reset the command flag. + iCommandIssued = EFalse; + + // Reset this, so we don't leave it in a bad state. + if (iCommandSegmenter) + { + iCommandSegmenter->Reset(); + } + } + } + +// from MSocketObserver +void CBTHidConnection::HandleSocketError(TUint /*aSocketID*/, + TBool aConnectionLost, TInt aErrorCode) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidConnection::HandleSocketError: connlost %d, error code %d"), aConnectionLost, aErrorCode) ); + if (aConnectionLost) + { + ConnectionLost(); + } + else + { + // If we failed to write to the device then inform Generic HID + // of the failure + if (iCommandIssued) + { + iCommandIssued = EFalse; + + // Reset this, so we don't leave it in a bad state. + if (iCommandSegmenter) + { + iCommandSegmenter->Reset(); + } + + iObserver.HandleCommandAck(iConnID, aErrorCode); + } + } + } + +// from MSocketObserver +TBool CBTHidConnection::HandleDataReceived(TUint aSocketID, + const TDesC8& aBuffer) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::HandledataReceived")); + TBool result = ETrue; + + // Cancel the inactivity timer. + iInactivityTimer->Cancel(); + + switch (aSocketID) + { + case EControlSocketID: + result = ProcessControlData(aBuffer); + break; + case EInterruptSocketID: + result = ProcessInterruptData(aBuffer); + break; + default: + // Shouldn't have any other socket id + User::Panic(KPanicBTConnection, ESocketsUnknownID); + break; + } + + // If the device will reconnect to us we are ok to drop the link + // after a period of inactivity. + if ((result) && (iDevice->iReconnectInit)) + { + iInactivityTimer->After(KInactivityTimeout); + } + + return result; + } + +// from MSocketObserver +void CBTHidConnection::HandleWriteComplete(TUint aSocketID) + { + //to handle DATA Output in interrupt channel (Host to Device DATA) + // Check the ID of the socket + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::HandleWriteComplete")); + if (aSocketID == EControlSocketID || aSocketID == EInterruptSocketID) + { + // Send any additional packets on the control channel + if (iCommandSegmenter) + { + const HBufC8* data = iCommandSegmenter->NextPacket(); + if (data) + { + if (aSocketID == EControlSocketID) + { + TRAPD(err, iControlSocketWriter->IssueWriteL(*data)); + if (KErrNone != err) + { + // Reset this, so we don't leave it in a bad state. + iCommandSegmenter->Reset(); + iCommandIssued = EFalse; + + iObserver.HandleCommandAck(iConnID, err); + } + } + else //aSocketID == EInterruptSocketID + { + TRAPD(err, iInterruptSocketWriter->IssueWriteL(*data)); + if (KErrNone != err) + { + // Reset this, so we don't leave it in a bad state. + iCommandSegmenter->Reset(); + iCommandIssued = EFalse; + + iObserver.HandleCommandAck(iConnID, err); + } + } + } + if (!data && aSocketID == EInterruptSocketID && iCommandIssued) + { //We don't expect response from HID Device, However we'll notify GenericHID + //that async write operation has been finished. + iObserver.HandleCommandAck(iConnID, KErrNone); //Socket write complete! + iCommandIssued = EFalse; + } + } + } + + } + +void CBTHidConnection::SocketsConnected() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::SocketsConnected")); + TRAPD(error, PrepareSocketsL()); + + if (KErrNone == error) + { + switch (iConnectionState) + { + case EFirstConnection: + // We are now connected + + ChangeState(EConnected); + + // If this was an initial connection inform the observer + iObserver.FirstTimeConnectionComplete(iConnID, KErrNone); + break; + + case EHostReconnecting: + // We are now connected + ChangeState(EConnected); + + iObserver.LinkRestored(iConnID); + break; + + default: + User::Panic(KPanicBTConnection, ESocketsBadState); + break; + } + } + else + { + SocketsConnFailed(error); + } + } + +void CBTHidConnection::SocketsConnFailed(TInt aStatus) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidConnection::SocketsConnFailed(%d)"),aStatus) ); + switch (iConnectionState) + { + case EFirstConnection: + // We are not connected + ChangeState(ENotConnected); + // If this was an initial connection inform the observer + iObserver.FirstTimeConnectionComplete(iConnID, aStatus); + break; + + case EHostReconnecting: + ChangeState(ELinkLost); + break; + + default: + // we don't expect to be connecting in any other state. + User::Panic(KPanicBTConnection, ESocketsBadState); + break; + } + } + +void CBTHidConnection::TimerExpired() + { + // Inactivity timer has expired. + // Drop the connection. + DropConnection(); + // Inform the observer of the state change. + iObserver.Disconnected(iConnID); + } + +void CBTHidConnection::GetProtocolL() + { + LeaveIfCommandNotReadyL(); + + iCommandBuffer.Zero(); + iCommandBuffer.Append(EGetProtocol); + iControlSocketWriter->IssueWriteL(iCommandBuffer); + iCommandIssued = ETrue; + } + +void CBTHidConnection::SetProtocolL(TUint16 aValue) + { + LeaveIfCommandNotReadyL(); + + iCommandBuffer.Zero(); + // Value should be + // 0 for boot + // 1 for report + // ESetProtocol is set for Boot mode. Add aValue to get the correct + // command + iCommandBuffer.Append(ESetProtocol + aValue); + iControlSocketWriter->IssueWriteL(iCommandBuffer); + iCommandIssued = ETrue; + } + +void CBTHidConnection::GetReportL(TUint8 aReportType, TUint8 aReportID, + TUint16 aLength) + { + LeaveIfCommandNotReadyL(); + + iCommandBuffer.Zero(); + + // Add the Transaction header byte + // Report Type 0 = Reserved + // Report Type 1 = Input + // Report Type 2 = Output + // Report Type 3 = Feature + iCommandBuffer.Append(EGetReportFullBufReserved + aReportType); + + // If Report ID's are declared in the report descriptor then we + // add this field + if (aReportID != 0) + { + iCommandBuffer.Append(aReportID); + } + + // We need to check we have a buffer large enough to hold the control + // data we get back from the device + if (!iControlDataBuffer) + { + // Allocate the buffer if it didn't exist + iControlDataBuffer = HBufC8::NewL(aLength); + } + else + { + // Get a modifiable pointer to the buffer. + TPtr8 dataPtr = iControlDataBuffer->Des(); + + if (dataPtr.MaxLength() < aLength) + { + // Reallocate the buffer if its too small. + delete iControlDataBuffer; + iControlDataBuffer = 0; + iControlDataBuffer = HBufC8::NewL(aLength); + } + else + { + // Existing buffer is large enough, just zero it. + dataPtr.Zero(); + } + } + + iControlSocketWriter->IssueWriteL(iCommandBuffer); + iCommandIssued = ETrue; + } + +void CBTHidConnection::SetReportL(TUint8 aReportType, TUint8 aReportID, + const TDesC8& aReport) + { + LeaveIfCommandNotReadyL(); + + if (!iCommandSegmenter) + { + iCommandSegmenter = CDataSegmenter::NewL(); + } + + iCommandBuffer.Zero(); + + // Add the Transaction header byte + // Report Type 0 = Reserved + // Report Type 1 = Input + // Report Type 2 = Output + // Report Type 3 = Feature + iCommandBuffer.Append(ESetReportReserved + aReportType); + + // If Report ID's are declared in the report descriptor then we + // add this field + if (aReportID != 0) + { + iCommandBuffer.Append(aReportID); + } + + iCommandSegmenter->SegmentDataL(iCommandBuffer, aReport, EDATCOutput, + iControlOutMTU); + + iControlSocketWriter->IssueWriteL(*(iCommandSegmenter->FirstPacketL())); + + iCommandIssued = ETrue; + } + +void CBTHidConnection::DataOutL(TUint8 aReportID, const TDesC8& aReport) + { + //This implementation is similar to SetReportL, but instead of Control channel, + //sends the data in Interrupt channel. + + LeaveIfCommandNotReadyL(); + //We'll use Command buffer instead of Data buffer to send. + //could they happen at the same time? + if (!iCommandSegmenter) + { + iCommandSegmenter = CDataSegmenter::NewL(); + } + + iCommandBuffer.Zero(); + + // Add the Transaction header byte + // Report Type 0 = Reserved + // Report Type 1 = Input + // Report Type 2 = Output + // Report Type 3 = Feature + iCommandBuffer.Append(EDATAOutput); + + // If Report ID's are declared in the report descriptor then we + // add this field + if (aReportID != 0) + { + iCommandBuffer.Append(aReportID); + } + + iCommandSegmenter->SegmentDataL(iCommandBuffer, aReport, EDATCOutput, + iInterruptOutMTU); + + iInterruptSocketWriter->IssueWriteL(*(iCommandSegmenter->FirstPacketL())); + + iCommandIssued = ETrue; //We have sent the data but we don't expect + //HANDSHAKE SUCCESSFULL for DATA OUT from HID device. + //We will notify Generic HID when data has been sent. + } + +void CBTHidConnection::GetIdleL() + { + LeaveIfCommandNotReadyL(); + + iCommandBuffer.Zero(); + iCommandBuffer.Append(EGetIdle); + iControlSocketWriter->IssueWriteL(iCommandBuffer); + iCommandIssued = ETrue; + } + +void CBTHidConnection::SetIdleL(TUint8 aDuration) + { + LeaveIfCommandNotReadyL(); + + iCommandBuffer.Zero(); + iCommandBuffer.Append(ESetIdle); + iCommandBuffer.Append(aDuration); + iControlSocketWriter->IssueWriteL(iCommandBuffer); + iCommandIssued = ETrue; + } + +void CBTHidConnection::PrepareSocketsL() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::PrepareSockets")); + // Retrieve the MTU values from the sockets + User::LeaveIfError(iControlSocket->GetOpt(KL2CAPGetOutboundMTU, + KSolBtL2CAP, iControlOutMTU)); + User::LeaveIfError(iControlSocket->GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, + iControlInMTU)); + User::LeaveIfError(iInterruptSocket->GetOpt(KL2CAPInboundMTU, + KSolBtL2CAP, iInterruptInMTU)); + User::LeaveIfError(iInterruptSocket->GetOpt(KL2CAPGetOutboundMTU, + KSolBtL2CAP, iInterruptOutMTU)); + + // Initialise the control socket writer with the new socket. + iControlSocketWriter->Initialise(iControlSocket); + + // Initialise the interrupt socket writer with the new socket. + iInterruptSocketWriter->Initialise(iInterruptSocket); + + } + +void CBTHidConnection::ChangeState(TBTConnectionState aNewStatus) + { + iConnectionState = aNewStatus; + } + +void CBTHidConnection::ConnectionLost() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ConnectionLost")); + CloseChannels(); + + // First go into link loss state + ChangeState(ELinkLost); + + // If a command is outstanding + if (iCommandIssued) + { + TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, command outstanding")); + // Generate an error to the parent. + iObserver.HandleCommandAck(iConnID, KErrNotReady); + // Reset the command flag. + iCommandIssued = EFalse; + + // Reset this, so we don't leave it in a bad state. + if (iCommandSegmenter) + { + iCommandSegmenter->Reset(); + } + } + + // Check if the device will reconnect to us. + if (iDevice->iReconnectInit) + { + TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, device inits reconnect")); + // Inform the parent of the link loss and the fact we are not + // reconnecting + iObserver.LinkLost(iConnID); + } + else + { + TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, host inits reconnect")); + // Device won't reconnect, check if we are able to. + if (iDevice->iNormallyConnectable) + { + TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, device is normally connectable")); + // Attempt to initiate reconnection to the device. + TRAPD(res, iSocketInitiator->ConnectSocketsL(iDevice->iAddress, + iDevice->iUseSecurity, + iControlSocket, + iInterruptSocket);) + if (res == KErrNone) + { + // Reconnection is in progress, so record this and inform + // the parent. + ChangeState(EHostReconnecting); + iObserver.LinkLost(iConnID); + } + else + { + // Inform the parent of the link loss and the fact we are not + // reconnecting + iObserver.LinkLost(iConnID); + } + } + else + { + TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, device does not allow reconnection")); + // Device won't allow reconnection, so this connection is + // effectively dead. + // Change to not-connected and inform the parent of the + // disconnection. + ChangeState(ENotConnected); + iObserver.Unplugged(iConnID); + } + } + } + +void CBTHidConnection::ReceivedVirtualCableUnplug() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ReceivedVirtualCableUnplug")); + CloseChannels(); + ChangeState(ENotConnected); + + iObserver.Unplugged(iConnID); + } + +void CBTHidConnection::LeaveIfCommandNotReadyL() const + { + if (iConnectionState != EConnected) + { + User::Leave(KErrNotReady); + } + + if (iCommandIssued) + { + User::Leave(KErrInUse); + } + } + +void CBTHidConnection::CloseChannels() + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::CloseChannels")); + // Cancel the inactivity timer. + iInactivityTimer->Cancel(); + + iControlSocketReader->Cancel(); + iControlSocketWriter->Cancel(); + iInterruptSocketReader->Cancel(); + iInterruptSocketWriter->Cancel(); + + // BT HID Spec. says the channels should be closed in the reverse + // order to when they were opened + if (iInterruptSocket) + { + if (iConnectionState == EConnected) + { + // Immediate shutdown + TRequestStatus status; + iInterruptSocket->Shutdown(RSocket::EImmediate, status); + User::WaitForRequest(status); + } + + iInterruptSocket->Close(); + } + + if (iControlSocket) + { + if (iConnectionState == EConnected) + { + // Immediate shutdown + TRequestStatus status; + iControlSocket->Shutdown(RSocket::EImmediate, status); + User::WaitForRequest(status); + } + + iControlSocket->Close(); + } + + } + +TBool CBTHidConnection::ProcessControlData(const TDesC8& aBuffer) + { + TBool result = ETrue; + + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ProcessControlData")); + // Reset this, so we don't leave it in a bad state; + if (iCommandSegmenter) + { + iCommandSegmenter->Reset(); + } + + TInt dataLength = aBuffer.Length(); + + if (dataLength > 0) + { + TBTTransaction transaction = static_cast (aBuffer[0]); + + // The only unsolicited response should be a Virtual Cable Unplugged + // notification. + // All other responses should only be handled, if we have an + // outstanding command + if (transaction == EHIDControlVCUnplug) + { + ReceivedVirtualCableUnplug(); + // Don't want to read any more + result = EFalse; + } + else if (iCommandIssued) + { + // Reset the command issued flag. + iCommandIssued = EFalse; + + TRACE_INFO( (_L("[BTHID]\tCBTHidConnection::ProcessControlData: transaction %d"), transaction) ); + switch (transaction) + { + case EHandshakeSuccess: + iObserver.HandleCommandAck(iConnID, KErrNone); + break; + case EHandshakeNotReady: + iObserver.HandleCommandAck(iConnID, KErrNotReady); + break; + case EHandshakeInvalidRepID: + iObserver.HandleCommandAck(iConnID, + KErrAckInvalidReportID); + break; + case EHandshakeUnsupported: + iObserver.HandleCommandAck(iConnID, KErrNotSupported); + break; + case EHandshakeInvalidParam: + iObserver.HandleCommandAck(iConnID, + KErrAckInvalidParameter); + break; + case EHandshakeUnknown: + iObserver.HandleCommandAck(iConnID, KErrAckUnknown); + break; + case EHandshakeFatal: + iObserver.HandleCommandAck(iConnID, KErrAckFatal); + break; + + case EDATAInput: + // Fall through. + case EDATAFeature: + // If this packet was smaller than the maximum transmission + // unit this is the only data we will get. + if (dataLength < iControlInMTU) + { + // Pass to the observer + iObserver.HandleControlData(iConnID, aBuffer.Mid(1)); + } + else + { + // Data was the size of the MTU, so we will expect + // further DATC packets. + + // Mark that the command hasn't finished + iCommandIssued = ETrue; + + // Store as much data as we can in the buffer allocated + if (iControlDataBuffer) + { + TPtr8 dataPtr = iControlDataBuffer->Des(); + dataPtr.Zero(); + AppendData(dataPtr, aBuffer.Mid(1)); + } + } + break; + + case EDATCInput: + // Fall through. + case EDATCFeature: + // If this packet was smaller than the maximum transmission + // this is the final packet. + HandleEDATCFeature(aBuffer); + break; + + case EDATAOther: + iObserver.HandleControlData(iConnID, aBuffer.Mid(1)); + break; + + default: + // This transaction was unknown or unexpected, but + // we must report the error. + iObserver.HandleCommandAck(iConnID, KErrAckUnknown); + break; + } + } + } + + return result; + } + +void CBTHidConnection::HandleEDATCFeature(const TDesC8& aBuffer) + { + TInt dataLength = aBuffer.Length(); + if (dataLength < iControlInMTU) + { + // If there is a data buffer. + if (iControlDataBuffer) + { + // Get a modifiable pointer to the data + TPtr8 dataPtr = iControlDataBuffer->Des(); + + // If there is already some data then we can + // append. + if (dataPtr.Length() > 0) + { + // Append as much as we can. + AppendData(dataPtr, aBuffer.Mid(1)); + + // Pass up what data we have. + iObserver.HandleControlData(iConnID, *iControlDataBuffer); + } + else + { + // No initial data was stored, so report an + // error. + iObserver.HandleCommandAck(iConnID, KErrAckUnknown); + } + } + else + { + // There is no buffer to handle the data so just + // report an error. + iObserver.HandleCommandAck(iConnID, KErrNoMemory); + } + } + else + { + // This is an intermediate packet. + + // Mark that the command hasn't finished + iCommandIssued = ETrue; + + if (iControlDataBuffer) + { + // Get a modifiable pointer to the data. + TPtr8 dataPtr = iControlDataBuffer->Des(); + + // If there is already some data then we can + // append. + if (dataPtr.Length() > 0) + { + // Append as much as we can. + AppendData(dataPtr, aBuffer.Mid(1)); + } + } + } + + } + +void CBTHidConnection::AppendData(TDes8& aDest, const TDesC8& aSource) + { + TInt remainingSpace = aDest.MaxLength() - aDest.Length(); + + // If the control data buffer can handle this new packet + if (aSource.Length() <= remainingSpace) + { + // Append the data + aDest.Append(aSource); + } + } + +TBool CBTHidConnection::ProcessInterruptData(const TDesC8& aBuffer) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ProcessInterruptData")); + TInt dataLength = aBuffer.Length(); + + if (dataLength > 0) + { + TBTTransaction transaction = static_cast (aBuffer[0]); + + switch (transaction) + { + case EDATAInput: + // If this packet was smaller than the maximum transmission + // unit this is the only data we will get + if (dataLength < iInterruptInMTU) + { + // Pass to the observer + iObserver.HandleInterruptData(iConnID, aBuffer.Mid(1)); + } + else + { + // Data was the size of the MTU, so we will expect further + // DATC packets. + // Try to handle the start of this sequence + TRAPD(res, StartSegmentedInterruptDataL(aBuffer.Mid(1));) + if (res != KErrNone) + { + // First segment wasn't handled, so just pass up + // what we have + iObserver.HandleInterruptData(iConnID, aBuffer.Mid(1)); + } + } + break; + + case EDATCInput: + // Handle the next segmented packet + // If this packet was smaller than the maximum transmission + // unit this is the last packet in the sequence + if (dataLength < iInterruptInMTU) + { + ContinueSegmentedInterruptData(aBuffer.Mid(1), ETrue); + } + else + { + ContinueSegmentedInterruptData(aBuffer.Mid(1), EFalse); + } + break; + + default: + // Don't expect anything more here + break; + } + } + + return ETrue; + } + +void CBTHidConnection::StartSegmentedInterruptDataL(const TDesC8& aBuffer) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::StartSegmentedInterruptDataL")); + // First check to see if we already have a data buffer + if (!iInterruptDataBuffer) + { + // Allocate a buffer based on the size of the data and copy it. + iInterruptDataBuffer = aBuffer.AllocL(); + } + else + { + // Get a modifiable pointer to the buffer + TPtr8 dataPtr = iInterruptDataBuffer->Des(); + + if (dataPtr.MaxLength() < aBuffer.Length()) + { + // If the buffer isn't large enough recreate it + delete iInterruptDataBuffer; + iInterruptDataBuffer = 0; + iInterruptDataBuffer = aBuffer.AllocL(); + } + else + { + // We have a large enough buffer so copy the data + dataPtr.Copy(aBuffer); + } + } + } + +void CBTHidConnection::ContinueSegmentedInterruptData(const TDesC8& aBuffer, + TBool aFinalSegment) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidConnection::ContinueSegmentedInterruptDataL")); + // If there is no buffer, then we haven't received a start packet, so + // just ignore this data + if (iInterruptDataBuffer) + { + // Get a modifiable pointer to the buffer + TPtr8 dataPtr = iInterruptDataBuffer->Des(); + + // If there is no data already, then we can't handle this continuation + // packet + if (dataPtr.Length() > 0) + { + // Append the new data to the end of the buffer + TBool dataWasAppended = ETrue; + TInt newSize = (dataPtr.Length() + aBuffer.Length()); + + if (dataPtr.MaxLength() < newSize) + { + // Reallocate the buffer if it isn't large enough + HBufC8* newBuffer = iInterruptDataBuffer->ReAlloc(newSize); + + if (newBuffer) + { + iInterruptDataBuffer = newBuffer; + dataPtr.Set(iInterruptDataBuffer->Des()); + dataPtr.Append(aBuffer); + } + else + { + // We couldn't append the data, so reset this + dataWasAppended = EFalse; + } + } + else + { + dataPtr.Append(aBuffer); + } + + // If this is the final segment, or we couldn't append this + // segment, pass up what we have. + if ((aFinalSegment) || (!dataWasAppended)) + { + iObserver.HandleInterruptData(iConnID, *iInterruptDataBuffer); + + // Zero the buffer so any more continuation segments will + // be ignored + dataPtr.Zero(); + } + } + } + } + +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/bthiddevice.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/bthiddevice.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "bthiddevice.h" +#include "hiddescriptorlist.h" + +// A version number for this object when externalised. +// Only for future proofing. +const TInt KVersionNumber = 1; + +CBTHidDevice* CBTHidDevice::NewL() + { + CBTHidDevice* self = NewLC(); + CleanupStack::Pop(self); + return self; + } + +CBTHidDevice* CBTHidDevice::NewLC() + { + CBTHidDevice* self = new (ELeave) CBTHidDevice(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CBTHidDevice::CBTHidDevice() + { + } + +CBTHidDevice::~CBTHidDevice() + { + delete iDescList; + } + +TInt CBTHidDevice::DiskSize() const + { + // Always using 10 bytes as an estimate for Series 60 Descriptor headers + + //4 for KVersionNumber + //6 + 10 for the iAddress + //4 for iDeviceReleaseNumber + //4 for iDeviceSubClass + //4 for iCountryCode + //1 for iVirtuallyCabled + //1 for iReconnectInit + //1 for iNormallyConnectable + //4 for iProfileVersion + //4 for iVendorID + //4 for iProductID + //1 for iUseSecurity + //256 + 10 for iDeviceName + //4 for iDeviceClass + TInt size = 318; + + // Now add the size required for the descriptor list + size += iDescList->DiskSize(); + + return size; + } + +void CBTHidDevice::ExternalizeL(RWriteStream& aStream) const + { + // NOTE!! When changing this function, also check DiskSize + + // Write the version number + aStream.WriteInt32L(KVersionNumber); + + // Write all member variables to the stream. + // Leave if we get any error + aStream.WriteL(iAddress.Des()); + aStream.WriteUint32L(iDeviceReleaseNumber); + aStream.WriteUint32L(iDeviceSubClass); + aStream.WriteUint32L(iCountryCode); + aStream.WriteInt8L(iVirtuallyCabled ? 1 : 0); + aStream.WriteInt8L(iReconnectInit ? 1 : 0); + aStream.WriteInt8L(iNormallyConnectable ? 1 : 0); + aStream.WriteUint32L(iProfileVersion); + aStream.WriteUint32L(iVendorID); + aStream.WriteUint32L(iProductID); + aStream.WriteInt8L(iUseSecurity ? 1 : 0); + aStream << iDeviceName; + aStream << iDeviceClass; + aStream << *iDescList; + } + +void CBTHidDevice::InternalizeL(RReadStream& aStream) + { + // Read the version number + // Ignored in this version. + aStream.ReadInt32L(); + + // Read all member variables from the stream + // Leave if we get any error + + // Get a pointer to the address to fill + TPtr8 addr = iAddress.Des(); + // Read the address in + aStream.ReadL(addr); + + iDeviceReleaseNumber = aStream.ReadUint32L(); + iDeviceSubClass = aStream.ReadUint32L(); + iCountryCode = aStream.ReadUint32L(); + iVirtuallyCabled = aStream.ReadInt8L(); + iReconnectInit = aStream.ReadInt8L(); + iNormallyConnectable = aStream.ReadInt8L(); + iProfileVersion = aStream.ReadUint32L(); + iVendorID = aStream.ReadUint32L(); + iProductID = aStream.ReadUint32L(); + iUseSecurity = aStream.ReadInt8L(); + aStream >> iDeviceName; + aStream >> iDeviceClass; + aStream >> *iDescList; + } + +void CBTHidDevice::ConstructL() + { + iDescList = new (ELeave) CHidDescriptorList; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/bthidserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1631 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + +#include +#include +#include +#include +//#include // for checking the MachineUID. also link to hal.lib +#include +//#include +#include +#include "bthidserver.h" +#include "bthidsession.h" +#include "bthidclientsrv.h" +#include "bthidconnection.h" +#include "socketlistener.h" +#include "bthidtypes.h" +#include "bthiddevice.h" +#include "hiddescriptorlist.h" +#include "hiddescriptor.h" +#include "bthidserver.pan" +#include "debug.h" +#include "debugconfig.h" +#include "hidgeneric.h" +#include "hidlayoutids.h" +#include "bthidPsKey.h" + + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +//File store location +_LIT(KFileStore,"C:\\private\\2001E301\\bthiddevices.dat"); + +/** PubSub key read and write policies */ +_LIT_SECURITY_POLICY_C2( KBTHIDPSKeyReadPolicy, + ECapabilityLocalServices, ECapabilityReadDeviceData ); +_LIT_SECURITY_POLICY_C2( KBTHIDPSKeyWritePolicy, + ECapabilityLocalServices, ECapabilityWriteDeviceData ); + +// A version number to use when storing device information +// Only for future proofing. +const TInt KDataFileVersionNumber = 1; + +CBTHidServer::CBTHidServer() : + CGenericServer(CActive::EPriorityStandard) + { + // Implementation not required + } + +CBTHidServer::~CBTHidServer() + { + delete iShutDownTimer; + + delete iControlListener; + + delete iInterruptListener; + + delete iBTConnIndex; + + delete iMasterContIndex; // Causes deletion of iBTConnContainer + + if (iTempInterrupt) + { + iTempInterrupt->Close(); + delete iTempInterrupt; + } + + if (iTempControl) + { + iTempControl->Close(); + delete iTempControl; + } + + iFs.Close(); + iSocketServ.Close(); + + iReqs.ResetAndDestroy(); + + delete iGenHID; + + RProperty::Delete( KPSUidBthidSrv, KBTMouseCursorState ); + } + +CBTHidServer* CBTHidServer::NewL() + { + CBTHidServer* self = CBTHidServer::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CBTHidServer* CBTHidServer::NewLC() + { + CBTHidServer* self = new (ELeave) CBTHidServer; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +const TInt KShutdownDelay = 5000000; + +void CBTHidServer::StartShutdownTimerIfNoSession() + { + if (!ConnectionCount() + && (!iShutDownTimer || !iShutDownTimer->IsActive())) + { + if (!iShutDownTimer)TRAP_IGNORE(iShutDownTimer = CPeriodic::NewL(CActive::EPriorityStandard)); + if (iShutDownTimer) + iShutDownTimer->Start(KShutdownDelay, 0, TCallBack( + CBTHidServer::TimerFired, this)); + TRACE_FUNC + } + } + +TInt CBTHidServer::TimerFired(TAny* /*aThis*/) + { + TRACE_STATIC_FUNC + CActiveScheduler::Stop(); + return KErrNone; + } + +void CBTHidServer::CancelShutdownTimer() + { + TRACE_FUNC + delete iShutDownTimer; + iShutDownTimer = NULL; + } + +void CBTHidServer::ConstructL() + { + + TRACE_INFO(_L("CBTHidServer::ConstructL()...")); + iMasterContIndex = CObjectConIx::NewL(); + + iBTConnContainer = iMasterContIndex->CreateL(); + + iBTConnIndex = CObjectIx::NewL(); + + // Connect to the file server + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Connecting to file server")); + User::LeaveIfError(iFs.Connect()); + + // Make the data storage path (if it doesn't exist) + // If we can't create it, we can still make connections. They just won't + // persist. + iFs.MkDirAll(KFileStore); + // Connect to the socket server. + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Connecting to socket server")); + User::LeaveIfError(iSocketServ.Connect()); + + // Create initial sockets to accept a connection on the control + // and interrupt channels + iTempControl = new (ELeave) RSocket; + iTempInterrupt = new (ELeave) RSocket; + + // Set the security required for incoming connections on the + // control and interrupt channels. This is handled in socket level now. + + // Create Socket listeners for the control and interrupt channel + // ETrue, authorisation from user for incoming connection is asked + iControlListener = CSocketListener::NewL(iSocketServ, KL2CAPHidControl, + *this, ETrue); + + //no authorisation needs to be asked, + //since it is asked during Control channel re-connection. + iInterruptListener = CSocketListener::NewL(iSocketServ, + KL2CAPHidInterrupt, *this, EFalse); + + // Request to accept connections into the sockets just created + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): AcceptingConnections...")); + User::LeaveIfError(iControlListener->AcceptConnection(*iTempControl)); + User::LeaveIfError(iInterruptListener->AcceptConnection(*iTempInterrupt)); + + // Create the generic HID: + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Creating Generic HID")); + iGenHID = CGenericHid::NewL(this); + + // Load details of any virtually-cabled devices. + // Trap the error, but we can live with failure to load stored + // information. The file may be corrupt and we don't want this + // to prevent us using the application + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Loading virtually cabled devices")); + TRAPD( err, LoadVirtuallyCabledDevicesL(KFileStore) ); + if (KErrNone != err) + { + err = err; + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Loading virtually cabled devices FAILED")); + } + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Starting the server")); + + User::LeaveIfError( RProperty::Define( KPSUidBthidSrv, + KBTMouseCursorState, + RProperty::EInt, + KBTHIDPSKeyReadPolicy, + KBTHIDPSKeyWritePolicy) ); + + StartL(KBTHidSrvName); + + iActiveState = EFalse; + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConstructL(): Server Started.")); + + } + +CSession2* CBTHidServer::NewSessionL(const TVersion& aVersion, + const RMessage2& /*aMessage*/) const + { + // check we're the right version + if (!User::QueryVersionSupported(TVersion(KBTHIDServMajorVersionNumber, + KBTHIDServMinorVersionNumber, KBTHIDServBuildVersionNumber), + aVersion)) + { + User::Leave(KErrNotSupported); + } + const_cast (this)->CancelShutdownTimer(); + // make new session + return CBTHidServerSession::NewL(*const_cast (this)); + } + +void CBTHidServer::InformClientsOfStatusChange( + const CBTHidDevice& aDeviceDetails, TBTHidConnState aState) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::InformClientsOfStatusChange, state=%d"),aState) ); + if (aState == EBTDeviceConnected || aState == EBTDeviceLinkRestored + || aState == EBTDeviceLinkLost || aState == EBTDeviceDisconnected) + { + iLastUsedAddr = aDeviceDetails.iAddress; + iActiveState = ETrue; + } + else + { + iActiveState = EFalse; + } + InformStatusChange(aDeviceDetails.iAddress, aState); + GlobalNotify(aDeviceDetails.iAddress, aState); + } + +void CBTHidServer::InformStatusChange(const TBTDevAddr& aAddress, + TBTHidConnState aState) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::InformStatusChange, state=%d"),aState) ); + THIDStateUpdateBuf updateBuf; + THIDStateUpdate& update = updateBuf(); + + update.iDeviceAddress = aAddress; + update.iState = aState; + + // Send to all clients + iSessionIter.SetToFirst(); + for (;;) + { + CBTHidServerSession* session; + session = reinterpret_cast (iSessionIter++); + if (!session) + { + break; + } + + session->InformStatusChange(updateBuf); + } + } + +void CBTHidServer::GlobalNotify(const TBTDevAddr& aDeviceAddr, + TBTHidConnState aState) + { + switch (aState) + { + case EBTDeviceLinkRestored: + { + HandleAsyncRequest(aDeviceAddr, EBTConnected); + break; + } + + case EBTDeviceLinkLost: + case EBTDeviceDisconnected: + case EBTDeviceUnplugged: + { + HandleAsyncRequest(aDeviceAddr, EBTDisconnected); + break; + } + default: + //No need to bother + break; + } + } + +TInt CBTHidServer::HandleAsyncRequest(const TBTDevAddr& aDeviceAddr, + TInt aNote) + { + TRAPD(err, HandleAsyncRequestL(aDeviceAddr, aNote)); + return err; + } + +void CBTHidServer::HandleAsyncRequestL(const TBTDevAddr& aDeviceAddr, + TInt aNote) + { + CBTHidNotifierHelper* notifier = CBTHidNotifierHelper::NewL(*this, aNote, aDeviceAddr); + CleanupStack::PushL(notifier); + + iReqs.AppendL(notifier); + CleanupStack::Pop(notifier); + + if (iReqs.Count() == 1) // only display our notifier if there's nothing already showing + { + notifier->Start(); + } + } + +void CBTHidServer::NotifierRequestCompleted() + { + delete iReqs[0]; + iReqs.Remove(0); + + if (iReqs.Count()) + { + iReqs[0]->Start(); + } + } + +void CBTHidServer::GenericHIDConnectL(CBTHidConnection* aConnection, + TBool aStartDriver) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::GenericHIDConnectL")); + CBTHidDevice& devDetails = aConnection->DeviceDetails(); + + // Search for the first report descriptor and give this + // to Generic HID + TBool foundRepDesc = EFalse; + TInt i = 0; + while ((i < devDetails.iDescList->DescriptorCount()) && (!foundRepDesc)) + { + // Get the next descriptor. + const CHidDescriptor& desc = + (*(aConnection->DeviceDetails().iDescList))[i]; + + if (desc.DescriptorType() == CHidDescriptor::EReportDescriptor) + { + foundRepDesc = ETrue; + User::LeaveIfError(iGenHID->ConnectedL(aConnection->ConnID(), + desc.RawData())); + + // Try to start the driver if required. + if (aStartDriver) + { + User::LeaveIfError(iGenHID->DriverActive( + aConnection->ConnID(), CHidTransport::EActive)); + } + } + + i++; + } + + // If we didn't find a report descriptor, the device information is corrupt + if (!foundRepDesc) + { + User::Leave(KErrCorrupt); + } + } + +void CBTHidServer::IncrementSessions() + { + iSessionCount++; + CancelShutdownTimer(); + } + +void CBTHidServer::DecrementSessions() + { + iSessionCount--; + __ASSERT_DEBUG(iSessionCount >= 0, PanicServer(EMainSchedulerError)); + + if (iSessionCount <= 0) + { + iSessionCount = 0; + StartShutdownTimerIfNoSession(); + } + } + +TInt CBTHidServer::RunError(TInt aError) + { + if (aError == KErrBadDescriptor) + { + // A bad descriptor error implies a badly programmed client, + // so panic it; + // otherwise report the error to the client + PanicClient(Message(), EBadDescriptor); + } + else + { + Message().Complete(aError); + } + + // The leave will result in an early return from CServer::RunL(), skipping + // the call to request another message. So do that now in order to keep the + // server running. + ReStart(); + + return KErrNone; // handled the error fully + } + +void CBTHidServer::PanicClient(const RMessage2& aMessage, TInt aPanic) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::PanicClient(%d)"), aPanic) ); + aMessage.Panic(KBTHIDServer, aPanic); + } + +void CBTHidServer::PanicServer(TInt aPanic) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::PanicServer( %d )"), aPanic) ); + User::Panic(KBTHIDServer, aPanic); + } + +void CBTHidServer::ShutdownListeners(TInt aError) + { + // Shutdown listeners and close accepting sockets + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::ShutdownListeners(%d)"), aError) ) + + (void) aError; + + iControlListener->Cancel(); + iInterruptListener->Cancel(); + + if (iTempInterrupt) + { + iTempInterrupt->Close(); + } + + if (iTempControl) + { + iTempControl->Close(); + } + } + +TUint CBTHidServer::ConnectionCount() + { + return iBTConnContainer->Count(); + } + +CBTHidDevice& CBTHidServer::ConnectionDetailsL(TInt aConnID) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + return connection->DeviceDetails(); + } + +TBTEngConnectionStatus CBTHidServer::ConnectStatus(const TBTDevAddr& aAddress) + { + TInt i = 0; + TBool foundItem = EFalse; + TBTEngConnectionStatus retVal = EBTEngNotConnected; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::ConnectStatus()")); + while ((i < BTConnectionObjCount) && (!foundItem)) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + if (devDetails.iAddress == aAddress) + { + foundItem = ETrue; + TBTConnectionState HidConnectionStatus = + connection->ConnectStatus(); + if (EFirstConnection == HidConnectionStatus || EConnecting + == HidConnectionStatus || EHIDReconnecting + == HidConnectionStatus || EHostReconnecting + == HidConnectionStatus) + { + retVal = EBTEngConnecting; + } + if (EConnected == HidConnectionStatus) + { + retVal = EBTEngConnected; + } + } + } + + i++; + } + + return retVal; + } + +TBool CBTHidServer::GetConnectionAddress(TDes8& aAddressBuf) + { + TInt i = 0; + TBool retVal = EFalse; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + TRACE_INFO(_L("[BTHID]\tCBTHidServer::IsAllowToConnect()")); + while ((i < BTConnectionObjCount)) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + if (connection->IsConnected()) + { + retVal = ETrue; + aAddressBuf.Append((devDetails.iAddress).Des()); + if (aAddressBuf.Length() == KBTDevAddrSize * 2) + break; + } + } + i++; + } + + return retVal; + } + +TBool CBTHidServer::IsAllowToConnectFromServerSide(TUint aDeviceSubClass) + { + TInt i = 0; + TBool retVal = ETrue; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::IsAllowToConnectFromServerSide()")); + while ((i < BTConnectionObjCount) && retVal) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + TBTConnectionState HidConnectionStatus = + connection->ConnectStatus(); + if (connection->IsConnected() || HidConnectionStatus + == EHIDReconnecting) + { + if ((IsKeyboard(aDeviceSubClass) && IsKeyboard( + devDetails.iDeviceSubClass)) || (IsPointer( + aDeviceSubClass) && IsPointer( + devDetails.iDeviceSubClass))) + { + retVal = EFalse; + iConflictAddr = devDetails.iAddress; + } + } + } + i++; + } + + return retVal; + } + +TBool CBTHidServer::IsKeyboard(TUint aDeviceSubClass) + { + TUint deviceSubClass = aDeviceSubClass; + TBool retVal = EFalse; + if ((deviceSubClass >> 2) & EMinorDevicePeripheralKeyboard) + { + retVal = ETrue; + } + return retVal; + } + +TBool CBTHidServer::IsPointer(TUint aDeviceSubClass) + { + TUint deviceSubClass = aDeviceSubClass; + TBool retVal = EFalse; + if ((deviceSubClass >> 2) & EMinorDevicePeripheralPointer) + { + retVal = ETrue; + } + return retVal; + } + +TBool CBTHidServer::IsAllowToConnectFromClientSide(TBTDevAddr aDevAddr) + { + TInt i = 0; + TBool retVal = ETrue; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + + TUint deviceSubClass = GetDeviceSubClass(aDevAddr); + TRACE_INFO(_L("[BTHID]\tCBTHidServer::IsAllowToConnectFromClientSide()")); + while ((i < BTConnectionObjCount) && retVal) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + TBTConnectionState HidConnectionStatus = + connection->ConnectStatus(); + if (connection->IsConnected() || HidConnectionStatus + == EConnecting) + { + if (devDetails.iAddress != aDevAddr) + { + if ((IsKeyboard(deviceSubClass) && IsKeyboard( + devDetails.iDeviceSubClass)) || (IsPointer( + deviceSubClass) && IsPointer( + devDetails.iDeviceSubClass))) + { + retVal = EFalse; + iConflictAddr = devDetails.iAddress; + } + } + } + } + i++; + } + + return retVal; + } + +TUint CBTHidServer::GetDeviceSubClass(TBTDevAddr aDevAddr) + { + TInt i = 0; + TUint deviceSubClass = 0; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::GetMinorDeviceClass()")); + while (i < BTConnectionObjCount) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + if (devDetails.iAddress == aDevAddr) + { + deviceSubClass = devDetails.iDeviceSubClass; + } + } + i++; + } + return deviceSubClass; + } + +TBTDevAddr CBTHidServer::ConflictAddress() + { + return iConflictAddr; + } + +void CBTHidServer::CleanOldConnection(TInt aConnID) + { + TInt i = 0; + TBTDevAddr currentAddr; + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::CleanOldConnection() aConnID[%d]"), aConnID) ); + CBTHidConnection* connection = + static_cast(iBTConnIndex->At(aConnID)); + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::CleanOldConnection() aConnID[%d]"), aConnID) ); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + if (connection) + { + TRACE_INFO( _L("[BTHID]\tCBTHidServer::CleanOldConnection() if ") ); + CBTHidDevice& currentDetails = connection->DeviceDetails(); + currentAddr = currentDetails.iAddress; + TRACE_INFO( _L("[BTHID]\tCBTHidServer::CleanOldConnection() if 1") ); + while (i < iBTConnContainer->Count()) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::CleanOldConnection() i = [%d]"), i) ); + connection = static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + if (devDetails.iAddress == currentAddr && !(connection->IsConnected())) + { + TRACE_INFO( _L("[BTHID]\tCBTHidServer::CleanOldConnection() if 2") ); + iGenHID->Disconnected(connection->ConnID()); + iBTConnIndex->Remove(connection->ConnID()); + } + } + i++; + } + } + + return; + } + +TInt CBTHidServer::NewConnectionL() + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::NewConnectionL")); + CBTHidConnection *connection = CBTHidConnection::NewLC(iSocketServ, + *this, EConnecting); + // Add to the connection container object. + iBTConnContainer->AddL(connection); + CleanupStack::Pop(); // connection + + // Now add the object to the index to get an id. + // We can't let this just leave since we have already inserted the + // connection object into the container. + TInt id = 0; + TRAPD( res, + id = iBTConnIndex->AddL(connection); + connection->SetConnID(id); + ) + + if (res != KErrNone) + { + // Couldn't make an index entry. + // Close the connection object, causing it to be removed from the + // container + connection->Close(); + User::Leave(res); + } + + return id; + } + +void CBTHidServer::DoFirstConnectionL(TInt aConnID) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::DoFirstConnectionL")); + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + CBTHidDevice &devDetails = ConnectionDetailsL(aConnID); + DBG(TUint DeviceClass = devDetails.iDeviceSubClass; + + DBG(RDebug::Print(_L("[BTHID]\tCBTHidServer::DoFirstConnectionL iDeviceSubClass = %d"), DeviceClass)); + ) + + + + if (!IsAllowToConnectFromServerSide(devDetails.iDeviceSubClass)) + { + User::Leave(KErrAlreadyExists); + } + + connection->ConnectL(); + } + +void CBTHidServer::DeleteNewConnection(TInt aConnID) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::DeleteNewConnection")); + iBTConnIndex->Remove(aConnID); + } + +/*Asks the server to disconnect (virtual cable unplug) a device totally, + * remove the connection entry from the connection container. + */ +void CBTHidServer::CloseBluetoothConnection(const TBTDevAddr& aAddress) + + { + TInt i = 0; + TBool foundItem = EFalse; + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::CloseBluetoothConnection")); + while ((i < iBTConnContainer->Count()) && (!foundItem)) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + CBTHidDevice& devDetails = connection->DeviceDetails(); + + if (devDetails.iAddress == aAddress) + { + foundItem = ETrue; + // Inform the Generic HID of the disconnection. + iGenHID->Disconnected(connection->ConnID()); + + // Get it to disconnect if its connected. + connection->Disconnect(); + + // Delete the connection object. + iBTConnIndex->Remove(connection->ConnID()); + + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + StoreVirtuallyCabledDevices(KFileStore); + } + + i++; + } + + } + +/*Asks the server to disconnect all the devices totally, + * remove the connection entries from the connection container. + */ +void CBTHidServer::CloseAllBluetoothConnection() + { + TInt i = 0; + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::CloseAllBluetoothConnection")); + + while (i < iBTConnContainer->Count()) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + if (connection) + { + if (connection->IsConnected()) + { + // Inform the Generic HID of the disconnection. + iGenHID->Disconnected(connection->ConnID()); + + // Get it to disconnect if its connected. + connection->Disconnect(); + + // Delete the connection object. + iBTConnIndex->Remove(connection->ConnID()); + + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + StoreVirtuallyCabledDevices(KFileStore); + } + } + + i++; + } + } + +void CBTHidServer::DisconnectDeviceL(const TBTDevAddr& aAddress) + { + TInt i = 0; + TBool foundItem = EFalse; + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::DisconnectDeviceL")); + while ((i < iBTConnContainer->Count()) && (!foundItem)) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + CBTHidDevice& devDetails = connection->DeviceDetails(); + + if (devDetails.iAddress == aAddress) + { + foundItem = ETrue; + + // Drop the bluetooth connection. + connection->DropConnection(); + + // Stop the driver. + iGenHID->DriverActive(connection->ConnID(), + CHidTransport::ESuspend); + + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceDisconnected); + //Microsoft Keyboard & other "Unsecure" devices + CheckAndSetControlListenerSecurityL( + connection->DeviceDetails().iUseSecurity); + } + + i++; + } + } + +void CBTHidServer::DisconnectAllDeviceL() + { + TInt i = 0; + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::DisconnectAllDeviceL")); + while (i < iBTConnContainer->Count()) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + if (connection->IsConnected()) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + // Drop the bluetooth connection. + connection->DropConnection(); + + // Stop the driver. + iGenHID->DriverActive(connection->ConnID(), + CHidTransport::ESuspend); + + InformClientsOfStatusChange(devDetails, + EBTDeviceDisconnected); + //Microsoft Keyboard & other "Unsecure" devices + CheckAndSetControlListenerSecurityL( + devDetails.iUseSecurity); + } + + i++; + } + } + } + +void CBTHidServer::CheckAndSetControlListenerSecurityL(TBool aSec) + { + + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::CheckAndSetControlListenerSecurityL(%d)"), aSec) ); + + //Checking for Microsoft Keyboard & other "Unsecure" devices + + if (!aSec) //Security is set on in Constructor of listener. This overrides that setting. + { + delete iControlListener; + iControlListener = NULL; + if (iTempControl) + iTempControl->Close(); + iControlListener = CSocketListener::NewL(iSocketServ, + KL2CAPHidControl, *this, EFalse); //iAuthorisationFlag); We need authorisation, unless otherwise stated. + User::LeaveIfError(iControlListener->AcceptConnection(*iTempControl)); + } + + } + +// from MBTConnectionObserver +void CBTHidServer::HandleControlData(TInt aConnID, const TDesC8& aBuffer) + { + iGenHID->DataIn(aConnID, CHidTransport::EHidChannelCtrl, aBuffer); + } + +void CBTHidServer::HandleCommandAck(TInt aConnID, TInt aStatus) + { + iGenHID->CommandResult(aConnID, aStatus); + } + +void CBTHidServer::HandleInterruptData(TInt aConnID, const TDesC8& aBuffer) + { + iGenHID->DataIn(aConnID, CHidTransport::EHidChannelInt, aBuffer); + } + +void CBTHidServer::FirstTimeConnectionComplete(TInt aConnID, TInt aStatus) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::FirstTimeConnectionComplete(%d)"), aStatus)); + TInt error = aStatus; + + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + if (error == KErrNone) + { + TBool genHidConnected = EFalse; + + TRAP( error, + // Inform the Generic HID of the Connection + GenericHIDConnectL(connection, ETrue); + + // Record that we got as far as informing the Generic HID. + genHidConnected = ETrue; + + // Try to start monitoring the channels. + connection->StartMonitoringChannelsL(); + ) + + if (error != KErrNone) + { + // If we informed the Generic HID of the connection, then + // we must also disconnect. + if (genHidConnected) + { + iGenHID->Disconnected(aConnID); + } + + // Delete the connection object. + iBTConnIndex->Remove(aConnID); + } + else + { + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + TRACE_INFO( _L("[BTHID]\tCBTHidServer::FirstTimeConnectionComplete() before CleanOldConnection") ); + CleanOldConnection(aConnID); + TRACE_INFO( _L("[BTHID]\tCBTHidServer::FirstTimeConnectionComplete() after CleanOldConnection") ); + StoreVirtuallyCabledDevices(KFileStore); + } + } + else + { + iBTConnIndex->Remove(aConnID); + } + + // Report the connection result to the sessions. + iSessionIter.SetToFirst(); + for (;;) + { + CBTHidServerSession* session; + session = reinterpret_cast (iSessionIter++); + if (!session) + { + break; + } + + session->InformConnectionResult(aConnID, error); + } + } + +void CBTHidServer::LinkLost(TInt aConnID) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::LinkLost(%d)"), aConnID)); + // Stop the driver. + iGenHID->DriverActive(aConnID, CHidTransport::ESuspend); + + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + // Inform clients of the change in status of this connection. + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceLinkLost); + } + +void CBTHidServer::LinkRestored(TInt aConnID) + { + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + // Inform the Generic HID of the reconnection + TInt error = iGenHID->DriverActive(aConnID, CHidTransport::EActive); + + // If there was no error, try to start monitoring the channels. + if (error == KErrNone) + { + // Try to start monitoring channels. + TRAP( error, connection->StartMonitoringChannelsL(); ) + } + + // Report new connection status. + if (error == KErrNone) + { + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceLinkRestored); + } + else + { + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceUnplugged); + // Inform the Generic HID of the disconnection. + iGenHID->Disconnected(aConnID); + // Delete the connection object. + iBTConnIndex->Remove(aConnID); + + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + StoreVirtuallyCabledDevices(KFileStore); + } + } + +void CBTHidServer::Disconnected(TInt aConnID) + { + CBTHidConnection *connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + // Stop the driver. + iGenHID->DriverActive(aConnID, CHidTransport::ESuspend); + + // Report new connection status. + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceDisconnected); + + //Check if no security is needed for listening socket + //Microsoft Keyboard & other "Unsecure" devices need this. + + // possible leave is sign of severe problems in BT stack. So no reason to handle leave. + TRAP_IGNORE( CheckAndSetControlListenerSecurityL(connection->DeviceDetails().iUseSecurity) ); + + } + +void CBTHidServer::Unplugged(TInt aConnID) + { + CBTHidConnection *connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + // Report new connection status. + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceUnplugged); + + // Inform the Generic HID of the disconnection. + iGenHID->Disconnected(aConnID); + + iBTConnIndex->Remove(aConnID); + + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + StoreVirtuallyCabledDevices(KFileStore); + } + +//from MListenerObserver +void CBTHidServer::SocketAccepted(TUint aPort, TInt aErrorCode) + { + TBTSockAddr sockAddr; + TBTDevAddr devAddr; + + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::SocketAccepted, port=%d, error code=%d"), aPort, aErrorCode) ); + + // Check error code + if (aErrorCode != KErrNone) + { + // If we do get an error there isn't much we can about it. + // Just tidy up. + + ShutdownListeners(aErrorCode); + } + else + { + TInt i = 0; + TInt count = iBTConnContainer->Count(); + TInt err = KErrNone; + + // Check which port has accepted a connection + switch (aPort) + { + // The HID Control Channel + case KL2CAPHidControl: + // Get the BT address of the device that has connected + iTempControl->RemoteName(sockAddr); + devAddr = sockAddr.BTAddr(); + if (IsAllowToConnectFromClientSide(devAddr)) + { + while ((i < count) && (iTempControl)) + { + CBTHidConnection + * connection = + static_cast ((*iBTConnContainer)[i]); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + connection->OfferControlSocket(devAddr, iTempControl); + i++; + } + + } + else + { + InformStatusChange(devAddr, EBTDeviceAnotherExist); + } + + // The next socket to accept into + if (iTempControl) + { + // Reuse this socket + iTempControl->Close(); + err = KErrNone; + } + else + { + // Socket ownership has been transferred so create a new + // socket + //TRAP( err, iTempControl = new (ELeave) RSocket; ) + iTempControl = new RSocket; + } + + // Created a socket to accept into so accept next connection + if (err == KErrNone) + { + err = iControlListener->AcceptConnection(*iTempControl); + } + + // If we failed to allocate a new RSocket or failed + // in the AcceptConnectionL call it means we can no longer + // accept connections from a device. + if (err != KErrNone) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::SocketAccepted, control channel failed, shutdown listener")); + ShutdownListeners(err); + } + + break; + + // The HID Interrupt Channel + case KL2CAPHidInterrupt: + // Get the BT address of the device that has connected + iTempInterrupt->RemoteName(sockAddr); + devAddr = sockAddr.BTAddr(); + if (IsAllowToConnectFromClientSide(devAddr)) + { + while ((i < count) && (iTempInterrupt)) + { + CBTHidConnection + *connection = + static_cast ((*iBTConnContainer)[i]); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + connection->OfferInterruptSocket(devAddr, + iTempInterrupt); + i++; + } + } + else + { + //Commented for avoiding display the same notes twice for same device + //because of two channels(Control+Interrupt) has been rejected + //InformStatusChange(devAddr, EBTDeviceAnotherExist); + } + + // The next socket to accept into + if (iTempInterrupt) + { + // Reuse this socket + iTempInterrupt->Close(); + err = KErrNone; + } + else + { + // Socket ownership has been transferred so create a new + // socket + //TRAP( err, iTempInterrupt = new (ELeave) RSocket; ) + iTempInterrupt = new RSocket; + } + + // Created a socket to accept into so accept next connection + if (err == KErrNone) + { + err = iInterruptListener->AcceptConnection( + *iTempInterrupt); + } + + // If we failed to allocate a new RSocket or failed + // in the AcceptConnectionL call it means we can no longer + // accept connections from a device. + if (err != KErrNone) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::SocketAccepted, interrupt channel failed, shutdown listener")); + ShutdownListeners(err); + } + break; + + default: + PanicServer(EInvalidHandle); + break; + } + } + + } + +//from MTransportLayer +TUint CBTHidServer::CountryCodeL(TInt aConnID) + { + // Identify the connection object. + CBTHidConnection* conn = IdentifyConnectionL(aConnID); + // Retrieve its device details. + const CBTHidDevice& device = conn->DeviceDetails(); + + //return the country code + return device.iCountryCode; + } + +TUint CBTHidServer::VendorIdL(TInt aConnID) + { + // Identify the connection object. + CBTHidConnection* conn = IdentifyConnectionL(aConnID); + // Retrieve its device details. + const CBTHidDevice& device = conn->DeviceDetails(); + + //return the Vendor Id. + return device.iVendorID; + } + +TUint CBTHidServer::ProductIdL(TInt aConnID) + { + // Identify the connection object. + CBTHidConnection* conn = IdentifyConnectionL(aConnID); + // Retrieve its device details. + const CBTHidDevice& device = conn->DeviceDetails(); + + //return the Product Id. + return device.iProductID; + } + +void CBTHidServer::GetProtocolL(TInt aConnID, TUint16 /*aInterface*/) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param. + connection->GetProtocolL(); + } + +void CBTHidServer::SetProtocolL(TInt aConnID, TUint16 aValue, TUint16 /*aInterface*/) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param. + connection->SetProtocolL(aValue); + } + +void CBTHidServer::GetReportL(TInt aConnID, TUint8 aReportType, + TUint8 aReportID, TUint16 /*aInterface*/, TUint16 aLength) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param. + connection->GetReportL(aReportType, aReportID, aLength); + } + +void CBTHidServer::SetReportL(TInt aConnID, TUint8 aReportType, + TUint8 aReportID, TUint16 /*aInterface*/, const TDesC8& aReport) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param + connection->SetReportL(aReportType, aReportID, aReport); + } + +void CBTHidServer::DataOutL(TInt aConnID, TUint8 aReportID, + TUint16 /*aInterface*/, const TDesC8& aReport) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param + connection->DataOutL(aReportID, aReport); //we disregard DATA Input, DATA Feature and DATA Other + } + +void CBTHidServer::GetIdleL(TInt aConnID, TUint8 /*aReportID*/, TUint16 /*aInterface*/) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param. + // Bluetooth HID doesn't specify Report ID. + connection->GetIdleL(); + } + +void CBTHidServer::SetIdleL(TInt aConnID, TUint8 aDuration, + TUint8 /*aReportID*/, TUint16 /*aInterface*/) + { + CBTHidConnection *connection = IdentifyConnectionL(aConnID); + + // Bluetooth HID only has one interface. We don't need the interface param. + // Bluetooth HID doesn't specify Report ID. + connection->SetIdleL(aDuration); + } + +CBTHidConnection* CBTHidServer::IdentifyConnectionL(TInt aConnID) const + { + CBTHidConnection *connection = + static_cast (iBTConnIndex->At(aConnID)); + + if (!connection) + { + User::Leave(KErrNotFound); + } + + return connection; + } + +void CBTHidServer::LoadVirtuallyCabledDevicesL(const TDesC& aStoreName) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::LoadVirtuallyCabledDevicesL")); + // Create the parsed name and open the store + TParse parsedName; + User::LeaveIfError(iFs.Parse(aStoreName, parsedName)); + + CFileStore* store = CDirectFileStore::OpenLC(iFs, parsedName.FullName(), + EFileRead); + + // Open the data stream inside the store + RStoreReadStream stream; + stream.OpenLC(*store, store->Root()); + + // Read the version number of the data file. + // Its not used in this version. + stream.ReadInt32L(); + + // Get the number of devices to load. + TInt count = stream.ReadInt32L(); + TInt i; + for (i = 0; i < count; i++) + { + // Create the connection object. Ok to leave. + CBTHidConnection* connection = CBTHidConnection::NewLC(iSocketServ, + *this, ENotConnected); + + stream >> connection->DeviceDetails(); + // Check if no security is needed, then override earlier Control listener with unsecure one. + // This is needed for Microsoft Keyboard fix. + CheckAndSetControlListenerSecurityL( + connection->DeviceDetails().iUseSecurity); + + // Add to the connection container object. + iBTConnContainer->AddL(connection); + CleanupStack::Pop(); // connection + + // We can't let this just leave since we have already inserted the + // connection object into the container. + TBool connectionIndexed = EFalse; + TRAPD( res, + // Now add the object to the index to get an id. + TInt id = iBTConnIndex->AddL(connection); + connection->SetConnID(id); + connectionIndexed = ETrue; + connection->ReconnectL(); + + // Inform the Generic HID of the connection, but don't + // start the driver yet. This will be done in LinkRestored. + GenericHIDConnectL(connection, EFalse); + ) + + if (res != KErrNone) + { + if (connectionIndexed) + { + // Connection object was added to the index, but reconnection + // failed. + iBTConnIndex->Remove(connection->ConnID()); + } + else + { + // Couldn't make an index entry. + // Close the connection object, causing it to be removed from + // the container. + connection->Close(); + } + } + } + + // Delete all the remaining stuff on the cleanup stack + // (store and stream) + CleanupStack::PopAndDestroy(2); + } + +void CBTHidServer::StoreVirtuallyCabledDevicesL(const TDesC& aStoreName) + { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::StoreVirtuallyCabledDevicesL")); + // Parse the filestore name into a usable version. + TParse parsedName; + User::LeaveIfError(iFs.Parse(aStoreName, parsedName)); + + // Count the number of devices that we will need to store. + // Also count the accumulated disk size require for each one. + TInt numVirtuallyCabled = 0; + TInt requiredDiskSize = 0; + + TInt i; + + for (i = 0; i < iBTConnContainer->Count(); i++) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice &device = connection->DeviceDetails(); + if (device.iVirtuallyCabled) + { + numVirtuallyCabled++; + // Increase the required size. + requiredDiskSize += device.DiskSize(); + } + } + } + + // Check for required disk size + // NOTE !! Be careful when changing functionality in here + + // We have the number of bytes required to store all the device objects + // we want to store + + // First thing written will be the file version which is 4 bytes + // Then the number of virtually cabled devices which is 4 bytes + requiredDiskSize += 8; + + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::StoreVirtuallyCabledDevicesL: Required disk size %d bytes"), + requiredDiskSize) ); + // Now check that the required number of bytes will not take us into + // the critical disk space area. + if (SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, requiredDiskSize, EDriveC)) + { + User::Leave(KErrDiskFull); + } + + // Start the write for real. + + CFileStore* store = CDirectFileStore::ReplaceLC(iFs, + parsedName.FullName(), EFileWrite); + store->SetTypeL(KDirectFileStoreLayoutUid); + + // Create the stream + RStoreWriteStream stream; + TStreamId id = stream.CreateLC(*store); + + // Write the version number of the data file + stream.WriteInt32L(KDataFileVersionNumber); + + // Write the number of devices we are going to store. + stream.WriteInt32L(numVirtuallyCabled); + + // Externalise each device object that is virtually cabled. + for (i = 0; i < iBTConnContainer->Count(); i++) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice &device = connection->DeviceDetails(); + if (device.iVirtuallyCabled) + { + stream << device; + } + } + + } + + // Commit the changes to the stream + stream.CommitL(); + CleanupStack::PopAndDestroy(); + + // Set the stream in the store and commit the store + store->SetRootL(id); + store->CommitL(); + CleanupStack::PopAndDestroy(); + } + +void CBTHidServer::StoreVirtuallyCabledDevices(const TDesC& aStoreName) + { + TRAP_IGNORE( StoreVirtuallyCabledDevicesL(aStoreName);) + } + +void RunServerL() + { + TRACE_FUNC_ENTRY + User::RenameThread(KBTHidSrvName); + // Create and install the active scheduler for this thread. + CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); + CleanupStack::PushL(scheduler); + CActiveScheduler::Install(scheduler); + // create the server (leave it on the cleanup stack) + CBTHidServer* btHidServer = CBTHidServer::NewLC(); + // Initialisation complete, now signal the client + RProcess::Rendezvous(KErrNone); + // The server is not up and running. + TRACE_INFO( ( _L( "[BTHID]\t BTHID server now up and running" ) ) ) + // The active scheduler runs during the lifetime of this thread. + CActiveScheduler::Start(); + // Cleanup the server and scheduler. + CleanupStack::PopAndDestroy(btHidServer); + CleanupStack::PopAndDestroy(scheduler); + TRACE_FUNC_EXIT + } + +GLDEF_C TInt E32Main() + { + __UHEAP_MARK; + TRACE_FUNC_ENTRY + CTrapCleanup* cleanup = CTrapCleanup::New(); + TInt err = KErrNoMemory; + if (cleanup) + { + TRAP( err, RunServerL() ); + delete cleanup; + } + __UHEAP_MARKEND; + return err; + } + +// CBTHidNotifierHelper + +CBTHidNotifierHelper* CBTHidNotifierHelper::NewL(CBTHidServer& aHidServer, TInt aNote, const TBTDevAddr& aDeviceAddr) + { + CBTHidNotifierHelper* self = new(ELeave) CBTHidNotifierHelper(aHidServer, aNote, aDeviceAddr); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBTHidNotifierHelper::~CBTHidNotifierHelper() + { + Cancel(); + iNotifier.Close(); + } + +void CBTHidNotifierHelper::Start() + { + TRACE_INFO(_L("CBTHidNotifierHelper::Start()...")); + + // Simple async handling + iNotifier.StartNotifierAndGetResponse(iStatus, + KBTGenericInfoNotifierUid, iGenericInfoNotifierType, + iNoResult); + + // assert object is not already active + __ASSERT_DEBUG(!IsActive(), CBTHidServer::PanicServer(ENotifierAlreadyActive)); + + SetActive(); + } + +void CBTHidNotifierHelper::DoCancel() + { + TRACE_INFO(_L("CBTHidNotifierHelper::DoCancel()...")); + + iNotifier.CancelNotifier(KBTGenericInfoNotifierUid); + } + +CBTHidNotifierHelper::CBTHidNotifierHelper(CBTHidServer& aHidServer, TInt aNote, const TBTDevAddr& aDeviceAddr) + : CActive(CActive::EPriorityStandard), + iHidServer(aHidServer) + { + TRACE_INFO(_L("CBTHidNotifierHelper::CBTHidNotifierHelper()...")); + + iGenericInfoNotifierType().iMessageType = (TBTGenericInfoNoteType) aNote; + iGenericInfoNotifierType().iRemoteAddr.Copy(aDeviceAddr.Des()); + + CActiveScheduler::Add(this); + } + +void CBTHidNotifierHelper::ConstructL() + { + TRACE_INFO(_L("CBTHidNotifierHelper::ConstructL()...")); + + User::LeaveIfError(iNotifier.Connect()); + } + +void CBTHidNotifierHelper::RunL() + { + TRACE_INFO(_L("CBTHidNotifierHelper::RunL()...")); + + iHidServer.NotifierRequestCompleted(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/bthidsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/bthidsession.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,350 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include +#include +#include "bthidsession.h" +#include "bthidserver.h" +#include "bthidclientsrv.h" +#include "hidsdpclient.h" +#include "bthiddevice.h" +#include "bthidserver.pan" +#include "debug.h" + +CBTHidServerSession::CBTHidServerSession(CBTHidServer& aServer) : + iServer(aServer) + { + // Implementation not required + } + +CBTHidServerSession::~CBTHidServerSession() + { + iServer.DecrementSessions(); + delete iHidSdpClient; + } + +void CBTHidServerSession::ServiceL(const RMessage2& aMessage) + { + TRAPD( err, DispatchMessageL( aMessage ) ); + + if (aMessage.Function() == EBTHIDGetConnections && !aMessage.IsNull()) + { + // Handle the error code, what to to? + err = err; + } + } + +void CBTHidServerSession::DispatchMessageL(const RMessage2& aMessage) + { + switch (aMessage.Function()) + { + case EBTHIDServConnectDevice: + RequestConnectionL(aMessage); + break; + + case EBTHIDServCancelConnect: + if (iConnectionMessage.Handle()) + { + delete iHidSdpClient; + iHidSdpClient = 0; + + iServer.DeleteNewConnection(iConnectingID); + + iConnectionMessage.Complete(KErrCancel); + } + aMessage.Complete(KErrNone); + break; + + case EBTHIDServNotifyConnectionChange: + if (iUpdateMessage.Handle()) + { + // We're already busy + CBTHidServer::PanicClient(aMessage, EReqAlreadyPending); + } + else + { + iUpdateMessage = aMessage; + } + break; + + case EBTHIDServCancelNotify: + if (iUpdateMessage.Handle()) + { + iUpdateMessage.Complete(KErrCancel); + } + aMessage.Complete(KErrNone); + break; + + case EBTHIDServDisconnectDevice: + RequestDisconnectionL(aMessage); + break; + + case EBTHIDServIsConnected: + IsConnectedL(aMessage); + break; + + case EBTHidSrvDisconnectAllGracefully: + if (iDisconnectMsg.Handle()) + { + aMessage.Complete(KErrServerBusy); + } + else + { + iDisconnectMsg = aMessage; + iServer.DisconnectAllDeviceL(); + iDisconnectMsg.Complete(KErrNone); + } + break; + + case EBTHIDGetConnections: + GetConnections(aMessage); + break; + + default: + { + TRACE_INFO( ( _L( "[BTHID]\t DispatchMessageL: bad request (%d)" ), + aMessage.Function() ) ) + CBTHidServer::PanicClient(aMessage, EBadRequest); + } + break; + } + } + +void CBTHidServerSession::HidSdpSearchComplete(TInt aResult) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidServerSession::HidSdpSearchComplete")); + // This is a callback for the Hid SDP client so we can't delete it here + // Get it to destroy itself when its convenient. + iHidSdpClient->Kill(); + // Deleted outside destructor. + iHidSdpClient = 0; + + TInt err = aResult; + + // If the SDP search was a success + if (err == KErrNone) + { + // Try to connect to the device as a HID + TRAP( err, iServer.DoFirstConnectionL(iConnectingID); ) + + if (err == KErrAlreadyExists) + { + //there is already an active connection with the same CoD + TBuf8 buf; + TBTDevAddr dummyAddr = iServer.ConflictAddress(); + buf.Append(dummyAddr.Des()); + if (buf.Length()) + { + iConnectionMessage.Write(1, buf); + } + + //delete the connection object in the server + iServer.DeleteNewConnection(iConnectingID); + iConnectionMessage.Complete(err); + return; + } + } + + // Any error causes clean up, + if (err != KErrNone) + { + //delete the connection object in the server + iServer.DeleteNewConnection(iConnectingID); + + //Inform the client of the result + iConnectionMessage.Complete(aResult); + } + } + +void CBTHidServerSession::RequestConnectionL(const RMessage2& aMessage) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidServerSession::RequestConnectionL")); + + if (iConnectionMessage.Handle()) + { + // We're already busy + CBTHidServer::PanicClient(aMessage, EReqAlreadyPending); + } + else + { + TRACE_INFO(_L("[BTHID]\tCBTHidServerSession::RequestConnectionL continue to connect")); + // Keep a copy of message - for use later + iConnectionMessage = aMessage; + + // Read the connection parameters + TBTDevAddr addr; + TPckg addrPack(addr); + + iConnectionMessage.ReadL(0, addrPack); + // Ask the server to create a new connection object + + + iConnectingID = iServer.NewConnectionL(); + TRAPD( res, + // Retrieve the hid device object for this new connection + CBTHidDevice &devDetails = + iServer.ConnectionDetailsL(iConnectingID); + + // Fill in the information we got from the client + devDetails.iAddress = addr; + devDetails.iUseSecurity = ETrue; + + // Create a new HID Sdp Client + // Its only used here so it doesn't matter if we leave. + delete iHidSdpClient; + iHidSdpClient = 0; + //Create a new hid sdp client using the hid device object. + iHidSdpClient = CHidSdpClient::NewL(devDetails, *this); + + // Start the hid sdp client + iHidSdpClient->StartL(); + ) + + // If there was any error, inform the client and finish + if (res != KErrNone) + { + // Get the server to delete the new connection object + iServer.DeleteNewConnection(iConnectingID); + aMessage.Complete(res); + } + } + + } + +void CBTHidServerSession::RequestDisconnectionL(const RMessage2& aMessage) + { + TBTDevAddr addr; + TPckg addrPack(addr); + + // Read the address from the client thread. + aMessage.ReadL(0, addrPack); + + // Since the user can select this option using the BT Keyboard + // and the keydown event triggers it, depending on how long they + // hold down the key, the connection could be restored to send + // the key up event. + // Add a small delay, sensible enough for a press of the enter + // key before disconnection. + // Currently 3/4 of a second. + User::After(750000); + + //Keep the connection alive, initial reconnect from HID device available... + iServer.CloseBluetoothConnection(addr); + + aMessage.Complete(KErrNone); + } + +void CBTHidServerSession::InformStatusChange( + const THIDStateUpdateBuf& aUpdateParams) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidServerSession::InformStatusChange")); + + THIDStateUpdate update = aUpdateParams(); + TBTHidConnState state = update.iState; + + TBuf8 buf; + if (state == EBTDeviceAnotherExist) + { + TBTDevAddr iDumyAddr = iServer.ConflictAddress(); + buf.Append(iDumyAddr.Des()); + } + + TRACE_INFO( (_L("[BTHID]\tCBTHidServerSession::InformStatusChange, state=%d"), state) ); + + if (iUpdateMessage.Handle()) + { + TRACE_FUNC + (_L("[BTHID]\tCBTHidServerSession::InformStatusChange, OK - send message")); + // Trap any error + TRAPD( res, + iUpdateMessage.WriteL(0,aUpdateParams); + if (buf.Length()) + { + iUpdateMessage.WriteL(1,buf); + } + ) + + if (state == EBTDeviceAnotherExist) + { + iUpdateMessage.Complete(KErrAlreadyExists); + } + else + { + // Complete the message, with the error code from the trap. + iUpdateMessage.Complete(res); + } + } + } + +void CBTHidServerSession::InformConnectionResult(TInt aConnID, TInt aResult) + { + TRACE_INFO( (_L("[BTHID new]\tCBTHidServerSession::InformConnectionResult, Ids: %d==%d aResult = %d"), + iConnectingID, aConnID, aResult) ); + if ((iConnectionMessage.Handle()) && (iConnectingID == aConnID)) + { + iConnectionMessage.Complete(aResult); + } + } + +void CBTHidServerSession::IsConnectedL(const RMessage2& aMessage) + { + TBTDevAddr addr; + TPckg addrPck(addr); + aMessage.ReadL(0, addrPck); + TBTEngConnectionStatus ret = iServer.ConnectStatus(addr); + + aMessage.Complete(ret); + } + +void CBTHidServerSession::GetConnections(const RMessage2& aMessage) + { + TRACE_FUNC + TBuf8 buf; + buf.Zero(); + iServer.GetConnectionAddress(buf); + if (buf.Length()) + { + aMessage.Write(0, buf); + } + + aMessage.Complete(KErrNone); + } + +CBTHidServerSession* CBTHidServerSession::NewL(CBTHidServer& aServer) + { + CBTHidServerSession* self = CBTHidServerSession::NewLC(aServer); + CleanupStack::Pop(self); + return self; + } + +CBTHidServerSession* CBTHidServerSession::NewLC(CBTHidServer& aServer) + { + CBTHidServerSession* self = new (ELeave) CBTHidServerSession(aServer); + + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +void CBTHidServerSession::ConstructL() + { + iServer.IncrementSessions(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/datasegmenter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/datasegmenter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "datasegmenter.h" + +CDataSegmenter* CDataSegmenter::NewL() + { + CDataSegmenter* self = NewLC(); + CleanupStack::Pop(self); + return self; + } + +CDataSegmenter* CDataSegmenter::NewLC() + { + CDataSegmenter* self = new (ELeave) CDataSegmenter(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CDataSegmenter::CDataSegmenter() + { + // No work to do + } + +CDataSegmenter::~CDataSegmenter() + { + delete iPayloadBuf; + + delete iPacket; + } + +void CDataSegmenter::SegmentDataL(const TDesC8& aInitialHeader, + const TDesC8& aPayload, TChar aAdditionalHeaderByte, TInt aMTU) + { + // Store the continuation packet header byte and MTU + iAdditionalHeaderByte = aAdditionalHeaderByte; + iMTU = aMTU; + + // Determine the payload that will go in the first packet + TInt initialPayLoadSize = Min((iMTU - aInitialHeader.Length()), + aPayload.Length()); + + // The initial packet size + TInt initialSize = aInitialHeader.Length() + initialPayLoadSize; + + TPtr8 dataPtr(0, 0); + if (!iPacket) + { + // Allocate the packet buffer, if it doesn't exist + iPacket = HBufC8::NewL(initialSize); + dataPtr.Set(iPacket->Des()); + } + else + { + // Ensure the existing buffer is large enough to hold the new data + dataPtr.Set(iPacket->Des()); + if (dataPtr.MaxLength() < initialSize) + { + delete iPacket; + iPacket = 0; + iPacket = HBufC8::NewL(initialSize); + dataPtr.Set(iPacket->Des()); + } + } + + // Reset the packet buffer + dataPtr.Zero(); + // Append the header and initial payload + dataPtr.Append(aInitialHeader); + dataPtr.Append(aPayload.Mid(0, initialPayLoadSize)); + + // Reset the payload pointer to NULL + iPayloadBufPtr.Set(TPtrC8(0, 0)); + + // Determine the remaining payload + TInt payloadRemaining = aPayload.Length() - initialPayLoadSize; + + // If there is some remaining payload, store it + if (payloadRemaining > 0) + { + if (!iPayloadBuf) + { + // Allocate the payload buffer, if it doesn't exist + iPayloadBuf = HBufC8::NewL(payloadRemaining); + dataPtr.Set(iPayloadBuf->Des()); + } + else + { + // Ensure the existing buffer is large enough to hold the new data + dataPtr.Set(iPayloadBuf->Des()); + if (dataPtr.MaxLength() < payloadRemaining) + { + delete iPayloadBuf; + iPayloadBuf = 0; + iPayloadBuf = HBufC8::NewL(payloadRemaining); + dataPtr.Set(iPayloadBuf->Des()); + } + } + + // Reset the payload buffer + dataPtr.Zero(); + // Copy the remaining payload + dataPtr.Append(aPayload.Mid(initialPayLoadSize)); + // Initialise the payload pointer + iPayloadBufPtr.Set(iPayloadBuf->Des()); + } + } + +const HBufC8* CDataSegmenter::FirstPacketL() const + { + // Leave if no packet created. + User::LeaveIfNull(iPacket); + + // Return the initial packet created + return iPacket; + } + +const HBufC8* CDataSegmenter::NextPacket() + { + HBufC8* result = iPacket; + TPtr8 packetPtr = iPacket->Des(); + + // If there is some payload left over + if (iPayloadBufPtr.Length() > 0) + { + // Reset the packet buffer + packetPtr.Zero(); + + // Append the additional packet header + packetPtr.Append(iAdditionalHeaderByte); + + // Determine how much payload to copy, minimum of what's left and what + // can fit in the packet + TInt dataToCopy = Min((iMTU - 1), iPayloadBufPtr.Length()); + + // Copy payload into the packet buffer + packetPtr.Append(iPayloadBufPtr.Mid(0, dataToCopy)); + + // Update the payload pointer + iPayloadBufPtr.Set(iPayloadBufPtr.Mid(dataToCopy)); + } + else if (packetPtr.Length() == iMTU) + { + // No payload left, but last packet was full, so we must send + // an additional packet with just the header + packetPtr.Zero(); + packetPtr.Append(iAdditionalHeaderByte); + } + else + { + // No more packets + result = 0; + } + + return result; + } + +void CDataSegmenter::Reset() + { + // If a packet has been allocated, then reset the data + if (iPacket) + { + TPtr8 packetPtr = iPacket->Des(); + packetPtr.Zero(); + } + + // Reset the payload pointer to NULL + iPayloadBufPtr.Set(TPtrC8(0, 0)); + } + +void CDataSegmenter::ConstructL() + { + // No work to do + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/descriptorlistparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/descriptorlistparser.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "descriptorlistparser.h" +#include "hiddescriptorlist.h" +#include "hiddescriptor.h" + +CDescriptorListParser::CDescriptorListParser( + CHidDescriptorList& aDescriptorList) : + iDescriptorList(aDescriptorList) + { + } + +CDescriptorListParser::~CDescriptorListParser() + { + delete iCurrentDescriptor; + } + +void CDescriptorListParser::VisitAttributeValueL(CSdpAttrValue& aValue, + TSdpElementType aType) + { + // We are only interested in the descriptor type and data + if (iCurrentDescriptor) + { + switch (aType) + { + case ETypeUint: + iCurrentDescriptor->SetDescriptorType( + static_cast (aValue.Uint())); + break; + + case ETypeString: + iCurrentDescriptor->SetRawDataL(aValue.Des()); + break; + + default: + break; + } + } + } + +void CDescriptorListParser::StartListL(CSdpAttrValueList& /*aList*/) + { + ++iIndentationLevel; + // 1 Indentation is the HID Descriptor List DES + // 2 Indentation is a HID Descriptor DES + if (iIndentationLevel == 2) + { + // Create a HID Descriptor to fill + if (!iCurrentDescriptor) + { + iCurrentDescriptor = CHidDescriptor::NewL(); + } + } + } + +void CDescriptorListParser::EndListL() + { + --iIndentationLevel; + // 1 Indentation is the HID Descriptor List DES + if (iIndentationLevel == 1 && iCurrentDescriptor) + { + // We have moved back from a HID Descriptor DES + // Store the populated HID Descriptor in the list + iDescriptorList.AddDescriptorL(iCurrentDescriptor); + iCurrentDescriptor = 0; + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/genericactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/genericactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2008 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 "genericactive.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CGenericActive* CGenericActive::New(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + return new CGenericActive(aObserver, aPriority, aRequestId); + } + +CGenericActive* CGenericActive::NewL(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CGenericActive* self = new (ELeave) CGenericActive(aObserver, aPriority, + aRequestId); + return self; + } + +CGenericActive::~CGenericActive() + { + Cancel(); + TRACE_FUNC + } + +void CGenericActive::GoActive() + { + TRACE_ASSERT(!IsActive(), -2); + SetActive(); + TRACE_INFO((_L("CGenericActive: Service %d starts"), iRequestId)) + } + +TInt CGenericActive::RequestId() const + { + return iRequestId; + } + +void CGenericActive::SetRequestId(TInt aRequestId) + { + iRequestId = aRequestId; + } + +TRequestStatus& CGenericActive::RequestStatus() + { + return iStatus; + } + +void CGenericActive::DoCancel() + { + iObserver.CancelRequest(*this); + TRACE_INFO((_L("Service %d cancelled"), iRequestId)) + } + +void CGenericActive::RunL() + { + TRACE_INFO((_L("Service %d completed with %d"), iRequestId, iStatus.Int())) + iObserver.RequestCompletedL(*this); + } + +TInt CGenericActive::RunError(TInt aError) + { + TRACE_INFO((_L("Service %d RunError with %d"), iRequestId, aError)) + iObserver.HandleError(iRequestId, aError); + return KErrNone; + } + +CGenericActive::CGenericActive(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) : + CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) + { + CActiveScheduler::Add(this); + TRACE_FUNC + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/hiddescriptor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/hiddescriptor.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "hiddescriptor.h" + +CHidDescriptor* CHidDescriptor::NewL() + { + CHidDescriptor* self = NewLC(); + CleanupStack::Pop(self); + return self; + } + +CHidDescriptor* CHidDescriptor::NewLC() + { + CHidDescriptor* self = new (ELeave) CHidDescriptor(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CHidDescriptor* CHidDescriptor::NewL(RReadStream& aStream) + { + CHidDescriptor* self = NewLC(aStream); + CleanupStack::Pop(self); + return self; + } + +CHidDescriptor* CHidDescriptor::NewLC(RReadStream& aStream) + { + CHidDescriptor* self = new (ELeave) CHidDescriptor(); + CleanupStack::PushL(self); + self->ConstructL(aStream); + return self; + } + +CHidDescriptor::CHidDescriptor() + { + } + +CHidDescriptor::~CHidDescriptor() + { + delete iRawData; + } + +void CHidDescriptor::ConstructL() + { + } + +void CHidDescriptor::ConstructL(RReadStream& aStream) + { + // First read in the type + iType = static_cast (aStream.ReadInt32L()); + + // The TInt size was written out using WriteInt32L + // Read in the buffer size + TInt size = aStream.ReadInt32L(); + + if (size > 0) + { + // Read in any data + iRawData = HBufC8::NewL(aStream, size); + } + } + +TInt CHidDescriptor::DiskSize() const + { + // Always using 10 bytes as an estimate for Series 60 Descriptor headers + + // We write out the type which is an int + TInt size = 4; + + // If there is raw data we will write out the descriptor + if (iRawData && iRawData->Length() > 0) + { + // An estimate of the header requirements. + size += 10; + size += iRawData->Length(); + } + + return size; + } + +void CHidDescriptor::ExternalizeL(RWriteStream& aStream) const + { + // NOTE!! When changing this function, also check DiskSize + + // First write out the type + aStream.WriteInt32L(iType); + + if (iRawData && iRawData->Length() > 0) + { + // Write out the buffer length + aStream.WriteInt32L(iRawData->Length()); + // Write out the buffer + aStream << *iRawData; + } + else + { + // No buffer so just put 0 + aStream.WriteInt32L(0); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/hiddescriptorlist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/hiddescriptorlist.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "hiddescriptorlist.h" +#include "hiddescriptor.h" +#include "bthidserver.pan" + +const TInt KArrayGranularity = 2; + +CHidDescriptorList::CHidDescriptorList() + { + } + +CHidDescriptorList::~CHidDescriptorList() + { + if (iDescriptorList) + { + // Clean up. + iDescriptorList->ResetAndDestroy(); + delete iDescriptorList; + } + } + +TInt CHidDescriptorList::DescriptorCount() const + { + if (iDescriptorList) + { + return iDescriptorList->Count(); + } + else + { + return 0; + } + } + +const CHidDescriptor& CHidDescriptorList::operator[](TInt aIndex) const + { + __ASSERT_ALWAYS(iDescriptorList && + 0 <= aIndex && aIndex < iDescriptorList->Count(), + User::Panic(KBTHIDServer, EBadRequest)); + + return (*iDescriptorList->At(aIndex)); + } + +void CHidDescriptorList::AddDescriptorL(const CHidDescriptor* aDesc) + { + if (iDescriptorList) + { + iDescriptorList->AppendL(aDesc); + } + else + { + iDescriptorList = new (ELeave) CArrayPtrFlat ( + KArrayGranularity); + iDescriptorList->AppendL(aDesc); + } + } + +TInt CHidDescriptorList::DiskSize() const + { + // We always write out the number of descriptors which is an int. + TInt size = 4; + + // Add on the size of all descriptors + if (iDescriptorList) + { + TInt count = iDescriptorList->Count(); + + for (TInt i = 0; i < count; i++) + { + const CHidDescriptor* tmp = ((*iDescriptorList)[i]); + size += tmp->DiskSize(); + } + } + + return size; + } + +void CHidDescriptorList::ExternalizeL(RWriteStream& aStream) const + { + // NOTE!! When changing this function, also check DiskSize + + if (iDescriptorList) + { + TInt count = iDescriptorList->Count(); + + aStream.WriteInt32L(count); + for (TInt i = 0; i < count; i++) + { + const CHidDescriptor* tmp = ((*iDescriptorList)[i]); + aStream << *tmp; + } + } + else + { + aStream.WriteInt32L(0); + } + } + +void CHidDescriptorList::InternalizeL(RReadStream& aStream) + { + // Read in the number of descriptors + TInt count = aStream.ReadInt32L(); + + if (count > 0) + { + // Create the array to hold the CHidDescriptor. + iDescriptorList = new (ELeave) CArrayPtrFlat ( + KArrayGranularity); + + // Load each descriptor in and add it to the list + for (TInt i = 0; i < count; i++) + { + CHidDescriptor *temp = CHidDescriptor::NewLC(aStream); + iDescriptorList->AppendL(temp); + CleanupStack::Pop(); // temp + } + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/hidsdpclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/hidsdpclient.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,438 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include +#include +#include "hidsdpclient.h" +#include "bthiddevice.h" +#include "hidsdpobserver.h" +#include "bthidtypes.h" +#include "bthidserver.pan" +#include "descriptorlistparser.h" + +class TServiceAttribute + { +public: + TSdpAttributeID iID; + }; + +// HID Service Attributes +static const TServiceAttribute gHIDServiceAttributes[] = + { + { + KHIDAttrDevRelNum + }, + { + KHIDAttrDevSubClass + }, + { + KHIDAttrCountryCode + }, + { + KHIDAttrVirtuallyCabled + }, + { + KHIDAttrReconnectInitiate + }, + { + KHIDAttrDescriptorList + }, + { + KHIDAttrProfileVersion + }, + { + KHIDAttrNormallyConnectable + } + }; + +// HID Service Attribute count +static const TUint gHIDServAttrCount = sizeof(gHIDServiceAttributes) / sizeof(TServiceAttribute); + +// PnP Service Attributes +static const TServiceAttribute gBTPnPServiceAttributes[] = + { + { + KPnPAttrVendorID + }, + { + KPnPAttrProductID + } + }; + +// PnP Service Attribute count +static const TUint gBTPnPAttrCount = sizeof(gBTPnPServiceAttributes) + / sizeof(TServiceAttribute); + +// Bit Mask flags for the mandatory fields value +const TUint KDevSubClassMandFlag = 1; +const TUint KCountryCodeMandFlag = 2; +const TUint KVirtuallyCabledMandFlag = 4; +const TUint KReconnectInitMandFlag = 8; +const TUint KDescriptorListMandFlag = 16; +const TUint KProfileVersionMandFlag = 32; +const TUint KVendorIDMandFlag = 64; +const TUint KProductIDMandFlag = 128; + +// Expected mandatory fields value after the hid service record. +const TUint KHidServiceMandValue = KDevSubClassMandFlag + | KCountryCodeMandFlag | KVirtuallyCabledMandFlag + | KReconnectInitMandFlag | KDescriptorListMandFlag + | KProfileVersionMandFlag; + +// Expected mandatory fields value after the bt pnp service record. +const TUint KPnPServiceMandValue = KHidServiceMandValue | KVendorIDMandFlag + | KProductIDMandFlag; + +CHidSdpClient* CHidSdpClient::NewL(CBTHidDevice& aDevice, + MHidSdpObserver& aObserver) + { + CHidSdpClient* self = NewLC(aDevice, aObserver); + CleanupStack::Pop(self); + return self; + } + +CHidSdpClient* CHidSdpClient::NewLC(CBTHidDevice& aDevice, + MHidSdpObserver& aObserver) + { + CHidSdpClient* self = new (ELeave) CHidSdpClient(aDevice, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CHidSdpClient::CHidSdpClient(CBTHidDevice& aDevice, + MHidSdpObserver& aObserver) : + CActive(EPriorityStandard), iDevice(aDevice), iObserver(aObserver), + iParserState(EIdle) + { + } + +CHidSdpClient::~CHidSdpClient() + { + delete iAgent; + + delete iHIDMatchList; + + delete iPNPMatchList; + + delete iSdpSearchPattern; + } + +void CHidSdpClient::ConstructL() + { + // Create the service search pattern object. + iSdpSearchPattern = CSdpSearchPattern::NewL(); + + // Create the attribute match list for HIDP Service. + iHIDMatchList = CSdpAttrIdMatchList::NewL(); + + TUint i; + + // Populate the list with the attributes we want to find. + for (i = 0; i < gHIDServAttrCount; i++) + { + iHIDMatchList->AddL(TAttrRange(gHIDServiceAttributes[i].iID)); + } + + //Create the attribute match list for the BT PnP Service. + iPNPMatchList = CSdpAttrIdMatchList::NewL(); + + // Populate the list with the attributes we want to find. + for (i = 0; i < gBTPnPAttrCount; i++) + { + iPNPMatchList->AddL(TAttrRange(gBTPnPServiceAttributes[i].iID)); + } + } + +void CHidSdpClient::Finish(TInt aError) + { + iParserState = EIdle; + iObserver.HidSdpSearchComplete(aError); + } + +void CHidSdpClient::StartL() + { + // Delete any current agent. + delete iAgent; + iAgent = 0; + + // Reset the mandatory value bitmask. + iMandAttrValue = 0; + + // Create a SDP Agent for the given BT Address. + iAgent = CSdpAgent::NewL(*this, iDevice.iAddress); + + // Fill the record filter with the UUID of the HIDP Service. + iSdpSearchPattern->AddL(KHidPServiceUUID); + + // Set the initial record filter. + iAgent->SetRecordFilterL(*iSdpSearchPattern); + + // Request the next record. + iAgent->NextRecordRequestL(); + + // Set that we are inquiring for the HIDP Service. + iParserState = EHIDService; + } + +void CHidSdpClient::Kill() + { + CActiveScheduler::Add(this); + iStatus = KRequestPending; + SetActive(); // Wait to be completed... + TRequestStatus* status = &iStatus; + User::RequestComplete(status, KErrNone); // ...which we do ourself + } + +void CHidSdpClient::NextRecordRequestComplete(TInt aError, + TSdpServRecordHandle aHandle, TInt /*aTotalRecordsCount*/) + { + + TInt error = aError; + + if (aError == KErrNone) + { + switch (iParserState) + { + // If this is supposed to be the HIDP Service Record. + case EHIDService: + // Request the attributes from the HIDP Service. + TRAP( error, + iAgent->AttributeRequestL(aHandle, *iHIDMatchList); + ) + break; + + // If this is supposed to be the BT Pnp Service Record. + case EBTPnPService: + // Request the attributes from the BT Pnp Service. + TRAP( error, + iAgent->AttributeRequestL(aHandle, *iPNPMatchList); + ) + error = KErrNone; //PNP not found but we don't care! FOR RUNNING WITH IAR TESTER! + break; + + default: + User::Panic(KBTHIDServer, EBadState); + break; + } + } + + // If we have had any error, inform the observer as we have finished. + if (error != KErrNone) + { + Finish(error); + } + } + +void CHidSdpClient::AttributeRequestResult(TSdpServRecordHandle /*aHandle*/, + TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue) + { + switch (iParserState) + { + // If this is supposed to be a HIDP Service Attribute. + case EHIDService: + // Check its type and assign to the appropriate member in the + // device object. + switch (aAttrValue->Type()) + { + case ETypeUint: + switch (aAttrID) + { + case KHIDAttrDevRelNum: + iDevice.iDeviceReleaseNumber = aAttrValue->Uint(); + break; + case KHIDAttrDevSubClass: + iDevice.iDeviceSubClass = aAttrValue->Uint(); + // Record that this mandatory item was found + iMandAttrValue |= KDevSubClassMandFlag; + break; + case KHIDAttrCountryCode: + iDevice.iCountryCode = aAttrValue->Uint(); + iMandAttrValue |= KCountryCodeMandFlag; + break; + case KHIDAttrProfileVersion: + iDevice.iProfileVersion = aAttrValue->Uint(); + iMandAttrValue |= KProfileVersionMandFlag; + break; + default: + // This is an attribute we didn't request, + // or wrong type. + break; + } + break; + + case ETypeBoolean: + switch (aAttrID) + { + case KHIDAttrVirtuallyCabled: + iDevice.iVirtuallyCabled = aAttrValue->Bool(); + iMandAttrValue |= KVirtuallyCabledMandFlag; + break; + case KHIDAttrReconnectInitiate: + iDevice.iReconnectInit = aAttrValue->Bool(); + iMandAttrValue |= KReconnectInitMandFlag; + break; + case KHIDAttrNormallyConnectable: + iDevice.iNormallyConnectable = aAttrValue->Bool(); + break; + default: + // This is an attribute we didn't request + // or wrong type. + break; + } + break; + + case ETypeDES: + switch (aAttrID) + { + case KHIDAttrDescriptorList: + { + TRAP_IGNORE( + CDescriptorListParser* visitor = new CDescriptorListParser(*(iDevice.iDescList)); + if( visitor ) + { + CleanupStack::PushL(visitor); + aAttrValue->AcceptVisitorL(*visitor); + CleanupStack::PopAndDestroy(visitor); + } + ) + // Don't care about any error that could occur + iMandAttrValue |= KDescriptorListMandFlag; + } + break; + default: + // This is an attribute we didn't request + // or wrong type. + break; + } + break; + + default: + // This is an attribute we didn't request or wrong type. + break; + } + + break; + + // If this is supposed to be a BT Pnp Service Attribute. + case EBTPnPService: + // Check its type and assign to the appropriate member in the + // device object. + switch (aAttrValue->Type()) + { + case ETypeUint: + switch (aAttrID) + { + case KPnPAttrVendorID: + iDevice.iVendorID = aAttrValue->Uint(); + iMandAttrValue |= KVendorIDMandFlag; + break; + case KPnPAttrProductID: + iDevice.iProductID = aAttrValue->Uint(); + iMandAttrValue |= KProductIDMandFlag; + break; + default: + // This is an attribute we didn't request, + // or wrong type. + break; + } + break; + + default: + // This is an attribute we didn't request or wrong type. + break; + } + + break; + + default: + // We shouldn't get this state. + User::Panic(KBTHIDServer, EBadState); + break; + } + + // Ownership has been transferred + delete aAttrValue; + } + +void CHidSdpClient::AttributeRequestComplete( + TSdpServRecordHandle /*aHandle*/, TInt aError) + { + if (aError == KErrNone) + { + switch (iParserState) + { + // If this is supposed to be the HIDP Service Record. + case EHIDService: + // If we found all the attributes we requested. + if (iMandAttrValue == KHidServiceMandValue) + { + // Start a new sdp agent to request the BT Pnp + // Service Record. + delete iAgent; + iAgent = 0; + TRAPD( res, + iAgent = CSdpAgent::NewL(*this, iDevice.iAddress); + iSdpSearchPattern->Reset(); + iSdpSearchPattern->AddL(KPnPServiceUUID); + iAgent->SetRecordFilterL(*iSdpSearchPattern); + iAgent->NextRecordRequestL(); + iParserState = EBTPnPService; + ) + + // If we failed, inform the observer of the error. + if (res != KErrNone) + { + Finish(res); + } + } + else + { + // Not all attributes were found so inform the observer. + Finish(KErrNotFound); + } + break; + + // If this is supposed to be the BT PnP Service Record. + case EBTPnPService: + // If we found all the attributes we requested. + if (iMandAttrValue == KPnPServiceMandValue) + { + // Report success to the observer. + Finish(KErrNone); + } + else + { + // Not all attributes were found so inform the observer. + Finish(KErrNone); //We don't care if all info wasn't found! + } + break; + + default: + // We shouldn't get this state. + User::Panic(KBTHIDServer, EBadState); + break; + } + } + else + { + // Inform the observer of the error. + Finish(aError); + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/socketinitiator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/socketinitiator.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,237 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + +#include +#include "hiddebug.h" +#include "socketinitiator.h" +#include "sockinitnotifier.h" +#include "timeouttimer.h" +#include "bthidtypes.h" +#include "sockets.pan" +#include "debug.h" +// The transport protocol of the sockets used by this object. +_LIT(KTransportProtocol, "L2CAP"); + +// 60*2 seconds socket connect time-out (initially this was 10 seconds, but was changed due to end-user feedback) +const TInt CSocketInitiator::KTimeOut = 120000000; + +CSocketInitiator* CSocketInitiator::NewL(RSocketServ& aSocketServ, + MSockInitNotifier& aNotifier) + { + CSocketInitiator* self = NewLC(aSocketServ, aNotifier); + CleanupStack::Pop(self); + return self; + } + +CSocketInitiator* CSocketInitiator::NewLC(RSocketServ& aSocketServ, + MSockInitNotifier& aNotifier) + { + CSocketInitiator* self = new (ELeave) CSocketInitiator(aSocketServ, + aNotifier); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CSocketInitiator::CSocketInitiator(RSocketServ& aSocketServ, + MSockInitNotifier& aNotifier) : + CActive(CActive::EPriorityStandard), iSocketServ(aSocketServ), iNotifier( + aNotifier), iState(EIdle) + { + CActiveScheduler::Add(this); + } + +CSocketInitiator::~CSocketInitiator() + { + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::~CSocketInitiator()"))); + Cancel(); // Causes DoCancel + + delete iTimer; + } + +void CSocketInitiator::ConnectSocketsL(const TBTDevAddr& aAddress, + TBool aUseSecurity, RSocket* aControlSocket, + RSocket* aInterruptSocket) + { + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::ConnectSocketsL"))); + // Store the params for later + iControlSocket = aControlSocket; + iInterruptSocket = aInterruptSocket; + iUseSecurity = aUseSecurity; + + // First close the sockets + iControlSocket->Close(); + iInterruptSocket->Close(); + + // Try to open the sockets as L2CAP + User::LeaveIfError(iControlSocket->Open(iSocketServ, KTransportProtocol)); + User::LeaveIfError( + iInterruptSocket->Open(iSocketServ, KTransportProtocol)); + + iSockAddress.SetBTAddr(aAddress); + // First connect the control channel + iSockAddress.SetPort(KL2CAPHidControl); + + // Set security requirements for the Control channel. + TBTServiceSecurity sec; + sec.SetAuthentication(aUseSecurity); //Require authentication + sec.SetEncryption(aUseSecurity); //and encryption. + sec.SetAuthorisation(EFalse); //and authorisation (This not needed for out-going connections) + iSockAddress.SetSecurity(sec); + + // Start a timer to timeout the connect request + if (!iTimer->IsActive()) + iTimer->After(KTimeOut); + // Issue the connect request + iControlSocket->Connect(iSockAddress, iStatus); + // Update the connect state + iState = EConnectingControl; + +#ifdef __WINS__ + + User::After(1); // Fix to allow emulator client to connect to server +#endif + + // Start this active object + SetActive(); + } + +void CSocketInitiator::TimerExpired() + { + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::TimerExpired()"))); + // Cancel the operation in progress + Cancel(); + // Inform the observer of this object that a failure occurred + // due to a timeout + iNotifier.SocketsConnFailed(KErrTimedOut); + } + +void CSocketInitiator::ConstructL() + { + // Create a timer + iTimer = CTimeOutTimer::NewL(EPriorityStandard, *this); + } + +void CSocketInitiator::DoCancel() + { + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::DoCancel()"))); + + // Cancel appropriate request + switch (iState) + { + case EConnectingControl: + { + iControlSocket->CancelConnect(); + break; + } + case EConnectingInterrupt: + { + iInterruptSocket->CancelConnect(); + break; + } + default: + { + User::Panic(KPanicBTConnection, ESocketsBadStatus); + break; + } + } + + //Close the sockets + iInterruptSocket->Close(); + iControlSocket->Close(); + + // Set the connect state back to idle + iState = EIdle; + } + +void CSocketInitiator::RunL() + { + // Cancel any outstanding timer + iTimer->Cancel(); + + // Any error stops us dead. + if (iStatus != KErrNone) + { + //Close the sockets + iControlSocket->Close(); + iInterruptSocket->Close(); + + // Set the connect state back to idle + iState = EIdle; + // Inform the observer that a failure occurred + iNotifier.SocketsConnFailed(iStatus.Int()); + } + else + { + switch (iState) + { + case EConnectingControl: + { + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::RunL(): Control channel connection request"))); + ConnectInterruptSocket(); + } + break; + + case EConnectingInterrupt: + // L2CAP Interrupt channel connection request + // We are connected + // Set the connect state back to idle + { + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::RunL(): Interrupt channel connection request"))); + iState = EIdle; + // Inform the observer that connection is complete + iNotifier.SocketsConnected(); + break; + } + + default: + { + User::Panic(KPanicBTConnection, ESocketsBadState); + break; + } + + }; + } + } + +void CSocketInitiator::ConnectInterruptSocket() + { + // Connect the interrupt channel. + TRACE_INFO((_L("[BTHID]\tCSocketInitiator::ConnectInterruptSocket()"))); + ///for BT Stack v2.0, use authentication and encryption + TBTServiceSecurity sec; + sec.SetAuthentication(iUseSecurity); // 2nd L2cap channel should need no authentication. + sec.SetEncryption(iUseSecurity); // but we need encryption. + iSockAddress.SetSecurity(sec); + //// + iSockAddress.SetPort(KL2CAPHidInterrupt); + + // Start a timer to timeout the connect request + if (!iTimer->IsActive()) + iTimer->After(KTimeOut); + // Issue the connect request + iInterruptSocket->Connect(iSockAddress, iStatus); + // Update the connect state + iState = EConnectingInterrupt; + +#ifdef __WINS__ + + User::After(1); // Fix to allow emulator client to connect to server +#endif + + SetActive(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/socketlistener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/socketlistener.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + +#include +#include "socketlistener.h" +#include "listenerobserver.h" +#include "sockets.pan" +#include "bthidclientsrv.h" //for BT Stack v2 security +#include "bthidtypes.h" +#include +#include +#include "debug.h" +// The transport protocol of the sockets used by this object. +_LIT(KTransportProtocol, "L2CAP"); + +const TInt KListenQueueSize = 2; + +CSocketListener* CSocketListener::NewL(RSocketServ& aSocketServ, TUint aPort, + MListenerObserver& aObserver, TBool aAuthorisation) + { + CSocketListener* self = NewLC(aSocketServ, aPort, aObserver, + aAuthorisation); + CleanupStack::Pop(self); + return self; + } + +CSocketListener* CSocketListener::NewLC(RSocketServ& aSocketServ, + TUint aPort, MListenerObserver& aObserver, TBool aAuthorisation) + { + CSocketListener* self = new (ELeave) CSocketListener(aSocketServ, aPort, + aObserver, aAuthorisation); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CSocketListener::CSocketListener(RSocketServ& aSocketServ, TUint aPort, + MListenerObserver& aObserver, TBool aAuthorisation) : + CActive(CActive::EPriorityStandard), iSocketServer(aSocketServ), iPort( + aPort), iObserver(aObserver), iAuthorisationAskedFlag( + aAuthorisation) + { + CActiveScheduler::Add(this); + } + +CSocketListener::~CSocketListener() + { + TRACE_INFO((_L("[BTHID]\tCSocketListener::~CSocketListener()"))); + Cancel(); // Causes DoCancel + + // Close the listening socket + iListeningSocket.Close(); + } + +void CSocketListener::ConstructL() + { + TRACE_INFO((_L("[BTHID]\tCSocketListener::ConstructL()"))); + // Open the listening socket + User::LeaveIfError(iListeningSocket.Open(iSocketServer, + KTransportProtocol)); + TL2CAPSockAddr addr; + addr.SetPort(iPort); + TBTServiceSecurity serverSecurity; + serverSecurity.SetUid(KUidBTHidServer); + serverSecurity.SetAuthentication(ETrue); //Microsoft KB reconnect needs this!?? --> This line has caused IOP problems before. + serverSecurity.SetAuthorisation(iAuthorisationAskedFlag); //This should be according to Authorisation setting + serverSecurity.SetDenied(EFalse); + + //No need for Interrupt channel to use encryption + if (KL2CAPHidInterrupt == iPort) + serverSecurity.SetEncryption(EFalse); //Logitech Mx5000 needs this false. + else + serverSecurity.SetEncryption(ETrue); + + addr.SetSecurity(serverSecurity); + //Bind + User::LeaveIfError(iListeningSocket.Bind(addr)); + User::LeaveIfError(iListeningSocket.Listen(KListenQueueSize)); + + } + +void CSocketListener::DoCancel() + { + // Cancel any outstanding request + iListeningSocket.CancelAccept(); + } + +void CSocketListener::RunL() + { + TInt err = iStatus.Int(); + + TRACE_INFO((_L("[BTHID]\tCSocketListener::RunL(), iStatus.Int()=%d"),err)); + + if (err == KErrCancel) + return; //Active task was cancelled. + + // In case of KErrHardwareNotAvailable, cancel and reset the listening + // socket and reissue the Accept is needed. + if (err == KErrHardwareNotAvailable) + { + iListeningSocket.CancelAll(); + + err = iListeningSocket.Listen(KListenQueueSize); + + if (err == KErrNone) + { + iListeningSocket.Accept(*iAcceptSocket, iStatus); + SetActive(); + } + else + { + // Report the result to the observer. + iObserver.SocketAccepted(iPort, err); + } + } + else + { + // Report the result to the observer. + iObserver.SocketAccepted(iPort, err); + } + } + +TInt CSocketListener::AcceptConnection(RSocket& aSocket) + { + + TRACE_INFO((_L("[BTHID]\tCSocketListener::AcceptConnection()"))); + + // If we aren't in the correct state to accept, panic. + __ASSERT_DEBUG(!IsActive(), + User::Panic(KPanicBTConnection, ESocketsBadState)); + + // close old connection - if any + aSocket.Close(); + + // Open abstract socket + TInt err = aSocket.Open(iSocketServer); + + if (err == KErrNone) + { + + TRACE_INFO((_L("[BTHID]\tCSocketListener::AcceptConnection(), opening new socket succeed"))); + // Accept onto the new socket + iListeningSocket.Accept(aSocket, iStatus); + + // Keep a handle on the accept socket. + iAcceptSocket = &aSocket; + + SetActive(); + } + else + TRACE_INFO((_L("[BTHID]\tCSocketListener::AcceptConnection(), opening new socket failed"))); + + return err; + } + +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/socketreader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/socketreader.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "sockets.pan" +#include "socketreader.h" +#include "socketobserver.h" +#include "debug.h" + +CSocketReader* CSocketReader::NewL(TUint aSocketID, + MSocketObserver& aObserver, TInt aInitialBufSize) + { + CSocketReader* self = CSocketReader::NewLC(aSocketID, aObserver, + aInitialBufSize); + CleanupStack::Pop(self); + return self; + } + +CSocketReader* CSocketReader::NewLC(TUint aSocketID, + MSocketObserver& aObserver, TInt aInitialBufSize) + { + CSocketReader* self = new (ELeave) CSocketReader(aSocketID, aObserver); + CleanupStack::PushL(self); + self->ConstructL(aInitialBufSize); + return self; + } + +CSocketReader::CSocketReader(TUint aSocketID, MSocketObserver& aObserver) : + CActive(EPriorityStandard), iSocketID(aSocketID), iObserver(aObserver), + iBufferPtr(0, 0) + { + } + +CSocketReader::~CSocketReader() + { + Cancel(); // Causes DoCancel + + delete iBuffer; + } + +void CSocketReader::ConstructL(TInt aInitialBufSize) + { + iBuffer = HBufC8::NewL(aInitialBufSize); + iBufferPtr.Set(iBuffer->Des()); + + CActiveScheduler::Add(this); + } + +void CSocketReader::DoCancel() + { + // Cancel asynchronous read request + iSocket->CancelRead(); + } + +void CSocketReader::RunL() + { + // Active object request complete handler + TRACE_INFO((_L("CSocketReader::RunL(), iStatus.Int()=%d, socketID=%d"),iStatus.Int(), iSocketID)); + + switch (iStatus.Int()) + { + case KErrNone: + { + // Data has been read from socket + // Inform the observer and issue another read if we want + // to continue listening + if (iObserver.HandleDataReceived(iSocketID, iBufferPtr)) + { + IssueRead(); + } + break; + } + + default: + { + // A read error has occurred. Inform the observer the connection is lost + iObserver.HandleSocketError(iSocketID, ETrue, iStatus.Int()); + break; + } + } + } + +void CSocketReader::IssueRead() + { + // Initiate a new read from socket into iBuffer + iSocket->Read(iBufferPtr, iStatus); + SetActive(); + } + +void CSocketReader::StartReadingL(RSocket* aSocket, TInt aMTU) + { + // Initiate a new read from socket into iBuffer + __ASSERT_DEBUG(!IsActive(), + User::Panic(KPanicSocketsEngineRead, ESocketsBadState)); + + if (aMTU > iBufferPtr.MaxLength()) + { + // Realloc the buffer as it isn't large enough. + iBufferPtr.Set(0, 0, 0); + delete iBuffer; + iBuffer = 0; + iBuffer = HBufC8::NewL(aMTU); + iBufferPtr.Set(iBuffer->Des()); + } + + iSocket = aSocket; + IssueRead(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/bthidserver/src/socketwriter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/bthidserver/src/socketwriter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "sockets.pan" +#include "socketwriter.h" +#include "socketobserver.h" +#include "timeouttimer.h" + +// ---------------------------------------------------------------------- + +// Initial size of the buffers for data to write +const TInt KWriteBufferInitialSize = 20; + +// 5 seconds socket write time-out +const TInt CSocketWriter::KTimeOut = 5000000; + +CSocketWriter* CSocketWriter::NewL(TUint aSocketID, + MSocketObserver& aObserver) + { + CSocketWriter* self = CSocketWriter::NewLC(aSocketID, aObserver); + CleanupStack::Pop(self); + return self; + } + +CSocketWriter* CSocketWriter::NewLC(TUint aSocketID, + MSocketObserver& aObserver) + { + CSocketWriter* self = new (ELeave) CSocketWriter(aSocketID, aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CSocketWriter::CSocketWriter(TUint aSocketID, MSocketObserver& aObserver) : + CActive(EPriorityStandard), iSocketID(aSocketID), iObserver(aObserver) + { + } + +CSocketWriter::~CSocketWriter() + { + Cancel(); + delete iTimer; + delete iWriteBuffer[0]; + delete iWriteBuffer[1]; + } + +void CSocketWriter::DoCancel() + { + // Cancel asynchronous write request + iSocket->CancelWrite(); + + iTimer->Cancel(); + + // Clear the buffers + *iWriteBuffer[0] = KNullDesC8; + *iWriteBuffer[1] = KNullDesC8; + } + +void CSocketWriter::ConstructL() + { + CActiveScheduler::Add(this); + + iTimer = CTimeOutTimer::NewL(CActive::EPriorityStandard, *this); + + iWriteBuffer[0] = HBufC8::NewL(KWriteBufferInitialSize); + iWriteBuffer[1] = HBufC8::NewL(KWriteBufferInitialSize); + iCurrentBuffer = 0; + } + +void CSocketWriter::TimerExpired() + { + Cancel(); + + // Clear the buffers + *iWriteBuffer[0] = KNullDesC8; + *iWriteBuffer[1] = KNullDesC8; + + iObserver.HandleSocketError(iSocketID, EFalse, KErrTimedOut); + } + +void CSocketWriter::RunL() + { + iTimer->Cancel(); + + // Remember the current status + TInt status = iStatus.Int(); + + // Clear the buffer that has been written + *iWriteBuffer[iCurrentBuffer] = KNullDesC8; + + // If the other buffer has data, write it now + if (iWriteBuffer[1 - iCurrentBuffer]->Length() > 0) + { + iCurrentBuffer = 1 - iCurrentBuffer; + DoWrite(); + } + + // Handle status of completed write + if (KErrNone == status) + { + iObserver.HandleWriteComplete(iSocketID); + } + else + { + // Error: pass it up to user interface + iObserver.HandleSocketError(iSocketID, EFalse, status); + } + } + +void CSocketWriter::Initialise(RSocket* aSocket) + { + __ASSERT_ALWAYS(!IsActive(), + User::Panic(KPanicSocketsEngineWrite, ESocketsBadState)); + + iSocket = aSocket; + } + +void CSocketWriter::IssueWriteL(const TDesC8& aData) + { + if (IsActive()) + { + // Put the data in the other buffer + StoreDataL(aData, 1 - iCurrentBuffer); + } + else + { + // Put the data in the current buffer and write immediately + StoreDataL(aData, iCurrentBuffer); + DoWrite(); + } + } + +void CSocketWriter::DoWrite() + { + // If we aren't in the correct state for a write, panic. + __ASSERT_ALWAYS(!IsActive(), + User::Panic(KPanicSocketsEngineWrite, ESocketsBadState)); + + // Initiate actual write + iSocket->Write(*iWriteBuffer[iCurrentBuffer], iStatus); + + // Request timeout + if (!iTimer->IsActive()) + iTimer->After(KTimeOut); + + SetActive(); + } + +void CSocketWriter::StoreDataL(const TDesC8& aData, TInt aBuffer) + { + __ASSERT_ALWAYS(iWriteBuffer[aBuffer]->Length() == 0, + User::Panic(KPanicSocketsEngineWrite, ESocketsBadState)); + + // Reallocate the buffer if it's too small + if (aData.Length() > iWriteBuffer[aBuffer]->Des().MaxLength()) + { + // Make sure we have a new buffer before deleting the old one + HBufC8* newBuffer = HBufC8::NewL(aData.Length()); + + delete iWriteBuffer[aBuffer]; + iWriteBuffer[aBuffer] = newBuffer; + } + + *iWriteBuffer[aBuffer] = aData; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/btkeyboard_backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/btkeyboard_backup_registration.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/bthidPsKey.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/bthidPsKey.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2004-2006 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: +* +* +*/ + + +#ifndef BTHIDPSKEY_H_ +#define BTHIDPSKEY_H_ + +const TUid KPSUidBthidSrv = {0x2001E301}; + +const TUint KBTMouseCursorState = 0x00000001; + +enum THidMouseCursorState + { + ECursorNotInitialized = 0, + ECursorShow = 1, + ECursorHide = 2 + }; + +#endif /* BTHIDPSKEY_H_ */ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/bthidcenrepwatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/bthidcenrepwatcher.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2006 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: + * This class handles CenRep notifications + * +*/ + + +#ifndef BTHIDCENREPWATCHER_H +#define BTHIDCENREPWATCHER_H + +// INCLUDES +#include +#include + +// CLASS DECLARATION + +class MBtHidCenRepObserver + { +public: + virtual void CenRepDataChanged(TUid& aUid, TUint32 aKey) = 0; + }; + +class CRepository; +class CTimeOutTimer; + +/** + * The class to handle CenRep notifications + */ +NONSHARABLE_CLASS(CBtHidCenRepWatcher) : public CBase, + public MCenRepNotifyHandlerCallback + { +public: + // Constructors and destructor + + /** + * Two-phased constructor. + * @param aUid The Uid of the repository we want to use. + * @param aObserver The parent who is interested in relevant CenRep changes + */ + static CBtHidCenRepWatcher* NewL(TUid aUid, + MBtHidCenRepObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBtHidCenRepWatcher(); + +protected: + // From MCenRepNotifyHandlerCallback + + /** + * This callback method is used to notify the client about + * changes in keys when the whole repository is listened for. + * + * Note: It is not guaranteed that a notification will be received + * for all keys, if multiple keys are changed in rapid succession + * by multiple threads or when the whole repository is reset, + * therefore only listen for whole repository if this is not an issue. + * + * @param aId Id of the key that has changed. If multiple keys were changed by + * whole repository reset, value will be KInvalidNotificationId. + */ + void HandleNotifyGeneric(TUint32 aId); + + /** + * This callback method is used to notify the client about errors + * in the handler. Any error in handling causes the handler to stop + * handling any more notifications. Handling can be restarted with + * a call to aHandler->StartListeningL(), if the error is non-fatal. + * However, be careful to trap any errors from this call if this is done. + * + * @param aId Id of the key this instance listens for or if notifications for + * whole repository are listened, could also be KInvalidNotificationId. + * @param aError Error code. + * @param aHandler Pointer to the handler instance. + * This pointer can be used to identify the handler or restart the listening. + */ + void HandleNotifyError(TUint32 aId, TInt aError, + CCenRepNotifyHandler* aHandler); + +public: + // New functions + + /** + * Disable notifications + */ + void DisableNotifications(); + + /** + * Enable notifications + */ + void EnableNotifications(); + +private: + + /** + * Constructor + * @param aUid The Uid of the repository. + * @param aObserver The instance which receives interested CenRep changes + */ + CBtHidCenRepWatcher(TUid aUid, MBtHidCenRepObserver& aObserver); + + /** + * 2nd phase constructor + * @param aUid The Uid of the repository. + */ + void ConstructL(); + +private: + // DATA + CCenRepNotifyHandler* iNotifier; + CRepository* iSession; + TUid iUid; + MBtHidCenRepObserver& iObserver; + TBool iNotificationsEnabled; + }; + +#endif // BTHIDCENREPWATCHER_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/bthidpskeywatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/bthidpskeywatcher.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2004-2006 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: +* +* +*/ + + +#ifndef BTHIDPSKEYWATCHER_H_ +#define BTHIDPSKEYWATCHER_H_ +// INCLUDES +#include +#include + +class MMouseCursorStatusObserver; + +/* +* An abstarct interface that defines a callback method +* for the hid mouse cursor observer. CursorStatusChangedL +* is called by CBTMouseCursorStatusObserver when the mouse device +* connection state has changed. aStatus represents the new status +* value. +*/ +class MMouseCursorStatusObserver + { + public: + virtual void MouseCursorStatusChangedL(TInt aStatus) = 0; + }; + +/* +* An observer that monitors KPSUidBluetoothSapConnectionState +* P&S key. The clients can call SubscribeCursorStatusL in order to +* get a chenged new SAP connection status returned via +* MSapStatusObserver::SapStatusChangedL. +*/ +class CBTMouseCursorStatusObserver : public CActive + { +public: + /** + * Two-phased constructor. + */ + static CBTMouseCursorStatusObserver* NewL(); + /** + * Destructor. + */ + virtual ~CBTMouseCursorStatusObserver(); + + /** + * Starts listening KPSUidBluetoothSapConnectionState P&S key. + * When the key value is changed, the new state is indicated + * through the observer interface (MSapStatusObserver). + */ + void SubscribeMouseCursorStatusL(MMouseCursorStatusObserver* aObserver); + +private: + /** + * Two-Phase constructor + */ + void ConstructL(); + + /** + * Default constructor + */ + CBTMouseCursorStatusObserver(); + + // From CActive + virtual void DoCancel(); + virtual void RunL(); + +private: + MMouseCursorStatusObserver* iObserver; + RProperty iProperty; + }; + + +#endif /* BTHIDPSKEYWATCHER_H_ */ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/genericclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/genericclient.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __GENERICCLIENT_H__ +#define __GENERICCLIENT_H__ + +#ifndef DBG + +#ifdef _DEBUG +#define DBG(a) a +#include +#else +#define DBG(a) +#endif + +#endif + +#include + +// ---------------------------------------------------------------------- + +/* + * Base class for client-side sessions for all servers. + */ +class RGenericSession : public RSessionBase + { +protected: + // Create a new session with the server, creating the server if necessary + TInt StartSession(const TDesC& aServer, const TVersion& aVersion, + const TDesC& aFilename, const TUidType& aUid, + TInt aAsyncMessageSlots); + +private: + // Load and start the server + TInt CreateServer(const TDesC& aServer, const TDesC& aFilename, + const TUidType& aUid); + }; + +#endif // __GENERICCLIENT_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/genericserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/genericserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __GENERICSERVER_H__ +#define __GENERICSERVER_H__ + +#include +#include + +// ---------------------------------------------------------------------- + +/* + * Information passed to the server to allow it to signal the client. + */ +struct TStartupRequest + { + inline TStartupRequest(); + inline TStartupRequest(TRequestStatus* status, TThreadId id); + + /** Request status to be signalled when the server has started */ + TRequestStatus* iStatus; + /** ID of the client's thread */ + TThreadId iId; + }; + +const TInt KStartupTextLength = sizeof(TStartupRequest) / sizeof(TText); + +// ---------------------------------------------------------------------- + +/* + * Base class for all servers. + */ +class CGenericServer : public CPolicyServer + + { +public: + /** + * Extract the client startup information from the command line passed + * to the server process. + * @param startup Structure to receive the client information. + * @return TInt KErrNone if successful. + */ + static TInt GetStartupFromCommandLine(TStartupRequest& startup); + +protected: + // Constructor + CGenericServer(TInt aPriority); + // Signal the client that server startup has finished + static void SignalStartup(TStartupRequest* startup, TInt aReason); + }; + +// ---------------------------------------------------------------------- + +inline TStartupRequest::TStartupRequest() : + iStatus(NULL), iId(0) + { + } + +inline TStartupRequest::TStartupRequest(TRequestStatus* status, TThreadId id) : + iStatus(status), iId(id) + { + } + +#endif // __GENERICSERVER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/genericserversecuritypolicy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/genericserversecuritypolicy.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +/** + @file + */ +#ifndef __GENERICSERVERSECURITYPOLICY_H__ +#define __GENERICSERVERSECURITYPOLICY_H__ + +const TUint KGenericServerRangeCount = 2; //16; + +const TInt KGenericServerRanges[KGenericServerRangeCount] = + { + 0, 16 + }; +/* + EGenericCreateHostResolverSubSession, // 0 = Alway fail + EGenericCreateRegistrySubSession, // 1 = Local Services + EGenericRegistrySearch, // 2 = Always pass + EBTRegistryRetrieveDevice, // 3 = Always fail + EBTRegistryAddDevice, // 4 = Always pass + EBTRegistryModifyBluetoothName, // 5 = Write Device Data + EBTRegistryModifyFriendlyName, // 6 = Always pass + EBTRegistryModifyNamelessDevice, // 7 = Write Device Data + EBTRegistryDeleteDevices, // 8 = Always pass + EBTRegistryDeleteLinkKey, // 9 = Write Device Data + EBTRegistryCloseView, // 10 = Always pass + EBTRegistryUpdateLocalDevice, // 11 = Write Device Data + EBTRegistryGetCommPortSettings, // 12 = Always pass + EBTHostResolverDeviceRequest, // 13 = Always fail + EGenericSetHeapFailure, // 14 = Local Services + // If new function enums are added, the following value needs to + // increase to be + 1. + // This defines a final range that extends from the first invalid + // function number to KMaxTInt, and protects against attempts to + // attack the server with invalid functions. + + EGenericSubSessionCount+1 // 15 = CPolicyServer::ENotSupported for all other fns. + }; + */ + +/** Index numbers into KGenericServerElements[] */ +const TInt KPolicyAlwaysFail = 0; +const TInt KPolicyLocalServices = 1; +const TInt KPolicyAlwaysPass = 2; +const TInt KPolicyWriteDeviceData = 3; + +/**Mapping IPCs to policy element */ +const TUint8 KGenericServerElementsIndex[KGenericServerRangeCount] = + { + KPolicyAlwaysPass, KPolicyAlwaysPass + + // KPolicyAlwaysFail, /** EGenericCreateHostResolverSubSession */ + // KPolicyLocalServices, /** EGenericCreateRegistrySubSession */ + /** EGenericCreateCommPortSettingsSubSession */ + /** EGenericCreateLocalDeviceSubSession */ + // KPolicyAlwaysPass, /** EGenericRegistrySearch */ + /** EGenericExtractRegistryDataIntoServer */ + /** EGenericRetrieveRegistryData */ + /** EGenericCloseSubSession */ + /** EGenericCancelRequest */ + // KPolicyAlwaysFail, /** EBTRegistryRetrieveDevice */ + // KPolicyAlwaysPass, /** EBTRegistryAddDevice */ + /** EBTRegistryGetNamelessDevice */ + // KPolicyWriteDeviceData, /** EBTRegistryModifyBluetoothName */ + // KPolicyAlwaysPass, /** EBTRegistryModifyFriendlyName */ + // KPolicyWriteDeviceData, /** EBTRegistryModifyNamelessDevice */ + // KPolicyAlwaysPass, /** EBTRegistryDeleteDevices */ + // KPolicyWriteDeviceData, /** EBTRegistryDeleteLinkKey */ + /** EBTRegistryUnpairView */ + // KPolicyAlwaysPass, /** EBTRegistryCloseView */ + /** EBTRegistryGetLocalDevice */ + // KPolicyWriteDeviceData, /** EBTRegistryUpdateLocalDevice */ + // KPolicyAlwaysPass, /** EBTRegistryGetCommPortSettings */ + /** EBTRegistryUpdateCommPortSettings */ + /** EBTRegistryDeleteCommPortSettings */ + // KPolicyAlwaysFail, /** EBTHostResolverDeviceRequest */ + /** EBTHostResolverGetNextDeviceRequest */ + /** EBTHostResolverDeviceModifyDevice */ + /** EBTHostResolverNotifyRequest */ + // KPolicyLocalServices, /** EGenericSetHeapFailure */ + /** EGenericSubSessionCount */ + // CPolicyServer::ENotSupported /** EGenericCreateSecManSubSession */ + /** EGenericCreateSecuritySettingsSubSession */ + /** EGenericCreateBasebandSecuritySubSession */ + /** EBTSecManAccessRequest */ + /** EBTSecuritySettingsRegister */ + /** EBTSecuritySettingsUnregister */ + /** EBTBasebandSecurityLinkKeyRequest */ + /** EBTBasebandSecurityNewLinkKey */ + /** EBTBasebandSecurityPinRequest */ + /** EBTBasebandSecurityNewLinkState */ + /** EBTBasebandSecurityHCIRequestHandler */ + /** EBTBasebandSecurityNameRequestResponse */ + /** ...and onwards to KMaxTInt */ + }; + +/** Individual policy elements */ +const CPolicyServer::TPolicyElement KGenericServerElements[] = + { + /** the EFailClient means that the if the check fails the CheckFailed method with return KErrPermissionDenied */ + { + _INIT_SECURITY_POLICY_FAIL + }, /** policyAlwaysFail */ + { + _INIT_SECURITY_POLICY_C1(ECapabilityLocalServices), + CPolicyServer::EFailClient + }, /** policyLocalService */ + { + _INIT_SECURITY_POLICY_PASS + }, /** policyAlwaysPass */ + { + _INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), + CPolicyServer::EFailClient + } /** policyWriteDevData */ + }; + +/** Main policy */ +const CPolicyServer::TPolicy KGenericServerPolicy = + { + CPolicyServer::EAlwaysPass, /** Specifies all connect attempts should pass */ + KGenericServerRangeCount, + KGenericServerRanges, + KGenericServerElementsIndex, + KGenericServerElements, + }; + +#endif //__GENERICSERVERSECURITYPOLICY_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/hiddebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/hiddebug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2008 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: This header file contains debug macro declarations + * +*/ + + +#ifndef BTHIDDEBUG_H +#define BTHIDDEBUG_H + +//#include + +// MACROS +#ifdef _DEBUG +#define DBG(a) a +#define DEBUG_PRINT(a) RDebug::Print(a) +#define DEBUG_PRINTF(a,b) RDebug::Print(a,b) +#define DEBUG_PRINTF2(a,b,c) RDebug::Print(a,b,c) +#else +#define DBG(a) +#define DEBUG_PRINT(a) +#define DEBUG_PRINTF(a,b) +#define DEBUG_PRINTF2(a,b,c) +#endif + +#endif // BTHIDDEBUG_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/layoututils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/layoututils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2008 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: + * +*/ + + +#ifndef __LAYOUTUTILS_H__ +#define __LAYOUTUTILS_H__ + +#include +#include "hidlayoutids.h" + +/*! + Utility class providing static function for keyboard layout + code manipulation. + */ +class CLayoutUtils : public CBase + { +public: + /*! + Return a position in the list of standard layout codes for a given + layout. + @param aLayoutId A Standard layout code. + @result The index of the layout. + */ + static TInt IndexFromStandardLayout(THidKeyboardLayoutId aLayoutId); + + /*! + Return a position in the list of nokia layout codes for a given + layout. + @param aLayoutId A Nokia layout code. + @result The index of the layout. + */ + static TInt IndexFromNokiaLayout(THidKeyboardLayoutId aLayoutId); + + /*! + Return a layout code for a given index in the list of standard layout + codes. + @param aIndex The index of the layout. + @result A Standard layout code. + */ + static THidKeyboardLayoutId StandardLayoutFromIndex(TInt aIndex); + + /*! + Return a layout code for a given index in the list of nokia layout + codes. + @param aIndex The index of the layout. + @result A Standard layout code. + */ + static THidKeyboardLayoutId NokiaLayoutFromIndex(TInt aIndex); + + /*! + Ensures a given layout is a valid standard layout. If it is not + then a default standard value is given. + @param aLayoutId A Standard layout code. + */ + static void ValidateStandardLayout(THidKeyboardLayoutId& aLayoutId); + + /*! + Ensures a given layout is a valid Nokia Su8 layout. If it is not + then a default Nokia Su8 value is given. + @param aLayoutId A Nokia Su8 layout code. + */ + static void ValidateNokiaSU8Layout(THidKeyboardLayoutId& aLayoutId); + + /*! + Identify the layout selected resource string for the given layout. + @param aLayoutCode The layout code of the string to return. + */ + static TInt LayoutConfirmationStringL(THidKeyboardLayoutId aLayoutCode); + + /*! + Identify the initialed layout ID belongs to same group than the layout ID in CenRep + @param aInitialLayoutCode the initialed layout ID. + @param aLayoutCode the layout ID in CenRep. + @return ETrue when IDs are in the same group ETrue, otherwise EFalse + */ + static TBool SameCategory(THidKeyboardLayoutId aInitialLayoutCode, + THidKeyboardLayoutId aLayoutCode); + }; + +#endif // __LAYOUTUTILS_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/timeoutnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/timeoutnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef _TIMEOUTNOTIFIER_H_ +#define _TIMEOUTNOTIFIER_H_ + +/*! + This class specifies the function to be called when a timeout occurs. + Used in conjunction with CTimeOutTimer class + */ +class MTimeOutNotifier + { +public: + /*! + The function to be called when a timeout occurs. + */ + virtual void TimerExpired() = 0; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/inc/timeouttimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/inc/timeouttimer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + +#ifndef __TIMEOUTTIMER_H__ +#define __TIMEOUTTIMER_H__ +#include +// ---------------------------------------------------------------------- +// Panics: +// Category: +_LIT(KTimeOutTimerPanic, "TimeOutTimer"); + +// Codes: +enum TTimeOutTimerPanic + { + ETimerFailed = 1 + }; + +// ---------------------------------------------------------------------- + +class MTimeOutNotifier; + +/*! + This class will notify an object after a specified timeout. + */ +class CTimeOutTimer : public CTimer + { +public: + /*! + Create a CTimeOutTimer object + @param aPriority priority to use for this timer + @param aTimeOutNotify object to notify of timeout event + @result A pointer to the created instance of CTimeOutTimer + */ + static CTimeOutTimer* NewL(const TInt aPriority, + MTimeOutNotifier& aTimeOutNotify); + + /*! + Create a CTimeOutTimer object + @param aPriority priority to use for this timer + @param aTimeOutNotify object to notify of timeout event + @result A pointer to the created instance of CTimeOutTimer + */ + static CTimeOutTimer* NewLC(const TInt aPriority, + MTimeOutNotifier& aTimeOutNotify); + + /*! + Destroy the object and release all memory objects + */ + ~CTimeOutTimer(); + +protected: + // From CTimer + /*! + Invoked when a timeout occurs + */ + virtual void RunL(); + +private: + /*! + Perform the first phase of two phase construction + @param aPriority priority to use for this timer + @param aTimeOutNotify An observer to notify + */ + CTimeOutTimer(const TInt aPriority, MTimeOutNotifier& aTimeOutNotify); + + /*! + Perform the second phase construction of a CTimeOutTimer + */ + void ConstructL(); + +private: + // Member variables + + /*! The observer for this objects events */ + MTimeOutNotifier& iNotify; + }; + +#endif // __TIMEOUTTIMER_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/src/bthidcenrepwatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/src/bthidcenrepwatcher.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2006 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: + * This class handles intereted CenRep notification. + * +*/ + + +// INCLUDE FILES +#include +#include "bthidcenrepwatcher.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CBtHidCenRepWatcher::NewL +// --------------------------------------------------------- +// +CBtHidCenRepWatcher* CBtHidCenRepWatcher::NewL(TUid aUid, + MBtHidCenRepObserver& aObserver) + { + CBtHidCenRepWatcher* self = new (ELeave) CBtHidCenRepWatcher(aUid, + aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBtHidCenRepWatcher::~CBtHidCenRepWatcher +// --------------------------------------------------------- +// +CBtHidCenRepWatcher::~CBtHidCenRepWatcher() + { + TRACE_INFO((_L("[BTHID]\t CBtHidCenRepWatcher[0x%08x]::~CBtHidCenRepWatcher >>"),this)); + if (iNotifier) + { + iNotifier->StopListening(); + } + delete iNotifier; + delete iSession; + TRACE_INFO(_L("[BTHID]\t CBtHidCenRepWatcher::~CBtHidCenRepWatcher <<")); + } + +// --------------------------------------------------------- +// CBtHidCenRepWatcher::CBtHidCenRepWatcher +// C++ default constructor can NOT contain any code that +// might leave. +// --------------------------------------------------------- +// +CBtHidCenRepWatcher::CBtHidCenRepWatcher(TUid aUid, + MBtHidCenRepObserver& aObserver) : + iUid(aUid), iObserver(aObserver) + { + } + +// --------------------------------------------------------- +// CBtHidCenRepWatcher::ConstructL +// --------------------------------------------------------- +// +void CBtHidCenRepWatcher::ConstructL() + { + TRACE_INFO((_L("[BTHID]\t CBtHidCenRepWatcher[0x%08x]::ConstructL: Uid: 0x%08x"), this, iUid.iUid)); + iNotificationsEnabled = ETrue; + iSession = CRepository::NewL(iUid); + iNotifier = CCenRepNotifyHandler::NewL(*this, *iSession); + iNotifier->StartListeningL(); + TRACE_INFO ((_L("[BTHID]\t CBtHidCenRepWatcher[0x%08x]::ConstructL, END"),this)); + } + +// --------------------------------------------------------- +// CBtHidCenRepWatcher::HandleNotifyGeneric +// +// --------------------------------------------------------- +// +void CBtHidCenRepWatcher::HandleNotifyGeneric(TUint32 aId) + { + TRACE_INFO((_L("[BTHID]\t CBtHidCenRepWatcher[0x%08x]::HandleNotifyGeneric"),this)); + if (iNotificationsEnabled) + iObserver.CenRepDataChanged(iUid, aId); + } + +// --------------------------------------------------------- +// CBtHidCenRepWatcher::HandleNotifyError +// --------------------------------------------------------- +// +void CBtHidCenRepWatcher::HandleNotifyError(TUint32 /*aId*/, TInt /*error*/, + CCenRepNotifyHandler* /*aHandler*/) + { + TRACE_INFO((_L("[BTHID]\t CBtHidCenRepWatcher[0x%08x]::HandleNotifyError"),this)); + iNotifier->StopListening(); + } + +// ----------------------------------------------------------------------------- +// CBtHidCenRepWatcher::DisableNotifications +// ----------------------------------------------------------------------------- +// +void CBtHidCenRepWatcher::DisableNotifications() + { + TRACE_INFO((_L("[BTHID]\t CBtHidCenRepWatcher::DisableNotifications"))); + iNotificationsEnabled = EFalse; + } + +// ----------------------------------------------------------------------------- +// CBtHidCenRepWatcher::EnableNotifications +// ----------------------------------------------------------------------------- +// +void CBtHidCenRepWatcher::EnableNotifications() + { + TRACE_INFO((_L("[BTHID]\t CBtHidCenRepWatcher::EnableNotifications"))); + iNotificationsEnabled = ETrue; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/src/bthidpskeywatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/src/bthidpskeywatcher.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2004-2006 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 FILES +#include +#include "bthidpskeywatcher.h" +#include "bthidPsKey.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::CBTMouseCursorStatusObserver() +//---------------------------------------------------------- +// +CBTMouseCursorStatusObserver::CBTMouseCursorStatusObserver(): CActive(CActive::EPriorityStandard) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::NewL() +//---------------------------------------------------------- +// +CBTMouseCursorStatusObserver* CBTMouseCursorStatusObserver::NewL() + { + CBTMouseCursorStatusObserver* self = new(ELeave) CBTMouseCursorStatusObserver(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::ConstructL() +//---------------------------------------------------------- +// +void CBTMouseCursorStatusObserver::ConstructL() + { + + User::LeaveIfError(iProperty.Attach( KPSUidBthidSrv, KBTMouseCursorState)); + } + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::~CBTMouseCursorStatusObserver +//---------------------------------------------------------- +// +CBTMouseCursorStatusObserver::~CBTMouseCursorStatusObserver() + { + Cancel(); + iProperty.Close(); + } + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::StartObservingL() +//---------------------------------------------------------- +// +void CBTMouseCursorStatusObserver::SubscribeMouseCursorStatusL(MMouseCursorStatusObserver* aObserver) + { + + ASSERT(aObserver); + + iObserver = aObserver; + + iProperty.Subscribe(iStatus); + SetActive(); + } + + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::DoCancel() +// --------------------------------------------------------- +// +void CBTMouseCursorStatusObserver::DoCancel() + { + iProperty.Cancel(); + } + +// --------------------------------------------------------- +// CBTMouseCursorStatusObserver::RunL() +// --------------------------------------------------------- +// +void CBTMouseCursorStatusObserver::RunL() + { + + TInt btMouseCursorState = ECursorNotInitialized; + TInt err = iStatus.Int(); + + if (err == KErrNotFound) + { + // someone deleted the P&S key - this is ok as we on error + // set the cursor to not initialized. + err = KErrNone; + } + + iProperty.Subscribe(iStatus); + SetActive(); + + if (err == KErrNone) + { + err = iProperty.Get(btMouseCursorState); + if (err == KErrNotFound) + { + // probably no longer present, so set to not initialized. + btMouseCursorState = ECursorNotInitialized; + err = KErrNone; + } + if(err == KErrNone) + { + iObserver->MouseCursorStatusChangedL(btMouseCursorState); + } + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/src/genericclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/src/genericclient.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include + +#include "genericclient.h" +#include "genericserver.h" + +// ---------------------------------------------------------------------- + +TInt RGenericSession::StartSession(const TDesC& aServer, + const TVersion& aVersion, const TDesC& aFilename, + const TUidType& aUid, TInt aAsyncMessageSlots) + { + // The server may be running already, so try connecting immediately + TInt error = CreateSession(aServer, aVersion, aAsyncMessageSlots); + + if (KErrNone != error) + { + // Failed to connect so create a new server instance and try again. + // If creating the server fails, it may be due to another client + // creating a server in the meantime, so ignore any error here. + DBG(RDebug::Print(_L("RGenericSession::StartSession(): calling CreateServer()..."))); + CreateServer(aServer, aFilename, aUid); + DBG(RDebug::Print(_L("RGenericSession::StartSession(): calling CreateSession()..."))); + error = CreateSession(aServer, aVersion, aAsyncMessageSlots); + } + + DBG(RDebug::Print(_L("RGenericSession::StartSession(): returning %d"),error)); + + return error; + } + +TInt RGenericSession::CreateServer(const TDesC& /*aServer*/, + const TDesC& aFilename, const TUidType& aUid) + { + TInt result; + TRequestStatus startup = KRequestPending; + TStartupRequest startupRequest(&startup, RThread().Id()); + + RProcess server; + TPtrC startupPtr(reinterpret_cast (&startupRequest), + KStartupTextLength); + + DBG(RDebug::Print(_L("RGenericSession::CreateServer(): calling server.Create()"))); + result = server.Create(aFilename, startupPtr, aUid); + + DBG(RDebug::Print(_L("RGenericSession::CreateServer(): server.Create() result: %d"),result)); + + if (KErrNone == result) + { + TRequestStatus stat; + server.Rendezvous(stat); + if (stat != KRequestPending) + { + DBG(RDebug::Print(_L("RGenericSession::CreateServer(): __SECURE_API__ ClientStart, stat != KRequestPending, Kill process "))); + server.Kill(0); // abort startup + } + else + { + DBG(RDebug::Print(_L("RGenericSession::CreateServer(): __SECURE_API__ ClientStart, logon OK - start the server "))); + server.Resume(); // logon OK - start the server + } + User::WaitForRequest(stat); // wait for start or death + // we can't use the 'exit reason' if the server panicked as this + // is the panic 'reason' and may be '0' which cannot be distinguished + // from KErrNone + result = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); + DBG(RDebug::Print(_L("RGenericSession::CreateServer(): __SECURE_API__ ClientStart, server exit result: %d"),result)); + + server.Close(); + } + + return result; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/src/genericserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/src/genericserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "genericserver.h" + +// ---------------------------------------------------------------------- +#include "genericserversecuritypolicy.h" +CGenericServer::CGenericServer(TInt aPriority) : /*CServer2(aPriority),*/ + CPolicyServer(/*EPriorityStandard*/aPriority, KGenericServerPolicy, + ESharableSessions) + { + } + +TInt CGenericServer::GetStartupFromCommandLine(TStartupRequest& startup) + { + + // Check the command line is the expected length + if (User::CommandLineLength() == KStartupTextLength) + { + // Copy the data to the supplied structure + TPtr ptr(reinterpret_cast (&startup), KStartupTextLength); + User::CommandLine(ptr); + return KErrNone; + } + + return KErrGeneral; + } + +void CGenericServer::SignalStartup(TStartupRequest* startup, TInt aReason) + { + RThread client; + + // Open a handle to the client's thread + if (startup && KErrNone == client.Open(startup->iId)) + { + // Signal the client + client.RequestComplete(startup->iStatus, aReason); + client.Close(); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/src/layoututils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/src/layoututils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,305 @@ +/* +* Copyright (c) 2004 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 "layoututils.h" + +TInt CLayoutUtils::IndexFromStandardLayout(THidKeyboardLayoutId aLayoutId) + { + TInt returnValue = 0; + // Map from layout code to item index position. + switch (aLayoutId) + { + case EUnitedKingdom: + returnValue = 0; + break; + case EUnitedStates: + returnValue = 1; + break; + case EUSInternational: + returnValue = 2; + break; + case EBelgian: + returnValue = 3; + break; + case EDanish: + returnValue = 4; + break; + case EDutch: + returnValue = 5; + break; + case EFinnishSwedish: + returnValue = 6; + break; + case EFrench: + returnValue = 7; + break; + case EGerman: + returnValue = 8; + break; + case EItalian: + returnValue = 9; + break; + case ENorwegian: + returnValue = 10; + break; + case EPortuguese: + returnValue = 11; + break; + case ESpanish: + returnValue = 12; + break; + case EUnitedStatesDvorak: + returnValue = 13; + break; + default: + break; + } + + return returnValue; + } + +TInt CLayoutUtils::IndexFromNokiaLayout(THidKeyboardLayoutId aLayoutId) + { + TInt returnValue = 0; + // Map from layout code to item index position. + switch (aLayoutId) + { + case ESu8USEnglish: + returnValue = 0; + break; + case ESu8FinnishSwedish: + returnValue = 1; + break; + case ESu8German: + returnValue = 2; + break; + case ESu8DanishNorwegian: + returnValue = 3; + break; + case ESu8Russian: + returnValue = 4; + break; + default: + break; + } + + return returnValue; + } + +THidKeyboardLayoutId CLayoutUtils::StandardLayoutFromIndex(TInt aIndex) + { + THidKeyboardLayoutId layoutCode = EUnitedKingdom; + + // Map it back from item index position to layout code. + switch (aIndex) + { + case 0: + layoutCode = EUnitedKingdom; + break; + case 1: + layoutCode = EUnitedStates; + break; + case 2: + layoutCode = EUSInternational; + break; + case 3: + layoutCode = EBelgian; + break; + case 4: + layoutCode = EDanish; + break; + case 5: + layoutCode = EDutch; + break; + case 6: + layoutCode = EFinnishSwedish; + break; + case 7: + layoutCode = EFrench; + break; + case 8: + layoutCode = EGerman; + break; + case 9: + layoutCode = EItalian; + break; + case 10: + layoutCode = ENorwegian; + break; + case 11: + layoutCode = EPortuguese; + break; + case 12: + layoutCode = ESpanish; + break; + case 13: + layoutCode = EUnitedStatesDvorak; + break; + default: + break; + } + + return layoutCode; + } + +THidKeyboardLayoutId CLayoutUtils::NokiaLayoutFromIndex(TInt aIndex) + { + THidKeyboardLayoutId layoutCode = ESu8USEnglish; + + // Map it back from item index position to layout code. + switch (aIndex) + { + case 0: + layoutCode = ESu8USEnglish; + break; + case 1: + layoutCode = ESu8FinnishSwedish; + break; + case 2: + layoutCode = ESu8German; + break; + case 3: + layoutCode = ESu8DanishNorwegian; + break; + case 4: + layoutCode = ESu8Russian; + break; + default: + break; + } + + return layoutCode; + } + +void CLayoutUtils::ValidateStandardLayout(THidKeyboardLayoutId& aLayoutId) + { + // If the layout isn't in the range of standard layouts, set it to + // UK + if (!((aLayoutId >= EUnitedKingdom) && (aLayoutId <= EUnitedStatesDvorak))) + { + aLayoutId = EUnitedKingdom; + } + } + +void CLayoutUtils::ValidateNokiaSU8Layout(THidKeyboardLayoutId& aLayoutId) + { + // If the layout isn't in the range of Nokia Su8 layouts, set it to + // English Su8 + if (!((aLayoutId >= ESu8USEnglish) && (aLayoutId <= ESu8Russian))) + { + aLayoutId = ESu8USEnglish; + } + } + +TInt CLayoutUtils::LayoutConfirmationStringL(THidKeyboardLayoutId aLayoutCode) + { + + TInt result = 0; + (void) aLayoutCode; + // Only Standard layouts are supported. + // Identify the layout confirmation string based on the layout code. + /* + switch ( aLayoutCode ) + { + case ESu8USEnglish: + result = R_STRING_LAYOUT_ENGLISH; + break; + case ESu8German: + result = R_STRING_LAYOUT_GERMAN; + break; + case ESu8FinnishSwedish: + result = R_STRING_LAYOUT_FINNISH_SWEDISH; + break; + case ESu8DanishNorwegian: + result = R_STRING_LAYOUT_NORWEGIAN_DANISH; + break; + case ESu8Russian: + result = R_STRING_LAYOUT_RUSSIAN; + break; + case EUnitedKingdom: + result = R_STRING_LAYOUT_UK; + break; + case EUnitedStates: + result = R_STRING_LAYOUT_US; + break; + case EUSInternational: + result = R_STRING_LAYOUT_US_INT; + break; + case EBelgian: + result = R_STRING_LAYOUT_BELGIAN; + break; + case EDanish: + result = R_STRING_LAYOUT_DANISH; + break; + case EDutch: + result = R_STRING_LAYOUT_DUTCH; + break; + case EFinnishSwedish: + result = R_STRING_LAYOUT_FINNISH_SWEDISH; + break; + case EFrench: + result = R_STRING_LAYOUT_FRENCH; + break; + case EGerman: + result = R_STRING_LAYOUT_GERMAN; + break; + case EItalian: + result = R_STRING_LAYOUT_ITALIAN; + break; + case ENorwegian: + result = R_STRING_LAYOUT_NORWEGIAN; + break; + case EPortuguese: + result = R_STRING_LAYOUT_PORTUGUESE; + break; + case ESpanish: + result = R_STRING_LAYOUT_SPANISH; + break; + case EUnitedStatesDvorak: + result = R_STRING_LAYOUT_US_DVORAK; + break; + default: + User::Leave(KErrNotSupported); + break; + } + */ + return result; + } + +TBool CLayoutUtils::SameCategory(THidKeyboardLayoutId aInitialLayoutCode, + THidKeyboardLayoutId aLayoutId) + { + // If the layout isn't in the range of Nokia Su8 layouts, set it to + // English Su8 + TBool ret = EFalse; + if (((aLayoutId >= ESu8USEnglish) && (aLayoutId <= ESu8Russian)) + && ((aInitialLayoutCode >= ESu8USEnglish) && (aInitialLayoutCode + <= ESu8Russian))) + { + ret = ETrue; + } + + if (((aLayoutId >= EUnitedKingdom) && (aLayoutId <= EUnitedStatesDvorak)) + && ((aInitialLayoutCode >= EUnitedKingdom) && (aInitialLayoutCode + <= EUnitedStatesDvorak))) + { + ret = ETrue; + } + return ret; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/common/src/timeouttimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/common/src/timeouttimer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#include "timeouttimer.h" +#include "timeoutnotifier.h" + +CTimeOutTimer* CTimeOutTimer::NewL(const TInt aPriority, + MTimeOutNotifier& aTimeOutNotify) + { + CTimeOutTimer* self = CTimeOutTimer::NewLC(aPriority, aTimeOutNotify); + CleanupStack::Pop(self); + return self; + } + +CTimeOutTimer* CTimeOutTimer::NewLC(const TInt aPriority, + MTimeOutNotifier& aTimeOutNotify) + { + CTimeOutTimer* self = new (ELeave) CTimeOutTimer(aPriority, + aTimeOutNotify); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CTimeOutTimer::CTimeOutTimer(const TInt aPriority, + MTimeOutNotifier& aTimeOutNotify) : + CTimer(aPriority), iNotify(aTimeOutNotify) + { + } + +CTimeOutTimer::~CTimeOutTimer() + { + } + +void CTimeOutTimer::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add(this); + } + +void CTimeOutTimer::RunL() + { + // Timer request has completed, so notify the timer's owner + if (iStatus == KErrNone) + { + iNotify.TimerExpired(); + } + else + { + User::Panic(KTimeOutTimerPanic, ETimerFailed); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2008 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: Project build file +* +*/ + +#include + +#include "../bthidserver/group/bld.inf" +#include "../bthidclient/group/bld.inf" +#include "../manager/group/bld.inf" +#include "../layouts/group/bld.inf" +#include "../bthidkbdsettings/group/bld.inf" +#include "../keyboard/group/bld.inf" +#include "../bthidengplugin/group/bld.inf" +#include "../mouse/group/bld.inf" + +PRJ_EXPORTS +../loc/btkeyboard.loc MW_LAYER_LOC_EXPORT_PATH(btkeyboard.loc) +../rom/btkeyboard.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btkeyboard.iby) +../rom/btkeyboard_resources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(btkeyboard_resources.iby) + +PRJ_MMPFILES diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/inc/bthidclientsrv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/inc/bthidclientsrv.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2008 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: Client-Server message passing declarations + * +*/ + + +#ifndef CLIENTSRV_H +#define CLIENTSRV_H + +// Opcodes used in message passing between client and server +enum TBTHidIpc + { + EBTHIDServConnectDevice, /*!< Connect New device command */ + EBTHIDServCancelConnect, /*!< Cancel connection attempt */ + EBTHIDServDisconnectDevice, /*!< Disconnect device command */ + EBTHidSrvDisconnectAllGracefully,/*!< Disconnect all device command */ + EBTHIDServDropConnection, /*!< Close Bluetooth Connection */ + EBTHIDServNotifyConnectionChange,/*!< Notify connection status change */ + EBTHIDServCancelNotify, /*!< Cancel outstanding notify command */ + EBTHIDServConnectionCount, /*!< Get connection count command */ + EBTHIDServConnectionStatus, /*!< Get connection details command */ + EBTHIDServFindConnection, /*!< Get connection details command */ + EBTHIDServAuthoriseFlag, /*!< Get Authorisation flag command */ + EBTHIDServSetAuthoriseFlag, /*!< Set Authorisation flag command */ + EBTHIDServIsAlreadyPairedFlag, /*!< Get pairing status for given address */ + EBTHIDServIsTrusted, /*!< Get trust status for given address */ + EBTHIDServIsConnected, /*!< Get Connected status for given address */ + EBTHIDServConnectionDetails, /*!< Get connection details */ + EBTHIDGetConnections, /*!< Get HID connections addresses */ + EInvalidIpc + }; + +// server name +_LIT(KBTHidSrvName,"bthidserver"); +_LIT(KBTHidServerFilename, "bthidserver.exe"); + +// UID of the server +const TUid KUidBTHidServer = + { + 0x2001E301 + }; + +//the server version. A version must be specified when +//creating a session with the server +const TUint KBTHIDServMajorVersionNumber = 0; +const TUint KBTHIDServMinorVersionNumber = 1; +const TUint KBTHIDServBuildVersionNumber = 1; + +typedef TPckgBuf TBTHidParamPkg; + +#endif // _BTACCCLIENTSRV_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/inc/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2007 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: Logging definition + * +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#include +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) + { + } + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) + { + } + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt, list, &overflow); + RDebug::Print(theFinalString); +#endif + + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); +#endif + + } + +inline void TracePanic(char* aFile, TInt aLine, TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*) aFile); + TPtrC8 + fileName(fullFileName.Ptr() + fullFileName.LocateReverse('\\') + + 1); + TBuf8 buf; + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*) aFile); + TPtrC8 + fileName(fullFileName.Ptr() + fullFileName.LocateReverse('\\') + + 1); + TBuf8 buf; + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + User::Leave(aReason); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, PTR);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +//#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +//#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE_IF_NULL(PTR) {static_cast(User::LeaveIfNull(PTR));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_STATIC_FUNC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} +#endif // PRJ_ENABLE_TRACE +#endif // PRJ_LOGGING_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2007 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: logging configure file. + * +*/ + + +#ifndef BTHID_DEBUGCONFIG_H +#define BTHID_DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"bthid.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTHID] "); +_LIT8(KTracePrefix8, "[BTHID] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTHid"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE + | KPRINTWARNING; + +#endif // BTHID_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/inc/hidlayoutids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/inc/hidlayoutids.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2008 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: Identifying codes for keyboard layouts. + * +*/ + + +#ifndef __HIDLAYOUTIDS_H +#define __HIDLAYOUTIDS_H + +enum THidKeyboardLayoutId + { + EInvalidLayoutId = 0, + // + // Nokia SU-8 layouts: + // + ESu8USEnglish = 1, //!< Nokia SU-8 US English + ESu8German = 2, //!< Nokia SU-8 German + ESu8FinnishSwedish = 3, //!< Nokia SU-8 Finnish and Swedish + ESu8DanishNorwegian = 4, //!< Nokia SU-8 Danish and Norwegian + ESu8Russian = 5, //!< Nokia SU-8 Russian + // + // Standard layouts: + // + EUnitedKingdom = 6, //!< UK layout + EUnitedStates = 7, //!< Standard US layout + EUSInternational = 8, //!< US layout with dead keys + EBelgian = 9, //!< Belgian + EDanish = 10, //!< Danish + EDutch = 11, //!< Dutch + EFinnishSwedish = 12, //!< Finnish and Swedish layouts are identical + EFrench = 13, //!< French + EGerman = 14, //!< German + EItalian = 15, //!< Italian + ENorwegian = 16, //!< Norwegian + EPortuguese = 17, //!< Portuguese + ESpanish = 18, //!< Spanish + EUnitedStatesDvorak = 19, //!< Standard two-hand Dvorak US layout + // + // ------------------------------------------------------------ + // The following are for testing purposes only and may be removed: + // + // Removed from requirements: + // + ESwissFrench = 22, + ESwissGerman = 23, + // + // Were never in requirements: + // + EUSDvorakLeftHand = 24, + EUSDvorakRightHand = 25, + ECanadianFrench = 26, + ECanadianMultilingual = 27, + EIcelandic = 28, + ELatinAmerican = 29, + EBelgianComma = 30, // As Belgian, but keypad '.' becomes ',' + EItalian142 = 31, + EGermanIBM = 32, + // New Requirements + ERussian = 33 + }; +#endif // __HIDLAYOUTIDS_H +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/inc/hiduids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/inc/hiduids.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2008 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: UID definitions. + * +*/ + + +#ifndef HIDUIDS_H +#define HIDUIDS_H + +#define ECOM_UID 0x10009d8d +#define REMCON_PLUGIN_IF 0x10204546 +//----- original HID uids, reserved from Symbian +#define BTHID_SRV_UID 0x2001E301 +#define LAYOUTMGR_UID 0x2001E302 +#define DRIVER_PLUGIN_IF 0x10201d26 +#define LAYOUT_PLUGIN_IF 0x10201d27 +//----- reserved from NSS list +#define HIDCLIENT_UID 0x2001E307 +#define KBD_ENGPLUGIN_UID 0x2001E308 +#define KBD_ENGPLUGIN_IMP 0x2001E309 +#define KBDSETTINGS_UIPLUGIN_UID 0x2001E30B +#define KBDSETTINGS_UIPLUGIN_IMP 0x2001E30C +#define CR_SETTINGS_UID 0x2001E320 +#define KBDCLIENT_UID 0x2001E30A +//#define DRIVER_PLUGIN_IF 0x2001E2FF + +#define KEYBOARD_UID 0x2001E304 +#define KEYBOARD_DRIVER_IMP 0x2001E305 + +#define MOUSE_UID 0x2001E303 +#define MOUSE_DRIVER_IMP 0x2001E306 + +#define LAYOUT_PLUGIN_UID 0x2001E2FE +//#define LAYOUT_PLUGIN_IF 0x2001E300 + +#define BELGIAN_LAYOUT_IMP 0x2001E30D +#define DANISH_LAYOUT_IMP 0x2001E30E +#define DUTCH_LAYOUT_IMP 0x2001E30F +#define FINSWE_LAYOUT_IMP 0x2001E310 +#define FRENCH_LAYOUT_IMP 0x2001E311 +#define GERMAN_LAYOUT_IMP 0x2001E312 +#define ITALIAN_LAYOUT_IMP 0x2001E313 +#define NORWEGIAN_LAYOUT_IMP 0x2001E314 +#define PORTUGUESE_LAYOUT_IMP 0x2001E315 +#define SPANISH_LAYOUT_IMP 0x2001E316 +#define UK_LAYOUT_IMP 0x2001E317 +#define US_LAYOUT_IMP 0x2001E318 +#define USDVORAK_LAYOUT_IMP 0x2001E319 +#define USINT_LAYOUT_IMP 0x2001E31A + +#define SU8GERMAN_LAYOUT_IMP 0x2001E31B +#define SU8RUSSIANINT_LAYOUT_IMP 0x2001E31C +#define SU8FINSWE_LAYOUT_IMP 0x2001E31D +#define SU8DANNOR_LAYOUT_IMP 0x2001E31E +#define SU8INTUSENGLISH_LAYOUT_IMP 0x2001E31F + +#define HEADSET_UID 0x10282c15 +#define HEADSET_DRIVER_IMP 0x10282c16 +#define HIDREMCON_UID 0x10282c17 +#define HIDREMCON_IMP 0x10282c18 +#define HIDEVENTPUBLISHER_UID 0x10282c19 + +#endif // __HIDUIDS_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2007 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: Project configure file. + * +*/ + + +#ifndef BTHID_PRJCONFIG_H +#define BTHID_PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // BTHID_PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/data/hidkeyboard.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/data/hidkeyboard.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2008 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: ECOM plugin resource file for keyboard driver. +* +*/ + +#include +#include "hiduids.h" + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = KEYBOARD_UID; + interfaces = + { + INTERFACE_INFO + { + interface_uid = DRIVER_PLUGIN_IF; // HID driver interface UID + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = KEYBOARD_DRIVER_IMP; + version_no = 1; + display_name = "HID Keyboard Driver Plugin"; + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +PRJ_MMPFILES +keyboard.mmp + +PRJ_TESTMMPFILES + +PRJ_PLATFORMS +WINSCW ARMV5 + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/group/keyboard.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/group/keyboard.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2006 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: BTHid keyboard driver +* +*/ + +#include +#include "../../inc/hiduids.h" + +TARGET hidkeyboard.dll +TARGETTYPE PLUGIN +UID ECOM_UID KEYBOARD_UID + +CAPABILITY CAP_APPLICATION +VENDORID VID_DEFAULT + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../common/inc +USERINCLUDE ../../manager/inc +USERINCLUDE ../../mouse/Sesame_client/inc +USERINCLUDE ../../bthidkbdsettings/inc + +SOURCEPATH ../src +SOURCE keyboard.cpp +SOURCE finder.cpp +SOURCE hidkeyboarddriverproxy.cpp + +SOURCEPATH ../../common/src +SOURCE timeouttimer.cpp +SOURCE layoututils.cpp + + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc + +SOURCEPATH ../data +START RESOURCE hidkeyboard.rss +#ifdef SYMBIAN_SECURE_ECOM +TARGET hidkeyboard.rsc +#endif +END // ECOM resource definition + +LIBRARY kbdclient.lib +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY ws32.lib +LIBRARY generichid.lib +LIBRARY apgrfx.lib +LIBRARY apparc.lib +LIBRARY bthidsettings.lib +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/inc/finder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/inc/finder.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,299 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __FINDER_H +#define __FINDER_H + +#include +#include "hidreportroot.h" + +// ---------------------------------------------------------------------- + +/** + * Field finder for the ordinary keyboard fields. + */ +class TKeyboardFinder : public MHidFieldFinder + { +public: + // From MHidFieldFinder + virtual TBool BeginCollection(const CCollection *aCollection); + virtual TBool EndCollection(const CCollection *aCollection); + virtual void Field(const CField* aField); + +public: + /** Constructor */ + TKeyboardFinder(); + /** + * Check whether the required fields have been found. + * @return ETrue if they have. + */ + inline TBool Found() const; + + /** + * Get the field containing the standard keys, if found. + * @return CField* Pointer to the field, or NULL. + */ + const CField* StandardKeyField() const; + /** + * Get the field containing the modifier keys, if found. + * @return CField* Pointer to the field, or NULL. + */ + const CField* ModifierKeyField() const; + /** + * Get the field containing the LEDs, if found. + * @return CField* Pointer to the field, or NULL. + */ + const CField* LedField() const; + +private: + /** + * Check whether a given field contains the standard keys. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsStandardKeys(const CField* aField) const; + /** + * Check whether a given field contains the modifier keys. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsModifiers(const CField* aField) const; + /** + * Check whether a given field contains the LEDs. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsLeds(const CField* aField) const; + +private: + /** Pointer to the field containing the standard keys. */ + const CField* iStandardKeys; + /** Pointer to the field containing the modifier keys. */ + const CField* iModifierKeys; + /** Pointer to the field containing the LEDs. */ + const CField* iLeds; + + /** Pointer to the top level application collection being searched. */ + const CCollection* iAppCollection; + }; + +/** + * Field finder for the consumer/multimedia keys field. + */ +class TConsumerKeysFinder : public MHidFieldFinder + { +public: + // From MHidFieldFinder + virtual TBool BeginCollection(const CCollection *aCollection); + virtual TBool EndCollection(const CCollection *aCollection); + virtual void Field(const CField* aField); + +public: + /** Constructor */ + TConsumerKeysFinder(); + + /** + * Get the field containing the consumer keys, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* ConsumerKeysField() const; + /** + * Check whether the consumer keys field has been found. + * @return ETrue if it has. + */ + inline TBool Found() const; + +private: + /** Pointer to the field containing the consumer keys. */ + const CField* iField; + }; + +/** + * Field finder for the power keys field. + */ +class TPowerKeysFinder : public MHidFieldFinder + { +public: + // From MHidFieldFinder + virtual TBool BeginCollection(const CCollection *aCollection); + virtual TBool EndCollection(const CCollection *aCollection); + virtual void Field(const CField* aField); + +public: + /** Constructor */ + TPowerKeysFinder(); + + /** + * Get the field containing the power keys, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* PowerKeysField() const; + /** + * Check whether the power keys field has been found. + * @return ETrue if it has. + */ + inline TBool Found() const; + +private: + /** Pointer to the field containing the power keys. */ + const CField* iField; + }; + +// ---------------------------------------------------------------------- + +inline TBool TKeyboardFinder::Found() const + { + // Standard and modifier key fields are always necessary, but the + // LED field is optional: + // + return iStandardKeys && iModifierKeys; + } + +inline const CField* TKeyboardFinder::StandardKeyField() const + { + return iStandardKeys; + } + +inline const CField* TKeyboardFinder::ModifierKeyField() const + { + return iModifierKeys; + } + +inline const CField* TKeyboardFinder::LedField() const + { + return iLeds; + } + +// ---------------------------------------------------------------------- + +inline const CField* TConsumerKeysFinder::ConsumerKeysField() const + { + return iField; + } + +inline TBool TConsumerKeysFinder::Found() const + { + return (iField != 0); + } + +// ---------------------------------------------------------------------- + +inline const CField* TPowerKeysFinder::PowerKeysField() const + { + return iField; + } + +inline TBool TPowerKeysFinder::Found() const + { + return (iField != 0); + } + +// ---------------------------------------------------------------------- +/** + * Field finder for the ordinary mouse fields. + */ +class TMouseFinder : public MHidFieldFinder + { +public: + // From MHidFieldFinder + virtual TBool BeginCollection(const CCollection *aCollection); + virtual TBool EndCollection(const CCollection *aCollection); + virtual void Field(const CField* aField); + +public: + /** Constructor */ + TMouseFinder(); + + /** + * Get the field containing the standard keys, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* ButtonsField() const; + /** + * Get the field containing the xy field, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* XYField() const; + /** + * Get the field containing the wheel info, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* WheelField() const; + /** + * Check whether the required fields have been found. + * @return ETrue if they have. + */ + inline TBool Found() const; + + /** + * Check whether a given field contains the XY Coordinates + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsXY(const CField* aField) const; + /** + * Check whether a given field contains the Buttons. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsButtons(const CField* aField) const; + /** + * Check whether a given field contains a wheel. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsWheel(const CField* aField) const; + +private: + /** Pointer to the field containing the XY pointer info. */ + const CField* iXY; + + /** Pointer to the field containing the buttons. */ + const CField* iButtons; + + /** Pointer to the field containing the Wheel info. */ + const CField* iWheel; + + /** Pointer to the top level application collection being searched. */ + const CCollection* iAppCollection; + }; +// ---------------------------------------------------------------------- + +inline TBool TMouseFinder::Found() const + { + // Standard and modifier key fields are always necessary, but the + // Wheel field is optional: + // + return iButtons && iXY; + } + +inline const CField* TMouseFinder::ButtonsField() const + { + return iButtons; + } + +inline const CField* TMouseFinder::XYField() const + { + return iXY; + } + +inline const CField* TMouseFinder::WheelField() const + { + return iWheel; + } +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/inc/keyboard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/inc/keyboard.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,395 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __KEYBOARD_H +#define __KEYBOARD_H + +#include +#include +#include + +#include "hidinterfaces.h" +#include "hidkeys.h" +#include "layoutmgr.h" +#include "timeoutnotifier.h" +#include +#include +#include "pointmsgqueue.h" +#include "bthidsettings.h" + +class CField; +class CHidKeyboardDriver; +class CTimeOutTimer; +/*! + HID keyboard driver class + */ +class CHidKeyboardDriver : public CHidDriver, public MTimeOutNotifier + { + +private: + /*! Initialisation states */ + enum TKeyboardDriverState + { + EUninitialised, /*!< Driver has not been initialised */ + EInitialised, /*!< Driver is initialised */ + EDisabled + /*!< The driver will not respond to interrupt data */ + }; + + // Flags indicating which locking keys are active + enum TLockVals + { + ENumLock = 1, ECapsLock = 2, EScrollLock = 4 + }; + + // The types of keyboard input report fields that we handle: + enum TKeyFieldType + { + EStandardKeys = 0, + EModifierKeys = 1, + EMediaKeys = 2, + EPowerKeys = 3, + KNumInputFieldTypes + }; + + // The types of keyboard input report fields that we handle: + enum TMouseFieldType + { + EMouseButtons = 0, + EMouseXY = 1, + EMouseWheel = 2, + EMouseMediaKeys = 3, + EMousePowerKeys = 4, + KMouseInputFieldTypes + }; +public: + // Constructors and destructor + /*! + Creates an instantiated CHidKeyboardDriver object. + @param aHid The generic HID layer that requested the driver + @param aFactory aFactory The factory that created the driver + @result A pointer to the instantiated keyboard driver + */ + static CHidKeyboardDriver* NewL(MDriverAccess* aHid); + /*! + Creates an instantiated CHidKeyboardDriver object and leaves it on the + cleanup stack. + @param aHid The generic HID layer that requested the driver + @param aFactory aFactory The factory that created the driver + @result A pointer to the instantiated keyboard driver + */ + static CHidKeyboardDriver* NewLC(MDriverAccess* aHid); + + /*! + Stops driver activity, deletes the key repeat and decode objects and closes + the window server session before the driver is deleted + */ + virtual ~CHidKeyboardDriver(); + +public: + // new functions + /*! + Called by the Generic HID layer to see if the driver can is able to use + reports from a newly-connected device + @result ETrue The driver can handle the reports + @result EFalse The driver cannot handle the reports + */ + virtual TInt CanHandleReportL(CReportRoot* aReportRoot); + + /*! + Called by the Generic HID layer when a device has been removed, prior to the + driver being removed. This allows the driver to notify any applications of + disconnection, if required + @param aReason The reason for device disconnection + */ + virtual void Disconnected(TInt aReason); + + /*! + Called by the Generic HID layer when data has been received from the device + handled by this driver. + @param aChannel The channel on which the data was received (as defined by the + transport layer + @param aPayload A pointer to the data buffer + */ + virtual TInt DataIn(CHidTransport::THidChannelType aChannel, + const TDesC8& aPayload); + + /*! + Called by the transport layers to inform the generic HID of the success of + the last Set... command. + @param aConnectionId ID of the device + @param aCmdAck Status of the last Set... command + */ + virtual void CommandResult(TInt aCmdAck); + + /*! + Called after a driver is sucessfully created by the Generic HID, when a + device is connected + */ + virtual void InitialiseL(TInt aConnectionId); + + /*! + Resets the internal state of the driver (any pressed keys are released) and + enables the driver + */ + virtual void StartL(TInt aConnectionId); + /*! + Cancels all pressed keys and disables the driver (so it will not + process interrupt data) + */ + virtual void Stop(); + + /** + * Return count of supported fields + * + * @since S60 v5.0 + * @return Number of supported fields. + */ + virtual TInt SupportedFieldCount(); + + /** + * Set input handling registy + * + * @since S60 v5.0 + * @param aHandlingReg a Input handling registry + */ + virtual void SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg); + + // ---------------------------------------- + // Repeat key timer interface: + + /*! + Callback function for the key repeat timer to trigger a repeat key event. + */ + TInt OnKeyRepeat(); + + static TInt TimerFiredOnKeyRepeat(TAny* aThis); + +private: + // Constructors + + // Constructor taking a pointer to the HID layer requesting the driver + // instance + CHidKeyboardDriver(MDriverAccess* aHid); + + void ConstructL(); + +private: + // Functions from base classes + + /** + * From MTimeoutNotifier + */ + void TimerExpired(); +private: + // New Functions + + // Called from within DataIn to handle interrupt and control channel data + void InterruptData(const TDesC8& aPayload); + + // Send key down / key up events to the window server: + void KeyEvent(TBool aIsKeyDown, TInt aHidKey, TInt aUsagePage); + TKeyEvent TKeyEventFromScanCode(TInt aScanCode) const; + inline void KeyUp(TInt aHidKey, TInt aUsagePage); + inline void KeyDown(TInt aHidKey, TInt aUsagePage); + + // Handles the states of the modifier keys + void UpdateModifiers(TInt aFieldIndex, const TDesC8& aReport); + // Handles the states of the XY (mouse up, down, left, right) + void UpdateXY(TInt aFieldIndex, const TDesC8& aReport); + + // Handles the states of the Buttons (left & right button) + void UpdateButtons(TInt aFieldIndex, const TDesC8& aReport); + + // Handles the states of the wheel + void UpdateWheel(TInt aFieldIndex, const TDesC8& aReport); + + // Handle key presses + void ProcessKeys(TInt aFieldIndex, const TDesC8& aReport); + + // Determines whether too many keys have been pressed on the device + TBool IsRollover(TInt aFieldIndex, const TDesC8& aReport) const; + + // Get current modifier state in the format used by TKeyEvent + TUint32 KeyEventModifiers() const; + + // Resets the internal keypress states and sends keyup events if required + void CancelKeysForField(TInt aFieldIndex); + void CancelAllKeys(); + + // Determines whether any lock (Caps,Num,scroll) keys are pressed + void UpdateLockState(TInt aKey); + + // Sets the LEDs on the keyboard according to the keyboard state + // (Not implemented) + void SetKeyboardLeds() const; + + // Send a key event to the system + void SendKeyPress(TUint16 aUnicode, TInt aUsagePage, TInt aScanCode, + TBool aIsRepeatingKey); + + void SendToWindowGroup(const TKeyEvent& aKeyEvent, TEventCode aType); + void SendToWindowServer(TKeyEvent aKeyEvent); + + // Determine which window group a key event should be sent to. + // Except for special cases this is the window group with the focus. + TInt WindowGroupForKeyEvent(const TKeyEvent& aKeyEvent, TEventCode aType); + + // Handles the sending of raw events to the phone application instead of key events. + void HandleTelephoneAppKeys(TInt aScanCode, TInt aUniCode, + TBool aIsKeyDown); + + // Checks if application launching key combination and launch a corresponding application + void HandleApplicationLaunchKeysL(TUint16 aScancodeKey, TBool aIsKeyDown, + TUint8 aModifiers); + + /** + * CHidKeyboardDriver::LaunchApplicationL + * @param aAppUid Application UID + */ + void LaunchApplicationL(TInt aAppUid); + + // Checks if multimedia-key (play,stop,..) and sends to RemCon + TBool HandleMultimediaKeys(TUint16 aScancodeKey, TBool aIsKeyDown, + TUint8 aModifiers); + TBool HandleMultimediaKeysForNokia(TUint16 aScancodeKey, + TBool aIsKeyDown, TUint8 aModifiers); + TBool HandleMultimediaKeysForStandard(TUint16 aScancodeKey, + TBool aIsKeyDown, TUint8 aModifiers); + + TInt AppMenuId(); + TInt PhoneAppId(); + TInt IdleAppId(); + TBool IsApplicationMenuTopMost(); + TBool IsPhoneAppTopMost(); + + // bitmap for Multimedia key states + enum TMmKeyDown + { + EVolUp = 1, + EVolDown = 2, + EPlay = 4, + EStop = 8, + ENext = 16, + EPrev = 32 + }; + + void ResetBitmap(TBool aIsKeyDown, TMmKeyDown aBitmapToReset); + + /** + * Send raw key event to window server + * @param aScancode key scancode + * @param aModifiers modifier + * @return Error code + */ + TInt SendRawEvent(TInt aScancode, TBool aIsKeyDown, TUint aModifier); + + // ---------------------------------------- + + static TInt ResetArrayToSize(RArray& aArray, TInt aSize); + void MoveCursor(const TPoint& aPoint); + TInt PostPointer(const TPoint& aPoint); + TInt SendButtonEvent(TBool aButtonDown); + + TBool IsDigitKey(TInt aScanCode); + TBool IsSpecialHandleKey(TInt aUniCode); + + void LaunchApplicationL(const TDesC& aName); +private: + + TKeyboardDriverState iDriverState; + + // Application UIDs + TInt iConnectionId; + TInt iAppMenuId; + TInt iPhoneAppId; + TInt iIdleAppId; + + // The Generic HID layer + MDriverAccess *iGenericHid; + + // Arrays of keys currently pressed for each field: + RArray iKeys[KNumInputFieldTypes]; + + // Pointers to the fields in the report descriptor containing the + // various types of key: + const CField* iField[KNumInputFieldTypes]; + + // Pointers to the fields in the report descriptor containing the + // various types of key: + const CField* iMouseField[KMouseInputFieldTypes]; + // Pointer to the field in the report descriptor containing the LEDs: + const CField* iLedField; + + // The current modifier state + TUint8 iModifiers; + // The current locking key states + TUint8 iLockState; + //Supported field types count + TInt iSupportedFieldCount; + + // A window server session, so keypresses can be sent to applications: + RWsSession iWsSession; + + // Timer object so the driver can generate repeat keypresses: + CPeriodic *iRepeatTimer; + + // The last keypress event sent to the window server (allows key repeat) + TKeyEvent iLastKey; + + // Layout manager session: + RLayoutManager iLayoutMgr; + + // Settings handler class + CBtHidSettings* iSettings; + + /*! The last keyboard layout selected by the user */ + THidKeyboardLayoutId iLastSelectedLayout; + + // Flag for Multimedia key state + TUint8 iMmKeyDown; + + CHidInputDataHandlingReg* iInputHandlingReg; + + // This timer stops key repeating after defined time to prevent endless key repeats in error cases. Fix for EMKD-7FBB9H + CTimeOutTimer* iRepeatEndTimer; + + TBool iComboDevice; + + RMsgQueue iPointBufQueue; + TPointBuffer iPointerBuffer; + TBool iButtonDown; + TBool iButton2Down; + }; + +// ---------------------------------------------------------------------- +// Helpers for sending key events: + +inline void CHidKeyboardDriver::KeyUp(TInt aHidKey, TInt aUsagePage) + { + KeyEvent(EFalse, aHidKey, aUsagePage); + } + +inline void CHidKeyboardDriver::KeyDown(TInt aHidKey, TInt aUsagePage) + { + KeyEvent(ETrue, aHidKey, aUsagePage); + } + +// ---------------------------------------------------------------------- + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/src/finder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/src/finder.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,391 @@ +/* +* Copyright (c) 2004 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: This is the implementation of application class + * +*/ + + +#include +#include + +#include "finder.h" + +// ---------------------------------------------------------------------- + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +// ---------------------------------------------------------------------- + +TKeyboardFinder::TKeyboardFinder() : + iStandardKeys(0), iModifierKeys(0), iLeds(0), iAppCollection(0) + { + // Nothing else to do + } + +// ---------------------------------------------------------------------- + +TBool TKeyboardFinder::BeginCollection(const CCollection* aCollection) + { + TBool examineCollection = ETrue; + + if ((aCollection->IsApplication()) && (iAppCollection == 0)) + { + // Top-level application collection. + + if ((aCollection->UsagePage() == EUsagePageGenericDesktop) + && (aCollection->Usage() == EGenericDesktopUsageKeyboard)) + { + DBG(RDebug::Print(_L("[HID]\tTKeyboardFinder::BeginCollection: this is keyboard collection "))); + // Collection is a keyboard device: + iAppCollection = aCollection; + iStandardKeys = iModifierKeys = iLeds = 0; + } + else + { + // (dont) Skip other types of top-level application collection: + DBG(RDebug::Print(_L("[HID]\tTKeyboardFinder::BeginCollection: not keyboard collection "))); + examineCollection = EFalse; + } + } + + return examineCollection; + } + +TBool TKeyboardFinder::EndCollection(const CCollection* aCollection) + { + TBool continueSearch = ETrue; + + if (aCollection == iAppCollection) + { + // Top-level application(Generic Desktop:Keyboard) finished: + // + iAppCollection = 0; + + // Stop if we've found a keyboard we can use in this + // application collection: + // + continueSearch = !Found(); + } + + return continueSearch; + } + +void TKeyboardFinder::Field(const CField* aField) + { + if (iAppCollection) + { + if (IsStandardKeys(aField)) + { + iStandardKeys = aField; + } + + if (IsModifiers(aField)) + { + iModifierKeys = aField; + } + + if (IsLeds(aField)) + { + iLeds = aField; + } + } + } + +// ---------------------------------------------------------------------- + +TBool TKeyboardFinder::IsModifiers(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && (aField->UsagePage() + == EUsagePageKeyboard)) + { + const TInt KKbdLeftControl = 224; + const TInt KKbdRightGUI = 231; + + // Test for a field containing only modifier keys + if ((aField->UsageMin() >= KKbdLeftControl) && (aField->UsageMax() + <= KKbdRightGUI)) + { + DBG(RDebug::Print(_L("[HID]\t Modifier field found"))); + found = ETrue; + } + } + + return found; + } + +TBool TKeyboardFinder::IsStandardKeys(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && (aField->UsagePage() + == EUsagePageKeyboard)) + { + const TInt KKeyboardRollOver = 0x01; + const TInt KKeyboardUpArrow = 0x52; + + if ((aField->UsageMin() <= KKeyboardRollOver) && (aField->UsageMax() + >= KKeyboardUpArrow)) + { + DBG(RDebug::Print(_L("[HID]\t Standard keys field found"))); + found = ETrue; + } + } + + return found; + } + +TBool TKeyboardFinder::IsLeds(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsOutput() && aField->IsData() && (aField->UsagePage() + == EUsagePageLEDs)) + { + const TInt KNumLockLed = 1; + const TInt KCapsLockLed = 2; + + // Test for a field containing at least num lock or caps lock + if ((aField->UsageMin() <= KCapsLockLed) && (aField->UsageMax() + >= KNumLockLed)) + { + DBG(RDebug::Print(_L("[HID]\t LED field found"))); + found = ETrue; + } + } + + return found; + } + +// ---------------------------------------------------------------------- + +TConsumerKeysFinder::TConsumerKeysFinder() : + iField(0) + { + // Nothing else to do + } + +void TConsumerKeysFinder::Field(const CField* aField) + { + if (!Found() && aField->IsInput() && aField->IsData() + && (aField->UsagePage() == EUsagePageConsumer)) + { + DBG(RDebug::Print(_L("Consumer keys field found\r\n"))); + iField = aField; + } + } + +TBool TConsumerKeysFinder::BeginCollection(const CCollection* aCollection) + { + const TInt KConsumerControl = 0x01; + + // Only look at top-level application (consumer devices: consumer + // control) collections: + // + return aCollection->IsApplication() && (aCollection->UsagePage() + == EUsagePageConsumer) && (aCollection->Usage() + == KConsumerControl); + } + +TBool TConsumerKeysFinder::EndCollection(const CCollection* /*aCollection*/) + { + return !Found(); + } + +// ---------------------------------------------------------------------- + +TPowerKeysFinder::TPowerKeysFinder() : + iField(0) + { + // Nothing else to do + } + +void TPowerKeysFinder::Field(const CField* aField) + { + if (!Found() && aField->IsInput() && aField->IsData() + && (aField->UsagePage() == EUsagePageGenericDesktop)) + { + // See if the range includes one or more of the power down, + // sleep or wakeup controls: + + const TInt KPowerDown = 0x81; + const TInt KWakeUp = 0x83; + + if ((aField->UsageMin() <= KWakeUp) && (aField->UsageMax() + >= KPowerDown)) + { + DBG(RDebug::Print(_L("[HID]\t Power keys field found\r\n"))); + iField = aField; + } + } + } + +TBool TPowerKeysFinder::BeginCollection(const CCollection* aCollection) + { + const TInt KSystemControl = 0x80; + + // Only look at top-level application (generic desktop: system + // control) collections: + // + return aCollection->IsApplication() && (aCollection->UsagePage() + == EUsagePageGenericDesktop) && (aCollection->Usage() + == KSystemControl); + } + +TBool TPowerKeysFinder::EndCollection(const CCollection*) + { + return !Found(); + } + +// ---------------------------------------------------------------------- +TMouseFinder::TMouseFinder() : + iXY(0), iButtons(0), iWheel(0), iAppCollection(0) + { + // Nothing else to do + } + +// ---------------------------------------------------------------------- + +TBool TMouseFinder::BeginCollection(const CCollection *aCollection) + { + TBool examineCollection = ETrue; + + if ((aCollection->IsApplication()) && (iAppCollection == 0)) + { + // Top-level application collection. + + if ((aCollection->UsagePage() == EUsagePageGenericDesktop) + && (aCollection->Usage() == EGenericDesktopUsageMouse)) + { + // Collection is a mouse device: + iAppCollection = aCollection; + iXY = iWheel = iButtons = 0; + } + else + { + // Skip other types of top-level application collection: + examineCollection = EFalse; + } + } + + return examineCollection; + } + +TBool TMouseFinder::EndCollection(const CCollection *aCollection) + { + TBool continueSearch = ETrue; + + DBG(RDebug::Print(_L("[HID]\tTHeadsetFinder::EndCollection"))); + if (aCollection == iAppCollection) + { + // Top-level application(Generic Desktop:Mouse) finished: + // + iAppCollection = 0; + + // Stop if we've found a mouse we can use in this + // application collection: + // + continueSearch = !Found(); + } + + return continueSearch; + } + +void TMouseFinder::Field(const CField* aField) + { + if (iAppCollection) + { + if (IsWheel(aField)) + { + iWheel = aField; + } + + if (IsXY(aField)) + { + iXY = aField; + } + + if (IsButtons(aField)) + { + iButtons = aField; + } + } + } + +// ---------------------------------------------------------------------- + + +TBool TMouseFinder::IsXY(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && (aField->UsagePage() + == EUsagePageGenericDesktop)) + { + + if (aField->HasUsage(EGenericDesktopUsageX) && aField->HasUsage( + EGenericDesktopUsageY)) + { + DBG(RDebug::Print(_L("[HID]\tXY field found"))); + found = ETrue; + } + } + + return found; + } + +TBool TMouseFinder::IsButtons(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && (aField->UsagePage() + == EUsagePageButton)) + { + const TInt KMinButtons = 1; + const TInt KMaxButtons = 15; + + // Test for a field containing at least num lock or caps lock + if ((aField->UsageMin() >= KMinButtons) && (aField->UsageMax() + <= KMaxButtons)) + { + DBG(RDebug::Print(_L("[HID]\tButtons field found"))); + found = ETrue; + } + } + + return found; + } + +TBool TMouseFinder::IsWheel(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && (aField->UsagePage() + == EUsagePageGenericDesktop)) + { + if (aField->HasUsage(EGenericDesktopUsageWheel)) + { + found = ETrue; + } + } + + return found; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/src/hidkeyboarddriverproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/src/hidkeyboarddriverproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2007 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: + * ECOM proxy table for this plugin + * +*/ + + +// System includes +// +#include +#include +#include "hiduids.h" + +// User includes +// +#include "keyboard.h" + +// Constants +// +const TImplementationProxy KHidKeyboardDriverProxy[] = + { + IMPLEMENTATION_PROXY_ENTRY( KEYBOARD_DRIVER_IMP, CHidKeyboardDriver::NewL ) + }; + +// --------------------------------------------------------------------------- +// ImplementationGroupProxy +// Gate/factory function +// +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( + TInt& aTableCount) + { + aTableCount = sizeof(KHidKeyboardDriverProxy) + / sizeof(TImplementationProxy); + return KHidKeyboardDriverProxy; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/keyboard/src/keyboard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/keyboard/src/keyboard.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1932 @@ +/* +* Copyright (c) 2004 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: This is the implementation of application class + * +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hidtranslate.h" +#include "finder.h" +#include "keyboard.h" +#include "layoutmgr.h" +#include "debug.h" +#include "timeouttimer.h" +#include "layoututils.h" +#include "bthidPsKey.h" + +// ---------------------------------------------------------------------- + +// Application UIDs for finding window groups. +const TInt KIdleAppUid = 0x102750f0; +const TInt KPhoneAppUid = 0x100058b3; +const TInt KMenuAppUid = 0x101f4cd2; +const TInt KSysApUid = 0x100058f3; +const TInt KActiveNotesUid = 0x10281a31; +const TInt KMessagingUid = 0x100058C5; +const TInt KServicesUid = 0x10008D39; +//const TInt KMultimediaMenuUid = 0x10281cfb; + +// Key repeat parameters to be configured +const TInt KRepeatEndTimeout = 5000000; // 5 seconds + +const TInt KKeyRepeatDelay = 500000; +const TInt KKeyRepeatInterval = 75000; +_LIT(KAppName, "PaintCursor.exe"); +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::CHidKeyboardDriver +//---------------------------------------------------------------------------- +// +CHidKeyboardDriver::CHidKeyboardDriver(MDriverAccess* aGenericHid) : + iDriverState(EUninitialised), iGenericHid(aGenericHid), iMmKeyDown(0) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::CHidKeyboardDriver(0x%08x)"), aGenericHid)); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::NewLC +//---------------------------------------------------------------------------- +// +CHidKeyboardDriver* CHidKeyboardDriver::NewLC(MDriverAccess* aGenericHid) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::NewLC(0x%08x)"), aGenericHid)); + CHidKeyboardDriver* self = new (ELeave) CHidKeyboardDriver(aGenericHid); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::NewL +//---------------------------------------------------------------------------- +// +CHidKeyboardDriver* CHidKeyboardDriver::NewL(MDriverAccess* aGenericHid) + { + CHidKeyboardDriver* self = CHidKeyboardDriver::NewLC(aGenericHid); + CleanupStack::Pop(); + return self; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::ConstructL +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::ConstructL() + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver{0x%08x}::ConstructL()"), this)); + + User::LeaveIfNull(iGenericHid); + + // Create a session with the window server: + User::LeaveIfError(iWsSession.Connect()); + + // Create a session with the layout manager: + User::LeaveIfError(iLayoutMgr.Connect()); + + // We also need a key repeat timer: + iRepeatTimer = CPeriodic::NewL(CActive::EPriorityStandard); + + // repeat ending timer + iRepeatEndTimer = CTimeOutTimer::NewL(EPriorityNormal, *this); + iAppMenuId = AppMenuId(); + iPhoneAppId = PhoneAppId(); + iIdleAppId = IdleAppId(); + + iComboDevice = EFalse; + + iSettings = CBtHidSettings::NewL(); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::~CHidKeyboardDriver +//---------------------------------------------------------------------------- +// +CHidKeyboardDriver::~CHidKeyboardDriver() + { + TRACE_INFO( (_L("[HID]\t~CHidKeyboardDriver() 0x%08x"), this)); + + CancelAllKeys(); + delete iRepeatTimer; + delete iRepeatEndTimer; + iWsSession.Close(); + iLayoutMgr.Close(); + + for (TInt i = 0; i < KNumInputFieldTypes; ++i) + { + iKeys[i].Reset(); + } + + iPointBufQueue.Close(); + + if (iComboDevice) + { + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + } + + if (iSettings) + delete iSettings; + } + +void CHidKeyboardDriver::MoveCursor(const TPoint& aPoint) + { + DBG(RDebug::Print( + _L("CHidKeyboard::MoveCursor"))); + + PostPointer(aPoint); + } +// --------------------------------------------------------------------------- +// CHidMouseDriver::PostPointer +// Save the event to the buffer +// --------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::PostPointer(const TPoint& aPoint) + { + DBG(RDebug::Print(_L("CHidKeyboard::PostPointer"))); + iPointerBuffer.iPoint[iPointerBuffer.iNum] = aPoint; + iPointerBuffer.iType[iPointerBuffer.iNum] = KBufferPlainPointer; + iPointerBuffer.iNum++; + TInt ret = KErrNone; + + if (iPointerBuffer.iNum > KPMaxEvent) + { + ret = iPointBufQueue.Send(iPointerBuffer); + iPointerBuffer.iNum = 0; + } + return ret; + } + +TInt CHidKeyboardDriver::SendButtonEvent(TBool aButtonDown) + { + DBG(RDebug::Print( + _L("CHidKeyboard::SendButtonEvent"))); + iPointerBuffer.iPoint[iPointerBuffer.iNum] = TPoint(0, 0); + iPointerBuffer.iType[iPointerBuffer.iNum] = aButtonDown + ? KBufferPenDown + : KBufferPenUp; + iPointerBuffer.iNum++; + TInt ret = iPointBufQueue.Send(iPointerBuffer); + iPointerBuffer.iNum = 0; + return ret; + } +//---------------------------------------------------------------------------- +// CHidKeyboardDriver:::StartL +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::StartL(TInt aConnectionId) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::StartL"))); + aConnectionId = aConnectionId; + // No keys are pressed: + iModifiers = 0; + for (TInt i = 0; i < KNumInputFieldTypes; ++i) + { + if (iField[i]) + { + // Reset the keys pressed array to all zeros + RArray& keys = iKeys[i]; + + for (TInt j = 0; j < keys.Count(); j++) + { + keys[j] = 0; + } + } + } + + // Start up with Num Lock active: + iLockState = ENumLock; + SetKeyboardLeds(); + + //In case of reconnection, try to initialize the Keybord driver... + InitialiseL(aConnectionId); + + // Reset the state of the layout decoder: + iLayoutMgr.Reset(); + + TInt initialLayout; + User::LeaveIfError(iLayoutMgr.GetLayout(initialLayout)); + iLastSelectedLayout = iSettings->LoadLayoutSetting(); + TBool sameCategory = CLayoutUtils::SameCategory( + static_cast (initialLayout), + iLastSelectedLayout); + if (sameCategory) + { + //Used the layoutID from CenRep + iLayoutMgr.SetLayout(iLastSelectedLayout); + } + TInt err = iPointBufQueue.OpenGlobal(KMsgBTMouseBufferQueue); + if (err == KErrNotFound) + { + User::LeaveIfError(iPointBufQueue.CreateGlobal(KMsgBTMouseBufferQueue, KPointQueueLen)); + } + else + { + User::LeaveIfError( err ); + } + + // Ready to process keyboard events: + iDriverState = EInitialised; + + if (iComboDevice) + { + LaunchApplicationL(KAppName); + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorShow ); + } + + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::InitialiseL +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::InitialiseL(TInt aConnectionId) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::InitialiseL(%d)"), + aConnectionId)); + + // Store the connection ID: + iConnectionId = aConnectionId; + + // Initialise the layout manager: + TInt country = iGenericHid->CountryCodeL(aConnectionId); + TInt vendor = iGenericHid->VendorIdL(aConnectionId); + TInt product = iGenericHid->ProductIdL(aConnectionId); + + TRACE_INFO( ( + _L("[HID]\t Country = %d, vendor = %d, product = %d"), + country, vendor, product)); + + User::LeaveIfError(iLayoutMgr.SetInitialLayout(country, vendor, product)); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::Stop +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::Stop() + { + iDriverState = EDisabled; + CancelAllKeys(); + if (iComboDevice) + { + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + } + } + +//---------------------------------------------------------------------------- +// CHidMouseDriver::LaunchApplicationL +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::LaunchApplicationL(const TDesC& aName) + { + //Check if application is already running in the background + TApaTaskList tasks(iWsSession); + TApaTask task = tasks.FindApp(aName); + if (task.Exists()) + { + // Application is active, so just bring to foreground + } + else + { + // If application is not running, then create a new one + CApaCommandLine* cmd = CApaCommandLine::NewLC(); + cmd->SetExecutableNameL(aName); + cmd->SetCommandL(EApaCommandBackground); // EApaCommandRun + + RApaLsSession arcSession; + //connect to AppArc server + User::LeaveIfError(arcSession.Connect()); + CleanupClosePushL(arcSession); + User::LeaveIfError(arcSession.StartApp(*cmd)); + arcSession.Close(); + CleanupStack::PopAndDestroy(2); + } + + } + +// ---------------------------------------------------------------------- +// CHidDriver mandatory functions: + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::DataIn +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::DataIn(CHidTransport::THidChannelType aChannel, + const TDesC8& aPayload) + { + TInt err = KErrNone; + switch (aChannel) + { + case CHidTransport::EHidChannelInt: + if (EInitialised == iDriverState) + { + if (iComboDevice) + { + TInt mouseStatus; + TInt err = RProperty::Get( KPSUidBthidSrv, KBTMouseCursorState, mouseStatus ); + if ( !err && (static_cast(mouseStatus) == ECursorHide) ) + { + err = RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorShow ); + } + } + InterruptData(aPayload); + } + break; + + case CHidTransport::EHidChannelCtrl: + break; + + default: + break; + } + return err; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::CommandResult +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::CommandResult(TInt /*aCmdAck*/) + { + // No implementation as we don't issue any requests to be acknowledged + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::Disconnected +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::Disconnected(TInt aReason) + { + RDebug::Print(_L("CHidKeyboardDriver::Disconnected(%d)"), aReason); + Stop(); + } + +void CHidKeyboardDriver::UpdateXY(TInt aFieldIndex, const TDesC8& aReport) + { + // DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateModifiers()"))); + + // Translate the HID usage values into a boot protocol style + // modifier bitmask: + // + TReportTranslator report(aReport, iMouseField[aFieldIndex]); + + TInt Xvalue = 0; + TInt Yvalue = 0; + + TInt errX = report.GetValue(Xvalue, EGenericDesktopUsageX); + TInt errY = report.GetValue(Yvalue, EGenericDesktopUsageY); + + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateXY (%d,%d)"), Xvalue, Yvalue)); + if ((Xvalue != 0) || (Yvalue != 0)) + { + MoveCursor(TPoint(Xvalue, Yvalue)); + } + } + +void CHidKeyboardDriver::UpdateWheel(TInt aFieldIndex, const TDesC8& aReport) + { + TReportTranslator report(aReport, iMouseField[aFieldIndex]); + + TInt Yvalue = 0; + + TInt errY = report.GetValue(Yvalue, EGenericDesktopUsageWheel); + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateWheel (%d)"), Yvalue)); + TInt absValue(Abs(Yvalue)); + if ((errY == KErrNone) && (absValue >= 1)) + { + TRawEvent rawEvent; + for (TInt ii = 0; ii < absValue; ii++) + { + rawEvent.Set(TRawEvent::EKeyDown, + (Yvalue > 0) ? EStdKeyUpArrow : EStdKeyDownArrow); + UserSvr::AddEvent(rawEvent); + rawEvent.Set(TRawEvent::EKeyUp, + (Yvalue > 0) ? EStdKeyUpArrow : EStdKeyDownArrow); + UserSvr::AddEvent(rawEvent); + } + } + DBG(RDebug::Print(_L("[HID]\t new iModifiers = %02x"), iModifiers)); + } + +void CHidKeyboardDriver::UpdateButtons(TInt aFieldIndex, + const TDesC8& aReport) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons()"))); + // Translate the HID usage values into a boot protocol style + // modifier bitmask: + // + const TInt KButton1 = 1; + const TInt KButton2 = 2; + const TInt KButton3 = 3; + + TBool buttonPressed(EFalse); + + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() %d, %d, %d"), + iMouseField[aFieldIndex]->UsagePage(), + iMouseField[aFieldIndex]->UsageMin(), + iMouseField[aFieldIndex]->UsageMax())); + (void) aFieldIndex; + // Hack but works + // We dont come here if the report is wrong? + TInt buttonByte = aReport[1]; + if (KButton1 == buttonByte) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button1"))); + buttonPressed = ETrue; + } + + if (KButton2 == buttonByte) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button2"))); + if (!iButton2Down) + { + iButton2Down = ETrue; + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyDown, EStdKeyApplication0); + UserSvr::AddEvent(rawEvent); + } + } + else + { + if (iButton2Down) + { + iButton2Down = EFalse; + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyUp, EStdKeyApplication0); + UserSvr::AddEvent(rawEvent); + } + } + + if (KButton3 == buttonByte) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button3"))); + buttonPressed = ETrue; + } + + if (buttonPressed) + { + if (!iButtonDown) + { + iButtonDown = ETrue; + SendButtonEvent(ETrue);//Send Mouse Button Down + } + } + else + { + if (iButtonDown) + { + iButtonDown = EFalse; + SendButtonEvent(EFalse); //Send Mouse Button Up + } + } + } +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::InterruptData +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::InterruptData(const TDesC8& aPayload) + { + // If the report has a report ID, it is in the first byte. + // If not, this value is ignored (see CField::IsInReport()). + // + TInt firstByte = aPayload[0]; + + TRACE_INFO( ( + _L("[HID]\tCHidKeyboardDriver::InterruptData(), report %d, length %d"), + firstByte, aPayload.Length())); +#ifdef _DEBUG + + for (TInt ii = 0; ii < aPayload.Length(); ii++) + { + TInt nextByte = aPayload[ii]; + DBG(RDebug::Print( + _L("[HID]\tCHidKeyboardDriver::InterruptData() report[%d] = %d"), + ii, nextByte)); + } +#endif + TBool mouseEvent(EFalse); + if (iMouseField[EMouseXY] && iMouseField[EMouseXY]->IsInReport(firstByte)) + { + UpdateXY(EMouseXY, aPayload); + mouseEvent = ETrue; + } + + if (iMouseField[EMouseButtons] && iMouseField[EMouseButtons]->IsInReport( + firstByte)) + { + UpdateButtons(EMouseButtons, aPayload); + mouseEvent = ETrue; + } + if (iMouseField[EMouseXY] && iMouseField[EMouseXY]->IsInReport(firstByte)) + { + UpdateWheel(EMouseWheel, aPayload); + mouseEvent = ETrue; + } + DBG(RDebug::Print(_L("[HID]\tCHidKeyboardDriver::InterruptData() mouseevent %d"), + mouseEvent)); + if (mouseEvent) + { + return; + } + // First check for any rollover errors: + // + TInt i; + for (i = 0; i < KNumInputFieldTypes; ++i) + { + if (iField[i] && iField[i]->IsInReport(firstByte) + && (iField[i]->UsagePage() == EUsagePageKeyboard)) + { + if (IsRollover(i, aPayload)) + { + CancelAllKeys(); + iLayoutMgr.Reset(); + return; + } + } + } + + // Update the modifier state: + // + if (iField[EModifierKeys] && iField[EModifierKeys]->IsInReport(firstByte)) + { + UpdateModifiers(EModifierKeys, aPayload); + } + + // Finally, look for key events in all fields in this report: + // + for (i = 0; i < KNumInputFieldTypes; ++i) + { + if (iField[i] && iField[i]->IsInReport(firstByte)) + { + ProcessKeys(i, aPayload); + } + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::IsRollover +// +// IsRollover() checks to see if the keyboard is in a rollover state +// (where too many keys are pressed to be able to give a sensible +// report). +// +// Rollover can only happen for fields with usage page 0x07. +// +// Returns ETrue if the keyboard is in a rollover state +//---------------------------------------------------------------------------- +// +TBool CHidKeyboardDriver::IsRollover(TInt aFieldIndex, const TDesC8& aReport) const + { + TBool rollover = ETrue; + + TReportTranslator report(aReport, iField[aFieldIndex]); + + for (TInt i = 0; rollover && (i < report.Count()); ++i) + { + const TInt KRolloverError = 1; + TInt usage; + + if (KErrNone == report.GetUsageId(usage, i) && usage + != KRolloverError) + { + rollover = EFalse; + } + } + + return rollover; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::ProcessKeys +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::ProcessKeys(TInt aFieldIndex, const TDesC8& aReport) + { + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::ProcessKeys()"))); + + // Get the appropriate field and key press array + const CField* field = iField[aFieldIndex]; + RArray& keysPressed = iKeys[aFieldIndex]; + + TInt bufferSize = keysPressed.Count(); + TReportTranslator report(aReport, field); + + // 1. For each key that appeared in the last report but does + // not appear in this report, send a key UP event. + + TRACE_FUNC + ((_L("[HID]\t Testing for keys up"))); + + TInt i; + for (i = 0; i < bufferSize; ++i) + { + TInt key = keysPressed[i]; + + if (key) + { + TInt pressed = EFalse; + + if ((report.GetValue(pressed, key) == KErrNone) && (!pressed)) + { + TRACE_INFO( (_L("[HID]\t Key up: %d [0x%04x]"), key, key)); + KeyUp(key, field->UsagePage()); + } + } + } + + // 2. For each key that appears in this report, but does + // not appear in the last report, send a key DOWN event. + + TRACE_FUNC + ((_L(" Testing for keys down"))); + + for (i = 0; i < report.Count(); ++i) + { + TInt key; + + if ((KErrNone == report.GetUsageId(key, i)) && (key != 0)) + { + // Was the key present (pressed) in the last report? + TBool match = EFalse; + + for (TInt j = 0; !match && (j < bufferSize); ++j) + { + match = (key == keysPressed[j]); + } + + // If it's a newly-pressed key then send a KeyDown + if (!match) + { + TRACE_INFO( (_L("[HID]\t Key down: %d [0x%02x]"), key, key)); + if (iInputHandlingReg->AllowedToHandleEvent( + EUsagePageKeyboard, key)) + { + iInputHandlingReg->AddHandledEvent( + EUsagePageGenericDesktop, key); + KeyDown(key, field->UsagePage()); + UpdateLockState(key); + } + } + } + } + + // 3. Finally, record what keys are down: + + TInt index = 0; + for (i = 0; (i < report.Count()) && (index < bufferSize); ++i) + { + TInt key; + + if (KErrNone == report.GetUsageId(key, i) && key != 0) + { + keysPressed[index++] = key; + } + } + while (index < bufferSize) + { + keysPressed[index++] = 0; + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::KeyEvent +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::KeyEvent(TBool aIsKeyDown, TInt aHidKey, + TInt aUsagePage) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::KeyEvent(%d, %d, %d)"), aIsKeyDown, + aUsagePage, aHidKey)); + + // Any type of key event will cancel a repeating key: + // + if (iRepeatTimer->IsActive()) + { + iRepeatTimer->Cancel(); + } + + if (iRepeatEndTimer->IsActive()) + { + iRepeatEndTimer->Cancel(); + } + + // Pass the key info to the keyboard layout translator: + // + TDecodedKeyInfo decodedKeys; + TInt err = iLayoutMgr.KeyEvent(aIsKeyDown, aHidKey, aUsagePage, + iModifiers, TLockKeys(iLockState & ECapsLock, iLockState + & ENumLock), decodedKeys); + + TTranslatedKey& key = decodedKeys.iEvent[0]; + if (err == KErrNone) + { + // Send the "key down" or "key up" event to the system: + // Handle special application launch key combinations + TRAPD( err, HandleApplicationLaunchKeysL(decodedKeys.iScanCode, aIsKeyDown, iModifiers)); + if (KErrNone != err) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::KeyEvent:Launch failed"))); + } + + //check if the key is multimedia key that needs to be sent as RawEvent and send it. + // if key event is consumed don't send it anymore. + if (!HandleMultimediaKeys(decodedKeys.iScanCode, aIsKeyDown, + iModifiers)) //check if the key is multimedia key that needs to be sent as RawEvent and send it. + { + if (decodedKeys.iScanCode != EStdKeyNull) + { + TKeyEvent event = + TKeyEventFromScanCode(decodedKeys.iScanCode); + + // remove other modifiers than autorepeat. + if (event.iScanCode == EStdKeyDevice3) + { + event.iModifiers &= EModifierAutorepeatable; + } + + //Number key events to phone app are handled differently. + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::KeyEvent: ScanCode: %d %c"), decodedKeys.iScanCode, decodedKeys.iScanCode)); + TInt unikey = key.iUnicode; + //Send key codes differently to idle app + if ((IsDigitKey(decodedKeys.iScanCode) || IsSpecialHandleKey( + unikey) || decodedKeys.iScanCode == EStdKeyYes + || decodedKeys.iScanCode == EStdKeyBackspace) + && IsPhoneAppTopMost()) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::KeyEvent: Send event %c to idle editor"), unikey)); + HandleTelephoneAppKeys(decodedKeys.iScanCode, unikey, + aIsKeyDown); + } + else + SendToWindowGroup(event, aIsKeyDown + ? EEventKeyDown + : EEventKeyUp); + } + + // Send any "key press" events to the system, if applicable: + // + for (TInt i = 0; i < decodedKeys.iCount; ++i) + { + TTranslatedKey & key = decodedKeys.iEvent[i]; + + SendKeyPress(key.iUnicode, key.iUsagePage, key.iScanCode, + key.iIsRepeatingKey); + } + } + } + else + { + TRACE_FUNC + ((_L("[HID]\tKeyboard event translation failed!"))); + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::TKeyEventFromScanCode +//---------------------------------------------------------------------------- +// +TKeyEvent CHidKeyboardDriver::TKeyEventFromScanCode(TInt aScanCode) const + { + TKeyEvent event; + + event.iScanCode = aScanCode; + event.iModifiers = KeyEventModifiers(); + + // The following are always zero for a key down or key up event: + event.iCode = 0; + event.iRepeats = 0; + + return event; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::IsDigitKey +//---------------------------------------------------------------------------- +// +TBool CHidKeyboardDriver::IsDigitKey(TInt aScanCode) + { + TBool ret = EFalse; + + if (aScanCode >= '0' && aScanCode <= '9') + { + ret = ETrue; + } + + return ret; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::IsDigit +//---------------------------------------------------------------------------- +// +TBool CHidKeyboardDriver::IsSpecialHandleKey(TInt aUniCode) + { + TBool ret = EFalse; + + if (aUniCode == '+' || aUniCode == '*' || aUniCode == '#' || aUniCode + == 'w' || aUniCode == 'p') + { + ret = ETrue; + } + + return ret; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::HandleTelephoneAppKeys +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::HandleTelephoneAppKeys(TInt aScanCode, + TInt aUniCode, TBool aIsKeyDown) + { + // Telephone view / idle view can't handle proper key events, but the key events must be sent as + // raw events. + TRawEvent rawEvent; + TUint modifier = 0; + TInt scancode = aScanCode; + switch (aUniCode) + { + case '+': + case EStdKeyNkpPlus: + scancode = EStdKeyNkpPlus; + modifier = EModifierLeftShift | EModifierShift; + break; + case '*': + //case EStdKeyNkpAsterisk: + scancode = EStdKeyNkpAsterisk; + modifier = 0; //EModifierLeftShift | EModifierShift; + break; + case '#': + //case EStdKeyHash: + scancode = EStdKeyHash; + modifier = EModifierLeftShift | EModifierShift; + break; + case 'w': + modifier = EModifierLeftShift | EModifierShift; + break; + case 'p': + modifier = EModifierLeftShift | EModifierShift; + break; + default: + break; + } + TRACE_INFO( (_L("[HID]\tHIDKeyboard: HandleTelephoneAppKeys: Overridden Scancode: %d, Modifier: %d"), scancode, modifier)); + TRACE_INFO( (_L("[HID]\tHIDKeyboard: HandleTelephoneAppKeys: Original unicode: %d"), aUniCode)); + + if (aIsKeyDown) + rawEvent.Set(TRawEvent::EKeyDown, scancode); + else + rawEvent.Set(TRawEvent::EKeyUp, scancode); //This will never be called for +,* and # + + TEventModifier ab = (TEventModifier) -1; //all bits set to 1. + TModifierState ba = (TModifierState) modifier; + TRACE_INFO( (_L("[HID]\t modifiers %d, modifierState: %d"), ab, (TUint)ba)); + + iWsSession.SetModifierState(ab, ba); + iWsSession.SimulateRawEvent(rawEvent); + iWsSession.Flush(); + TRACE_FUNC + ((_L("[HID]\tHIDKeyboard: HandleTelephoneAppKeys: Event sent!"))); + // Plus, Asterix and Hash keys need to send separate KeyUp event too. + if (aUniCode == '+' || aUniCode == '*' || aUniCode == '#' || aUniCode + == 'p' || aUniCode == 'w') + { + rawEvent.Set(TRawEvent::EKeyUp, scancode); + iWsSession.SimulateRawEvent(rawEvent); //Key up event + iWsSession.Flush(); + TRACE_FUNC + ((_L("[HID]\tHIDKeyboard: HandleTelephoneAppKeys: Separate Key up event sent!"))); + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::CancelKeysForField +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::CancelKeysForField(TInt aFieldIndex) + { + //TRACE_FUNC((_L("[HID]\tCHidKeyboardDriver::CancelKeysForField(%d)"), + if (iField[aFieldIndex]) + { + for (TInt i = 0; i < iField[aFieldIndex]->Count(); ++i) + { + TInt key = iKeys[aFieldIndex][i]; + //TRACE_FUNC((_L("[HID]\t Cancel key@%d=%02x (%d)"), + // i, key, key)); + if (key != 0) + { + KeyUp(key, iField[aFieldIndex]->UsagePage()); + iKeys[aFieldIndex][i] = 0; + } + } + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::CancelAllKeys +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::CancelAllKeys() + { + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::CancelAllKeys()"))); + + // Stop the key repeat timer: + if (iRepeatTimer->IsActive()) + { + iRepeatTimer->Cancel(); + } + + // Stop the key repeat safety timer: + if (iRepeatEndTimer->IsActive()) + { + iRepeatEndTimer->Cancel(); + } + + // Send key up events for any pressed keys: + for (TInt i = 0; i < KNumInputFieldTypes; ++i) + { + CancelKeysForField(i); + } + + // No modifier keys pressed: + iModifiers = 0; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::UpdateModifiers +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::UpdateModifiers(TInt aFieldIndex, + const TDesC8& aReport) + { + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::UpdateModifiers()"))); + TRACE_INFO( (_L("[HID]\t old iModifiers = %02x"), iModifiers)); + + const TInt KLeftControl = 224; // => bit 0 of modifier bitmask + const TInt KRightGui = 231; // => bit 7 + + TUint8 newModifiers = 0; + + // Translate the HID usage values into a boot protocol style + // modifier bitmask: + // + TReportTranslator report(aReport, iField[aFieldIndex]); + for (TInt i = KLeftControl; i <= KRightGui; i++) + { + TInt value; + + if (KErrNone == report.GetValue(value, i) && value) + { + newModifiers |= (1 << (i - KLeftControl)); + } + } + + // Finally, record the new state: + // + iModifiers = newModifiers; + + TRACE_INFO( (_L("[HID]\t new iModifiers = %02x"), iModifiers)); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::UpdateLockState +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::UpdateLockState(TInt aHidKey) + { + const TInt KHidCapsLock = 57; + const TInt KHidScrollLock = 71; + const TInt KHidNumLock = 83; + + TUint oldLockState = iLockState; + + switch (aHidKey) + { + case KHidNumLock: + iLockState ^= ENumLock; + break; + case KHidCapsLock: + iLockState ^= ECapsLock; + break; + case KHidScrollLock: + iLockState ^= EScrollLock; + break; + } + + if (oldLockState != iLockState) + { + TRACE_INFO( (_L("[HID]\tChanged lock state: %d -> %d"), + oldLockState, iLockState)); + SetKeyboardLeds(); + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::KeyEventModifiers +//---------------------------------------------------------------------------- +// +TUint32 CHidKeyboardDriver::KeyEventModifiers() const + { + // Modifier state: + + const TInt KNumModifierKeys = 8; + + const TUint32 KModifierMask[KNumModifierKeys] = + { + EModifierLeftCtrl | EModifierCtrl, // 0x A0 (report bit 0) + EModifierLeftShift | EModifierShift, // 0x 500 + EModifierLeftAlt | EModifierAlt, // 0x 14 + EModifierLeftFunc | EModifierFunc, // 0x2800 + EModifierRightCtrl | EModifierCtrl, // 0x C0 + EModifierRightShift | EModifierShift, // 0x 600 + EModifierRightAlt | EModifierAlt, // 0x 18 + EModifierRightFunc | EModifierFunc + // 0x3000 (report bit 7) + }; + + TUint32 result = 0; + + TUint bitPosn = 1; + for (TInt i = 0; i < KNumModifierKeys; ++i) + { + if (iModifiers & bitPosn) + { + result |= KModifierMask[i]; + } + bitPosn <<= 1; + } + + // Lock state: + + if (iLockState & ECapsLock) + { + result |= EModifierCapsLock; // 0x 4000 + } + + if (iLockState & ENumLock) + { + result |= EModifierNumLock; // 0x 8000 + } + + if (iLockState & EScrollLock) + { + result |= EModifierScrollLock; // 0x10000 + } + + // Flag used by the FEP to identify events from the HID keyboard + const TUint KHidKeyboardFepFlag = 0x00200000; + result |= KHidKeyboardFepFlag; + + return result; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::SetKeyboardLeds +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::SetKeyboardLeds() const + { + // Not supported at present + } + +// ---------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::OnKeyRepeat +// Key repeat call-back: +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::OnKeyRepeat() + { + // Send another key-press event: + iLastKey.iRepeats = 1; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::OnKeyRepeat() event [%d, %d, 0x%06x, %d]"), + iLastKey.iCode, iLastKey.iScanCode, + iLastKey.iModifiers, iLastKey.iRepeats)); + SendToWindowGroup(iLastKey, EEventKey); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelController::VolumePSChangeTimedoutCallback +// ----------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::TimerFiredOnKeyRepeat(TAny* aThis) + { + return reinterpret_cast (aThis)->OnKeyRepeat(); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::SendKeyPress +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::SendKeyPress(TUint16 aUnicodeKey, TInt aUsagePage, + TInt aScanCode, TBool aIsRepeatingKey) + { + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::SendKeyPress([%d], %d, %d)"), + aUnicodeKey, aScanCode, aIsRepeatingKey)); + +#ifdef _DEBUG + //Please the compiler + //TBuf<256> winGroupName; + //iWsSession.GetWindowGroupNameFromIdentifier(iWsSession.GetFocusWindowGroup(), winGroupName); + //TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver: Focused Window group:<%S>"), winGroupName)); +#endif + + //Number entry to Telephone app is handled differently. + if ((IsDigitKey(aScanCode) || IsSpecialHandleKey(aUnicodeKey)) + && IsPhoneAppTopMost()) + return; + + TKeyEvent event = TKeyEventFromScanCode(aScanCode); + event.iCode = aUnicodeKey; + + if (aIsRepeatingKey) + { + event.iModifiers |= EModifierAutorepeatable; + } + + // Cancel any current key repeat: + if (iRepeatTimer->IsActive()) + { + iRepeatTimer->Cancel(); + } + + // Send the key press event: + + const TInt KConsumerControlPage = 0x0c; + + // Number entry in telephony does not activate unless we send the key event through WindowServer. + if (aUsagePage == KConsumerControlPage) + + { + // Send media keys using RWsSession::SimulateKeyEvent() so + // that the window server "capture key" function will + // operate. Note that this means that media keys won't have + // standard repeat key functionality because we can't set + // the iRepeats member using SimulateKeyEvent(). + SendToWindowServer(event); + } + else + { + //If Chr-key, send '*' to open Special Character Dialog, but not if idle app (telephone). + if (event.iCode == EKeyApplication2) + { + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::SendKeyPress, AltGr pressed"))); + if (IsPhoneAppTopMost()) //If idle app top-most, don't send '*'. + return; + event.iCode = '*'; + event.iScanCode = EStdKeyNkpAsterisk; + event.iModifiers = 0; + } + //If Enter-key, check if AppMenu or Phone/Idle is topmost --> make it Selection key! + if (event.iCode == EKeyEnter) + { + if (IsApplicationMenuTopMost() || IsPhoneAppTopMost()) + { + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::SendKeyPress, Change enter to selection"))); + event.iCode = EKeyDevice3; + event.iScanCode = EStdKeyDevice3; + } + } + + // remove other modifiers than autorepeat. + if (event.iScanCode == EStdKeyDevice3) + { + event.iModifiers &= EModifierAutorepeatable; + } + + // Send all other keys using RWsSession::SendEventToWindowGroup(): + SendToWindowGroup(event, EEventKey); + + // Set up a key repeat timer, if necessary: + if (aIsRepeatingKey) + { + iLastKey = event; + TTimeIntervalMicroSeconds32 KDefaultDelay = KKeyRepeatDelay; + TTimeIntervalMicroSeconds32 KDefaultRate = KKeyRepeatInterval; + iRepeatTimer->Start(KDefaultDelay, KDefaultRate, TCallBack( + CHidKeyboardDriver::TimerFiredOnKeyRepeat, this)); + if (!iRepeatEndTimer->IsActive()) + { + DBG(RDebug::Print(_L("[HID]\tCHidKeyboardDriver::SendKeyPress, start repeat ending timer"))); + iRepeatEndTimer->After(KRepeatEndTimeout); + } + } + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::IsPhoneAppTopMost +// Check if Application Menu is the active application receiving the key presses +//---------------------------------------------------------------------------- +// +TBool CHidKeyboardDriver::IsApplicationMenuTopMost() + { + TBool ret = EFalse; + if (iAppMenuId == KErrNotFound) //was not found earlier in Constructor (WKB app launched at boot) + iAppMenuId = AppMenuId(); //if in constructor the AppMenu was not active, then ask is it now + TInt focusedId = iWsSession.GetFocusWindowGroup(); + if (focusedId == iAppMenuId) + ret = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::IsApplicationMenuTopMost(): %d"), ret )); + return ret; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::IsPhoneAppTopMost +//---------------------------------------------------------------------------- +// +TBool CHidKeyboardDriver::IsPhoneAppTopMost() + { + TBool ret = EFalse; + if (iPhoneAppId == KErrNotFound) //was not found earlier in Constructor (WKB app launched at boot) + iPhoneAppId = PhoneAppId(); //if in constructor the AppMenu was not active, then ask is it now + if (iIdleAppId == KErrNotFound) + iIdleAppId = IdleAppId(); + + TInt focusedId = iWsSession.GetFocusWindowGroup(); + if (focusedId == iPhoneAppId || focusedId == iIdleAppId) //KPhoneIdleViewUid || focusedId == KIdleAppUid) + ret = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::IsPhoneAppTopMost(): %d"), ret )); + return ret; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::AppMenuId +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::AppMenuId() + { + TApaTaskList taskList(iWsSession); + TApaTask task = taskList.FindApp(TUid::Uid(KMenuAppUid)); + TInt Id = task.WgId(); + DBG(if (KErrNotFound == Id) RDebug::Print(_L("[HID]\tCHidKeyboardDriver::AppMenuId(): Menu not found!"))); + + return Id; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::PhoneAppId +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::PhoneAppId() + { + + TApaTaskList taskList(iWsSession); + TApaTask task = taskList.FindApp(TUid::Uid(KPhoneAppUid)); + TInt Id = task.WgId(); + DBG(if (KErrNotFound == Id) RDebug::Print(_L("[HID]\tCHidKeyboardDriver::PhoneAppId(): Phone not found!"))); + + return Id; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::IdleAppId +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::IdleAppId() + { + TApaTaskList taskList(iWsSession); + TApaTask task = taskList.FindApp(TUid::Uid(KIdleAppUid)); + TInt Id = task.WgId(); + DBG(if (KErrNotFound == Id) RDebug::Print(_L("[HID]\tCHidKeyboardDriver::IdleAppId(): Idle not found!"))); + + return Id; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::SendToWindowServer +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::SendToWindowServer(TKeyEvent aKeyEvent) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::SendToWindowServer, event: kc 0x%08x, sc 0x%08x, mod 0x%06x, rep %d]"), + aKeyEvent.iCode, aKeyEvent.iScanCode, + aKeyEvent.iModifiers, aKeyEvent.iRepeats)); + + // Prevent the window server generating key repeats as we do this ourselves + aKeyEvent.iModifiers &= ~EModifierAutorepeatable; + iWsSession.SimulateKeyEvent(aKeyEvent); + iWsSession.Flush(); + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::SendToWindowServer, Event sent!"))); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::SendToWindowGroup +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::SendToWindowGroup(const TKeyEvent& aKeyEvent, + TEventCode aType) + { + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::SendToWindowGroup, Event: type %d, kc 0x%08x, sc 0x%08x, mod 0x%06x, rep %d]"), + aType, aKeyEvent.iCode, aKeyEvent.iScanCode, + aKeyEvent.iModifiers, aKeyEvent.iRepeats)); + + // Using RWsSession::SendEventToWindowGroup() bypasses the normal + // key handling in the window server, and so capture keys don't + // work. Therefore we check for the known captured keys in + // WindowGroupForKeyEvent(). + + TInt wGroup = WindowGroupForKeyEvent(aKeyEvent, aType); + + if (0 < wGroup) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::SendToWindowGroup: Send event to window group %d"), wGroup)); + + TWsEvent event; + + event.SetType(aType); + event.SetHandle(0); + + *(event.Key()) = aKeyEvent; + + // Remove shift modifiers from call key events because + // the phone application ignores them otherwise + // + if (EStdKeyYes == aKeyEvent.iScanCode || EStdKeyNo + == aKeyEvent.iScanCode) + { + event.Key()->iModifiers &= ~(EModifierLeftShift + | EModifierRightShift | EModifierShift); + } + + // don't send ctrl and shift keys. + if (EStdKeyLeftShift != aKeyEvent.iScanCode && EStdKeyRightShift + != aKeyEvent.iScanCode && EStdKeyLeftCtrl + != aKeyEvent.iScanCode && EStdKeyRightCtrl + != aKeyEvent.iScanCode) + { + iWsSession.SendEventToWindowGroup(wGroup, event); + iWsSession.Flush(); + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::SendToWindowGroup: Event sent!"))); + } + else + TRACE_FUNC + ((_L("[HID]\tCHidKeyboardDriver::SendToWindowGroup: Shift or ctrl not sent!"))); + + } + + // Keypresses should reset the backlight timer: + User::ResetInactivityTime(); + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::WindowGroupForKeyEvent +// Determine which window group a key event should be sent to. +// Except for special cases this is the window group with the focus. +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::WindowGroupForKeyEvent(const TKeyEvent& aKeyEvent, + TEventCode aType) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::WindowGroupForKeyEvent: type %d, kc 0x%08x, sc 0x%08x, mod 0x%06x, rep %d]"), + aType, aKeyEvent.iCode, aKeyEvent.iScanCode, + aKeyEvent.iModifiers, aKeyEvent.iRepeats)); + _LIT(KBackDrop, "*EiksrvBackdrop*"); + + if (EStdKeyApplication0 == aKeyEvent.iScanCode && (EEventKeyDown == aType + || EEventKeyUp == aType)) + { + // Application key up/down events go to the Eikon server + // Use this old way for application key + TInt result = iWsSession.FindWindowGroupIdentifier(0, KBackDrop); //This was in A2.x __EIKON_SERVER_NAME + DBG(if (KErrNotFound == result) RDebug::Print(_L("[HID]\tCHidKeyboardDriver::WindowGroupForKeyEvent(): BackDropWindowGroup Name not found!"))); + return result; + } + + if (EKeyDevice2 == aKeyEvent.iCode && EEventKey == aType) + { + // Power key press events go to SysAp + TApaTaskList taskList( iWsSession ); + TApaTask task = taskList.FindApp( TUid::Uid( KSysApUid ) ); + TInt result = task.WgId(); + DBG(if (KErrNotFound == result) RDebug::Print(_L("[HID]\tCHidKeyboardDriver::WindowGroupForKeyEvent(): SysApWindowGroup Name not found!"))) + ; + return result; + } + + if (EStdKeyNo == aKeyEvent.iScanCode + && (EEventKeyDown == aType || EEventKeyUp == aType)) + { + // End key up/down events go to the phone app + TApaTaskList taskList( iWsSession ); + TApaTask task = taskList.FindApp( TUid::Uid( KPhoneAppUid ) ); + TInt result = task.WgId(); + DBG(if (KErrNotFound == result) RDebug::Print(_L("[HID]\tCHidKeyboardDriver::WindowGroupForKeyEvent(): PhoneAppWindowGroup Name not found!"))) + ; + return result; + } + + // All other key events go to the window group with the keyboard focus + return iWsSession.GetFocusWindowGroup(); + } + +// ---------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::ResetArrayToSize +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::ResetArrayToSize(RArray& aArray, TInt aSize) + { + TInt err = KErrNone; + + aArray.Reset(); + + for (TInt i = 0; !err && (i < aSize); ++i) + { + err = aArray.Append(0); + } + + return err; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::CanHandleReportL +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::CanHandleReportL(CReportRoot* aReportRoot) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboard::CanHandleReport(0x%08x)"), + aReportRoot)); + iSupportedFieldCount = 0; + // Look for keyboard reports: + + THidFieldSearch search; + + TKeyboardFinder finder; + search.SearchL(aReportRoot, &finder); + iField[EStandardKeys] = finder.StandardKeyField(); + iField[EModifierKeys] = finder.ModifierKeyField(); + iLedField = finder.LedField(); + + TConsumerKeysFinder mmFinder; + search.SearchL(aReportRoot, &mmFinder); + iField[EMediaKeys] = mmFinder.ConsumerKeysField(); + + TPowerKeysFinder pwrFinder; + search.SearchL(aReportRoot, &pwrFinder); + iField[EPowerKeys] = pwrFinder.PowerKeysField(); + + for (TInt i = 0; i < KNumInputFieldTypes; ++i) + { + if (iField[i]) + { + iSupportedFieldCount++; + User::LeaveIfError(ResetArrayToSize(iKeys[i], iField[i]->Count())); + } + } + + TInt valid = KErrHidUnrecognised; + + // We only require standard and modifier key reports; the + // LED and consumer keys are optional: + + if ((iField[EStandardKeys] != 0) && (iField[EModifierKeys] != 0)) + { + valid = KErrNone; + } + + TMouseFinder mousefinder; + search.SearchL(aReportRoot, &mousefinder); + iMouseField[EMouseButtons] = mousefinder.ButtonsField(); + iMouseField[EMouseXY] = mousefinder.XYField(); + iMouseField[EMouseWheel] = mousefinder.WheelField(); + + if ((iMouseField[EMouseButtons] != 0) && (iMouseField[EMouseXY] != 0)) + { + iComboDevice = ETrue; + } + + TRACE_INFO( ( + _L("CHidKeyboard::CanHandleReport() returning %d"), valid)); + + return valid; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::HandleApplicationLaunchKeysL +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::HandleApplicationLaunchKeysL(TUint16 aScancodeKey, + TBool aIsKeyDown, TUint8 aHIDModifiers) + { + // Note that aHIDModifier is not Symbian Modifier bits, but in below format: (from HID spec) + /* const TUint32 KModifierMask[KNumModifierKeys] = + { + EModifierLeftCtrl | EModifierCtrl, // 0x A0 (report bit 0) + EModifierLeftShift | EModifierShift, // 0x 500 + EModifierLeftAlt | EModifierAlt, // 0x 14 + EModifierLeftFunc | EModifierFunc, // 0x2800 + EModifierRightCtrl | EModifierCtrl, // 0x C0 + EModifierRightShift | EModifierShift, // 0x 600 + EModifierRightAlt | EModifierAlt, // 0x 18 + EModifierRightFunc | EModifierFunc // 0x3000 (report bit 7) + }; + */ + const TUint KHIDModifierAlt = 0x04; + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleApplicationLaunchKeys: scancode 0x%08x, HIDmodifiers 0x%08x"), aScancodeKey, aHIDModifiers)); + + switch (aScancodeKey) + { + // Alt-m launches MultimediaMenu + case 'm': + case 'M': + { + if (aHIDModifiers & KHIDModifierAlt) + { + TRACE_FUNC + ((_L("Launch multimediamenu"))); + //LaunchApplicationL( KMultimediaMenuUid ); + TInt err = SendRawEvent(EStdKeyApplication6, aIsKeyDown, 0); + if (KErrNone != err) + { + TRACE_FUNC + ((_L("[HID]\t Event sending failed"))); + } + } + break; + } + + // Alt-n launches ActiveNotes + case 'n': + case 'N': + { + if (aHIDModifiers & KHIDModifierAlt) + { + TRACE_FUNC + ((_L("[HID]\t Launch active notes"))); + LaunchApplicationL(KActiveNotesUid); + } + break; + } + case EStdKeyF1: + { + DBG(RDebug::Print(_L("[HID]\t Launch Web service"))); + LaunchApplicationL(KServicesUid); + } + break; + case EStdKeyF2: + { + DBG(RDebug::Print(_L("[HID]\t Launch messages"))); + LaunchApplicationL(KMessagingUid); + } + break; + default: + break; + } + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::LaunchApplicationL +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::LaunchApplicationL(TInt aAppUid) + { + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::LaunchApplication: UID 0x%08x"), aAppUid)); + + TApaTaskList taskList(iWsSession); + TUid uid = TUid::Uid(aAppUid); + TApaTask task = taskList.FindApp(uid); + if (task.Exists()) + { + // Application is active, so just bring to foreground + task.BringToForeground(); + } + else + { + RApaLsSession appArcSession; + // connect to AppArc server + User::LeaveIfError(appArcSession.Connect()); + + CleanupClosePushL(appArcSession); + + TThreadId threadID; + + // Launch the application with no params. + User::LeaveIfError(appArcSession.StartDocument(KNullDesC, uid, + threadID)); + + CleanupStack::Pop(1); // appArcSession + + appArcSession.Close(); + } + + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::HandleNokiaMultimediaKeys +// Takes some Multimedia keyevents from HID and converts them to Nokia raw events format +// to simulate as if the key presses came from phone keypad (volume +/-, play, pause, frwd, rewind) +// +// This is temporary solution that shall be replaced by "proper" RemCon Bearer solution. +// Because the keycodes used here may change in future terminal! +// Note that aHIDModifier is not Symbian Modifier bits, but in below format: (from HID spec) +// const TUint32 KModifierMask[KNumModifierKeys] = +// { +// EModifierLeftCtrl | EModifierCtrl, // 0x A0 (report bit 0) +// EModifierLeftShift | EModifierShift, // 0x 500 +// EModifierLeftAlt | EModifierAlt, // 0x 14 +// EModifierLeftFunc | EModifierFunc, // 0x2800 +// EModifierRightCtrl | EModifierCtrl, // 0x C0 +// EModifierRightShift | EModifierShift, // 0x 600 +// EModifierRightAlt | EModifierAlt, // 0x 18 +// EModifierRightFunc | EModifierFunc // 0x3000 (report bit 7) +// }; +//---------------------------------------------------------------------------- +// + +TBool CHidKeyboardDriver::HandleMultimediaKeys(TUint16 aScancodeKey, + TBool aIsKeyDown, TUint8 aHIDModifiers) + { + TBool ret = HandleMultimediaKeysForNokia(aScancodeKey, aIsKeyDown, + aHIDModifiers); + + if (!ret) + { + ret = HandleMultimediaKeysForStandard(aScancodeKey, aIsKeyDown, + aHIDModifiers); + } + return ret; + } + +void CHidKeyboardDriver::ResetBitmap(TBool aIsKeyDown, + TMmKeyDown aBitmapToReset) + { + if (aIsKeyDown) + { + iMmKeyDown = (iMmKeyDown | aBitmapToReset); + } + else + { + iMmKeyDown = (iMmKeyDown & !aBitmapToReset); + } + } + +TBool CHidKeyboardDriver::HandleMultimediaKeysForNokia(TUint16 aScancodeKey, + TBool aIsKeyDown, TUint8 aHIDModifiers) + { + const TUint KHidModifierCtrl = 0x01; + const TUint KHidModifierCtrlRight = 0x10; + const TUint KHidModifierAlt = 0x04; + + // const TUint KHidModifierAltGr = 0x64; + TInt scancode = 0; + TUint modifier = 0; + TBool isMmKey = EFalse; + + TMmKeyDown bitmapToReset; + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: scancode 0x%08x, HIDmodifiers 0x%08x"), aScancodeKey, aHIDModifiers)); + + switch (aScancodeKey) + { + + // Mappings for Nokia SU-8W + // Key down events are stored into bitmap in order to detect if keys are released in reverse order, which caused jamming. + // For example: control key released before arrow key. + + case EStdKeyUpArrow: + { + if (aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight) + || iMmKeyDown & EVolUp) + { + scancode = EStdKeyIncVolume; //Volume Up = Ctrl + ArrowUp + isMmKey = ETrue; + // Set or reset flag bit + + bitmapToReset = EVolUp; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume up %d"), aIsKeyDown)); + } + break; + } + + case EStdKeyDownArrow: + { + if (aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight) + || iMmKeyDown & EVolDown) + { + scancode = EStdKeyDecVolume; //Volume Down = Ctrl + ArrowDown + isMmKey = ETrue; + bitmapToReset = EVolDown; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume down %d"), aIsKeyDown)); + } + break; + } + + case EStdKeyRightArrow: + { + if (aHIDModifiers & KHidModifierAlt || iMmKeyDown & EPlay) + { + scancode = EStdKeyApplication2; //Play = Alt + ArrowRight + isMmKey = ETrue; + bitmapToReset = EPlay; + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Play %d"), aIsKeyDown)); + } + else if (aHIDModifiers & (KHidModifierCtrl + | KHidModifierCtrlRight) || iMmKeyDown & ENext) + { + scancode = EStdKeyApplication4; //Next = Ctrl + ArrowRight + isMmKey = ETrue; + bitmapToReset = ENext; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Next %d"), aIsKeyDown)); + } + break; + } + + case EStdKeyLeftArrow: + { + if (aHIDModifiers & KHidModifierAlt || iMmKeyDown & EStop) + { + scancode = EStdKeyApplication3; //Stop = Alt + ArrowLeft + isMmKey = ETrue; + bitmapToReset = EStop; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Stop %d"), aIsKeyDown)); + } + else if (aHIDModifiers & (KHidModifierCtrl + | KHidModifierCtrlRight) || iMmKeyDown & EPrev) + { + scancode = EStdKeyApplication5; //Prev = Ctrl + ArrowLeft + isMmKey = ETrue; + bitmapToReset = EPrev; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Prev %d"), aIsKeyDown)); + } + break; + } + + default: + break; + } + + if (isMmKey) + { + ResetBitmap(aIsKeyDown, bitmapToReset); + SendRawEvent(scancode, aIsKeyDown, modifier); + } + return isMmKey; + } + +TBool CHidKeyboardDriver::HandleMultimediaKeysForStandard( + TUint16 aScancodeKey, TBool aIsKeyDown, TUint8 aHIDModifiers) + { + TInt scancode = 0; + TUint modifier = 0; + TBool isMmKey = EFalse; + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: scancode 0x%08x, HIDmodifiers 0x%08x"), aScancodeKey, aHIDModifiers)); + //please complier... + (void) aHIDModifiers; + + switch (aScancodeKey) + { + // Mappings for standard keyboards + + case EStdKeyApplication2: //Play + { + scancode = EStdKeyApplication2; + isMmKey = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Play %d"), aIsKeyDown)); + break; + } + + case EStdKeyApplication3: //Stop + { + scancode = EStdKeyApplication3; + isMmKey = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Stop %d"), aIsKeyDown)); + break; + } + + case EStdKeyApplication4: //Next + { + scancode = EStdKeyApplication4; + isMmKey = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Next %d"), aIsKeyDown)); + break; + } + + case EStdKeyApplication5: //Prev + { + scancode = EStdKeyApplication5; + isMmKey = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Prev %d"), aIsKeyDown)); + break; + } + + case EStdKeyIncVolume: //Volume up + { + scancode = EStdKeyIncVolume; + isMmKey = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume up %d"), aIsKeyDown)); + break; + } + + case EStdKeyDecVolume: //Volume down + { + scancode = EStdKeyDecVolume; + isMmKey = ETrue; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume down %d"), aIsKeyDown)); + break; + } + + default: + break; + } + + if (isMmKey) + { + SendRawEvent(scancode, aIsKeyDown, modifier); + } + return isMmKey; + } + +// ---------------------------------------------------------------------- +// CHidKeyboardDriver::SendRawEvent +// Send raw key event to window server +// ---------------------------------------------------------------------- +TInt CHidKeyboardDriver::SendRawEvent(TInt aScancode, TBool aIsKeyDown, + TUint aModifier) + { + TRawEvent rawEvent; + TInt err = KErrNone; + + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::SendRawEvent: scancode %d, modifier: %d, keydown: %d"), aScancode, aModifier, aIsKeyDown )); + if (aScancode != 0) + { + if (aIsKeyDown) + rawEvent.Set(TRawEvent::EKeyDown, aScancode); + else + rawEvent.Set(TRawEvent::EKeyUp, aScancode); //This will never be called for +,* and # + + TEventModifier eventmodifier = (TEventModifier) -1; //all bits set to 1. + TModifierState modifierstate = (TModifierState) aModifier; + TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::SendRawEvents: modifiers %d, modifierState: %d"), aModifier, (TUint)modifierstate)); + + err = iWsSession.SetModifierState(eventmodifier, modifierstate); + iWsSession.SimulateRawEvent(rawEvent); + iWsSession.Flush(); + } + return err; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::SupportedFieldCount +//---------------------------------------------------------------------------- +// +TInt CHidKeyboardDriver::SupportedFieldCount() + { + return iSupportedFieldCount; + } + +//---------------------------------------------------------------------------- +// CHidKeyboardDriver::SetInputHandlingReg +//---------------------------------------------------------------------------- +// +void CHidKeyboardDriver::SetInputHandlingReg( + CHidInputDataHandlingReg* aHandlingReg) + { + iInputHandlingReg = aHandlingReg; + } + +// ---------------------------------------------------------------------- +// CHidKeyboardDriver::TimerExpired +// Callback function from CTimeOutTimer +// ---------------------------------------------------------------------- +void CHidKeyboardDriver::TimerExpired() + { + DBG(RDebug::Print(_L("[HID]\tCHidKeyboardDriver::TimerExpired, cancel all key presses"))); + CancelAllKeys(); + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/data/kbdlayout.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/data/kbdlayout.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2008 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: ECOM plugin resource file for keyboard layouts. +* +*/ + +#include +#include "hiduids.h" + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = LAYOUT_PLUGIN_UID; + interfaces = + { + INTERFACE_INFO + { + interface_uid = LAYOUT_PLUGIN_IF; // HID driver interface UID + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = BELGIAN_LAYOUT_IMP; + version_no = 1; + display_name = "Belgian Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = DANISH_LAYOUT_IMP; + version_no = 1; + display_name = "Danish Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = DUTCH_LAYOUT_IMP; + version_no = 1; + display_name = "Dutch Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = FINSWE_LAYOUT_IMP; + version_no = 1; + display_name = "FinnishSwedish Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = FRENCH_LAYOUT_IMP; + version_no = 1; + display_name = "French Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = GERMAN_LAYOUT_IMP; + version_no = 1; + display_name = "German Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = ITALIAN_LAYOUT_IMP; + version_no = 1; + display_name = "Italian Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = NORWEGIAN_LAYOUT_IMP; + version_no = 1; + display_name = "Norwegian Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = PORTUGUESE_LAYOUT_IMP; + version_no = 1; + display_name = "Portuguese Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = SPANISH_LAYOUT_IMP; + version_no = 1; + display_name = "Spanish Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = SU8DANNOR_LAYOUT_IMP; + version_no = 1; + display_name = "SU-8 DanishNorwegian Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = SU8FINSWE_LAYOUT_IMP; + version_no = 1; + display_name = "SU-8 FinnishSwedish Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = SU8GERMAN_LAYOUT_IMP; + version_no = 1; + display_name = "SU-8 German Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = SU8INTUSENGLISH_LAYOUT_IMP; + version_no = 1; + display_name = "SU-8 US International Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = SU8RUSSIANINT_LAYOUT_IMP; + version_no = 1; + display_name = "SU-8 Russian International Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = UK_LAYOUT_IMP; + version_no = 1; + display_name = "United Kingdom Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = US_LAYOUT_IMP; + version_no = 1; + display_name = "United States Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = USDVORAK_LAYOUT_IMP; + version_no = 1; + display_name = "Unoted States Dvorak Keyboard Layout Plugin"; + }, + IMPLEMENTATION_INFO + { + implementation_uid = USINT_LAYOUT_IMP; + version_no = 1; + display_name = "United States International Keyboard Layout Plugin"; + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +PRJ_MMPFILES +kbdlayout.mmp + +PRJ_PLATFORMS +WINSCW ARMV5 + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/group/kbdlayout.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/group/kbdlayout.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2008 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 "../../inc/hiduids.h" + +TARGET kbdlayout.dll +TARGETTYPE PLUGIN +UID ECOM_UID LAYOUT_PLUGIN_UID +CAPABILITY CAP_ECOM_PLUGIN //CAP_APPLICATION PowerMgmt NetworkControl + +SOURCEPATH ../src +SOURCE layout.cpp +SOURCE hidlayoutimplproxy.cpp +SOURCE belgian.cpp +SOURCE danish.cpp +SOURCE dutch.cpp +SOURCE finnishswedish.cpp +SOURCE french.cpp +SOURCE german.cpp +SOURCE italian.cpp +SOURCE norwegian.cpp +SOURCE portuguese.cpp +SOURCE spanish.cpp +SOURCE su8danishnorwegian.cpp +SOURCE su8finnishswedish.cpp +SOURCE su8german.cpp +SOURCE su8intusenglish.cpp unitedkingdom.cpp unitedstates.cpp unitedstatesdvorak.cpp usinternational.cpp su8russianint.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../manager/inc +USERINCLUDE ../../common/inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc + +SOURCEPATH ../data +START RESOURCE kbdlayout.rss +#ifdef SYMBIAN_SECURE_ECOM +TARGET kbdlayout.rsc +#endif +END // ECOM resource definition + + +LIBRARY ecom.lib +LIBRARY euser.lib + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/belgian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/belgian.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef BELGIAN_H +#define BELGIAN_H + +// INCLUDES +#include +#include +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CBelgianLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // Report what layouts are supported: + virtual TInt LayoutId() const; + +private: + + /* C++ constructor */ + CBelgianLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyTilde[]; + }; + +#endif // BELGIAN_H +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/danish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/danish.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#ifndef DANISH_H +#define DANISH_H + +// INCLUDES +#include +#include +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CDanishLayout : public CDeadKeyLayout + { + public: + + static CKeyboardLayout* NewL(); + + // Layout has additional Caps Lock keys: + virtual TBool ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const; + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + + private: + + /* C++ constructor */ + CDanishLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyTilde[]; + }; + +#endif //DANISH_H + +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/dutch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/dutch.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#ifndef DUTCH_H +#define DUTCH_H + +// INCLUDES +#include +#include +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CDutchLayout : public CDeadKeyLayout + { + public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + private: + + /* C++ constructor */ + CDutchLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyTilde[]; + static const TKeyPair KDeadKeyCedilla[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + }; + +#endif //DUTCH_H + +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/finnishswedish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/finnishswedish.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef FINNISHSWEDISH_H +#define FINNISHSWEDISH_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CFinnishSwedishLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CFinnishSwedishLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyTilde[]; + }; + +#endif //FINNISHSWEDISH_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/french.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/french.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef FRENCH_H +#define FRENCH_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CFrenchLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // Report what layouts are supported: + virtual TInt LayoutId() const; + +private: + + /* C++ constructor */ + CFrenchLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyTilde[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyDiaeresis[]; + }; + +#endif //FRENCH_H +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/german.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/german.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef GERMAN_H +#define GERMAN_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CGermanLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // Report what layouts are supported: + virtual TInt LayoutId() const; + +private: + + /* C++ constructor */ + CGermanLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyCircumflex[]; + }; + +#endif //GERMAN_H +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/hidlayoutplugininterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/hidlayoutplugininterface.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2008 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: HID Keyboard Layout ECOM interface definition. + * +*/ + + +#ifndef __HIDLAYOUTPLUGININTERFACE_H__ +#define __HIDLAYOUTPLUGININTERFACE_H__ + +#include +#include "hiddebug.h" +#include "hiduids.h" + +// Constant for plugin interface: +const TUid KHidLayoutPluginInterfaceUid = + { + LAYOUT_PLUGIN_IF + }; + +/** + * Interface class for HID Layout plugin. All plugins will implement this class. + * + * @lib kbdlayout.lib ? + * @since ... + */ +class CHidLayoutPluginInterface : public CBase + { +public: + // Constructors & destructors + + /** + * Creates new plugin having the given UID. + * Uses Leave code KErrNotFound if implementation is not found. + * + * @param aImplementationUid Implementation UID of the plugin to be + * created. + */ + inline static CHidLayoutPluginInterface* NewL( + const TUid aImplementationUid); + + /** + * Destructor + */ + inline ~CHidLayoutPluginInterface(); + +protected: + // New + + /** + * C++ constructor. + */ + inline CHidLayoutPluginInterface(); + +private: + // Data + + /** + * ECOM plugin instance UID. + */ + TUid iDtor_ID_Key; + }; + +inline CHidLayoutPluginInterface::CHidLayoutPluginInterface() + { + } + +inline CHidLayoutPluginInterface::~CHidLayoutPluginInterface() + { + DBG(RDebug::Print(_L("[HID]\tCHidLayoutPluginInterface: destroying plugin 0x%08x"),iDtor_ID_Key)); + REComSession::DestroyedImplementation(iDtor_ID_Key); + } + +inline CHidLayoutPluginInterface* CHidLayoutPluginInterface::NewL( + TUid aImplementationUid) + { + DBG(RDebug::Print(_L("[HID]\tCHidLayoutPluginInterface: Loading plugin 0x%08x"),aImplementationUid.iUid)); + + TAny* ptr; + TInt32 keyOffset = _FOFF( CHidLayoutPluginInterface, iDtor_ID_Key ); + + ptr = REComSession::CreateImplementationL(aImplementationUid, keyOffset); + + DEBUG_PRINT( _L( "[HID]\tCHidLayoutPluginInterface: Loading done." ) ); + + return reinterpret_cast (ptr); + } + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/italian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/italian.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef ITALIAN_H +#define ITALIAN_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CItalianLayout : public CStandardKeyboardLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + +private: + + /* C++ constructor */ + CItalianLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + }; + +#endif //ITALIAN_H +//End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/layout.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/layout.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,368 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __LAYOUT_H +#define __LAYOUT_H + +#include +#include +#include "hidlayoutplugininterface.h" + +// FORWARD DECLARATIONS +class TLockKeys; +class THidModifier; + +// CLASS DECLARATION + +/*! + CKeyboardLayout is the abstract base class for all keyboard layouts. + */ +class CKeyboardLayout : public CHidLayoutPluginInterface + { +public: + /*! + Translate a HID usage into a Symbian raw scan code value, + taking into account both the current modifier state, and the + lock key (Num Lock, Caps Lock) state. + + This function is called by the default implementation of + TranslateKey(). + + @param aHidKey The HID usage ID of the key + @param aUsagePage The HID usage page of the key + @param aModifiers The current modifier state + @param aLockKeys The current lock key state + + @result A Symbian Unicode key value, cf TKeyCode. EKeyNull (0) + if the key code could not be translated. + */ + virtual TUint16 TranslateKey(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers, TLockKeys aLockKeys) const; + + /*! + Translate a HID usage ID (keyboard usage page, 0x07) into a + Symbian Unicode key value, taking into account the current + modifier state. This is normally just an interface to one or + more static look up tables. + + Unicode() is pure virtual. + + @param aHidKey The HID usage ID of the key + @param aModifiers The current modifier state + + @result A Symbian Unicode key value, cf TKeyCode. EKeyNull (0) + if the key code could not be translated. + */ + virtual TUint16 Unicode(TInt aHidKey, THidModifier aModifiers) const = 0; + + /*! + Translate a HID usage into a Symbian raw scan code value, + taking into account the current modifier state. + + This function is called by the default implementation of + TranslateKey(). + + @param aHidKey The HID usage ID of the key + @param aUsagePage The HID usage page of the key + @param aModifiers The current modifier state + + @result A Symbian raw scan code value, cf TStdScanCode. + EStdKeyNull (0) if the key code could not be translated. + */ + virtual TInt RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + + /*! + Determine if a given Unicode key value corresponds to an + auto-repeating key. + + @param aUnicodeKey Symbian Unicode key value + + @result ETrue if the key should be allowed to repeat. + */ + virtual TBool IsRepeatingKey(TInt aUnicodeKey) const; + + /*! + Determine if the given Unicode key value corresponds to a + dead key. + + @param aUnicodeKey Symbian Unicode key value + + @result ETrue if the key is a dead key. + */ + virtual TBool IsDeadKey(TInt aUnicodeKey) const; + + /*! + Find the Unicode character, if any, which results from a + combination of the dead key, aDeadKeyUnicode, followed by the + second key press, aUnicodeKey. + + @result Symbian Unicode key value for the combination + character. EKeyNull (0) if the combination wasn't found. + */ + virtual TUint16 FindCombiningChar(TUint16 aDeadKeyUnicode, + TUint16 aUnicodeKey) const; + + /*! + Determine if the given HID key code behaves as if the shift + modifier is inverted when Num Lock is active. This function is + called by the default implementation of TranslateKey(). + + @param aHidKey The HID usage ID of the key (keyboard usage page, 0x07) + + @result ETrue if the key changes with Num Lock + */ + virtual TBool ChangesWithNumLock(TInt aHidKey) const; + + /*! + Determine if the given HID key code behaves as if the shift + modifier is inverted when Caps Lock is active, taking into + account the current modifier state. This function is + called by the default implementation of TranslateKey(). + + @param aHidKey The HID usage ID of the key (keyboard usage page, 0x07) + @param aModifiers The current modifier state + + @result ETrue if the key changes with Caps Lock + */ + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + /*! + Determine if the right Alt key (Alt Gr) should produce the same + effect as pressing Control-Alt. + + @result ETrue if Alt Gr is equivalent to Control-Alt + */ + virtual TBool AltGrIsControlAlt() const; + + /*! + Return the keyboard layout ID for a given layout. + */ + virtual TInt LayoutId() const = 0; + +protected: + TUint16 TranslateKeyboardKey(TInt aHidKey, THidModifier aModifiers, + TLockKeys aLockKeys) const; + TUint16 TranslateOtherKey(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers, TLockKeys aLockKeys) const; + +private: + static TInt CheckChangingKeys(TInt aHidKey, THidModifier aModifiers); + static TInt CheckModifierKeys(TInt aHidKey); + static TInt CheckSpecialRawCode(TInt aHidKey, TInt aUsagePage); + +protected: + // Scan code look-up tables: + + static const TInt KRawCodes[]; // standard keys from HID usage page 7 + + struct TUsagePageKey + { + TInt iHidPage; + TInt iHidId; + TInt iScanCode; + TUint16 iCode; + }; + + static const TUsagePageKey KEnhancedKeyCodes[]; // Usage page != 0x07 + }; + +// ---------------------------------------------------------------------- + +/*! + Base class for all standard keyboard layouts. Assumes a specific + configuration of look-up tables: + + - A main look-up table, indexed by HID code. This contains one or + more columns of data, where each column corresponds to a particular + modifier state. The size of the table is specified in the constructor. + + - A list of the modifier states that correspond to each column in + the main table. + + - A table containing special cases. This is intended to reduce the + number of columns needed in the main table. This table is searched + linearly and is zero terminated. + + An implementation of CKeyboardLayout::Unicode() is provided that + performs a HID key look-up using the main table, and then, if + no match was found, searches the special case table. + */ +class CStandardKeyboardLayout : public CKeyboardLayout + { +public: + /*! + TSpecialKey items are used to create a standard special case + table. If the HID usage ID of the key matches iHidKey, and the + current modifier state matches iFoldedModifiers, then the decoded + key code will be iUnicode. + */ + struct TSpecialKey + { + TUint16 iHidKey; //!< HID key usage (keyboard usage page) + TUint8 iFoldedModifiers; //!< Modifiers, as from THidModifier::Fold() + TUint16 iUnicode; //!< The resulting Unicode value + }; + +public: + /*! + Constructor + + @param aColumnMap Mapping from modifier state to main table columns + @param aMapSize Size of the columns map, in bytes + @param aKeyCodes The main look-up table + @param aTableSize Size of the main table, in bytes + @param aSpecialCases The special case table + */ + CStandardKeyboardLayout(const TInt* aColumnMap, TInt aMapSize, + const TUint16* aKeyCodes, TInt aTableSize, + const TSpecialKey* aSpecialCases); + + /*! + Translate a HID usage ID (keyboard usage page, 0x07) into a + Symbian Unicode key value, taking into account the current + modifier state. + + @param aHidKey The HID usage ID of the key + @param aModifiers The current modifier state + + @result A Symbian Unicode key value, cf TKeyCode. EKeyNull (0) + if the key code could not be translated. + */ + virtual TUint16 Unicode(TInt aHidKey, THidModifier aModifiers) const; + +protected: + /*! + Search for a given HID usage ID (keyboard usage page, 0x07) + in the special case table. + + @param aMap The special case table + @param aHidKey HID usage ID to search for + @param aFoldedModifiers Modifier state to search for + + @result A Symbian Unicode key value, cf TKeyCode. EKeyNull (0) + if the key code could not be translated. + */ + static TUint16 FindSpecialKey(const TSpecialKey* aMap, TInt aHidKey, + TUint8 aFoldedModifiers); + +protected: + // Standard look-up table: + const TInt* iColumnMap; + const TUint16* iKeyCodes; + + const TInt iNumColumns; + const TInt iNumKeys; + + // Special cases: + const TSpecialKey* iSpecialCases; + }; + +// ---------------------------------------------------------------------- + +/*! + Base class for keyboard layouts that use dead keys, derived from + CStandardKeyboardLayout. Assumes a specific configuration of look-up + tables: + + - An index table containing one TIndexPair entry for each dead + key. The TIndexPair provides the unicode value for the dead key, + and a link to a TKeyPair table. + + - One table of TKeyPair items for each dead key. Each TKeyPair + contains the Unicode value for the combination (second) key press + together with the Unicode key value that should result. + + - Other tables as for CStandardKeyboardLayout + + Implementations of CKeyboardLayout::IsDeadKey() and + CKeyboardLayout::FindCombiningChar() are provided that can + use these dead keys tables. + */ +class CDeadKeyLayout : public CStandardKeyboardLayout + { +public: + /*! + TKeyPair items are used to create dead key tables. The dead key + followed by a Unicode key code iBaseChar will produce the decoded + Unicode value of iComboChar. The Unicode value for the dead key + itself is given in a TIndexPair structure. + */ + struct TKeyPair + { + TUint16 iBaseChar; //!< Unicode character that follows the dead key + TUint16 iComboChar; //!< Resulting Unicode value + }; + + /*! + TIndexPair items are used to create dead key tables. There is one + TIndexPair for each possible dead key. Each TIndexPair links in turn + to a table of TKeyPair items. + */ + struct TIndexPair + { + TUint16 iUnicode; //!< Unicode value for the dead key + const TKeyPair *iMap; //!< Corresponding table of TKeyPair items + }; + +public: + /*! + Constructor + + @param aColumnMap Mapping from modifier state to main table columns + @param aMapSize Size of the columns map, in bytes + @param aKeyCodes The main look-up table + @param aTableSize Size of the main table, in bytes + @param aSpecialCases The special case table + @param aDeadKeyIndex The dead key index table + */ + CDeadKeyLayout(const TInt* aColumnMap, TInt aMapSize, + const TUint16* aKeyCodes, TInt aTableSize, + const TSpecialKey* aSpecialCases, + const TIndexPair* aDeadKeyIndex); + + /*! + Determine if the given Unicode key value corresponds to a + dead key. + + @param aUnicodeKey Symbian Unicode key value + + @result ETrue if the key is a dead key. + */ + virtual TBool IsDeadKey(TInt aUnicodeKey) const; + + /*! + Find the Unicode character, if any, which results from a + combination of the dead key, aDeadKeyUnicode, followed by the + second key press, aUnicodeKey. + + @result Symbian Unicode key value for the combination + character. EKeyNull (0) if the combination wasn't found. + */ + virtual TUint16 FindCombiningChar(TUint16 aDeadKeyUnicode, + TUint16 aKeyCode) const; + +protected: + const TIndexPair* iDeadKeyIndex; + + }; + +// ---------------------------------------------------------------------- + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/norwegian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/norwegian.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef NORWEGIAN_H +#define NORWEGIAN_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CNorwegianLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CNorwegianLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyTilde[]; + }; + +#endif //NORWEGIAN_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/portuguese.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/portuguese.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef PORTUGUESE_H +#define PORTUGUESE_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CPortugueseLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CPortugueseLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyTilde[]; + static const TKeyPair KDeadKeyCircumflex[]; + }; + +#endif //PORTUGUESE_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/spanish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/spanish.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SPANISH_H +#define SPANISH_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSpanishLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSpanishLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyTilde[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyDiaeresis[]; + }; + +#endif //SPANISH_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8danishnorwegian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8danishnorwegian.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8DANISHNORWEGIAN_H +#define SU8DANISHNORWEGIAN_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8DanishNorwegianLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Handle the minor differences between the Danish/Norwegian and + // Finnish/Swedish layouts: + virtual TUint16 Unicode(TInt aHidKey, THidModifier aModifiers) const; + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8DanishNorwegianLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyTilde[]; + + // Caps Lock look-up table for Danish/Norwegian: + static const TSpecialKey KDanishKeyCodes[]; + }; + +#endif //SU8DANISHNORWEGIAN_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8finnishswedish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8finnishswedish.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8FINNISHSWEDISH_H +#define SU8FINNISHSWEDISH_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8FinnishSwedishLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8FinnishSwedishLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyDiaeresis[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyTilde[]; + + // Caps Lock look-up table for Danish/Norwegian: + static const TSpecialKey KDanishKeyCodes[]; + }; + +#endif //SU8FINNISHSWEDISH_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8german.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8german.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8GERMAN_H +#define SU8GERMAN_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8GermanLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8GermanLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyCircumflex[]; + }; + +#endif //SU8GERMAN_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8intusenglish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8intusenglish.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8INTUSENGLISH_H +#define SU8INTUSENGLISH_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8IntUsEnglishLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8IntUsEnglishLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyApostrophe[]; + static const TKeyPair KDeadKeyQuotationMark[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyTilde[]; + }; + +#endif //SU8INTUSENGLISH_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8russian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8russian.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8RUSSIAN_H +#define SU8RUSSIAN_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8RussianLayout : public CStandardKeyboardLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8RussianLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + }; + +#endif //SU8RUSSIAN_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8russianint.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8russianint.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8RUSSIANINT_H +#define SU8RUSSIANINT_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8RussianIntLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8RussianIntLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyAcute[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyCircumflex[]; + }; + +#endif //SU8RUSSIANINT_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/su8usenglish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/su8usenglish.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef SU8USENGLISH_H +#define SU8USENGLISH_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CSu8UnitedStatesLayout : public CStandardKeyboardLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // For application switch key and middle softkey scancodes: + TInt + RawScanCode(TInt aHidKey, TInt aUsagePage, + THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CSu8UnitedStatesLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + }; + +#endif //SU8USENGLISH_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/unitedkingdom.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/unitedkingdom.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef UNITEDKINGDOM_H +#define UNITEDKINGDOM_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CUnitedKingdomLayout : public CStandardKeyboardLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CUnitedKingdomLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + }; + +#endif //UNITEDKINGDOM_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/unitedstates.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/unitedstates.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef UNITEDSTATES_H +#define UNITEDSTATES_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CUnitedStatesLayout : public CStandardKeyboardLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + +private: + + /* C++ constructor */ + CUnitedStatesLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + }; + +#endif //UNITEDSTATES_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/unitedstatesdvorak.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/unitedstatesdvorak.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef UNITEDSTATESDVORAK_H +#define UNITEDSTATESDVORAK_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CUnitedStatesDvorakLayout : public CStandardKeyboardLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CUnitedStatesDvorakLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + }; + +#endif //UNITEDSTATESDVORAK_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/inc/usinternational.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/inc/usinternational.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class + * +*/ + + +#ifndef USINTERNATIONAL_H +#define USINTERNATIONAL_H + +// INCLUDES +#include +#include + +#include "layout.h" +#include "modifier.h" + +// CLASS DECLARATION + +class CUSInternationalLayout : public CDeadKeyLayout + { +public: + + static CKeyboardLayout* NewL(); + + // Report what layouts are supported: + virtual TInt LayoutId() const; + + // Layout has additional Caps Lock keys: + virtual TBool + ChangesWithCapsLock(TInt aHidKey, THidModifier aModifiers) const; + +private: + + /* C++ constructor */ + CUSInternationalLayout(); + + // Standard look-up table: + static const TInt KColumnMap[]; + static const TUint16 KKeyCodes[]; + + // Special cases: + static const TSpecialKey KSpecialCases[]; + + // Dead key tables: + static const TIndexPair KDeadKeyIndex[]; + static const TKeyPair KDeadKeyCircumflex[]; + static const TKeyPair KDeadKeyApostrophe[]; + static const TKeyPair KDeadKeyQuotationMark[]; + static const TKeyPair KDeadKeyGrave[]; + static const TKeyPair KDeadKeyTilde[]; + }; + +#endif //USINTERNATIONAL_H +//End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/belgian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/belgian.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,342 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "belgian.h" +#include "debug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// ---------------------------------------------------------------------- +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CBelgianLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CBelgianLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'q', 'Q', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + ',', '?', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'a', 'A', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'z', 'Z', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'w', 'W', // 0x1d 29 z Z + '&', '1', // 0x1e 30 1 ! + 0x00e9, '2', // 0x1f 31 2 " + '"', '3', // 0x20 32 3 £ + '\'', '4', // 0x21 33 4 $ + '(', '5', // 0x22 34 5 % + 0x00a7, '6', // 0x23 35 6 ^ + 0x00e8, '7', // 0x24 36 7 & + '!', '8', // 0x25 37 8 * + 0x00e7, '9', // 0x26 38 9 ( + 0x00e0, '0', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + ')', 0x00b0, // 0x2d 45 - _ + '-', '_', // 0x2e 46 = + + '^', 0x00a8, // 0x2f 47 [ { + '$', '*', // 0x30 48 ] } + 0x00b5, 0x00a3, // 0x31 49 US \ bar + 0x00b5, 0x00a3, // 0x32 50 # ~ + 'm', 'M', // 0x33 51 ; : + 0x00f9, '%', // 0x34 52 ' @ + 0x00b2, 0x00b3, // 0x35 53 Grave/not/bar + ';', '.', // 0x36 54 , < + ':', '/', // 0x37 55 . > + '=', '+', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CBelgianLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x1e, THidModifier::EAltCtrl, 0x007c }, // 1 ! + { 0x1f, THidModifier::EAltCtrl, 0x0040 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x0023 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x007b }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x005b }, // 5 % + { 0x23, THidModifier::EAltCtrl, 0x005e }, // 6 ^ + { 0x26, THidModifier::EAltCtrl, 0x007b }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x007d }, // 0 ) + { 0x2f, THidModifier::EAltCtrl, 0x005b }, // [ { + { 0x30, THidModifier::EAltCtrl, 0x005d }, // ] } + { 0x31, THidModifier::EAltCtrl, 0x0060 }, // US \ bar + { 0x32, THidModifier::EAltCtrl, 0x0060 }, // # ~ + { 0x34, THidModifier::EAltCtrl, 0x00b4 }, // ' @ + { 0x38, THidModifier::EAltCtrl, 0x007e }, // / ? + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0x64, THidModifier::EAltCtrl, 0x005c }, // \ | (near left shift) + { 0x31, THidModifier::EAltCtrlShift, 0x0060 }, // US \ bar + { 0x32, THidModifier::EAltCtrlShift, 0x0060 }, // # ~ + { 0x34, THidModifier::EAltCtrlShift, 0x00b4 }, // ' @ + { 0x38, THidModifier::EAltCtrlShift, 0x007e }, // / ? + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CBelgianLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CBelgianLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CBelgianLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CBelgianLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CBelgianLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CBelgianLayout::KDeadKeyIndex[] = + { + { 0x005e, KDeadKeyCircumflex }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + + +CBelgianLayout::CBelgianLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CBelgianLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x1e) || // 1 ! + (aHidKey == 0x1f) || // 2 " + (aHidKey == 0x20) || // 3 £ + (aHidKey == 0x21) || // 4 $ + (aHidKey == 0x22) || // 5 % + (aHidKey == 0x23) || // 6 ^ + (aHidKey == 0x24) || // 7 & + (aHidKey == 0x25) || // 8 * + (aHidKey == 0x26) || // 9 ( + (aHidKey == 0x27) || // 0 ) + (aHidKey == 0x2d) || // - _ + (aHidKey == 0x2e) || // = + + (aHidKey == 0x2f) || // [ { + (aHidKey == 0x30) || // ] } + (aHidKey == 0x31) || // US \ bar + (aHidKey == 0x32) || // # ~ + (aHidKey == 0x33) || // ; : + (aHidKey == 0x34) || // ' @ + (aHidKey == 0x36) || // , < + (aHidKey == 0x37) || // . > + (aHidKey == 0x38); + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CBelgianLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCBelgianLayout::LayoutId()"))); + return EBelgian; + } + +CKeyboardLayout* CBelgianLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCBelgianLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CBelgianLayout; + return layout; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/danish.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/danish.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,319 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "danish.h" +#include "debug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// ---------------------------------------------------------------------- +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CDanishLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CDanishLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', '#', // 0x20 32 3 £ + '4', 0x00a4, // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '&', // 0x23 35 6 ^ + '7', '/', // 0x24 36 7 & + '8', '(', // 0x25 37 8 * + '9', ')', // 0x26 38 9 ( + '0', '=', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '+', '?', // 0x2d 45 - _ + 0x00b4, '`', // 0x2e 46 = + + 0x00e5, 0x00c5, // 0x2f 47 [ { + 0x00a8, '^', // 0x30 48 ] } + '\'', '*', // 0x31 49 US \ bar + '\'', '*', // 0x32 50 # ~ + 0x00e6, 0x00c6, // 0x33 51 ; : + 0x00f8, 0x00d8, // 0x34 52 ' @ + 0x00bd, 0x00a7, // 0x35 53 Grave/not/bar + ',', ';', // 0x36 54 , < + '.', ':', // 0x37 55 . > + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + ',', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CDanishLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x10, THidModifier::EAltCtrl, 0x00b5 }, // m M + { 0x1f, THidModifier::EAltCtrl, 0x0040 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x00a3 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x0024 }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x20ac }, // 5 % + { 0x24, THidModifier::EAltCtrl, 0x007b }, // 7 & + { 0x25, THidModifier::EAltCtrl, 0x005b }, // 8 * + { 0x26, THidModifier::EAltCtrl, 0x005d }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x007d }, // 0 ) + { 0x2e, THidModifier::EAltCtrl, 0x007c }, // = + + { 0x30, THidModifier::EAltCtrl, 0x007e }, // ] } + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0x64, THidModifier::EAltCtrl, 0x005c }, // \ | (near left shift) + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CDanishLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CDanishLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CDanishLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CDanishLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CDanishLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CDanishLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x005e, KDeadKeyCircumflex }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + + +CDanishLayout::CDanishLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CDanishLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x2f) || // [ { + (aHidKey == 0x33) || // ; : + (aHidKey == 0x34); // ' @ + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + + +TInt CDanishLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCDanishLayout::LayoutId()"))); + return EDanish; + } + +CKeyboardLayout* CDanishLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCDanishLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CDanishLayout; + return layout; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/dutch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/dutch.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "dutch.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CDutchLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift, // ---S + THidModifier::EAltCtrl // -AC- + }; + +const TUint16 CDutchLayout::KKeyCodes[] = + { + //---- ---S -AC- // Hex Dec Usage name (UK) + 0, 0, 0, // 0x00 0 Reserved (no event) + 0, 0, 0, // 0x01 1 Rollover error + 0, 0, 0, // 0x02 2 POST Fail + 0, 0, 0, // 0x03 3 Undefined error + 'a', 'A', 0, // 0x04 4 a A + 'b', 'B', 0, // 0x05 5 b B + 'c', 'C', 0x00a2, // 0x06 6 c C + 'd', 'D', 0, // 0x07 7 d D + 'e', 'E', 0x20ac, // 0x08 8 e E + 'f', 'F', 0, // 0x09 9 f F + 'g', 'G', 0, // 0x0a 10 g G + 'h', 'H', 0, // 0x0b 11 h H + 'i', 'I', 0, // 0x0c 12 i I + 'j', 'J', 0, // 0x0d 13 j J + 'k', 'K', 0, // 0x0e 14 k K + 'l', 'L', 0, // 0x0f 15 l L + 'm', 'M', 0x00b5, // 0x10 16 m M + 'n', 'N', 0, // 0x11 17 n N + 'o', 'O', 0, // 0x12 18 o O + 'p', 'P', 0, // 0x13 19 p P + 'q', 'Q', 0, // 0x14 20 q Q + 'r', 'R', 0x00b6, // 0x15 21 r R + 's', 'S', 0x00df, // 0x16 22 s S + 't', 'T', 0, // 0x17 23 t T + 'u', 'U', 0, // 0x18 24 u U + 'v', 'V', 0, // 0x19 25 v V + 'w', 'W', 0, // 0x1a 26 w W + 'x', 'X', 0x00bb, // 0x1b 27 x X + 'y', 'Y', 0, // 0x1c 28 y Y + 'z', 'Z', 0x00ab, // 0x1d 29 z Z + '1', '!', 0x00b9, // 0x1e 30 1 ! + '2', '"', 0x00b2, // 0x1f 31 2 " + '3', '#', 0x00b3, // 0x20 32 3 £ + '4', '$', 0x00bc, // 0x21 33 4 $ + '5', '%', 0x00bd, // 0x22 34 5 % + '6', '&', 0x00be, // 0x23 35 6 ^ + '7', '_', 0x00a3, // 0x24 36 7 & + '8', '(', '{', // 0x25 37 8 * + '9', ')', '}', // 0x26 38 9 ( + '0', '\'', 0, // 0x27 39 0 ) + 0x000d, 0xf845, 0, // 0x28 40 Enter (Return) + 0x001b, 0x001b, 0, // 0x29 41 Escape + 0x0008, 0x0008, 0, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, 0, // 0x2b 43 Tab + ' ', ' ', 0, // 0x2c 44 Spacebar + '/', '?', '\\', // 0x2d 45 - _ + 0x00b0, '~', 0x00b8, // 0x2e 46 = + + 0x00a8, '^', 0, // 0x2f 47 [ { + '*', '|', 0, // 0x30 48 ] } + '<', '>', 0, // 0x31 49 US \ bar + '<', '>', 0, // 0x32 50 # ~ + '+', 0x00b1, 0, // 0x33 51 ; : + 0x00b4, '`', 0, // 0x34 52 ' @ + '@', 0x00a7, 0x00ac, // 0x35 53 Grave/not/bar + ',', ';', 0, // 0x36 54 , < + '.', ':', 0x00b7, // 0x37 55 . > + '-', '=', 0, // 0x38 56 / ? + 0, 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, 0, // 0x3a 58 F1 + 0xf817, 0xf817, 0, // 0x3b 59 F2 + 0xf818, 0xf818, 0, // 0x3c 60 F3 + 0xf819, 0xf819, 0, // 0x3d 61 F4 + 0xf81a, 0xf81a, 0, // 0x3e 62 F5 + 0xf81b, 0xf81b, 0, // 0x3f 63 F6 + 0xf81c, 0xf81c, 0, // 0x40 64 F7 + 0xf81d, 0xf81d, 0, // 0x41 65 F8 + 0xf81e, 0xf81e, 0, // 0x42 66 F9 + 0xf81f, 0xf81f, 0, // 0x43 67 F10 + 0xf820, 0xf820, 0, // 0x44 68 F11 + 0xf821, 0xf821, 0, // 0x45 69 F12 + 0xf800, 0xf800, 0, // 0x46 70 Print Screen + 0xf815, 0xf815, 0, // 0x47 71 Scroll Lock + 0xf801, 0xf801, 0, // 0x48 72 Break / Pause + 0xf806, 0xf806, 0, // 0x49 73 Insert + 0xf802, 0xf802, 0, // 0x4a 74 Home + 0xf804, 0xf804, 0, // 0x4b 75 Page Up + 0x007f, 0x007f, 0xf844, // 0x4c 76 Delete + 0xf803, 0xf803, 0, // 0x4d 77 End + 0xf805, 0xf805, 0, // 0x4e 78 Page Down + 0xf808, 0xf808, 0, // 0x4f 79 Right Arrow + 0xf807, 0xf807, 0, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, 0, // 0x51 81 Down Arrow + 0xf809, 0xf809, 0, // 0x52 82 Up Arrow + 0, 0, 0, // 0x53 83 Num Lock + '/', '/', 0, // 0x54 84 Keypad / + '*', '*', 0, // 0x55 85 Keypad * + '-', '-', 0, // 0x56 86 Keypad - + '+', '+', 0, // 0x57 87 Keypad + + 0x000d, 0xf845, 0, // 0x58 88 Keypad Enter + '1', 0xf803, 0, // 0x59 89 Keypad 1 End + '2', 0xf80a, 0, // 0x5a 90 Keypad 2 Down + '3', 0xf805, 0, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, 0, // 0x5c 92 Keypad 4 Left + '5', ' ', 0, // 0x5d 93 Keypad 5 + '6', 0xf808, 0, // 0x5e 94 Keypad 6 Right + '7', 0xf802, 0, // 0x5f 95 Keypad 7 Home + '8', 0xf809, 0, // 0x60 96 Keypad 8 Up + '9', 0xf804, 0, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, 0, // 0x62 98 Keypad 0 Insert + ',', 0x007f, 0xf844, // 0x63 99 Keypad . Delete + ']', '[', 0x00a6, // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, 0, // 0x65 101 Application key + 0, 0, 0, // 0x66 102 Keyboard power + '=', '=', 0, // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CDutchLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CDutchLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// 0x00b8 (Cedilla) +// +const CDeadKeyLayout::TKeyPair CDutchLayout::KDeadKeyCedilla[] = + { + { 0x0020, 0x00b8 }, // space + { 0x0043, 0x00c7 }, // C + { 0x0063, 0x00e7 }, // c + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CDutchLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CDutchLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CDutchLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CDutchLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CDutchLayout::KDeadKeyIndex[] = + { + { 0x007e, KDeadKeyTilde }, + { 0x00b8, KDeadKeyCedilla }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x005e, KDeadKeyCircumflex }, + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x0000 } // end of table + }; + + +CDutchLayout::CDutchLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TInt CDutchLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCDutchLayout::LayoutId()"))); + return EDutch; + } + +CKeyboardLayout* CDutchLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCDutchLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CDutchLayout; + return layout; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/finnishswedish.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/finnishswedish.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,324 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "finnishswedish.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CFinnishSwedishLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CFinnishSwedishLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', '#', // 0x20 32 3 £ + '4', 0x00a4, // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '&', // 0x23 35 6 ^ + '7', '/', // 0x24 36 7 & + '8', '(', // 0x25 37 8 * + '9', ')', // 0x26 38 9 ( + '0', '=', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '+', '?', // 0x2d 45 - _ + 0x00b4, '`', // 0x2e 46 = + + 0x00e5, 0x00c5, // 0x2f 47 [ { + 0x00a8, '^', // 0x30 48 ] } + '\'', '*', // 0x31 49 US \ bar + '\'', '*', // 0x32 50 # ~ + 0x00f6, 0x00d6, // 0x33 51 ; : + 0x00e4, 0x00c4, // 0x34 52 ' @ + 0x00a7, 0x00bd, // 0x35 53 Grave/not/bar + ',', ';', // 0x36 54 , < + '.', ':', // 0x37 55 . > + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home // Left Gui: 0xf842, 0xf842 (For ThinkOutSide) + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End // Right Gui: 0xf843 0xf843 + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + ',', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CFinnishSwedishLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x10, THidModifier::EAltCtrl, 0x00b5 }, // m M + { 0x1f, THidModifier::EAltCtrl, 0x0040 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x00a3 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x0024 }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x20ac }, // 5 % + { 0x24, THidModifier::EAltCtrl, 0x007b }, // 7 & + { 0x25, THidModifier::EAltCtrl, 0x005b }, // 8 * + { 0x26, THidModifier::EAltCtrl, 0x005d }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x007d }, // 0 ) + { 0x2d, THidModifier::EAltCtrl, 0x005c }, // - _ + { 0x30, THidModifier::EAltCtrl, 0x007e }, // ] } + +// { 0x4a, THidModifier::EFunc, 0xf842 }, // Left GUI key //Added to test ThinkOutside + + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + +// { 0x4d, THidModifier::EFunc, 0xf843 }, // Right GUI key // + + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0x64, THidModifier::EAltCtrl, 0x007c }, // \ | (near left shift) + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CFinnishSwedishLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CFinnishSwedishLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CFinnishSwedishLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CFinnishSwedishLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CFinnishSwedishLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CFinnishSwedishLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x005e, KDeadKeyCircumflex }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CFinnishSwedishLayout::CFinnishSwedishLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +CKeyboardLayout* CFinnishSwedishLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCFinnishSwedishLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CFinnishSwedishLayout; + return layout; + } + +TInt CFinnishSwedishLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCFinnishSwedishLayout::LayoutId()"))); + return EFinnishSwedish; + } + +TBool CFinnishSwedishLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x2f) || // [ { + (aHidKey == 0x33) || // ; : + (aHidKey == 0x34); // ' @ + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/french.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/french.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,316 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "french.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CFrenchLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CFrenchLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'q', 'Q', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + ',', '?', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'a', 'A', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'z', 'Z', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'w', 'W', // 0x1d 29 z Z + '&', '1', // 0x1e 30 1 ! + 0x00e9, '2', // 0x1f 31 2 " + '"', '3', // 0x20 32 3 £ + '\'', '4', // 0x21 33 4 $ + '(', '5', // 0x22 34 5 % + '-', '6', // 0x23 35 6 ^ + 0x00e8, '7', // 0x24 36 7 & + '_', '8', // 0x25 37 8 * + 0x00e7, '9', // 0x26 38 9 ( + 0x00e0, '0', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + ')', 0x00b0, // 0x2d 45 - _ + '=', '+', // 0x2e 46 = + + '^', 0x00a8, // 0x2f 47 [ { + '$', 0x00a3, // 0x30 48 ] } + '*', 0x00b5, // 0x31 49 US \ bar + '*', 0x00b5, // 0x32 50 # ~ + 'm', 'M', // 0x33 51 ; : + 0x00f9, '%', // 0x34 52 ' @ + 0x00b2, 0, // 0x35 53 Grave/not/bar + ';', '.', // 0x36 54 , < + ':', '/', // 0x37 55 . > + '!', 0x00a7, // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CFrenchLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x1f, THidModifier::EAltCtrl, 0x007e }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x0023 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x007b }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x005b }, // 5 % + { 0x23, THidModifier::EAltCtrl, 0x007c }, // 6 ^ + { 0x24, THidModifier::EAltCtrl, 0x0060 }, // 7 & + { 0x25, THidModifier::EAltCtrl, 0x005c }, // 8 * + { 0x26, THidModifier::EAltCtrl, 0x005e }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x0040 }, // 0 ) + { 0x2d, THidModifier::EAltCtrl, 0x005d }, // - _ + { 0x2e, THidModifier::EAltCtrl, 0x007d }, // = + + { 0x30, THidModifier::EAltCtrl, 0x00a4 }, // ] } + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CFrenchLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CFrenchLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CFrenchLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CFrenchLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CFrenchLayout::KDeadKeyIndex[] = + { + { 0x007e, KDeadKeyTilde }, + { 0x0060, KDeadKeyGrave }, + { 0x005e, KDeadKeyCircumflex }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CFrenchLayout::CFrenchLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CFrenchLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x1e) || // 1 ! + (aHidKey == 0x1f) || // 2 " + (aHidKey == 0x20) || // 3 £ + (aHidKey == 0x21) || // 4 $ + (aHidKey == 0x22) || // 5 % + (aHidKey == 0x23) || // 6 ^ + (aHidKey == 0x24) || // 7 & + (aHidKey == 0x25) || // 8 * + (aHidKey == 0x26) || // 9 ( + (aHidKey == 0x27) || // 0 ) + (aHidKey == 0x2d) || // - _ + (aHidKey == 0x2e) || // = + + (aHidKey == 0x2f) || // [ { + (aHidKey == 0x30) || // ] } + (aHidKey == 0x31) || // US \ bar + (aHidKey == 0x32) || // # ~ + (aHidKey == 0x33) || // ; : + (aHidKey == 0x34) || // ' @ + (aHidKey == 0x36) || // , < + (aHidKey == 0x37) || // . > + (aHidKey == 0x38); // / ? + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + + +TInt CFrenchLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCFrenchLayout::LayoutId()"))); + return EFrench; + } + +CKeyboardLayout* CFrenchLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCFrenchLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CFrenchLayout; + return layout; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/german.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/german.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,301 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "german.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CGermanLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CGermanLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'z', 'Z', // 0x1c 28 y Y + 'y', 'Y', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', 0x00a7, // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '&', // 0x23 35 6 ^ + '7', '/', // 0x24 36 7 & + '8', '(', // 0x25 37 8 * + '9', ')', // 0x26 38 9 ( + '0', '=', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + 0x00df, '?', // 0x2d 45 - _ + 0x00b4, '`', // 0x2e 46 = + + 0x00fc, 0x00dc, // 0x2f 47 [ { + '+', '*', // 0x30 48 ] } + '#', '\'', // 0x31 49 US \ bar + '#', '\'', // 0x32 50 # ~ + 0x00f6, 0x00d6, // 0x33 51 ; : + 0x00e4, 0x00c4, // 0x34 52 ' @ + '^', 0x00b0, // 0x35 53 Grave/not/bar + ',', ';', // 0x36 54 , < + '.', ':', // 0x37 55 . > + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + ',', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CGermanLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x10, THidModifier::EAltCtrl, 0x00b5 }, // m M + { 0x14, THidModifier::EAltCtrl, 0x0040 }, // q Q + { 0x1f, THidModifier::EAltCtrl, 0x00b2 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x00b3 }, // 3 £ + { 0x24, THidModifier::EAltCtrl, 0x007b }, // 7 & + { 0x25, THidModifier::EAltCtrl, 0x005b }, // 8 * + { 0x26, THidModifier::EAltCtrl, 0x005d }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x007d }, // 0 ) + { 0x2d, THidModifier::EAltCtrl, 0x005c }, // - _ + { 0x30, THidModifier::EAltCtrl, 0x007e }, // ] } + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0x64, THidModifier::EAltCtrl, 0x007c }, // \ | (near left shift) + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CGermanLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CGermanLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CGermanLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CGermanLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x005e, KDeadKeyCircumflex }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CGermanLayout::CGermanLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CGermanLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x1e) || // 1 ! + (aHidKey == 0x1f) || // 2 " + (aHidKey == 0x20) || // 3 £ + (aHidKey == 0x21) || // 4 $ + (aHidKey == 0x22) || // 5 % + (aHidKey == 0x23) || // 6 ^ + (aHidKey == 0x24) || // 7 & + (aHidKey == 0x25) || // 8 * + (aHidKey == 0x26) || // 9 ( + (aHidKey == 0x27) || // 0 ) + (aHidKey == 0x2d) || // - _ + (aHidKey == 0x2f) || // [ { + (aHidKey == 0x30) || // ] } + (aHidKey == 0x31) || // US \ bar + (aHidKey == 0x32) || // # ~ + (aHidKey == 0x33) || // ; : + (aHidKey == 0x34) || // ' @ + (aHidKey == 0x36) || // , < + (aHidKey == 0x37); // . > + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + + +TInt CGermanLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCGermanLayout::LayoutId()"))); + return EGerman; + } + +CKeyboardLayout* CGermanLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCGermanLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CGermanLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/hidlayoutimplproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/hidlayoutimplproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2008 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: +* ECOM proxy table for this plugin +* +*/ + + +// System includes +// +#include +#include + +// User includes +// +#include "belgian.h" +#include "danish.h" +#include "dutch.h" +#include "finnishswedish.h" +#include "french.h" +#include "german.h" +#include "italian.h" +#include "norwegian.h" +#include "portuguese.h" +#include "spanish.h" +#include "su8danishnorwegian.h" +#include "su8finnishswedish.h" +#include "su8german.h" +//#include "su8russian.h" +#include "su8russianint.h" +#include "su8intusenglish.h" +//#include "su8usenglish.h" +#include "unitedkingdom.h" +#include "unitedstates.h" +#include "unitedstatesdvorak.h" +#include "usinternational.h" + +// Constants +// +const TImplementationProxy KHidKeyboardLayoutProxy[] = + { + IMPLEMENTATION_PROXY_ENTRY( BELGIAN_LAYOUT_IMP, CBelgianLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( DANISH_LAYOUT_IMP, CDanishLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( DUTCH_LAYOUT_IMP, CDutchLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( FINSWE_LAYOUT_IMP, CFinnishSwedishLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( FRENCH_LAYOUT_IMP, CFrenchLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( GERMAN_LAYOUT_IMP, CGermanLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( ITALIAN_LAYOUT_IMP, CItalianLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( NORWEGIAN_LAYOUT_IMP, CNorwegianLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( PORTUGUESE_LAYOUT_IMP, CPortugueseLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( SPANISH_LAYOUT_IMP, CSpanishLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( SU8DANNOR_LAYOUT_IMP, CSu8DanishNorwegianLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( SU8FINSWE_LAYOUT_IMP, CSu8FinnishSwedishLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( SU8GERMAN_LAYOUT_IMP, CSu8GermanLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( SU8RUSSIANINT_LAYOUT_IMP, CSu8RussianIntLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( SU8INTUSENGLISH_LAYOUT_IMP, CSu8IntUsEnglishLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( UK_LAYOUT_IMP, CUnitedKingdomLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( US_LAYOUT_IMP, CUnitedStatesLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( USDVORAK_LAYOUT_IMP, CUnitedStatesDvorakLayout::NewL ), + IMPLEMENTATION_PROXY_ENTRY( USINT_LAYOUT_IMP, CUSInternationalLayout::NewL ) + }; + + +// --------------------------------------------------------------------------- +// ImplementationGroupProxy +// Gate/factory function +// +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KHidKeyboardLayoutProxy) + / sizeof(TImplementationProxy); + return KHidKeyboardLayoutProxy; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/italian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/italian.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "italian.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CItalianLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CItalianLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', 0x00a3, // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '&', // 0x23 35 6 ^ + '7', '/', // 0x24 36 7 & + '8', '(', // 0x25 37 8 * + '9', ')', // 0x26 38 9 ( + '0', '=', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '\'', '?', // 0x2d 45 - _ + 0x00ec, '^', // 0x2e 46 = + + 0x00e8, 0x00e9, // 0x2f 47 [ { + '+', '*', // 0x30 48 ] } + 0x00f9, 0x00a7, // 0x31 49 US \ bar + 0x00f9, 0x00a7, // 0x32 50 # ~ + 0x00f2, 0x00e7, // 0x33 51 ; : + 0x00e0, 0x00b0, // 0x34 52 ' @ + '\\', '|', // 0x35 53 Grave/not/bar + ',', ';', // 0x36 54 , < + '.', ':', // 0x37 55 . > + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CItalianLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x22, THidModifier::EAltCtrl, 0x20ac }, // 5 % + { 0x2f, THidModifier::EAltCtrl, 0x005b }, // [ { + { 0x30, THidModifier::EAltCtrl, 0x005d }, // ] } + { 0x33, THidModifier::EAltCtrl, 0x0040 }, // ; : + { 0x34, THidModifier::EAltCtrl, 0x0023 }, // ' @ + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0x2f, THidModifier::EAltCtrlShift, 0x007b }, // [ { + { 0x30, THidModifier::EAltCtrlShift, 0x007d }, // ] } + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +CItalianLayout::CItalianLayout() + : CStandardKeyboardLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases) + { + // nothing else to do + } + + + +TInt CItalianLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCItalianLayout::LayoutId()"))); + return EItalian; + } + +CKeyboardLayout* CItalianLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCItalianLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CItalianLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/layout.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/layout.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,624 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include +#include +#include // for CTRL() + +//#include "hidkeys.h" // included from decode.h +#include "layout.h" +#include "decode.h" +#include "modifier.h" +#include "hiddebug.h" + +#include "hidvalues.h" + +// ---------------------------------------------------------------------- +// Map HID keyboard usage values (usage page 7) to EPOC raw "scan" codes: + +const TInt CKeyboardLayout::KRawCodes[] = + { + EStdKeyNull, // 0x00 0 No Event + EStdKeyNull, // 0x01 1 Overrun Error + EStdKeyNull, // 0x02 2 POST Fail + EStdKeyNull, // 0x03 3 ErrorUndefined + 'A', // 0x04 4 a A + 'B', // 0x05 5 b B + 'C', // 0x06 6 c C + 'D', // 0x07 7 d D + 'E', // 0x08 8 e E + 'F', // 0x09 9 f F + 'G', // 0x0A 10 g G + 'H', // 0x0B 11 h H + 'I', // 0x0C 12 i I + 'J', // 0x0D 13 j J + 'K', // 0x0E 14 k K + 'L', // 0x0F 15 l L + 'M', // 0x10 16 m M + 'N', // 0x11 17 n N + 'O', // 0x12 18 o O + 'P', // 0x13 19 p P + 'Q', // 0x14 20 q Q + 'R', // 0x15 21 r R + 'S', // 0x16 22 s S + 'T', // 0x17 23 t T + 'U', // 0x18 24 u U + 'V', // 0x19 25 v V + 'W', // 0x1A 26 w W + 'X', // 0x1B 27 x X + 'Y', // 0x1C 28 y Y + 'Z', // 0x1D 29 z Z + '1', // 0x1E 30 1 ! + '2', // 0x1F 31 2 @ + '3', // 0x20 32 3 # + '4', // 0x21 33 4 $ Euro + '5', // 0x22 34 5 % + '6', // 0x23 35 6 ^ + '7', // 0x24 36 7 & + '8', // 0x25 37 8 * + '9', // 0x26 38 9 ( + '0', // 0x27 39 0 ) + EStdKeyEnter, // 0x28 40 Return + EStdKeyEscape, // 0x29 41 Escape + EStdKeyBackspace, // 0x2A 42 Backspace + EStdKeyTab, // 0x2B 43 Tab + EStdKeySpace, // 0x2C 44 Space + EStdKeyMinus, // 0x2D 45 - _ + EStdKeyEquals, // 0x2E 46 = + + EStdKeySquareBracketLeft, // 0x2F 47 [ { + EStdKeySquareBracketRight, // 0x30 48 ] } + EStdKeyBackSlash, // 0x31 49 US backslash and bar + EStdKeyHash, // 0x32 50 Near the enter key (UK #~) + EStdKeySemiColon, // 0x33 51 ; : + EStdKeySingleQuote, // 0x34 52 UK ' @ (US ' ") + EStdKeyXXX, // 0x35 53 Top left: UK grave/not/bar + EStdKeyComma, // 0x36 54 , < + EStdKeyFullStop, // 0x37 55 . > + EStdKeyForwardSlash, // 0x38 56 / ? + EStdKeyCapsLock, // 0x39 57 Caps Lock + EStdKeyF1, // 0x3A 58 F1 + EStdKeyF2, // 0x3B 59 F2 + EStdKeyF3, // 0x3C 60 F3 + EStdKeyF4, // 0x3D 61 F4 + EStdKeyF5, // 0x3E 62 F5 + EStdKeyF6, // 0x3F 63 F6 + EStdKeyF7, // 0x40 64 F7 + EStdKeyF8, // 0x41 65 F8 + EStdKeyF9, // 0x42 66 F9 + EStdKeyF10, // 0x43 67 F10 + EStdKeyF11, // 0x44 68 F11 + EStdKeyF12, // 0x45 69 F12 + EStdKeyPrintScreen, // 0x46 70 Print Screen + EStdKeyScrollLock, // 0x47 71 Scroll Lock + EStdKeyPause, // 0x48 72 Break (Ctrl-Pause) + EStdKeyInsert, // 0x49 73 Insert + EStdKeyHome, // 0x4A 74 Home + EStdKeyPageUp, // 0x4B 75 Page Up + EStdKeyDelete, // 0x4C 76 Delete + EStdKeyEnd, // 0x4D 77 End + EStdKeyPageDown, // 0x4E 78 Page Down + EStdKeyRightArrow, // 0x4F 79 Right Arrow + EStdKeyLeftArrow, // 0x50 80 Left Arrow + EStdKeyDownArrow, // 0x51 81 Down Arrow + EStdKeyUpArrow, // 0x52 82 Up Arrow + EStdKeyNumLock, // 0x53 83 Num Lock + EStdKeyNkpForwardSlash, // 0x54 84 Keypad / + EStdKeyNkpAsterisk, // 0x55 85 Keypad * + EStdKeyNkpMinus, // 0x56 86 Keypad - + EStdKeyNkpPlus, // 0x57 87 Keypad + + EStdKeyNkpEnter, // 0x58 88 Keypad Enter + EStdKeyNkp1, // 0x59 89 Keypad 1 End + EStdKeyNkp2, // 0x5A 90 Keypad 2 Down + EStdKeyNkp3, // 0x5B 91 Keypad 3 PageDn + EStdKeyNkp4, // 0x5C 92 Keypad 4 Left + EStdKeyNkp5, // 0x5D 93 Keypad 5 + EStdKeyNkp6, // 0x5E 94 Keypad 6 Right + EStdKeyNkp7, // 0x5F 95 Keypad 7 Home + EStdKeyNkp8, // 0x60 96 Keypad 8 Up + EStdKeyNkp9, // 0x61 97 Keypad 9 PageUp + EStdKeyNkp0, // 0x62 98 Keypad 0 Insert + EStdKeyNkpFullStop, // 0x63 99 Keypad . Delete + EStdKeyBackSlash, // 0x64 100 Next to LH shift (UK \|) + EStdKeyMenu, // 0x65 101 Application key + EStdKeyNull, // 0x66 102 Keyboard power + EStdKeyEquals // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +// These apply in any modifier state: + +const CKeyboardLayout::TUsagePageKey CKeyboardLayout::KEnhancedKeyCodes[] = + { + // Usage page, usage ID, Symbian raw code, Symbian key code (unicode) + // + // Generic functionality: + // + { 12, 0x00cd, EStdKeyApplication2, EKeyApplication2 }, // Play/pause (was: EKeyDictaphonePlay) + { 12, 0x00b7, EStdKeyApplication3, EKeyApplication3 }, // Stop (was: EKeyDictaphoneStop) + { 12, 0x00e9, EStdKeyIncVolume, EKeyIncVolume }, // Volume - + { 12, 0x00ea, EStdKeyDecVolume, EKeyDecVolume }, // Volume + + { 12, 0x0095, EStdKeyHelp, EKeyHelp }, // Help + { 12, 0x019c, EStdKeyDevice2, EKeyDevice2 }, // Log off + // + // Map system control power and menu keys to the power key: + // + { 1, 0x0081, EStdKeyDevice2, EKeyDevice2 }, // Power down + { 1, 0x0082, EStdKeyDevice2, EKeyDevice2 }, // Sleep + { 1, 0x0083, EStdKeyDevice2, EKeyDevice2 }, // Wake + { 1, 0x0084, EStdKeyDevice2, EKeyDevice2 }, // Context menu + { 1, 0x0085, EStdKeyDevice2, EKeyDevice2 }, // Main menu + { 1, 0x0086, EStdKeyDevice2, EKeyDevice2 }, // App menu + // + // Map common consumer keys to the application and device key ranges: + // (Note that Series 60 AVKON reserves device keys 0-6, and app key 0.) + // (Also, we're reserving EStdKeyApplication1 for FEP symbol menu) + // + { 12, 0x00e2, EStdKeyApplication3, EKeyApplication3 }, // Mute (was: EkeyApplication2) + { 12, 0x00b5, EStdKeyApplication4, EKeyApplication4 }, // Next track (Was: EKeyApplication3) + { 12, 0x00b6, EStdKeyApplication5, EKeyApplication5 }, // Prev track (was: EKeyApplication4) + { 12, 0x021a, EStdKeyApplication5, EKeyApplication5 }, // Undo + { 12, 0x0279, EStdKeyApplication6, EKeyApplication6 }, // Redo + { 12, 0x0183, EStdKeyApplication7, EKeyApplication7 }, // Media + { 12, 0x0223, EStdKeyF1, EKeyF1 }, // Web/Home [WAP] was: EKeyApplication8 + { 12, 0x0199, EStdKeyApplication9, EKeyApplication9 }, // Messenger [SMS] + { 12, 0x018a, EStdKeyF2, EKeyF2 }, // Mail [Email] was: EKeyApplicationA + { 12, 0x0192, EStdKeyApplicationC, EKeyApplicationB }, // Calculator + { 12, 0x01ab, EStdKeyApplicationD, EKeyApplicationD }, // Spell + { 12, 0x0207, EStdKeyApplicationE, EKeyApplicationE }, // Save + { 12, 0x0208, EStdKeyApplicationF, EKeyApplicationF }, // Print + { 12, 0x0201, EStdKeyDevice7, EKeyDevice7 }, // New + { 12, 0x0202, EStdKeyDevice8, EKeyDevice8 }, // Open + { 12, 0x0203, EStdKeyDevice9, EKeyDevice9 }, // Close + { 12, 0x0289, EStdKeyDeviceA, EKeyDeviceA }, // Reply + { 12, 0x028b, EStdKeyDeviceB, EKeyDeviceB }, // Fwd + { 12, 0x028C, EStdKeyDeviceC, EKeyDeviceC }, // Send + { 12, 0x01a7, EStdKeyDeviceD, EKeyDeviceD }, // My Docs [Notepad] + { 12, 0x01b6, EStdKeyDeviceE, EKeyDeviceE }, // My Pics + { 12, 0x01b7, EStdKeyDeviceF, EKeyDeviceF } // My Music + }; + +// ---------------------------------------------------------------------- + + TUint16 CKeyboardLayout::TranslateKey(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers, TLockKeys aLockKeys) const + { + if (aUsagePage == EUsagePageKeyboard) + { + return TranslateKeyboardKey(aHidKey, aModifiers, aLockKeys); + } + else + { + return TranslateOtherKey(aHidKey, aUsagePage, aModifiers, aLockKeys); + } + } + +// ---------------------------------------------------------------------- + +TUint16 CKeyboardLayout::TranslateKeyboardKey(TInt aHidKey, + THidModifier aModifiers, TLockKeys aLockKeys) const + { + // For most layouts, right alt (AltGr) is defined to have the + // same effect as ctrl-alt: + // + if (AltGrIsControlAlt() && aModifiers.RightAlt()) + { + aModifiers.Merge(THidModifier::ELeftControl); + } + + // Caps lock and num lock usually just invert the behaviour of + // the shift key: + // + if ((aLockKeys.iCapsLock && ChangesWithCapsLock(aHidKey, aModifiers)) || + (!aLockKeys.iNumLock && ChangesWithNumLock(aHidKey))) + { + aModifiers.InvertShift(); + } + + // All standard layouts avoid control and shift-control modifiers. + // We map the standard control and shift-control key combinations + // to Symbian shortcut key codes: + // + TUint16 unicode = 0; + + if (aModifiers.Control() && !aModifiers.Alt()) + { + // Symbian Knowledgebase articles FAQ-0507 and FAQ-0511 say + // that this is the correct way to handle control keys so + // that keyboard shortcuts (such as ctrl-x) will work: + + const TInt KCtrlMin = 4; // aA + const TInt KCtrlMax = 29; // zZ + + if ((aHidKey >= KCtrlMin) && (aHidKey <= KCtrlMax)) + { + unicode = static_cast(CTRL( + Unicode(aHidKey, THidModifier(0)))); + } + } + + // If the key wasn't a standard control or shift-control + // combination: + // + if (unicode == 0) + { + unicode = Unicode(aHidKey, aModifiers); + } + + return unicode; + } + +// ---------------------------------------------------------------------- + + TBool CKeyboardLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + // For most layouts Caps Lock only changes those keys in the + // standard A..Z positions: + // + const TInt KCapsLockKeysMin = 4; // aA + const TInt KCapsLockKeysMax = 29; // zZ + + TBool inRange = (aHidKey >= KCapsLockKeysMin) && + (aHidKey <= KCapsLockKeysMax); + + // The standard behaviour is that Caps Lock shouldn't have any + // effect on alt-ctrl ("Alt Gr") modified keys: + // + TBool altGr = aModifiers.Control() && aModifiers.Alt(); + + return !altGr && inRange; + } + +// ---------------------------------------------------------------------- + + TBool CKeyboardLayout::ChangesWithNumLock(TInt aHidKey) const + { + // Num Lock only ever affects a standard subset of the keypad keys: + + const TInt KNumLockMin = 89; // Keypad End + const TInt KNumLockMax = 99; // Keypad Delete + + return (aHidKey >= KNumLockMin) && (aHidKey <= KNumLockMax); + } + +// ---------------------------------------------------------------------- + + TBool CKeyboardLayout::AltGrIsControlAlt() const + { + return ETrue; + } + +// ---------------------------------------------------------------------- + + TBool CKeyboardLayout::IsDeadKey(TInt /*aUnicodeKey*/) const + { + return EFalse; + } + + TUint16 CKeyboardLayout::FindCombiningChar( + TUint16 /*aDeadKeyUnicode*/, TUint16 /*aUnicodeKey*/) const + { + return 0; + } + +// ---------------------------------------------------------------------- + + TBool CKeyboardLayout::IsRepeatingKey(TInt aUnicodeKey) const + { + const TInt KNoRepeatKeys[] = + { + // The modifier and lock keys: + EKeyLeftShift, + EKeyRightShift, + EKeyLeftAlt, + EKeyRightAlt, + EKeyLeftCtrl, + EKeyRightCtrl, + EKeyLeftFunc, + EKeyRightFunc, + EKeyCapsLock, + EKeyNumLock, + EKeyScrollLock, + + // Other keys that toggle: + EKeyPause, + EKeyInsert, + + // Some special cases: + EKeyEscape, + EKeyPrintScreen + }; + + const TInt KNumberOfNoRepeatKeys = + (sizeof (KNoRepeatKeys)) / (sizeof (TInt)); + + TBool match = EFalse; + + for (TInt i=0; i= KHidIdLeftCtrl) && (aHidKey <= KHidIdRightFunc)) + { + result = KModifierCodes[aHidKey - KHidIdLeftCtrl]; + } + + return result; + } + +TInt CKeyboardLayout::CheckSpecialRawCode(TInt aHidKey, TInt aUsagePage) + { + static const TInt KEnhancedKeyCodesSize = + (sizeof (KEnhancedKeyCodes)) / (sizeof (TUsagePageKey)); + + TInt scanCode = EStdKeyNull; + + for (TInt i=0; (scanCode == EStdKeyNull) && (i= 0) && (aHidKey < iNumKeys)) + { + for (TInt i=0; i + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + ',', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CNorwegianLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x10, THidModifier::EAltCtrl, 0x00b5 }, // m M + { 0x1f, THidModifier::EAltCtrl, 0x0040 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x00a3 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x0024 }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x20ac }, // 5 % + { 0x24, THidModifier::EAltCtrl, 0x007b }, // 7 & + { 0x25, THidModifier::EAltCtrl, 0x005b }, // 8 * + { 0x26, THidModifier::EAltCtrl, 0x005d }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x007d }, // 0 ) + { 0x2e, THidModifier::EAltCtrl, 0x00b4 }, // = + + { 0x30, THidModifier::EAltCtrl, 0x007e }, // ] } + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CNorwegianLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CNorwegianLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CNorwegianLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CNorwegianLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CNorwegianLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CNorwegianLayout::KDeadKeyIndex[] = + { + { 0x0060, KDeadKeyGrave }, + { 0x00b4, KDeadKeyAcute }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x005e, KDeadKeyCircumflex }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CNorwegianLayout::CNorwegianLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CNorwegianLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x2f) || // [ { + (aHidKey == 0x33) || // ; : + (aHidKey == 0x34); // ' @ + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CNorwegianLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCNorwegianLayout::LayoutId()"))); + return ENorwegian; + } + +CKeyboardLayout* CNorwegianLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCNorwegianLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CNorwegianLayout; + return layout; + } + +// End of file + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/portuguese.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/portuguese.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,316 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "portuguese.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CPortugueseLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CPortugueseLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', '#', // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '&', // 0x23 35 6 ^ + '7', '/', // 0x24 36 7 & + '8', '(', // 0x25 37 8 * + '9', ')', // 0x26 38 9 ( + '0', '=', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '\'', '?', // 0x2d 45 - _ + 0x00ab, 0x00bb, // 0x2e 46 = + + '+', '*', // 0x2f 47 [ { + 0x00b4, '`', // 0x30 48 ] } + '~', '^', // 0x31 49 US \ bar + '~', '^', // 0x32 50 # ~ + 0x00e7, 0x00c7, // 0x33 51 ; : + 0x00ba, 0x00aa, // 0x34 52 ' @ + '\\', '|', // 0x35 53 Grave/not/bar + ',', ';', // 0x36 54 , < + '.', ':', // 0x37 55 . > + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CPortugueseLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x1f, THidModifier::EAltCtrl, 0x0040 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x00a3 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x00a7 }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x20ac }, // 5 % + { 0x24, THidModifier::EAltCtrl, 0x007b }, // 7 & + { 0x25, THidModifier::EAltCtrl, 0x005b }, // 8 * + { 0x26, THidModifier::EAltCtrl, 0x005d }, // 9 ( + { 0x27, THidModifier::EAltCtrl, 0x007d }, // 0 ) + { 0x2f, THidModifier::EAltCtrl, 0x00a8 }, // [ { + { 0x30, THidModifier::EAltCtrl, 0x005d }, // ] } + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CPortugueseLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CPortugueseLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CPortugueseLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CPortugueseLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CPortugueseLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CPortugueseLayout::KDeadKeyIndex[] = + { + { 0x00a8, KDeadKeyDiaeresis }, + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x007e, KDeadKeyTilde }, + { 0x005e, KDeadKeyCircumflex }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CPortugueseLayout::CPortugueseLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CPortugueseLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = (aHidKey == 0x33); // ; : + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CPortugueseLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCPortugueseLayout::LayoutId()"))); + return EPortuguese; + } + +CKeyboardLayout* CPortugueseLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCPortugueseLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CPortugueseLayout; + return layout; + } + +// End of file + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/spanish.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/spanish.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,321 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "spanish.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSpanishLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CSpanishLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', 0x00b7, // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '&', // 0x23 35 6 ^ + '7', '/', // 0x24 36 7 & + '8', '(', // 0x25 37 8 * + '9', ')', // 0x26 38 9 ( + '0', '=', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '\'', '?', // 0x2d 45 - _ + 0x00a1, 0x00bf, // 0x2e 46 = + + '`', '^', // 0x2f 47 [ { + '+', '*', // 0x30 48 ] } + 0x00e7, 0x00c7, // 0x31 49 US \ bar + 0x00e7, 0x00c7, // 0x32 50 # ~ + 0x00f1, 0x00d1, // 0x33 51 ; : + 0x00b4, 0x00a8, // 0x34 52 ' @ + 0x00ba, 0x00aa, // 0x35 53 Grave/not/bar + ',', ';', // 0x36 54 , < + '.', ':', // 0x37 55 . > + '-', '_', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '<', '>', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CSpanishLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x08, THidModifier::EAltCtrl, 0x20ac }, // e E + { 0x1e, THidModifier::EAltCtrl, 0x007c }, // 1 ! + { 0x1f, THidModifier::EAltCtrl, 0x0040 }, // 2 " + { 0x20, THidModifier::EAltCtrl, 0x0023 }, // 3 £ + { 0x21, THidModifier::EAltCtrl, 0x007e }, // 4 $ + { 0x22, THidModifier::EAltCtrl, 0x20ac }, // 5 % + { 0x23, THidModifier::EAltCtrl, 0x00ac }, // 6 ^ + { 0x2f, THidModifier::EAltCtrl, 0x005b }, // [ { + { 0x30, THidModifier::EAltCtrl, 0x005d }, // ] } + { 0x31, THidModifier::EAltCtrl, 0x007d }, // US \ bar + { 0x32, THidModifier::EAltCtrl, 0x007d }, // # ~ + { 0x34, THidModifier::EAltCtrl, 0x007b }, // ' @ + { 0x35, THidModifier::EAltCtrl, 0x005c }, // Grave/not/bar + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CSpanishLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CSpanishLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CSpanishLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CSpanishLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CSpanishLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CSpanishLayout::KDeadKeyIndex[] = + { + { 0x007e, KDeadKeyTilde }, + { 0x0060, KDeadKeyGrave }, + { 0x005e, KDeadKeyCircumflex }, + { 0x00b4, KDeadKeyAcute }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSpanishLayout::CSpanishLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CSpanishLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x31) || // US \ bar + (aHidKey == 0x32) || // # ~ + (aHidKey == 0x33); // ; : + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CSpanishLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSpanishLayout::LayoutId()"))); + return ESpanish; + } + +CKeyboardLayout* CSpanishLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSpanishLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSpanishLayout; + return layout; + } + +// End of file + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8danishnorwegian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8danishnorwegian.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,338 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8danishnorwegian.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSu8DanishNorwegianLayout::KColumnMap[] = + { + THidModifier::EUnmodified, + THidModifier::EShift, + THidModifier::EAltCtrl + }; + +const TUint16 CSu8DanishNorwegianLayout::KKeyCodes[] = + { + //---- ---S -AC- // Hex Dec + 0, 0, 0, // 0x00 0 + 0, 0, 0, // 0x01 1 + 0, 0, 0, // 0x02 2 + 0, 0, 0, // 0x03 3 + 'a', 'A', 0, // 0x04 4 + 'b', 'B', 0, // 0x05 5 + 'c', 'C', 0, // 0x06 6 + 'd', 'D', 0, // 0x07 7 + 'e', 'E', 0x20ac, // 0x08 8 + 'f', 'F', 0, // 0x09 9 + 'g', 'G', 0, // 0x0a 10 + 'h', 'H', 0, // 0x0b 11 + 'i', 'I', '[', // 0x0c 12 //was: } + 'j', 'J', 0, // 0x0d 13 + 'k', 'K', 0, // 0x0e 14 + 'l', 'L', 0, // 0x0f 15 + 'm', 'M', 0, // 0x10 16 + 'n', 'N', 0, // 0x11 17 + 'o', 'O', ']', // 0x12 18 was: [ + 'p', 'P', '}', // 0x13 19 was: ] + 'q', 'Q', 0x005e, // 0x14 20 + 'r', 'R', '$', // 0x15 21 + 's', 'S', 0, // 0x16 22 + 't', 'T', 0x00a3, // 0x17 23 + 'u', 'U', '{', // 0x18 24 + 'v', 'V', 0, // 0x19 25 + 'w', 'W', '@', // 0x1a 26 + 'x', 'X', 0, // 0x1b 27 + 'y', 'Y', 0, // 0x1c 28 + 'z', 'Z', 0, // 0x1d 29 + '1', '!', 0x005e, // 0x1e 30 + '2', '"', '@', // 0x1f 31 + '3', '#', 0x20ac, // 0x20 32 + '4', 0x00a4, '$', // 0x21 33 + '5', '%', 0x00a3, // 0x22 34 + '6', '&', 0, // 0x23 35 + '7', '/', '{', // 0x24 36 + '8', '(', '[', // 0x25 37 was: } + '9', ')', ']', // 0x26 38 was: [ + '0', '=', '}', // 0x27 39 was: ] + 0x000d, 0xf845, 0, // 0x28 40 + 0x001b, 0x001b, 0, // 0x29 41 + 0x0008, 0x0008, 0, // 0x2a 42 + 0x0009, 0x0009, 0, // 0x2b 43 + ' ', ' ', 0, // 0x2c 44 + '+', '?', 0, // 0x2d 45 + 0x00b4, 0x0060, '\\', // 0x2e 46 + 0x00e5, 0x00c5, 0, // 0x2f 47 + 0x00df, 0x00df, '\\', // 0x30 48 + 0x00e4, 0x00c4, 0, // 0x31 49 + 0, 0, 0, // 0x32 50 + 0x00f6, 0x00d6, 0, // 0x33 51 + 0x00e4, 0x00c4, 0, // 0x34 52 + 0x0027, 0x002a, 0x007e, // 0x35 53 + ',', ';', '<', // 0x36 54 + '.', ':', '>', // 0x37 55 + '-', '_', 0x00a8 // 0x38 56 + }; + +// ---------------------------------------------------------------------- +// Keys 0x33 and 0x34 change for the Danish/Norwegian layout: + +const CStandardKeyboardLayout::TSpecialKey + CSu8DanishNorwegianLayout::KDanishKeyCodes[] = + { + { 0x33, THidModifier::EUnmodified, 0x00f8 }, + { 0x33, THidModifier::EShift, 0x00d8 }, + { 0x34, THidModifier::EUnmodified, 0x00e6 }, + { 0x34, THidModifier::EShift, 0x00c6 }, + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- +// Other codes not included in the KKeyCodes table: + +const CStandardKeyboardLayout::TSpecialKey + CSu8DanishNorwegianLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch to App0 + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-App switch to App0 + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CSu8DanishNorwegianLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CSu8DanishNorwegianLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CSu8DanishNorwegianLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CSu8DanishNorwegianLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CSu8DanishNorwegianLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CSu8DanishNorwegianLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x005e, KDeadKeyCircumflex }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSu8DanishNorwegianLayout::CSu8DanishNorwegianLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TUint16 CSu8DanishNorwegianLayout::Unicode(TInt aHidKey, + THidModifier aModifiers) const + { + TUint16 unicode = 0; + + // Keys 0x33 and 0x34 change for the Danish/Norwegian layout: + unicode = CDeadKeyLayout::FindSpecialKey( + KDanishKeyCodes, aHidKey, aModifiers.Fold()); + + return (unicode != 0) ? unicode : + CDeadKeyLayout::Unicode(aHidKey, aModifiers); + } + +TBool CSu8DanishNorwegianLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x2f) || + (aHidKey == 0x31) || + (aHidKey == 0x33) || + (aHidKey == 0x34); + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CSu8DanishNorwegianLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CDeadKeyLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8DanishNorwegianLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8DanishNorwegianLayout::LayoutId()"))); + return ESu8DanishNorwegian; + } + +CKeyboardLayout* CSu8DanishNorwegianLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8DanishNorwegianLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8DanishNorwegianLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8finnishswedish.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8finnishswedish.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,325 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8finnishswedish.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSu8FinnishSwedishLayout::KColumnMap[] = + { + THidModifier::EUnmodified, + THidModifier::EShift, + THidModifier::EAltCtrl + }; + +const TUint16 CSu8FinnishSwedishLayout::KKeyCodes[] = + { + //---- ---S -AC- // Hex Dec + 0, 0, 0, // 0x00 0 + 0, 0, 0, // 0x01 1 + 0, 0, 0, // 0x02 2 + 0, 0, 0, // 0x03 3 + 'a', 'A', 0, // 0x04 4 + 'b', 'B', 0, // 0x05 5 + 'c', 'C', 0, // 0x06 6 + 'd', 'D', 0, // 0x07 7 + 'e', 'E', 0x20ac, // 0x08 8 + 'f', 'F', 0, // 0x09 9 + 'g', 'G', 0, // 0x0a 10 + 'h', 'H', 0, // 0x0b 11 + 'i', 'I', '[', // 0x0c 12 //was: } + 'j', 'J', 0, // 0x0d 13 + 'k', 'K', 0, // 0x0e 14 + 'l', 'L', 0, // 0x0f 15 + 'm', 'M', 0, // 0x10 16 + 'n', 'N', 0, // 0x11 17 + 'o', 'O', ']', // 0x12 18 was: [ + 'p', 'P', '}', // 0x13 19 was: ] + 'q', 'Q', 0x005e, // 0x14 20 + 'r', 'R', '$', // 0x15 21 + 's', 'S', 0, // 0x16 22 + 't', 'T', 0x00a3, // 0x17 23 + 'u', 'U', '{', // 0x18 24 + 'v', 'V', 0, // 0x19 25 + 'w', 'W', '@', // 0x1a 26 + 'x', 'X', 0, // 0x1b 27 + 'y', 'Y', 0, // 0x1c 28 + 'z', 'Z', 0, // 0x1d 29 + '1', '!', 0x005e, // 0x1e 30 + '2', '"', '@', // 0x1f 31 + '3', '#', 0x20ac, // 0x20 32 + '4', 0x00a4, '$', // 0x21 33 + '5', '%', 0x00a3, // 0x22 34 + '6', '&', 0, // 0x23 35 + '7', '/', '{', // 0x24 36 + '8', '(', '[', // 0x25 37 was: } + '9', ')', ']', // 0x26 38 was: [ + '0', '=', '}', // 0x27 39 was: ] + 0x000d, 0xf845, 0, // 0x28 40 + 0x001b, 0x001b, 0, // 0x29 41 + 0x0008, 0x0008, 0, // 0x2a 42 + 0x0009, 0x0009, 0, // 0x2b 43 + ' ', ' ', 0, // 0x2c 44 + '+', '?', 0, // 0x2d 45 + 0x00b4, 0x0060, '\\', // 0x2e 46 + 0x00e5, 0x00c5, 0, // 0x2f 47 + 0x00df, 0x00df, '\\', // 0x30 48 + 0x00e4, 0x00c4, 0, // 0x31 49 + 0, 0, 0, // 0x32 50 + 0x00f6, 0x00d6, 0, // 0x33 51 + 0x00e4, 0x00c4, 0, // 0x34 52 + 0x0027, 0x002a, 0x007e, // 0x35 53 + ',', ';', '<', // 0x36 54 + '.', ':', '>', // 0x37 55 + '-', '_', 0x00a8 // 0x38 56 + }; + +// ---------------------------------------------------------------------- +// Keys 0x33 and 0x34 change for the Danish/Norwegian layout: + +const CStandardKeyboardLayout::TSpecialKey + CSu8FinnishSwedishLayout::KDanishKeyCodes[] = + { + { 0x33, THidModifier::EUnmodified, 0x00f8 }, + { 0x33, THidModifier::EShift, 0x00d8 }, + { 0x34, THidModifier::EUnmodified, 0x00e6 }, + { 0x34, THidModifier::EShift, 0x00c6 }, + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- +// Other codes not included in the KKeyCodes table: + +const CStandardKeyboardLayout::TSpecialKey + CSu8FinnishSwedishLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch to App0 + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-App switch to App0 + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x00a8 (Diaeresis) +// +const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyDiaeresis[] = + { + { 0x0020, 0x00a8 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CSu8FinnishSwedishLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x00a8, KDeadKeyDiaeresis }, + { 0x005e, KDeadKeyCircumflex }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSu8FinnishSwedishLayout::CSu8FinnishSwedishLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CSu8FinnishSwedishLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x2f) || + (aHidKey == 0x31) || + (aHidKey == 0x33) || + (aHidKey == 0x34); + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CSu8FinnishSwedishLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CDeadKeyLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8FinnishSwedishLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8FinnishSwedishLayout::LayoutId()"))); + return ESu8FinnishSwedish; + } + +CKeyboardLayout* CSu8FinnishSwedishLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8FinnishSwedishLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8FinnishSwedishLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8german.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8german.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,280 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8german.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSu8GermanLayout::KColumnMap[] = + { + THidModifier::EUnmodified, + THidModifier::EShift, + THidModifier::EAltCtrl + }; + +const TUint16 CSu8GermanLayout::KKeyCodes[] = + { + //---- ---S -AC- // Hex Dec + 0, 0, 0, // 0x00 0 + 0, 0, 0, // 0x01 1 + 0, 0, 0, // 0x02 2 + 0, 0, 0, // 0x03 3 + 'a', 'A', 0, // 0x04 4 + 'b', 'B', 0, // 0x05 5 + 'c', 'C', 0, // 0x06 6 + 'd', 'D', 0, // 0x07 7 + 'e', 'E', 0x20ac, // 0x08 8 + 'f', 'F', 0, // 0x09 9 + 'g', 'G', 0, // 0x0a 10 + 'h', 'H', 0, // 0x0b 11 + 'i', 'I', '[', // 0x0c 12 + 'j', 'J', 0, // 0x0d 13 + 'k', 'K', 0, // 0x0e 14 + 'l', 'L', 0, // 0x0f 15 + 'm', 'M', 0, // 0x10 16 + 'n', 'N', 0, // 0x11 17 + 'o', 'O', ']', // 0x12 18 + 'p', 'P', '}', // 0x13 19 + 'q', 'Q', 0x005e, // 0x14 20 + 'r', 'R', '$', // 0x15 21 + 's', 'S', 0, // 0x16 22 + 't', 'T', 0x00a3, // 0x17 23 + 'u', 'U', '{', // 0x18 24 + 'v', 'V', 0, // 0x19 25 + 'w', 'W', '@', // 0x1a 26 + 'x', 'X', 0, // 0x1b 27 + 'z', 'Z', 0, // 0x1c 28 + 'y', 'Y', 0, // 0x1d 29 + '1', '!', 0x005e, // 0x1e 30 + '2', '"', '@', // 0x1f 31 + '3', '#', 0x20ac, // 0x20 32 + '4', 0x00a4, '$', // 0x21 33 + '5', '%', 0x00a3, // 0x22 34 + '6', '&', 0, // 0x23 35 + '7', '/', '{', // 0x24 36 + '8', '(', '[', // 0x25 37 + '9', ')', ']', // 0x26 38 + '0', '=', '}', // 0x27 39 + 0x000d, 0xf845, 0, // 0x28 40 + 0x001b, 0x001b, 0, // 0x29 41 + 0x0008, 0x0008, 0, // 0x2a 42 + 0x0009, 0x0009, 0, // 0x2b 43 + ' ', ' ', 0, // 0x2c 44 + '+', '?', 0, // 0x2d 45 + 0x00b4, 0x0060, '\\', // 0x2e 46 + 0x00fc, 0x00dc, 0, // 0x2f 47 + 0x00df, 0x00df, '\\', // 0x30 48 + 0x00e4, 0x00c4, 0, // 0x31 49 + 0, 0, 0, // 0x32 50 + 0x00f6, 0x00d6, 0, // 0x33 51 + 0x00e4, 0x00c4, 0, // 0x34 52 + 0x0027, 0x002a, 0x007e, // 0x35 53 + ',', ';', '<', // 0x36 54 + '.', ':', '>', // 0x37 55 + '-', '_', 0x00a8 // 0x38 56 + }; + + +// ---------------------------------------------------------------------- +// Other codes not included in the KKeyCodes table: + +const CStandardKeyboardLayout::TSpecialKey + CSu8GermanLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch to App0 + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-App switch to App0 + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CSu8GermanLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CSu8GermanLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CSu8GermanLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CSu8GermanLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x005e, KDeadKeyCircumflex }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSu8GermanLayout::CSu8GermanLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CSu8GermanLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x1e) || (aHidKey == 0x1f) || (aHidKey == 0x20) || + (aHidKey == 0x21) || (aHidKey == 0x22) || (aHidKey == 0x23) || + (aHidKey == 0x24) || (aHidKey == 0x25) || (aHidKey == 0x26) || + (aHidKey == 0x27) || (aHidKey == 0x2d) || (aHidKey == 0x2f) || + (aHidKey == 0x31) || (aHidKey == 0x33) || (aHidKey == 0x34) || + (aHidKey == 0x36) || (aHidKey == 0x37); + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CSu8GermanLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CDeadKeyLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8GermanLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8GermanLayout::LayoutId()"))); + return ESu8German; + } + +CKeyboardLayout* CSu8GermanLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8GermanLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8GermanLayout; + return layout; + } + +// End of file + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8intusenglish.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8intusenglish.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,319 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8intusenglish.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSu8IntUsEnglishLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift, // ---S + THidModifier::EAltCtrl, // -AC- + THidModifier::EAltCtrlShift // -ACS + }; + +const TUint16 CSu8IntUsEnglishLayout::KKeyCodes[] = + { + //---- ---S -AC- -ACS // Hex Dec Usage name (UK) + 0, 0, 0, 0, // 0x00 0 Reserved (no event) + 0, 0, 0, 0, // 0x01 1 Rollover error + 0, 0, 0, 0, // 0x02 2 POST Fail + 0, 0, 0, 0, // 0x03 3 Undefined error + 'a', 'A', 0x00e1, 0x00c1, // 0x04 4 a A + 'b', 'B', 0, 0, // 0x05 5 b B + 'c', 'C', 0x00a9, 0x00a2, // 0x06 6 c C + 'd', 'D', 0x00f0, 0x00d0, // 0x07 7 d D + 'e', 'E', 0x00e9, 0x00c9, // 0x08 8 e E + 'f', 'F', 0, 0, // 0x09 9 f F + 'g', 'G', 0, 0, // 0x0a 10 g G + 'h', 'H', 0, 0, // 0x0b 11 h H + 'i', 'I', 0x00ed, 0x00cd, // 0x0c 12 i I + 'j', 'J', 0, 0, // 0x0d 13 j J + 'k', 'K', 0, 0, // 0x0e 14 k K + 'l', 'L', 0x00f8, 0x00d8, // 0x0f 15 l L + 'm', 'M', 0x00b5, 0, // 0x10 16 m M + 'n', 'N', 0x00f1, 0x00d1, // 0x11 17 n N + 'o', 'O', 0x00f3, 0x00d3, // 0x12 18 o O + 'p', 'P', 0x00f6, 0x00d6, // 0x13 19 p P + 'q', 'Q', 0x00e4, 0x00c4, // 0x14 20 q Q + 'r', 'R', 0x00ae, 0, // 0x15 21 r R + 's', 'S', 0x00df, 0x00a7, // 0x16 22 s S + 't', 'T', 0x00fe, 0x00de, // 0x17 23 t T + 'u', 'U', 0x00fa, 0x00da, // 0x18 24 u U + 'v', 'V', 0, 0, // 0x19 25 v V + 'w', 'W', 0x00e5, 0x00c5, // 0x1a 26 w W + 'x', 'X', 0, 0, // 0x1b 27 x X + 'y', 'Y', 0x00fc, 0x00dc, // 0x1c 28 y Y + 'z', 'Z', 0x00e6, 0x00c6, // 0x1d 29 z Z + '1', '!', 0x00a1, 0x00b9, // 0x1e 30 1 ! + '2', '@', 0x00b2, 0, // 0x1f 31 2 " + '3', '#', 0x00b3, 0, // 0x20 32 3 £ + '4', '$', 0x00a4, 0x00a3, // 0x21 33 4 $ + '5', '%', 0x20ac, 0, // 0x22 34 5 % + '6', '^', 0x00bc, 0, // 0x23 35 6 ^ + '7', '&', 0x00bd, 0, // 0x24 36 7 & + '8', '*', 0x00be, 0, // 0x25 37 8 * + '9', '(', 0x2018, 0, // 0x26 38 9 ( + '0', ')', 0x2019, 0, // 0x27 39 0 ) + 0x000d, 0xf845, 0, 0, // 0x28 40 Enter (Return) + 0x001b, 0x001b, 0, 0, // 0x29 41 Escape + 0x0008, 0x0008, 0, 0, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, 0, 0, // 0x2b 43 Tab + ' ', ' ', 0, 0, // 0x2c 44 Spacebar + '-', '_', 0x00a5, 0, // 0x2d 45 - _ + '=', '+', 0x00d7, 0x00f7, // 0x2e 46 = + + '[', '{', 0x00ab, 0, // 0x2f 47 [ { + ']', '}', 0x00bb, 0, // 0x30 48 ] } + '\\', '|', 0x00ac, 0x00a6, // 0x31 49 US \ bar + '\\', '|', 0x00ac, 0x00a6, // 0x32 50 # ~ + ';', ':', 0x00b6, 0x00b0, // 0x33 51 ; : + '\'', '"', 0x00b4, 0x00a8, // 0x34 52 ' @ + '`', '~', 0, 0, // 0x35 53 Grave/not/bar + ',', '<', 0x00e7, 0x00c7, // 0x36 54 , < + '.', '>', 0, 0, // 0x37 55 . > + '/', '?', 0x00bf, 0, // 0x38 56 / ? + }; + +// ---------------------------------------------------------------------- +// Other codes not included in the KKeyCodes table: + +const CStandardKeyboardLayout::TSpecialKey + CSu8IntUsEnglishLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch to App0 + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-App switch to App0 + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CSu8IntUsEnglishLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x0027 (Apostrophe) +// +const CDeadKeyLayout::TKeyPair CSu8IntUsEnglishLayout::KDeadKeyApostrophe[] = + { + { 0x0020, 0x0027 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0043, 0x00c7 }, // C + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0063, 0x00e7 }, // c + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0022 (Quotation mark) +// +const CDeadKeyLayout::TKeyPair CSu8IntUsEnglishLayout::KDeadKeyQuotationMark[] = + { + { 0x0020, 0x0022 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CSu8IntUsEnglishLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CSu8IntUsEnglishLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CSu8IntUsEnglishLayout::KDeadKeyIndex[] = + { + { 0x005e, KDeadKeyCircumflex }, + { 0x0027, KDeadKeyApostrophe }, + { 0x0022, KDeadKeyQuotationMark }, + { 0x0060, KDeadKeyGrave }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + + +// ---------------------------------------------------------------------- + +CSu8IntUsEnglishLayout::CSu8IntUsEnglishLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CSu8IntUsEnglishLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x1e) || (aHidKey == 0x1f) || (aHidKey == 0x20) || + (aHidKey == 0x21) || (aHidKey == 0x22) || (aHidKey == 0x23) || + (aHidKey == 0x24) || (aHidKey == 0x25) || (aHidKey == 0x26) || + (aHidKey == 0x27) || (aHidKey == 0x2d) || (aHidKey == 0x2f) || + (aHidKey == 0x31) || (aHidKey == 0x33) || (aHidKey == 0x34) || + (aHidKey == 0x36) || (aHidKey == 0x37); + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CSu8IntUsEnglishLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CDeadKeyLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8IntUsEnglishLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8IntUsEnglishLayout::LayoutId()"))); + return ESu8USEnglish; + } + +CKeyboardLayout* CSu8IntUsEnglishLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8IntUsEnglishLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8IntUsEnglishLayout; + return layout; + } + +// End of file + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8russian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8russian.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8russian.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSu8RussianLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CSu8RussianLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 0x444, 0x424, // 0x04 4 a + 0x438, 0x418, // 0x05 5 b + 'c', 'C', // 0x06 6 c + 0x432, 0x412, // 0x07 7 d + 0x443, 0x423, // 0x08 8 e + 0x430, 0x410, // 0x09 9 f + 0x43f, 0x41f, // 0x0a 10 g + 0x440, 0x420, // 0x0b 11 h + 0x448, 0x428, // 0x0c 12 i + 0x43e, 0x41e, // 0x0d 13 j + 0x43b, 0x41b, // 0x0e 14 k + 0x434, 0x414, // 0x0f 15 l + 0x44c, 0x42c, // 0x10 16 m + 0x442, 0x422, // 0x11 17 n + 0x449, 0x429, // 0x12 18 o + 0x437, 0x417, // 0x13 19 p + 0x439, 0x419, // 0x14 20 q + 0x43a, 0x41a, // 0x15 21 r + 0x44b, 0x42b, // 0x16 22 s + 0x435, 0x415, // 0x17 23 t + 0x433, 0x413, // 0x18 24 u + 0x43c, 0x41c, // 0x19 25 v + 0x446, 0x426, // 0x1a 26 w + 0x447, 0x427, // 0x1b 27 x + 0x43d, 0x41d, // 0x1c 28 y + 0x44f, 0x42f, // 0x1d 29 z + '1', '!', // 0x1e 30 1 + '2', '@', // 0x1f 31 2 + '3', '#', // 0x20 32 3 + '4', '$', // 0x21 33 4 + '5', '%', // 0x22 34 5 + '6', '^', // 0x23 35 6 + '7', '&', // 0x24 36 7 + '8', '*', // 0x25 37 8 + '9', '(', // 0x26 38 9 + '0', ')', // 0x27 39 0 + 0x000d, 0xf845, // 0x28 40 Enter + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Space + '-', '_', // 0x2d 45 + '=', '+', // 0x2e 46 + 0x445, 0x425, // 0x2f 47 + 0x44a, 0x42a, // 0x30 48 + '\\', '|', // 0x31 49 + 0, 0, // 0x32 50 + 0x436, 0x416, // 0x33 51 + 0x44d, 0x42d, // 0x34 52 + 0x451, 0x401, // 0x35 53 + 0x431, 0x411, // 0x36 54 + 0x44e, 0x42e, // 0x37 55 + '/', '?' // 0x38 56 + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey + CSu8RussianLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Shift-left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Shift-right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-app switch + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSu8RussianLayout::CSu8RussianLayout() + : CStandardKeyboardLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases) + { + // nothing else to do + } + +// ---------------------------------------------------------------------- + +TInt CSu8RussianLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CStandardKeyboardLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8RussianLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8RussianLayout::LayoutId()"))); + return ESu8Russian; + } + +CKeyboardLayout* CSu8RussianLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8RussianLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8RussianLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8russianint.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8russianint.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,341 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8russianint.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CSu8RussianIntLayout::KColumnMap[] = + { + THidModifier::EUnmodified, + THidModifier::EShift, + THidModifier::EAltCtrl, + THidModifier::EAltCtrlShift + }; + +const TUint16 CSu8RussianIntLayout::KKeyCodes[] = + + { + //---- ---S AC ACS // Hex Dec Usage name (UK) + 0, 0, 0, 0, // 0x00 0 Reserved (no event) + 0, 0, 0, 0, // 0x01 1 Rollover error + 0, 0, 0, 0, // 0x02 2 POST Fail + 0, 0, 0, 0, // 0x03 3 Undefined error + 0x444, 0x424, 'a', 'A', // 0x04 4 a + 0x438, 0x418, 'b', 'B', // 0x05 5 b + 'c', 'C', 'c', 'C', // 0x06 6 c + 0x432, 0x412, 'd', 'D', // 0x07 7 d + 0x443, 0x423, 'e', 'E', // 0x08 8 e + 0x430, 0x410, 'f', 'F', // 0x09 9 f + 0x43f, 0x41f, 'g', 'G', // 0x0a 10 g + 0x440, 0x420, 'h', 'H', // 0x0b 11 h + 0x448, 0x428, 'i', 'I', // 0x0c 12 i + 0x43e, 0x41e, 'j', 'J', // 0x0d 13 j + 0x43b, 0x41b, 'k', 'K', // 0x0e 14 k + 0x434, 0x414, 'l', 'L', // 0x0f 15 l + 0x44c, 0x42c, 'm', 'M', // 0x10 16 m + 0x442, 0x422, 'n', 'N', // 0x11 17 n + 0x449, 0x429, 'o', 'O', // 0x12 18 o + 0x437, 0x417, 'p', 'P', // 0x13 19 p + 0x439, 0x419, 'q', 'Q', // 0x14 20 q + 0x43a, 0x41a, 'r', 'R', // 0x15 21 r + 0x44b, 0x42b, 's', 'S', // 0x16 22 s + 0x435, 0x415, 't', 'T', // 0x17 23 t + 0x433, 0x413, 'u', 'U', // 0x18 24 u + 0x43c, 0x41c, 'v', 'V', // 0x19 25 v + 0x446, 0x426, 'w', 'W', // 0x1a 26 w + 0x447, 0x427, 'x', 'X', // 0x1b 27 x + 0x43d, 0x41d, 'y', 'Y', // 0x1c 28 y + 0x44f, 0x42f, 'z', 'Z', // 0x1d 29 z + '1', '!', '!', '!', // 0x1e 30 1 + '2', '@', '"', '@', // 0x1f 31 2 + '3', '#', '#', '#', // 0x20 32 3 + '4', '$', 0x00a4, '$', // 0x21 33 4 + '5', '%', '%', '%', // 0x22 34 5 + '6', '^', '&', '^', // 0x23 35 6 + '7', '&', '/', '&', // 0x24 36 7 + '8', '*', '(', '*', // 0x25 37 8 + '9', '(', ')', '(', // 0x26 38 9 + '0', ')', '=', ')', // 0x27 39 0 + 0x000d, 0xf845, 0,0, // 0x28 40 Enter + 0x001b, 0x001b, 0,0, // 0x29 41 Escape + 0x0008, 0x0008, 0,0, // 0x2a 42 Backspace + 0x0009, 0x0009, 0,0, // 0x2b 43 Tab + ' ', ' ', 0,0, // 0x2c 44 Space + '-', '_', '+', '?', // 0x2d 45 + '=', '+', '=', '+', // 0x2e 46 + 0x445, 0x425, '[', '{', // 0x2f 47 + 0x44a, 0x42a, ']', '}', // 0x30 48 + '\\', '|', '\\','|', // 0x31 49 + 0, 0, 0,0, // 0x32 50 + 0x436, 0x416, ';', ':', // 0x33 51 + 0x44d, 0x42d, '\'','"', // 0x34 52 + 0x451, 0x401, '`', '~', // 0x35 53 + 0x431, 0x411, ',', '<', // 0x36 54 + 0x44e, 0x42e, '.', '>', // 0x37 55 + '/', '?', '/', '?' // 0x38 56 + }; +/* + //---- ---S -AC- // Hex Dec + 0, 0, 0, // 0x00 0 + 0, 0, 0, // 0x01 1 + 0, 0, 0, // 0x02 2 + 0, 0, 0, // 0x03 3 + 'a', 'A', 0, // 0x04 4 + 'b', 'B', 0, // 0x05 5 + 'c', 'C', 0, // 0x06 6 + 'd', 'D', 0, // 0x07 7 + 'e', 'E', 0x20ac, // 0x08 8 + 'f', 'F', 0, // 0x09 9 + 'g', 'G', 0, // 0x0a 10 + 'h', 'H', 0, // 0x0b 11 + 'i', 'I', '[', // 0x0c 12 + 'j', 'J', 0, // 0x0d 13 + 'k', 'K', 0, // 0x0e 14 + 'l', 'L', 0, // 0x0f 15 + 'm', 'M', 0, // 0x10 16 + 'n', 'N', 0, // 0x11 17 + 'o', 'O', ']', // 0x12 18 + 'p', 'P', '}', // 0x13 19 + 'q', 'Q', 0x005e, // 0x14 20 + 'r', 'R', '$', // 0x15 21 + 's', 'S', 0, // 0x16 22 + 't', 'T', 0x00a3, // 0x17 23 + 'u', 'U', '{', // 0x18 24 + 'v', 'V', 0, // 0x19 25 + 'w', 'W', '@', // 0x1a 26 + 'x', 'X', 0, // 0x1b 27 + 'z', 'Z', 0, // 0x1c 28 + 'y', 'Y', 0, // 0x1d 29 + '1', '!', 0x005e, // 0x1e 30 + '2', '"', '@', // 0x1f 31 + '3', '#', 0x20ac, // 0x20 32 + '4', 0x00a4, '$', // 0x21 33 + '5', '%', 0x00a3, // 0x22 34 + '6', '&', 0, // 0x23 35 + '7', '/', '{', // 0x24 36 + '8', '(', '[', // 0x25 37 + '9', ')', ']', // 0x26 38 + '0', '=', '}', // 0x27 39 + 0x000d, 0xf845, 0, // 0x28 40 + 0x001b, 0x001b, 0, // 0x29 41 + 0x0008, 0x0008, 0, // 0x2a 42 + 0x0009, 0x0009, 0, // 0x2b 43 + ' ', ' ', 0, // 0x2c 44 + '+', '?', 0, // 0x2d 45 + 0x00b4, 0x0060, '\\', // 0x2e 46 + 0x00fc, 0x00dc, 0, // 0x2f 47 + 0x00df, 0x00df, '\\', // 0x30 48 + 0x00e4, 0x00c4, 0, // 0x31 49 + 0, 0, 0, // 0x32 50 + 0x00f6, 0x00d6, 0, // 0x33 51 + 0x00e4, 0x00c4, 0, // 0x34 52 + 0x0027, 0x002a, 0x007e, // 0x35 53 + ',', ';', '<', // 0x36 54 + '.', ':', '>', // 0x37 55 + '-', '_', 0x00a8 // 0x38 56 + }; +*/ + +// ---------------------------------------------------------------------- +// Other codes not included in the KKeyCodes table: + +const CStandardKeyboardLayout::TSpecialKey + CSu8RussianIntLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch to App0 + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-App switch to App0 + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x00b4 (Acute accent) +// +const CDeadKeyLayout::TKeyPair CSu8RussianIntLayout::KDeadKeyAcute[] = + { + { 0x0020, 0x00b4 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CSu8RussianIntLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CSu8RussianIntLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CSu8RussianIntLayout::KDeadKeyIndex[] = + { + { 0x00b4, KDeadKeyAcute }, + { 0x0060, KDeadKeyGrave }, + { 0x005e, KDeadKeyCircumflex }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSu8RussianIntLayout::CSu8RussianIntLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CSu8RussianIntLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x1e) || (aHidKey == 0x1f) || (aHidKey == 0x20) || + (aHidKey == 0x21) || (aHidKey == 0x22) || (aHidKey == 0x23) || + (aHidKey == 0x24) || (aHidKey == 0x25) || (aHidKey == 0x26) || + (aHidKey == 0x27) || (aHidKey == 0x2d) || (aHidKey == 0x2f) || + (aHidKey == 0x31) || (aHidKey == 0x33) || (aHidKey == 0x34) || + (aHidKey == 0x36) || (aHidKey == 0x37); + + if (isExtraCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CSu8RussianIntLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CDeadKeyLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8RussianIntLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8RussianIntLayout::LayoutId()"))); + return ESu8Russian; + } + +CKeyboardLayout* CSu8RussianIntLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8RussianIntLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8RussianIntLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/su8usenglish.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/su8usenglish.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "su8usenglish.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CUSInternationalLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift, // ---S + THidModifier::EAltCtrl, // -AC- + THidModifier::EAltCtrlShift // -ACS + }; + +const TUint16 CUSInternationalLayout::KKeyCodes[] = + { + //---- ---S -AC- -ACS // Hex Dec Usage name (UK) + 0, 0, 0, 0, // 0x00 0 Reserved (no event) + 0, 0, 0, 0, // 0x01 1 Rollover error + 0, 0, 0, 0, // 0x02 2 POST Fail + 0, 0, 0, 0, // 0x03 3 Undefined error + 'a', 'A', 0x00e1, 0x00c1, // 0x04 4 a A + 'b', 'B', 0, 0, // 0x05 5 b B + 'c', 'C', 0x00a9, 0x00a2, // 0x06 6 c C + 'd', 'D', 0x00f0, 0x00d0, // 0x07 7 d D + 'e', 'E', 0x00e9, 0x00c9, // 0x08 8 e E + 'f', 'F', 0, 0, // 0x09 9 f F + 'g', 'G', 0, 0, // 0x0a 10 g G + 'h', 'H', 0, 0, // 0x0b 11 h H + 'i', 'I', 0x00ed, 0x00cd, // 0x0c 12 i I + 'j', 'J', 0, 0, // 0x0d 13 j J + 'k', 'K', 0, 0, // 0x0e 14 k K + 'l', 'L', 0x00f8, 0x00d8, // 0x0f 15 l L + 'm', 'M', 0x00b5, 0, // 0x10 16 m M + 'n', 'N', 0x00f1, 0x00d1, // 0x11 17 n N + 'o', 'O', 0x00f3, 0x00d3, // 0x12 18 o O + 'p', 'P', 0x00f6, 0x00d6, // 0x13 19 p P + 'q', 'Q', 0x00e4, 0x00c4, // 0x14 20 q Q + 'r', 'R', 0x00ae, 0, // 0x15 21 r R + 's', 'S', 0x00df, 0x00a7, // 0x16 22 s S + 't', 'T', 0x00fe, 0x00de, // 0x17 23 t T + 'u', 'U', 0x00fa, 0x00da, // 0x18 24 u U + 'v', 'V', 0, 0, // 0x19 25 v V + 'w', 'W', 0x00e5, 0x00c5, // 0x1a 26 w W + 'x', 'X', 0, 0, // 0x1b 27 x X + 'y', 'Y', 0x00fc, 0x00dc, // 0x1c 28 y Y + 'z', 'Z', 0x00e6, 0x00c6, // 0x1d 29 z Z + '1', '!', 0x00a1, 0x00b9, // 0x1e 30 1 ! + '2', '@', 0x00b2, 0, // 0x1f 31 2 " + '3', '#', 0x00b3, 0, // 0x20 32 3 £ + '4', '$', 0x00a4, 0x00a3, // 0x21 33 4 $ + '5', '%', 0x20ac, 0, // 0x22 34 5 % + '6', '^', 0x00bc, 0, // 0x23 35 6 ^ + '7', '&', 0x00bd, 0, // 0x24 36 7 & + '8', '*', 0x00be, 0, // 0x25 37 8 * + '9', '(', 0x2018, 0, // 0x26 38 9 ( + '0', ')', 0x2019, 0, // 0x27 39 0 ) + 0x000d, 0xf845, 0, 0, // 0x28 40 Enter (Return) + 0x001b, 0x001b, 0, 0, // 0x29 41 Escape + 0x0008, 0x0008, 0, 0, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, 0, 0, // 0x2b 43 Tab + ' ', ' ', 0, 0, // 0x2c 44 Spacebar + '-', '_', 0x00a5, 0, // 0x2d 45 - _ + '=', '+', 0x00d7, 0x00f7, // 0x2e 46 = + + '[', '{', 0x00ab, 0, // 0x2f 47 [ { + ']', '}', 0x00bb, 0, // 0x30 48 ] } + '\\', '|', 0x00ac, 0x00a6, // 0x31 49 US \ bar + '\\', '|', 0x00ac, 0x00a6, // 0x32 50 # ~ + ';', ':', 0x00b6, 0x00b0, // 0x33 51 ; : + '\'', '"', 0x00b4, 0x00a8, // 0x34 52 ' @ + '`', '~', 0, 0, // 0x35 53 Grave/not/bar + ',', '<', 0x00e7, 0x00c7, // 0x36 54 , < + '.', '>', 0, 0, // 0x37 55 . > + '/', '?', 0x00bf, 0, // 0x38 56 / ? + + }; + +/* OLD AND ORIGINAL SU-8W ENGLISH LAYOUT +const TInt CSu8UnitedStatesLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CSu8UnitedStatesLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a + 'b', 'B', // 0x05 5 b + 'c', 'C', // 0x06 6 c + 'd', 'D', // 0x07 7 d + 'e', 'E', // 0x08 8 e + 'f', 'F', // 0x09 9 f + 'g', 'G', // 0x0a 10 g + 'h', 'H', // 0x0b 11 h + 'i', 'I', // 0x0c 12 i + 'j', 'J', // 0x0d 13 j + 'k', 'K', // 0x0e 14 k + 'l', 'L', // 0x0f 15 l + 'm', 'M', // 0x10 16 m + 'n', 'N', // 0x11 17 n + 'o', 'O', // 0x12 18 o + 'p', 'P', // 0x13 19 p + 'q', 'Q', // 0x14 20 q + 'r', 'R', // 0x15 21 r + 's', 'S', // 0x16 22 s + 't', 'T', // 0x17 23 t + 'u', 'U', // 0x18 24 u + 'v', 'V', // 0x19 25 v + 'w', 'W', // 0x1a 26 w + 'x', 'X', // 0x1b 27 x + 'y', 'Y', // 0x1c 28 y + 'z', 'Z', // 0x1d 29 z + '1', '!', // 0x1e 30 1 + '2', '@', // 0x1f 31 2 + '3', '#', // 0x20 32 3 + '4', '$', // 0x21 33 4 + '5', '%', // 0x22 34 5 + '6', '^', // 0x23 35 6 + '7', '&', // 0x24 36 7 + '8', '*', // 0x25 37 8 + '9', '(', // 0x26 38 9 + '0', ')', // 0x27 39 0 + 0x000d, 0xf845, // 0x28 40 Enter + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Space + '-', '_', // 0x2d 45 + '=', '+', // 0x2e 46 + '[', '{', // 0x2f 47 + ']', '}', // 0x30 48 + '\\', '|', // 0x31 49 + 0, 0, // 0x32 50 + ';', ':', // 0x33 51 + '\'', '"', // 0x34 52 + '`', '~', // 0x35 53 + ',', '<', // 0x36 54 + '.', '>', // 0x37 55 + '/', '?' // 0x38 56 + }; +*/ +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey + CSu8UnitedStatesLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode + { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar + { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab + { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete + { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete + { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow + { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow + { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow + { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow + { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow + { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow + { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow + { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Shift-left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Shift-right GUI key + { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch + { 0x76, THidModifier::EShift, 0xf852 }, // Shift-app switch + { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK + { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK + // + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +CSu8UnitedStatesLayout::CSu8UnitedStatesLayout() + : CStandardKeyboardLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases) + { + // nothing else to do + } + + +TInt CSu8UnitedStatesLayout::RawScanCode(TInt aHidKey, + TInt aUsagePage, THidModifier aModifiers) const + { + TInt result = EStdKeyNull; + + const TInt KKeyboardUsagePage = 0x07; + if (aUsagePage == KKeyboardUsagePage) + { + // Application switch key is HID "Keyboard Menu" usage: + // + const TInt KHidKeyboardMenu = 0x76; + if (aHidKey == KHidKeyboardMenu) + { + result = EStdKeyApplication0; + } + + // Middle soft key is HID "Keyboard Select" usage: + // + const TInt KHidKeyboardSelect = 0x77; + if (aHidKey == KHidKeyboardSelect) + { + result = EStdKeyDevice3; + } + } + + if (result == EStdKeyNull) + { + result = CStandardKeyboardLayout::RawScanCode(aHidKey, + aUsagePage, aModifiers); + } + + return result; + } + +TInt CSu8UnitedStatesLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCSu8UnitedStatesLayout::LayoutId()"))); + return ESu8IntRussian; + } + +CKeyboardLayout* CSu8UnitedStatesLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCSu8UnitedStatesLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CSu8UnitedStatesLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/unitedkingdom.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/unitedkingdom.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,217 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "unitedkingdom.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CUnitedKingdomLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CUnitedKingdomLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '"', // 0x1f 31 2 " + '3', 0x00a3, // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '^', // 0x23 35 6 ^ + '7', '&', // 0x24 36 7 & + '8', '*', // 0x25 37 8 * + '9', '(', // 0x26 38 9 ( + '0', ')', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '-', '_', // 0x2d 45 - _ + '=', '+', // 0x2e 46 = + + '[', '{', // 0x2f 47 [ { + ']', '}', // 0x30 48 ] } + '#', '~', // 0x31 49 US \ bar + '#', '~', // 0x32 50 # ~ + ';', ':', // 0x33 51 ; : + '\'', '@', // 0x34 52 ' @ + '`', 0x00ac, // 0x35 53 Grave/not/bar + ',', '<', // 0x36 54 , < + '.', '>', // 0x37 55 . > + '/', '?', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '\\', '|', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CUnitedKingdomLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x04, THidModifier::EAltCtrl, 0x00e1 }, // a A + { 0x08, THidModifier::EAltCtrl, 0x00e9 }, // e E + { 0x0c, THidModifier::EAltCtrl, 0x00ed }, // i I + { 0x12, THidModifier::EAltCtrl, 0x00f3 }, // o O + { 0x18, THidModifier::EAltCtrl, 0x00fa }, // u U + { 0x21, THidModifier::EAltCtrl, 0x20ac }, // 4 $ + { 0x35, THidModifier::EAltCtrl, 0x00a6 }, // Grave/not/bar + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0x04, THidModifier::EAltCtrlShift, 0x00c1 }, // a A + { 0x08, THidModifier::EAltCtrlShift, 0x00c9 }, // e E + { 0x0c, THidModifier::EAltCtrlShift, 0x00cd }, // i I + { 0x12, THidModifier::EAltCtrlShift, 0x00d3 }, // o O + { 0x18, THidModifier::EAltCtrlShift, 0x00da }, // u U + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +CUnitedKingdomLayout::CUnitedKingdomLayout() + : CStandardKeyboardLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases) + { + // nothing else to do + } + +TBool CUnitedKingdomLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.ControlAlt()) + { + // Allow caps lock to invert the shift state for these ctrl-alt keys: + // + TBool isAltGrCapsKey = + (aHidKey == 0x04) || // a A + (aHidKey == 0x08) || // e E + (aHidKey == 0x0c) || // i I + (aHidKey == 0x12) || // o O + (aHidKey == 0x18); // u U + + if (isAltGrCapsKey) + return ETrue; + } + + return CStandardKeyboardLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CUnitedKingdomLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCUnitedKingdomLayout::LayoutId()"))); + return EUnitedKingdom; + } + +CKeyboardLayout* CUnitedKingdomLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCUnitedKingdomLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CUnitedKingdomLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/unitedstates.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/unitedstates.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "unitedstates.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CUnitedStatesLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CUnitedStatesLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'b', 'B', // 0x05 5 b B + 'c', 'C', // 0x06 6 c C + 'd', 'D', // 0x07 7 d D + 'e', 'E', // 0x08 8 e E + 'f', 'F', // 0x09 9 f F + 'g', 'G', // 0x0a 10 g G + 'h', 'H', // 0x0b 11 h H + 'i', 'I', // 0x0c 12 i I + 'j', 'J', // 0x0d 13 j J + 'k', 'K', // 0x0e 14 k K + 'l', 'L', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'n', 'N', // 0x11 17 n N + 'o', 'O', // 0x12 18 o O + 'p', 'P', // 0x13 19 p P + 'q', 'Q', // 0x14 20 q Q + 'r', 'R', // 0x15 21 r R + 's', 'S', // 0x16 22 s S + 't', 'T', // 0x17 23 t T + 'u', 'U', // 0x18 24 u U + 'v', 'V', // 0x19 25 v V + 'w', 'W', // 0x1a 26 w W + 'x', 'X', // 0x1b 27 x X + 'y', 'Y', // 0x1c 28 y Y + 'z', 'Z', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '@', // 0x1f 31 2 " + '3', '#', // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '^', // 0x23 35 6 ^ + '7', '&', // 0x24 36 7 & + '8', '*', // 0x25 37 8 * + '9', '(', // 0x26 38 9 ( + '0', ')', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '-', '_', // 0x2d 45 - _ + '=', '+', // 0x2e 46 = + + '[', '{', // 0x2f 47 [ { + ']', '}', // 0x30 48 ] } + '\\', '|', // 0x31 49 US \ bar + '\\', '|', // 0x32 50 # ~ + ';', ':', // 0x33 51 ; : + '\'', '"', // 0x34 52 ' @ + '`', '~', // 0x35 53 Grave/not/bar + ',', '<', // 0x36 54 , < + '.', '>', // 0x37 55 . > + '/', '?', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '\\', '|', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CUnitedStatesLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +CUnitedStatesLayout::CUnitedStatesLayout() + : CStandardKeyboardLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases) + { + // nothing else to do + } + +TInt CUnitedStatesLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCUnitedStatesLayout::LayoutId()"))); + return EUnitedStates; + } + +CKeyboardLayout* CUnitedStatesLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCUnitedStatesLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CUnitedStatesLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/unitedstatesdvorak.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/unitedstatesdvorak.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "unitedstatesdvorak.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CUnitedStatesDvorakLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift // ---S + }; + +const TUint16 CUnitedStatesDvorakLayout::KKeyCodes[] = + { + //---- ---S // Hex Dec Usage name (UK) + 0, 0, // 0x00 0 Reserved (no event) + 0, 0, // 0x01 1 Rollover error + 0, 0, // 0x02 2 POST Fail + 0, 0, // 0x03 3 Undefined error + 'a', 'A', // 0x04 4 a A + 'x', 'X', // 0x05 5 b B + 'j', 'J', // 0x06 6 c C + 'e', 'E', // 0x07 7 d D + '.', '>', // 0x08 8 e E + 'u', 'U', // 0x09 9 f F + 'i', 'I', // 0x0a 10 g G + 'd', 'D', // 0x0b 11 h H + 'c', 'C', // 0x0c 12 i I + 'h', 'H', // 0x0d 13 j J + 't', 'T', // 0x0e 14 k K + 'n', 'N', // 0x0f 15 l L + 'm', 'M', // 0x10 16 m M + 'b', 'B', // 0x11 17 n N + 'r', 'R', // 0x12 18 o O + 'l', 'L', // 0x13 19 p P + '\'', '"', // 0x14 20 q Q + 'p', 'P', // 0x15 21 r R + 'o', 'O', // 0x16 22 s S + 'y', 'Y', // 0x17 23 t T + 'g', 'G', // 0x18 24 u U + 'k', 'K', // 0x19 25 v V + ',', '<', // 0x1a 26 w W + 'q', 'Q', // 0x1b 27 x X + 'f', 'F', // 0x1c 28 y Y + ';', ':', // 0x1d 29 z Z + '1', '!', // 0x1e 30 1 ! + '2', '@', // 0x1f 31 2 " + '3', '#', // 0x20 32 3 £ + '4', '$', // 0x21 33 4 $ + '5', '%', // 0x22 34 5 % + '6', '^', // 0x23 35 6 ^ + '7', '&', // 0x24 36 7 & + '8', '*', // 0x25 37 8 * + '9', '(', // 0x26 38 9 ( + '0', ')', // 0x27 39 0 ) + 0x000d, 0xf845, // 0x28 40 Enter (Return) + 0x001b, 0x001b, // 0x29 41 Escape + 0x0008, 0x0008, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, // 0x2b 43 Tab + ' ', ' ', // 0x2c 44 Spacebar + '[', '{', // 0x2d 45 - _ + ']', '}', // 0x2e 46 = + + '/', '?', // 0x2f 47 [ { + '=', '+', // 0x30 48 ] } + '\\', '|', // 0x31 49 US \ bar + '\\', '|', // 0x32 50 # ~ + 's', 'S', // 0x33 51 ; : + '-', '_', // 0x34 52 ' @ + '`', '~', // 0x35 53 Grave/not/bar + 'w', 'W', // 0x36 54 , < + 'v', 'V', // 0x37 55 . > + 'z', 'Z', // 0x38 56 / ? + 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, // 0x3a 58 F1 + 0xf817, 0xf817, // 0x3b 59 F2 + 0xf818, 0xf818, // 0x3c 60 F3 + 0xf819, 0xf819, // 0x3d 61 F4 + 0xf81a, 0xf81a, // 0x3e 62 F5 + 0xf81b, 0xf81b, // 0x3f 63 F6 + 0xf81c, 0xf81c, // 0x40 64 F7 + 0xf81d, 0xf81d, // 0x41 65 F8 + 0xf81e, 0xf81e, // 0x42 66 F9 + 0xf81f, 0xf81f, // 0x43 67 F10 + 0xf820, 0xf820, // 0x44 68 F11 + 0xf821, 0xf821, // 0x45 69 F12 + 0xf800, 0xf800, // 0x46 70 Print Screen + 0xf815, 0xf815, // 0x47 71 Scroll Lock + 0xf801, 0xf801, // 0x48 72 Break / Pause + 0xf806, 0xf806, // 0x49 73 Insert + 0xf802, 0xf802, // 0x4a 74 Home + 0xf804, 0xf804, // 0x4b 75 Page Up + 0x007f, 0x007f, // 0x4c 76 Delete + 0xf803, 0xf803, // 0x4d 77 End + 0xf805, 0xf805, // 0x4e 78 Page Down + 0xf808, 0xf808, // 0x4f 79 Right Arrow + 0xf807, 0xf807, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, // 0x51 81 Down Arrow + 0xf809, 0xf809, // 0x52 82 Up Arrow + 0, 0, // 0x53 83 Num Lock + '/', '/', // 0x54 84 Keypad / + '*', '*', // 0x55 85 Keypad * + '-', '-', // 0x56 86 Keypad - + '+', '+', // 0x57 87 Keypad + + 0x000d, 0xf845, // 0x58 88 Keypad Enter + '1', 0xf803, // 0x59 89 Keypad 1 End + '2', 0xf80a, // 0x5a 90 Keypad 2 Down + '3', 0xf805, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, // 0x5c 92 Keypad 4 Left + '5', ' ', // 0x5d 93 Keypad 5 + '6', 0xf808, // 0x5e 94 Keypad 6 Right + '7', 0xf802, // 0x5f 95 Keypad 7 Home + '8', 0xf809, // 0x60 96 Keypad 8 Up + '9', 0xf804, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, // 0x62 98 Keypad 0 Insert + '.', 0x007f, // 0x63 99 Keypad . Delete + '\\', '|', // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, // 0x65 101 Application key + 0, 0, // 0x66 102 Keyboard power + '=', '=', // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CUnitedStatesDvorakLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Delete + { 0x63, THidModifier::EAltCtrl, 0xf844 }, // Keypad . Delete + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +CUnitedStatesDvorakLayout::CUnitedStatesDvorakLayout() + : CStandardKeyboardLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases) + { + // nothing else to do + } + +TBool CUnitedStatesDvorakLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.None() || aModifiers.ShiftOnly()) + { + // Keys in the normal range that shouldn't change with caps lock: + // + TBool isRemovedCapsKey = + (aHidKey == 0x08) || // e E + (aHidKey == 0x14) || // q Q + (aHidKey == 0x1a) || // w W + (aHidKey == 0x1d); // z Z + + if (isRemovedCapsKey) + return EFalse; + + // Additional keys that should behave as if shift is pressed + // whenever caps lock is active: + // + TBool isExtraCapsKey = + (aHidKey == 0x33) || // ; : + (aHidKey == 0x36) || // , < + (aHidKey == 0x37) || // . > + (aHidKey == 0x38); // / ? + + if (isExtraCapsKey) + return ETrue; + } + + return CStandardKeyboardLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CUnitedStatesDvorakLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCUnitedStatesDvorakLayout::LayoutId()"))); + return EUnitedStatesDvorak; + } + +CKeyboardLayout* CUnitedStatesDvorakLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCUnitedStatesDvorakLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CUnitedStatesDvorakLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/layouts/src/usinternational.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/layouts/src/usinternational.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,320 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include "usinternational.h" +#include "hiddebug.h" +#include "hidlayoutids.h" + +// CONSTANTS + +// Look-up tables to translate HID keyboard usage codes (usage page 7) +// to the corresponding Symbian "TKeyCode" (Unicode) values: + +const TInt CUSInternationalLayout::KColumnMap[] = + { + THidModifier::EUnmodified, // ---- + THidModifier::EShift, // ---S + THidModifier::EAltCtrl, // -AC- + THidModifier::EAltCtrlShift // -ACS + }; + +const TUint16 CUSInternationalLayout::KKeyCodes[] = + { + //---- ---S -AC- -ACS // Hex Dec Usage name (UK) + 0, 0, 0, 0, // 0x00 0 Reserved (no event) + 0, 0, 0, 0, // 0x01 1 Rollover error + 0, 0, 0, 0, // 0x02 2 POST Fail + 0, 0, 0, 0, // 0x03 3 Undefined error + 'a', 'A', 0x00e1, 0x00c1, // 0x04 4 a A + 'b', 'B', 0, 0, // 0x05 5 b B + 'c', 'C', 0x00a9, 0x00a2, // 0x06 6 c C + 'd', 'D', 0x00f0, 0x00d0, // 0x07 7 d D + 'e', 'E', 0x00e9, 0x00c9, // 0x08 8 e E + 'f', 'F', 0, 0, // 0x09 9 f F + 'g', 'G', 0, 0, // 0x0a 10 g G + 'h', 'H', 0, 0, // 0x0b 11 h H + 'i', 'I', 0x00ed, 0x00cd, // 0x0c 12 i I + 'j', 'J', 0, 0, // 0x0d 13 j J + 'k', 'K', 0, 0, // 0x0e 14 k K + 'l', 'L', 0x00f8, 0x00d8, // 0x0f 15 l L + 'm', 'M', 0x00b5, 0, // 0x10 16 m M + 'n', 'N', 0x00f1, 0x00d1, // 0x11 17 n N + 'o', 'O', 0x00f3, 0x00d3, // 0x12 18 o O + 'p', 'P', 0x00f6, 0x00d6, // 0x13 19 p P + 'q', 'Q', 0x00e4, 0x00c4, // 0x14 20 q Q + 'r', 'R', 0x00ae, 0, // 0x15 21 r R + 's', 'S', 0x00df, 0x00a7, // 0x16 22 s S + 't', 'T', 0x00fe, 0x00de, // 0x17 23 t T + 'u', 'U', 0x00fa, 0x00da, // 0x18 24 u U + 'v', 'V', 0, 0, // 0x19 25 v V + 'w', 'W', 0x00e5, 0x00c5, // 0x1a 26 w W + 'x', 'X', 0, 0, // 0x1b 27 x X + 'y', 'Y', 0x00fc, 0x00dc, // 0x1c 28 y Y + 'z', 'Z', 0x00e6, 0x00c6, // 0x1d 29 z Z + '1', '!', 0x00a1, 0x00b9, // 0x1e 30 1 ! + '2', '@', 0x00b2, 0, // 0x1f 31 2 " + '3', '#', 0x00b3, 0, // 0x20 32 3 £ + '4', '$', 0x00a4, 0x00a3, // 0x21 33 4 $ + '5', '%', 0x20ac, 0, // 0x22 34 5 % + '6', '^', 0x00bc, 0, // 0x23 35 6 ^ + '7', '&', 0x00bd, 0, // 0x24 36 7 & + '8', '*', 0x00be, 0, // 0x25 37 8 * + '9', '(', 0x2018, 0, // 0x26 38 9 ( + '0', ')', 0x2019, 0, // 0x27 39 0 ) + 0x000d, 0xf845, 0, 0, // 0x28 40 Enter (Return) + 0x001b, 0x001b, 0, 0, // 0x29 41 Escape + 0x0008, 0x0008, 0, 0, // 0x2a 42 Backspace (Delete) + 0x0009, 0x0009, 0, 0, // 0x2b 43 Tab + ' ', ' ', 0, 0, // 0x2c 44 Spacebar + '-', '_', 0x00a5, 0, // 0x2d 45 - _ + '=', '+', 0x00d7, 0x00f7, // 0x2e 46 = + + '[', '{', 0x00ab, 0, // 0x2f 47 [ { + ']', '}', 0x00bb, 0, // 0x30 48 ] } + '\\', '|', 0x00ac, 0x00a6, // 0x31 49 US \ bar + '\\', '|', 0x00ac, 0x00a6, // 0x32 50 # ~ + ';', ':', 0x00b6, 0x00b0, // 0x33 51 ; : + '\'', '"', 0x00b4, 0x00a8, // 0x34 52 ' @ + '`', '~', 0, 0, // 0x35 53 Grave/not/bar + ',', '<', 0x00e7, 0x00c7, // 0x36 54 , < + '.', '>', 0, 0, // 0x37 55 . > + '/', '?', 0x00bf, 0, // 0x38 56 / ? + 0, 0, 0, 0, // 0x39 57 Caps Lock + 0xf816, 0xf816, 0, 0, // 0x3a 58 F1 + 0xf817, 0xf817, 0, 0, // 0x3b 59 F2 + 0xf818, 0xf818, 0, 0, // 0x3c 60 F3 + 0xf819, 0xf819, 0, 0, // 0x3d 61 F4 + 0xf81a, 0xf81a, 0, 0, // 0x3e 62 F5 + 0xf81b, 0xf81b, 0, 0, // 0x3f 63 F6 + 0xf81c, 0xf81c, 0, 0, // 0x40 64 F7 + 0xf81d, 0xf81d, 0, 0, // 0x41 65 F8 + 0xf81e, 0xf81e, 0, 0, // 0x42 66 F9 + 0xf81f, 0xf81f, 0, 0, // 0x43 67 F10 + 0xf820, 0xf820, 0, 0, // 0x44 68 F11 + 0xf821, 0xf821, 0, 0, // 0x45 69 F12 + 0xf800, 0xf800, 0, 0, // 0x46 70 Print Screen + 0xf815, 0xf815, 0, 0, // 0x47 71 Scroll Lock + 0xf801, 0xf801, 0, 0, // 0x48 72 Break / Pause + 0xf806, 0xf806, 0, 0, // 0x49 73 Insert + 0xf802, 0xf802, 0, 0, // 0x4a 74 Home + 0xf804, 0xf804, 0, 0, // 0x4b 75 Page Up + 0x007f, 0x007f, 0xf844, 0, // 0x4c 76 Delete + 0xf803, 0xf803, 0, 0, // 0x4d 77 End + 0xf805, 0xf805, 0, 0, // 0x4e 78 Page Down + 0xf808, 0xf808, 0, 0, // 0x4f 79 Right Arrow + 0xf807, 0xf807, 0, 0, // 0x50 80 Left Arrow + 0xf80a, 0xf80a, 0, 0, // 0x51 81 Down Arrow + 0xf809, 0xf809, 0, 0, // 0x52 82 Up Arrow + 0, 0, 0, 0, // 0x53 83 Num Lock + '/', '/', 0, 0, // 0x54 84 Keypad / + '*', '*', 0, 0, // 0x55 85 Keypad * + '-', '-', 0, 0, // 0x56 86 Keypad - + '+', '+', 0, 0, // 0x57 87 Keypad + + 0x000d, 0xf845, 0, 0, // 0x58 88 Keypad Enter + '1', 0xf803, 0, 0, // 0x59 89 Keypad 1 End + '2', 0xf80a, 0, 0, // 0x5a 90 Keypad 2 Down + '3', 0xf805, 0, 0, // 0x5b 91 Keypad 3 PageDn + '4', 0xf807, 0, 0, // 0x5c 92 Keypad 4 Left + '5', ' ', 0, 0, // 0x5d 93 Keypad 5 + '6', 0xf808, 0, 0, // 0x5e 94 Keypad 6 Right + '7', 0xf802, 0, 0, // 0x5f 95 Keypad 7 Home + '8', 0xf809, 0, 0, // 0x60 96 Keypad 8 Up + '9', 0xf804, 0, 0, // 0x61 97 Keypad 9 PageUp + '0', 0xf806, 0, 0, // 0x62 98 Keypad 0 Insert + '.', 0x007f, 0xf844, 0, // 0x63 99 Keypad . Delete + '\\', '|', 0, 0, // 0x64 100 \ | (near left shift) + 0xf843, 0xf863, 0, 0, // 0x65 101 Application key + 0, 0, 0, 0, // 0x66 102 Keyboard power + '=', '=', 0, 0, // 0x67 103 Keypad = + }; + +// ---------------------------------------------------------------------- + +const CStandardKeyboardLayout::TSpecialKey CUSInternationalLayout::KSpecialCases[] = + { + // HID usage, modifiers, Unicode // Usage name (UK) + { 0x28, THidModifier::ECtrl, 0xf845 }, // Enter (Return) + { 0x2c, THidModifier::ECtrl, 0x0020 }, // Spacebar + { 0x58, THidModifier::ECtrl, 0xf845 }, // Keypad Enter + { 0x2b, THidModifier::EAlt, 0xf852 }, // Tab + { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key + { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key + { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key + { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key + { 0x00 } // end of table + }; + +// ---------------------------------------------------------------------- + +// 0x005e (Circumflex accent) +// +const CDeadKeyLayout::TKeyPair CUSInternationalLayout::KDeadKeyCircumflex[] = + { + { 0x0020, 0x005e }, // space + { 0x0041, 0x00c2 }, // A + { 0x0045, 0x00ca }, // E + { 0x0049, 0x00ce }, // I + { 0x004f, 0x00d4 }, // O + { 0x0055, 0x00db }, // U + { 0x0061, 0x00e2 }, // a + { 0x0065, 0x00ea }, // e + { 0x0069, 0x00ee }, // i + { 0x006f, 0x00f4 }, // o + { 0x0075, 0x00fb }, // u + { 0x0000 } // end of table + }; + +// 0x0027 (Apostrophe) +// +const CDeadKeyLayout::TKeyPair CUSInternationalLayout::KDeadKeyApostrophe[] = + { + { 0x0020, 0x0027 }, // space + { 0x0041, 0x00c1 }, // A + { 0x0043, 0x00c7 }, // C + { 0x0045, 0x00c9 }, // E + { 0x0049, 0x00cd }, // I + { 0x004f, 0x00d3 }, // O + { 0x0055, 0x00da }, // U + { 0x0059, 0x00dd }, // Y + { 0x0061, 0x00e1 }, // a + { 0x0063, 0x00e7 }, // c + { 0x0065, 0x00e9 }, // e + { 0x0069, 0x00ed }, // i + { 0x006f, 0x00f3 }, // o + { 0x0075, 0x00fa }, // u + { 0x0079, 0x00fd }, // y + { 0x0000 } // end of table + }; + +// 0x0022 (Quotation mark) +// +const CDeadKeyLayout::TKeyPair CUSInternationalLayout::KDeadKeyQuotationMark[] = + { + { 0x0020, 0x0022 }, // space + { 0x0041, 0x00c4 }, // A + { 0x0045, 0x00cb }, // E + { 0x0049, 0x00cf }, // I + { 0x004f, 0x00d6 }, // O + { 0x0055, 0x00dc }, // U + { 0x0061, 0x00e4 }, // a + { 0x0065, 0x00eb }, // e + { 0x0069, 0x00ef }, // i + { 0x006f, 0x00f6 }, // o + { 0x0075, 0x00fc }, // u + { 0x0079, 0x00ff }, // y + { 0x0000 } // end of table + }; + +// 0x0060 (Grave accent) +// +const CDeadKeyLayout::TKeyPair CUSInternationalLayout::KDeadKeyGrave[] = + { + { 0x0020, 0x0060 }, // space + { 0x0041, 0x00c0 }, // A + { 0x0045, 0x00c8 }, // E + { 0x0049, 0x00cc }, // I + { 0x004f, 0x00d2 }, // O + { 0x0055, 0x00d9 }, // U + { 0x0061, 0x00e0 }, // a + { 0x0065, 0x00e8 }, // e + { 0x0069, 0x00ec }, // i + { 0x006f, 0x00f2 }, // o + { 0x0075, 0x00f9 }, // u + { 0x0000 } // end of table + }; + +// 0x007e (Tilde) +// +const CDeadKeyLayout::TKeyPair CUSInternationalLayout::KDeadKeyTilde[] = + { + { 0x0020, 0x007e }, // space + { 0x0041, 0x00c3 }, // A + { 0x004e, 0x00d1 }, // N + { 0x004f, 0x00d5 }, // O + { 0x0061, 0x00e3 }, // a + { 0x006e, 0x00f1 }, // n + { 0x006f, 0x00f5 }, // o + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +const CDeadKeyLayout::TIndexPair CUSInternationalLayout::KDeadKeyIndex[] = + { + { 0x005e, KDeadKeyCircumflex }, + { 0x0027, KDeadKeyApostrophe }, + { 0x0022, KDeadKeyQuotationMark }, + { 0x0060, KDeadKeyGrave }, + { 0x007e, KDeadKeyTilde }, + { 0x0000 } // end of table + }; + +// ---------------------------------------------------------------------- + +CUSInternationalLayout::CUSInternationalLayout() + : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), + KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) + { + // nothing else to do + } + +TBool CUSInternationalLayout::ChangesWithCapsLock(TInt aHidKey, + THidModifier aModifiers) const + { + if (aModifiers.ControlAlt()) + { + // Allow caps lock to invert the shift state for these ctrl-alt keys: + // + TBool isAltGrCapsKey = + (aHidKey == 0x04) || // a A + (aHidKey == 0x07) || // d D + (aHidKey == 0x08) || // e E + (aHidKey == 0x0c) || // i I + (aHidKey == 0x0f) || // l L + (aHidKey == 0x11) || // n N + (aHidKey == 0x12) || // o O + (aHidKey == 0x13) || // p P + (aHidKey == 0x14) || // q Q + (aHidKey == 0x17) || // t T + (aHidKey == 0x18) || // u U + (aHidKey == 0x1a) || // w W + (aHidKey == 0x1c) || // y Y + (aHidKey == 0x1d) || // z Z + (aHidKey == 0x36); // , < + + if (isAltGrCapsKey) + return ETrue; + } + + return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); + } + +TInt CUSInternationalLayout::LayoutId() const + { + DBG(RDebug::Print(_L("[HID]\tCUSInternationalLayout::LayoutId()"))); + return EUSInternational; + } + +CKeyboardLayout* CUSInternationalLayout::NewL() + { + DBG(RDebug::Print(_L("[HID]\tCUSInternationalLayout::NewL()"))); + CKeyboardLayout* layout = new (ELeave) CUSInternationalLayout; + return layout; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/loc/btkeyboard.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/loc/btkeyboard.loc Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,175 @@ +/* +* Copyright (c) 2002-2007 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: Localisation file for Wireless Keyboard Application, v3.2 +* 8 +* +*/ + + +// LOCALISATION STRINGS + +// +// Softkey labels +// +//d:Command text associated to a softkey in the control pane. +//d:Opens options menu. +//d:Same as text_softkey_option from avkon.loc +//l:control_pane_t1/opt7 +// +#define qtn_hid_options "Options" + +//d:Command text associated to a softkey in the control pane. +//d:Back functionality. +//d:Same as text_softkey_back from avkon.loc//l:control_pane_t2/opt7 +// +#define qtn_hid_back "Back" + +// d: Command in Options list. +// d: Show help content. +// l: list_single_pane_t1_cp2 +// +#define qtn_hid_help "Help" + +// d: Command in Options list of setting view. +// d: Opens setting change dialog. +// l: list_single_pane_t1_cp2 +// +#define qtn_hid_change "Change" + +// +// Settings List Item Names +// + +// d: Settings list item static text. +// d: Selected keyboard layout. +// d: This item is visible only when the keyboard is connected and layout is selected. +// d: Dynamic string for this item is qtn_hid_layout_xxx +// l: list_setting_pane_t1 +// +#define qtn_hid_layout "Keyboard layout" + +// +// Country Strings for the Nokia Su8 Layout Override Settings Page +// + +// d: Nokia SU-8W Keyboard layout setting radio button text +// d: Select this to use English keyboard layout +// d: Dynamic part for static text qtn_hid_layout and qtn_hid_select_layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_english_su8 "English" + +// d: Nokia SU-8W Keyboard layout setting radio button text +// d: Select this to use Norwegian/Danish keyboard layout +// d: Dynamic part for static text qtn_hid_layout and qtn_hid_select_layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_norwegian_danish_su8 "Norwegian/Danish" + +// +// Country Strings for the Standard Layout Override Settings Page +// + +// d: Standard keyboard layout setting radio button text +// d: Select this to use UK keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_uk "UK" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use US keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_us "US" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use International US keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_us_int "Int. US" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Belgian keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_belgian "Belgian" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Danish keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_danish "Danish" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Dutch keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_dutch "Dutch" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Finnish/Swedish keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_finnish_swedish "Finnish/Swedish" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use French keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_french "French" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use German keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_german "German" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Italian keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_italian "Italian" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Norwegian keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_norwegian "Norwegian" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Portuguese keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_portuguese "Portuguese" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Spanish keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_spanish "Spanish" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use US Dvorak keyboard layout +// d: "Dvorak" is an official name of the layout. +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_us_dvorak "US Dvorak" + +// d: Standard keyboard layout setting radio button text +// d: Select this to use Russian keyboard layout +// l: list_set_graphic_pane_t1 +// +#define qtn_hid_layout_russian "Russian" + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/bmarm/kbdclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/bmarm/kbdclientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,12 @@ +EXPORTS + __14RLayoutManager @ 1 NONAME R3UNUSED ; RLayoutManager::RLayoutManager(void) + E32Dll__F10TDllReason @ 2 NONAME R3UNUSED ; E32Dll(TDllReason) + GetDeviceInfo__C14RLayoutManagerRiT1 @ 3 NONAME R3UNUSED ; RLayoutManager::GetDeviceInfo(int &, int &) const + GetInitialLayout__C14RLayoutManagerRi @ 4 NONAME R3UNUSED ; RLayoutManager::GetInitialLayout(int &) const + GetLayout__C14RLayoutManagerRi @ 5 NONAME R3UNUSED ; RLayoutManager::GetLayout(int &) const + KeyEvent__C14RLayoutManageriiiiRC9TLockKeysR15TDecodedKeyInfo @ 6 NONAME ; RLayoutManager::KeyEvent(int, int, int, int, TLockKeys const &, TDecodedKeyInfo &) const + Reset__C14RLayoutManager @ 7 NONAME R3UNUSED ; RLayoutManager::Reset(void) const + SetInitialLayout__C14RLayoutManageriii @ 8 NONAME ; RLayoutManager::SetInitialLayout(int, int, int) const + SetLayout__C14RLayoutManageri @ 9 NONAME R3UNUSED ; RLayoutManager::SetLayout(int) const + Connect__14RLayoutManager @ 10 NONAME R3UNUSED ; RLayoutManager::Connect(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/bwins/kbdclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/bwins/kbdclientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,11 @@ +EXPORTS + ??0RLayoutManager@@QAE@XZ @ 1 NONAME ; RLayoutManager::RLayoutManager(void) + ?Connect@RLayoutManager@@QAEHXZ @ 2 NONAME ; int RLayoutManager::Connect(void) + ?GetDeviceInfo@RLayoutManager@@QBEHAAH0@Z @ 3 NONAME ; int RLayoutManager::GetDeviceInfo(int &, int &) const + ?GetInitialLayout@RLayoutManager@@QBEHAAH@Z @ 4 NONAME ; int RLayoutManager::GetInitialLayout(int &) const + ?GetLayout@RLayoutManager@@QBEHAAH@Z @ 5 NONAME ; int RLayoutManager::GetLayout(int &) const + ?KeyEvent@RLayoutManager@@QBEHHHHHABVTLockKeys@@AAVTDecodedKeyInfo@@@Z @ 6 NONAME ; int RLayoutManager::KeyEvent(int, int, int, int, class TLockKeys const &, class TDecodedKeyInfo &) const + ?Reset@RLayoutManager@@QBEHXZ @ 7 NONAME ; int RLayoutManager::Reset(void) const + ?SetInitialLayout@RLayoutManager@@QBEHHHH@Z @ 8 NONAME ; int RLayoutManager::SetInitialLayout(int, int, int) const + ?SetLayout@RLayoutManager@@QBEHH@Z @ 9 NONAME ; int RLayoutManager::SetLayout(int) const + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/eabi/kbdclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/eabi/kbdclientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,12 @@ +EXPORTS + _ZN14RLayoutManager7ConnectEv @ 1 NONAME + _ZN14RLayoutManagerC1Ev @ 2 NONAME + _ZN14RLayoutManagerC2Ev @ 3 NONAME + _ZNK14RLayoutManager13GetDeviceInfoERiS0_ @ 4 NONAME + _ZNK14RLayoutManager16GetInitialLayoutERi @ 5 NONAME + _ZNK14RLayoutManager16SetInitialLayoutEiii @ 6 NONAME + _ZNK14RLayoutManager5ResetEv @ 7 NONAME + _ZNK14RLayoutManager8KeyEventEiiiiRK9TLockKeysR15TDecodedKeyInfo @ 8 NONAME + _ZNK14RLayoutManager9GetLayoutERi @ 9 NONAME + _ZNK14RLayoutManager9SetLayoutEi @ 10 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +PRJ_MMPFILES +layoutmgr +kbdclient + +PRJ_TESTMMPFILES + +PRJ_PLATFORMS +WINSCW ARMV5 + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/group/kbdclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/group/kbdclient.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2008 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 "../../inc/hiduids.h" + +TARGET kbdclient.dll +TARGETTYPE dll +UID 0x1000008d KBDCLIENT_UID +CAPABILITY CAP_CLIENT_DLL +VENDORID VID_DEFAULT + + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../layouts/inc +USERINCLUDE ../../common/inc + +SOURCEPATH ../src +SOURCE ../../common/src/genericclient.cpp client.cpp + + + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY ecom.lib +DEBUGLIBRARY flogger.lib + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/group/layoutmgr.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/group/layoutmgr.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008 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 "../../inc/hiduids.h" + +TARGET layoutmgr.exe +TARGETTYPE exe +UID 0x1000008d LAYOUTMGR_UID + +VENDORID VID_DEFAULT +CAPABILITY CAP_APPLICATION + + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../common/inc +USERINCLUDE ../../layouts/inc + +SOURCEPATH ../src +SOURCE server.cpp +SOURCE shutdown.cpp +SOURCE session.cpp +SOURCE library.cpp +SOURCE decode.cpp +SOURCE mapping.cpp +SOURCE codestore.cpp + +SOURCEPATH ../../common/src +SOURCE genericserver.cpp + + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc + +LIBRARY euser.lib +LIBRARY ecom.lib +DEBUGLIBRARY flogger.lib + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/client.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/client.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __CLIENT_H +#define __CLIENT_H + +#include + +#include "hidkeys.h" // for TLockKeys +#include "modifier.h" // for THidModifier +// ---------------------------------------------------------------------- + +enum TLayoutManagerService + { + EKeyEvent, + EResetDecoder, + ESetLayout, + EGetLayout, + ESetInitialLayout, + EGetInitialLayout, + EGetDeviceInfo + }; + +// ---------------------------------------------------------------------- + +class TKeyEventInfo + { +public: + inline TKeyEventInfo(); + inline TKeyEventInfo(TInt aHidKey, TInt aUsagePage, TBool aIsKeyDown, + THidModifier aModifiers, TLockKeys aLockKeys); + + TInt iHidKey; + TInt iUsagePage; + TBool iIsKeyDown; + THidModifier iModifiers; + TLockKeys iLockKeys; + }; + +// ---------------------------------------------------------------------- + +inline TKeyEventInfo::TKeyEventInfo() : + iHidKey(0), iUsagePage(0), iIsKeyDown(EFalse), iModifiers(0), iLockKeys( + EFalse, EFalse) + { + // nothing else to do + } + +inline TKeyEventInfo::TKeyEventInfo(TInt aHidKey, TInt aUsagePage, + TBool aIsKeyDown, THidModifier aModifiers, TLockKeys aLockKeys) : + iHidKey(aHidKey), iUsagePage(aUsagePage), iIsKeyDown(aIsKeyDown), + iModifiers(aModifiers), iLockKeys(aLockKeys) + { + // nothing else to do + } + +// ---------------------------------------------------------------------- + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/codestore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/codestore.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __CODESTORE_H +#define __CODESTORE_H + +#include +#include + +// ---------------------------------------------------------------------- + +class CScanCodeStore : public CBase + { +public: + static CScanCodeStore* NewL(); + + TInt Store(TInt aHidKey, TInt aUsagePage, TInt aScanCode); + TInt Retrieve(TInt aHidKey, TInt aUsagePage); + + virtual ~CScanCodeStore(); + +private: + CScanCodeStore(); + +private: + class TKeyDownInfo + { + public: + inline TKeyDownInfo(); + inline TKeyDownInfo(TInt aHidKey, TInt aUsagePage, TInt aScanCode); + + TInt iHidKey; + TInt iUsagePage; + TInt iScanCode; + }; + + RArray iKeys; + }; + +// ---------------------------------------------------------------------- + +inline CScanCodeStore::TKeyDownInfo::TKeyDownInfo() : + iHidKey(0), iUsagePage(0), iScanCode(0) + { + // nothing else to do + } + +inline CScanCodeStore::TKeyDownInfo::TKeyDownInfo(TInt aHidKey, + TInt aUsagePage, TInt aScanCode) : + iHidKey(aHidKey), iUsagePage(aUsagePage), iScanCode(aScanCode) + { + // nothing else to do + } + +// ---------------------------------------------------------------------- + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/decode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/decode.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __DECODE_H +#define __DECODE_H + +// INCLUDES +#include "hidkeys.h" + +// FORWARD DECLARATIONS + +class CScanCodeStore; +class CKeyboardLayout; +class TDecodedKeyInfo; +class TKeyEventInfo; + +// CLASS DECLARATION +class CKeyboardDecoder : public CBase + { +public: + static CKeyboardDecoder* NewL(); + virtual ~CKeyboardDecoder(); + + void Event(const TKeyEventInfo& aKeyEvent, TDecodedKeyInfo &aDecodedKeys); + void SetLayout(CKeyboardLayout* aLayout); + void Reset(); + +private: + CKeyboardDecoder(); + void ConstructL(); + + void ProcessDeadKeys(TUint16 aUnicodeKey, TInt aHidKey, TInt aUsagePage, + TDecodedKeyInfo &aDecodedKeys); + TBool HandleRightAlt(const TKeyEventInfo &aEvent, + TDecodedKeyInfo& aDecodedKeys); + +private: + TTranslatedKey iDeadKey; + CKeyboardLayout* iLayout; + CScanCodeStore* iScanCodes; + + TBool iAltGrSequence; + TInt iNumKeysDown; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/hidkeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/hidkeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2008 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: Key types. + * +*/ + + +#ifndef __HIDKEYS_H +#define __HIDKEYS_H + +#include +#include + +// CLASS DECLARATIONS + +/*! + TLockKeys is used to represent the current state of the locking + modifier keys, i.e. Caps Lock and Num Lock. + */ + +class TLockKeys + { +public: + inline TLockKeys(); + inline TLockKeys(TBool aCapsLock, TBool aNumLock); + + TBool iCapsLock; //!< ETrue if Caps Lock is active + TBool iNumLock; //!< ETrue if Num Lock is active + }; + +/*! + TTranslatedKey contains the details of a decoded HID key event. It + is returned (as part of a TDecodedKeyInfo object) from a call to + RLayoutManager::KeyEvent(). + */ + +class TTranslatedKey + { +public: + inline TTranslatedKey(); + inline TTranslatedKey(TUint16 aUnicode, TInt aScanCode, TInt aHidKey, + TInt aUsagePage, TBool aIsRepeatingKey); + + TUint16 iUnicode; //!< Symbian (Unicode) key code value (cf TKeyCode) + TInt iScanCode; //!< Symbian raw scan code value (cf TStdScanCode) + TInt iHidKey; //!< HID code for the key that caused this event + TInt iUsagePage; //!< Usage page for the key that caused this event + TBool iIsRepeatingKey; //!< ETrue if the key can repeat + }; + +/*! + TDecodedKeyInfo contains the results of decoding a HID key event. It is + the output of a call to RLayoutManager::KeyEvent(). + + Note that the iScanCode member corresponds to the current key event + as given in the arguments to RLayoutManager::KeyEvent(), whereas the + iScanCode values in #iEvent correspond to the key event that caused + the translated key press; this could be the previous event in the + case of a dead key. + */ + +class TDecodedKeyInfo + { +public: + inline TDecodedKeyInfo(); + + TInt iCount; //!< Number of key press events (0, 1 or 2) + TInt iScanCode; //!< Symbian raw scan code value + TTranslatedKey iEvent[2]; //!< Translated key press data + }; + +// ---------------------------------------------------------------------- + +inline TTranslatedKey::TTranslatedKey() : + iUnicode(0), iScanCode(0), iHidKey(0), iUsagePage(0), iIsRepeatingKey( + EFalse) + { + // nothing else to do + } + +inline TTranslatedKey::TTranslatedKey(TUint16 aUnicode, TInt aScanCode, + TInt aHidKey, TInt aUsagePage, TBool aIsRepeatingKey) : + iUnicode(aUnicode), iScanCode(aScanCode), iHidKey(aHidKey), iUsagePage( + aUsagePage), iIsRepeatingKey(aIsRepeatingKey) + { + // nothing else to do + } + +inline TDecodedKeyInfo::TDecodedKeyInfo() : + iCount(0), iScanCode(0) + { + // nothing else to do + } + +// ---------------------------------------------------------------------- + +inline TLockKeys::TLockKeys() : + iCapsLock(EFalse), iNumLock(EFalse) + { + // nothing else to do + } + +inline TLockKeys::TLockKeys(TBool aCapsLock, TBool aNumLock) : + iCapsLock(aCapsLock), iNumLock(aNumLock) + { + // nothing else to do + } + +#endif //HIDKEYS_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/layoutmgr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/layoutmgr.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,262 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + +/*! + \file + Keyboard layout manager interface, public header. + */ +#ifndef __LAYOUTMGR_H +#define __LAYOUTMGR_H +#include +#include +#include "genericclient.h" +#include "hidlayoutids.h" +// CONSTANTS +/*! + Layout server sessions are created indirectly using this server name. + */ +_LIT(KLayoutServerName,"LayoutServer"); +/*! + Name of the semaphore used to confirm server startup. Semaphores + are globally accessible kernel objects and are referenced by name. + */ +_LIT(KLayoutServerSemaphoreName, "LayoutServerSemaphore"); + +// FORWARD DECLARATIONS +class TDecodedKeyInfo; +class TLockKeys; +class TTranslatedKey; + +/*! + Handle class representing a session with the keyboard layout + manager server. + */ + +// CLASS DECLARATION + +class RLayoutManager : public RGenericSession + { +public: + IMPORT_C RLayoutManager(); + + /*! + Connect to the keyboard layout manager server and create a new session. + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt Connect(); + + // ------------------------------------------ + // API intended for use by keyboard driver: + // ------------------------------------------ + + /*! + Notify the layout server of a key-down or key-up event. Every + key down event must be followed by a corresponding key up event; + the two events do not have to be consecutive. + + @param aIsKeyDown ETrue for a key down event, EFalse for a key up event. + @param aHidKey HID usage ID for the key causing this event + @param aUsagePage HID usage page for the key causing this event + @param aModifiers Current modifier state + @param aLockKeys Current lock key state + @param aDecodedKeys The results of the key decoding + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + + IMPORT_C TInt KeyEvent(TBool aIsKeyDown, TInt aHidKey, TInt aUsagePage, + TInt aModifiers, const TLockKeys& aLockKeys, + TDecodedKeyInfo& aDecodedKeys) const; + + /*! Convenience function, equivalent to #KeyEvent(ETrue, ...) */ + inline TInt KeyDownEvent(TInt aHidKey, TInt aUsagePage, TInt aModifiers, + const TLockKeys& aLockKeys, TDecodedKeyInfo& aDecodedKeys) const; + + /*! Convenience function, equivalent to #KeyEvent(EFalse, ...) */ + inline TInt KeyUpEvent(TInt aHidKey, TInt aUsagePage, TInt aModifiers, + const TLockKeys& aLockKeys, TDecodedKeyInfo& aDecodedKeys) const; + + /*! + Reset the state of keyboard layout decoder object associated + with this session. + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt Reset() const; + + /*! + %SetInitialLayout() causes the layout manager to select the most + appropriate keyboard layout given the country, vendor and + product parameters read from a keyboard device. The server will + choose the layout DLL (reword here) in the following + order: + + -# By keyboard vendor and product code + -# By keyboard country code + -# By current phone language setting + + If no appropriate layout can be found, the server will attempt + to load the default US layout (EUnitedStates). + + As the layout server only maintains a single keyboard layout, + this setting will affect all other RLayoutManager sessions. + + @param aCountry HID country ID code for the keyboard device + (refer to bCountryCode in "Device Class Definition for Human + Interface Devices", USB Implementers' Forum, Version 1.11, + 2001, Section 6.2.1, "HID descriptor".) + + @param aVendor HID manufacturer ID code for the keyboard device, + as supplied by the USB Implementers' Forum, http://www.usb.org/. + + @param aProduct Vendor specific product code for the keyboard + device. + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt + SetInitialLayout(TInt aCountry, TInt aVendor, TInt aProduct) const; + + /*! + As SetInitialLayout() but will Leave() if there is an error. + */ + inline void + SetInitialLayoutL(TInt aCountry, TInt aVendor, TInt aProduct) const; + + // ------------------------------------------ + // API intended for use by applications: + // ------------------------------------------ + + /*! + Query the current HID system keyboard layout + + @param aLayoutId Keyboard layout ID code + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt GetLayout(TInt& aLayoutId) const; + + /*! + As GetLayout() but will Leave() if there is an error. + + @result Keyboard layout ID code + */ + inline TInt GetLayoutL() const; + + /*! + Query the initial layout chosen for the current keyboard. + This is the result of the last call to SetInitialLayoutL(). + + @param aLayoutId Keyboard layout ID code + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt GetInitialLayout(TInt& aLayoutId) const; + + /*! + As GetInitialLayout() but will Leave() if there is an error. + + @result Keyboard layout ID code + */ + inline TInt GetInitialLayoutL() const; + + /*! + Set the HID system keyboard layout by ID. If the server can't + find a keyboard layout DLL containing the given layout ID, then + the layout will remain unchanged. + + @param aLayoutId Keyboard layout ID code + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt SetLayout(TInt aLayoutId) const; + + /*! + As SetLayout() but will Leave() if there is an error. + */ + inline void SetLayoutL(TInt aLayoutId) const; + + /*! + Return information about the attached keyboard + + @param aIsNokiaSu8 ETrue if the keyboard is a Nokia SU-8 + + @param aFoundLayout ETrue if the keyboard returned a valid + country code and a matching keyboard layout ID exists. + + @result KErrNone if successful; otherwise another of the standard + Symbian system-wide error codes. + */ + IMPORT_C TInt GetDeviceInfo(TBool& aIsNokiaSu8, TBool& aFoundLayout) const; + }; + +// ---------------------------------------------------------------------- + +inline TInt RLayoutManager::KeyDownEvent(TInt aHidKey, TInt aUsagePage, + TInt aModifiers, const TLockKeys& aLockKeys, + TDecodedKeyInfo& aDecodedKeys) const + { + return KeyEvent(ETrue, aHidKey, aUsagePage, aModifiers, aLockKeys, + aDecodedKeys); + } + +inline TInt RLayoutManager::KeyUpEvent(TInt aHidKey, TInt aUsagePage, + TInt aModifiers, const TLockKeys& aLockKeys, + TDecodedKeyInfo& aDecodedKeys) const + { + return KeyEvent(EFalse, aHidKey, aUsagePage, aModifiers, aLockKeys, + aDecodedKeys); + } + +// ---------------------------------------------------------------------- + +inline void RLayoutManager::SetInitialLayoutL(TInt aCountry, TInt aVendor, + TInt aProduct) const + { + User::LeaveIfError(SetInitialLayout(aCountry, aVendor, aProduct)); + } + +inline void RLayoutManager::SetLayoutL(TInt aLayoutId) const + { + User::LeaveIfError(SetLayout(aLayoutId)); + } + +inline TInt RLayoutManager::GetLayoutL() const + { + TInt layout; + User::LeaveIfError(GetLayout(layout)); + return layout; + } + +inline TInt RLayoutManager::GetInitialLayoutL() const + { + TInt layout; + User::LeaveIfError(GetInitialLayout(layout)); + return layout; + } + +// ---------------------------------------------------------------------- + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/library.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/library.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __LAYOUTLIBRARY_H +#define __LAYOUTLIBRARY_H + +#include + +// ---------------------------------------------------------------------- + +class CKeyboardLayout; + +class CLayoutLibrary : public CBase + { +public: + static CLayoutLibrary* NewL(); + + virtual ~CLayoutLibrary(); + + TInt SetLayout(TInt aLayoutId); + + inline TInt Id() const; + inline TBool Loaded() const; + inline CKeyboardLayout* Layout(); + + void Close(); + +private: + CLayoutLibrary(); + +private: + // data + + static const TUid KLayoutUid2; + TInt iId; + TBool iLoaded; + CKeyboardLayout* iLayout; + + }; + +// ---------------------------------------------------------------------- + +inline TInt CLayoutLibrary::Id() const + { + return iId; + } + +inline TInt CLayoutLibrary::Loaded() const + { + return iLoaded; + } + +inline CKeyboardLayout* CLayoutLibrary::Layout() + { + return iLayout; + } + +// ---------------------------------------------------------------------- + +#endif + +// End of file + + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/mapping.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/mapping.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __MAPPING_H +#define __MAPPING_H + +#include + +// ---------------------------------------------------------------------- + +class TFindLayoutId + { +public: + TFindLayoutId(TInt aHidCountryId, TInt aVendorId, TInt aProductCode); + + inline TInt LayoutId() const; + inline TBool IsNokiaSu8() const; + inline TBool FoundLayout() const; + +private: + static TInt LanguageToLayout(TLanguage aLanguage, TBool aIsNokiaSu8); + static TInt CountryToLayout(TInt aHidCountryId, TBool aIsNokiaSu8); + +private: + static const TInt KDefaultLayoutId; + + struct TCountryMapEntry + { + TInt iHidCountryId; + TInt iLayoutId; + }; + + static const TCountryMapEntry KMapCountryToLayout[]; + static const TInt KCountryMapSize; + + static const TCountryMapEntry KMapSu8CountryToLayout[]; + static const TInt KSu8CountryMapSize; + + struct TLanguageMapEntry + { + TLanguage iLanguage; + TInt iLayoutId; + TInt iSu8LayoutId; + }; + + static const TLanguageMapEntry KMapLanguageToLayout[]; + static const TInt KLanguageMapSize; + +private: + TInt iLayout; + + TBool iIsNokiaSu8; + TBool iFoundLayout; + }; + +// ---------------------------------------------------------------------- + +inline TBool TFindLayoutId::IsNokiaSu8() const + { + return iIsNokiaSu8; + } + +inline TBool TFindLayoutId::FoundLayout() const + { + return iFoundLayout; + } + +inline TInt TFindLayoutId::LayoutId() const + { + return iLayout; + } + +// ---------------------------------------------------------------------- + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/modifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/modifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,280 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __MODIFIER_H +#define __MODIFIER_H + +#include + +// ---------------------------------------------------------------------- + +/*! + Convenience functions for working with HID (boot protocol style) + keyboard modifier flags. These are stored as an eight bit vector as + follows: + +
+ +-------------------------------------------------------+
+ |           Right           |           Left            |
+ +-------------------------------------------------------+
+ | Func |  Alt | Shft | Ctrl | Func |  Alt | Shft | Ctrl |
+ +-------------------------------------------------------+
+ bit:  7      6      5      4      3      2      1      0
+ 
+ + We also make use of a "folded" representation, where there + is no distinction between the left and right versions of + the modifier keys: + +
+ +---------------------------+---------------------------+
+ |   0  |   0  |   0  |   0  | Func |  Alt | Shft | Ctrl |
+ +---------------------------+---------------------------+
+ bit:  7      6      5      4      3      2      1      0
+ 
+ + i.e. folded = left OR right. + */ +class THidModifier + { +public: + THidModifier(TUint8 aFlags); + + inline void Set(TUint8 aValue); + inline void Merge(TUint8 aValue); + inline void Clear(TUint8 aValue); + + inline TUint8 Value() const; + + inline TBool None() const; + inline TBool Shift() const; + inline TBool Control() const; + inline TBool Alt() const; + inline TBool Func() const; + + inline TBool LeftControl() const; + inline TBool LeftShift() const; + inline TBool LeftAlt() const; + inline TBool LeftFunc() const; + + inline TBool RightControl() const; + inline TBool RightShift() const; + inline TBool RightAlt() const; + inline TBool RightFunc() const; + + inline TBool ControlAlt() const; + + inline TBool ShiftOnly() const; + inline TBool ControlOnly() const; + inline TBool AltOnly() const; + inline TBool FuncOnly() const; + + inline TUint8 Fold() const; + + inline void InvertShift(); + +public: + enum TModifiers + { + ELeftControl = (1 << 0), + ELeftShift = (1 << 1), + ELeftAlt = (1 << 2), + ELeftFunc = (1 << 3), + ERightControl = (1 << 4), + ERightShift = (1 << 5), + ERightAlt = (1 << 6), + ERightFunc = (1 << 7) + }; + + enum TFoldedModifiers + { + EUnmodified = 0, // ---- + ECtrl = 1, // ---C + EShift = 2, // --S- + ECtrlShift = 3, // --SC + EAlt = 4, // -A-- + EAltCtrl = 5, // -A-C + EAltShift = 6, // -AS- + EAltCtrlShift = 7, // -ASC + EFunc = 8, // F--- + EFuncCtrl = 9, // F--C + EFuncShift = 10, // F-S- + EFuncCtrlShift = 11, // F-SC + EFuncAlt = 12, // FA-- + EFuncAltCtrl = 13, // FA-C + EFuncAltShift = 14, // FAS- + EFuncAltCtrlShift = 15 + // FASC + }; + +private: + TUint8 iFlags; + }; + +// ---------------------------------------------------------------------- + +inline THidModifier::THidModifier(TUint8 aFlags) : + iFlags(aFlags) + { + // nothing else to do + } + +inline TUint8 THidModifier::Value() const + { + return iFlags; + } + +inline void THidModifier::Set(TUint8 aValue) + { + iFlags = aValue; + } + +inline void THidModifier::Merge(TUint8 aValue) + { + iFlags |= aValue; + } + +inline void THidModifier::Clear(TUint8 aValue) + { + iFlags &= ~aValue; + } + +// ---------------------------------------------------------------------- +// Individual keys: + +inline TBool THidModifier::LeftControl() const + { + return iFlags & ELeftControl; + } + +inline TBool THidModifier::LeftShift() const + { + return iFlags & ELeftShift; + } + +inline TBool THidModifier::LeftAlt() const + { + return iFlags & ELeftAlt; + } + +inline TBool THidModifier::LeftFunc() const + { + return iFlags & ELeftFunc; + } + +inline TBool THidModifier::RightControl() const + { + return iFlags & ERightControl; + } + +inline TBool THidModifier::RightShift() const + { + return iFlags & ERightShift; + } + +inline TBool THidModifier::RightAlt() const + { + return iFlags & ERightAlt; + } + +inline TBool THidModifier::RightFunc() const + { + return iFlags & ERightFunc; + } + +// ---------------------------------------------------------------------- +// Modifier states: + +inline TBool THidModifier::None() const + { + return iFlags == 0; + } + +inline TBool THidModifier::Shift() const + { + return LeftShift() || RightShift(); + } + +inline TBool THidModifier::Control() const + { + return LeftControl() || RightControl(); + } + +inline TBool THidModifier::Alt() const + { + return LeftAlt() || RightAlt(); + } + +inline TBool THidModifier::Func() const + { + return LeftFunc() || RightFunc(); + } + +inline TBool THidModifier::ControlAlt() const + { + return Alt() && Control(); + } + +// ---------------------------------------------------------------------- + +inline TUint8 THidModifier::Fold() const + { + TUint left = iFlags & 0x0f; + TUint right = (iFlags & 0xf0) >> 4; + return static_cast (left | right); + } + +// ---------------------------------------------------------------------- + +inline TBool THidModifier::ShiftOnly() const + { + return Fold() == EShift; + } + +inline TBool THidModifier::ControlOnly() const + { + return Fold() == ECtrl; + } + +inline TBool THidModifier::AltOnly() const + { + return Fold() == EAlt; + } + +inline TBool THidModifier::FuncOnly() const + { + return Fold() == EFunc; + } + +// ---------------------------------------------------------------------- + +inline void THidModifier::InvertShift() + { + if (iFlags & (ELeftShift | ERightShift)) + { + iFlags &= ~(ELeftShift | ERightShift); + } + else + { + iFlags |= ELeftShift; + } + } + +// ---------------------------------------------------------------------- + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/server.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/server.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + +#ifndef __SERVER_H +#define __SERVER_H +#include +#include +#include "genericserver.h" +#define RMESSAGE RMessage2 +// ---------------------------------------------------------------------- +// Panics: +// Category: +_LIT(KLayoutServerPanic, "LayoutServer"); + +// Codes: +enum TLayoutServPanic + { + EBadRequest = 1, EBadDescriptor = 2, ENegativeSessionCount = 3 + }; + +// ---------------------------------------------------------------------- + +class CLayoutMgrShutdown; +class CLayoutLibrary; + +class CLayoutServer : public CGenericServer + { +public: + static CLayoutServer* NewL(); + static CLayoutServer* NewLC(); + virtual ~CLayoutServer(); + + static TInt ThreadFunction(TAny* aThreadArg); + + void SessionAdded(); + void SessionClosed(); + + TInt Layout() const; + TInt SetLayout(TInt aLayoutId); + + TInt InitialLayout() const; + void SetInitialLayoutL(TInt aCountry, TInt aVendor, TInt aProduct); + + TBool FoundLayout() const; + TBool IsNokiaSu8() const; + static void PanicClient(const RMessage2& aMessage, TInt aReason); + static void PanicServer(TInt aPanic); + +private: + CLayoutServer(); + void ConstructL(); + + static void ThreadFunctionL(TStartupRequest* startup); + + // from CServer: + virtual CSession2* NewSessionL(const TVersion& aVersion, + const RMessage2& aMessage) const; + +protected: + // from CActive: + virtual TInt RunError(TInt aErr); + +private: + TInt iSessionCount; + + CLayoutLibrary* iLayoutLibrary; + CLayoutMgrShutdown* iShutdown; + + TInt iInitialLayout; + + TBool iIsNokiaSu8; + TBool iFoundLayout; + }; + +// ---------------------------------------------------------------------- + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/session.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/session.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SESSION_H +#define __SESSION_H + +#include +#include + +// ---------------------------------------------------------------------- + +class CKeyboardDecoder; +class CLayoutLibrary; +class CLayoutServer; + +class CLayoutSession : public CSession2 + + { +public: + static CLayoutSession* NewL(); + static CLayoutSession* NewLC(); + + virtual ~CLayoutSession(); + + // from CSession: + virtual void ServiceL(const RMESSAGE& aMessage); + + void SetLayout(CLayoutLibrary* aLayoutLibrary); + +private: + CLayoutSession(); + void ConstructL(); + + void DispatchMessageL(const RMESSAGE& aMessage); + + // hides base class version (not virtual): + CLayoutServer* Server(); + +private: + CKeyboardDecoder* iDecoder; // ownership + CLayoutLibrary* iLayoutLibrary; // no ownership + }; + +// ---------------------------------------------------------------------- + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/inc/shutdown.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/inc/shutdown.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __SHUTDOWN_H +#define __SHUTDOWN_H + +#include + +// ---------------------------------------------------------------------- + +class CLayoutMgrShutdown : public CActive + { +public: + static CLayoutMgrShutdown* NewL(); + virtual ~CLayoutMgrShutdown(); + + void Start(); + +private: + CLayoutMgrShutdown(); + void ConstructL(); + +protected: + // from CActive: + virtual void DoCancel(); + virtual void RunL(); + +private: + static const TInt KShutdownInterval; + + RTimer iTimer; + }; + +// ---------------------------------------------------------------------- + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/client.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/client.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include + +#include "layoutmgr.h" +#include "client.h" +#include "debug.h" +#include "hiduids.h" + +// ---------------------------------------------------------------------- + +EXPORT_C RLayoutManager::RLayoutManager() + { + // Nothing else to do + } + +EXPORT_C TInt RLayoutManager::Connect() + { + const TVersion KMinServerVersion(1, 0, 0); + _LIT(KLayoutServerFilename, "LayoutMgr"); + const TUid KServerUid3 = + { + LAYOUTMGR_UID + } + ; //This was KServerUid2 before + const TUidType serverUid(KNullUid, KNullUid, KServerUid3); + const TUint KDefaultMessageSlots = 3; + + return StartSession(KLayoutServerName, KMinServerVersion, + KLayoutServerFilename, serverUid, KDefaultMessageSlots); + } + +// ---------------------------------------------------------------------- + +EXPORT_C TInt RLayoutManager::KeyEvent(TBool aIsKeyDown, + TInt aHidKey, TInt aUsagePage, TInt aModifiers, + const TLockKeys& aLockKeys, TDecodedKeyInfo& aDecodedKeys) const + { + //#ifdef DBG_ACTIVE + TRACE_INFO( (aIsKeyDown ? + _L("RLayoutManager::KeyEvent(down, 0x%x:0x%x, 0x%x, %d, %d]\r\n") + : _L("RLayoutManager::KeyEvent(up, 0x%x:0x%x, 0x%x, %d, %d]\r\n"), + aIsKeyDown, aUsagePage, aHidKey, aModifiers, + aLockKeys.iCapsLock, aLockKeys.iNumLock)); + //#endif + + TPckgBuf infoPkg; + TKeyEventInfo& info = infoPkg(); + info.iIsKeyDown = aIsKeyDown; + info.iHidKey = aHidKey; + info.iUsagePage = aUsagePage; + info.iModifiers = THidModifier(static_cast(aModifiers)); + info.iLockKeys = aLockKeys; + + TPckgBuf keyPkg; + + TInt result = SendReceive(EKeyEvent, TIpcArgs(&infoPkg, &keyPkg)); + + aDecodedKeys.iCount = 0; + if (result == KErrNone) + { + aDecodedKeys = keyPkg(); + } + + return result; + } + +EXPORT_C TInt RLayoutManager::Reset() const + { + TRACE_INFO( (_L("RLayoutManager::Reset()"))); + return SendReceive(EResetDecoder); + } + +// ---------------------------------------------------------------------- + +EXPORT_C TInt RLayoutManager::SetInitialLayout(TInt aCountry, + TInt aVendor, TInt aProduct) const + { + return SendReceive(ESetInitialLayout, TIpcArgs(aCountry, aVendor, aProduct)); + } + +// ---------------------------------------------------------------------- + +EXPORT_C TInt RLayoutManager::SetLayout(TInt aLayoutId) const + { + return SendReceive(ESetLayout, TIpcArgs(aLayoutId)); + } + +EXPORT_C TInt RLayoutManager::GetLayout(TInt& aLayoutId) const + { + TPckg layoutPkg(aLayoutId); + return SendReceive(EGetLayout, TIpcArgs(&layoutPkg)); + } + +EXPORT_C TInt RLayoutManager::GetInitialLayout(TInt& aLayoutId) const + { + TPckg layoutPkg(aLayoutId); + return SendReceive(EGetInitialLayout, TIpcArgs(&layoutPkg)); + } + +// ---------------------------------------------------------------------- + +EXPORT_C TInt RLayoutManager::GetDeviceInfo(TBool& aIsNokiaSu8, + TBool& aFoundLayout) const + { + + TPckg isNokiaPkg(aIsNokiaSu8); + TPckg foundLayoutPkg(aFoundLayout); + + return SendReceive(EGetDeviceInfo, TIpcArgs(&isNokiaPkg,&foundLayoutPkg)); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/codestore.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/codestore.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include + +#include "codestore.h" +#include "debug.h" + +// ---------------------------------------------------------------------- + +CScanCodeStore::CScanCodeStore() + { + // nothing else to do + } + +CScanCodeStore* CScanCodeStore::NewL() + { + // no second phase construction necessary: + return new (ELeave) CScanCodeStore; + } + +CScanCodeStore::~CScanCodeStore() + { + iKeys.Reset(); + } + +// ---------------------------------------------------------------------- + +TInt CScanCodeStore::Store(TInt aHidKey, TInt aUsagePage, TInt aScanCode) + { + TRACE_INFO( (_L("CScanCodeStore::Store(%d, %d, %d)"), + aHidKey, aUsagePage, aScanCode)); + + return iKeys.Append(TKeyDownInfo(aHidKey, aUsagePage, aScanCode)); + } + +TInt CScanCodeStore::Retrieve(TInt aHidKey, TInt aUsagePage) + { + + TInt result = EStdKeyNull; + + for (TInt i=0; (result == EStdKeyNull) && (i < iKeys.Count()); ++i) + { + if ((iKeys[i].iHidKey == aHidKey) && + (iKeys[i].iUsagePage == aUsagePage)) + { + result = iKeys[i].iScanCode; + iKeys.Remove(i); + } + } + + TRACE_INFO( (_L("CScanCodeStore::Retrieve(%d, %d) = %d"), + aHidKey, aUsagePage, result)); + + return result; + } + +// ---------------------------------------------------------------------- diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/decode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/decode.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,265 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include +#include +#include "modifier.h" +#include "layout.h" +#include "decode.h" +#include "codestore.h" +#include "client.h" +#include "debug.h" +#include "hidvalues.h" + +// ---------------------------------------------------------------------- + +CKeyboardDecoder::CKeyboardDecoder() + : iLayout(0), iAltGrSequence(EFalse), iNumKeysDown(0) + { + TRACE_INFO( ( + _L("[HID]\tCKeyboardDecoder::CKeyboardDecoder at 0x%08x"), this)); + } + +CKeyboardDecoder* CKeyboardDecoder::NewL() + { + CKeyboardDecoder* self = + new (ELeave) CKeyboardDecoder; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CKeyboardDecoder::ConstructL() + { + iScanCodes = CScanCodeStore::NewL(); + } + +CKeyboardDecoder::~CKeyboardDecoder() + { + TRACE_INFO( (_L("[HID]\t~CKeyboardDecoder() 0x%08x"), this)); + + iLayout = 0; // (we don't own iLayout) + + delete iScanCodes; + } + +// ---------------------------------------------------------------------- + +void CKeyboardDecoder::Event(const TKeyEventInfo &aEvent, + TDecodedKeyInfo& aDecodedKeys) + { + aDecodedKeys.iCount = 0; + aDecodedKeys.iScanCode = EStdKeyNull; + + iNumKeysDown += (aEvent.iIsKeyDown ? 1 : -1); + // (NB. it is possible to get an up without a down just after a new + // decoder goes into use when the keyboard layout is changed -- but + // only if the Bluetooth keyboard is used to make the layout change.) + if (iNumKeysDown < 0) + iNumKeysDown = 0; + + if (iLayout) + { + if (!HandleRightAlt(aEvent, aDecodedKeys)) + { + if (aEvent.iIsKeyDown) + { + // Key down event: + + TInt rawCode = iLayout->RawScanCode(aEvent.iHidKey, + aEvent.iUsagePage, aEvent.iModifiers); + + // Store the raw scan code, so that the scan code for + // the "key up" event for this key will match the one + // sent for the "key down" event. These could be + // different, for example, if the scan code changes + // depending on the current modifier state. + // + if (iScanCodes->Store(aEvent.iHidKey, aEvent.iUsagePage, + rawCode) == KErrNone) + { + aDecodedKeys.iScanCode = rawCode; + } + else + { + // Store() may fail due to low memory. In that + // case we don't send key down (or key up) events: + // + aDecodedKeys.iScanCode = EStdKeyNull; + } + + // Decode any key press events: + + TUint16 unicodeKey = iLayout->TranslateKey(aEvent.iHidKey, + aEvent.iUsagePage, aEvent.iModifiers, aEvent.iLockKeys); + + if (unicodeKey != 0) + { + ProcessDeadKeys(unicodeKey, aEvent.iHidKey, + aEvent.iUsagePage, aDecodedKeys); + } + } + else + { + // Key up event: + + aDecodedKeys.iScanCode = + iScanCodes->Retrieve(aEvent.iHidKey, aEvent.iUsagePage); + } + } + } + } + +// ---------------------------------------------------------------------- + +TBool CKeyboardDecoder::HandleRightAlt(const TKeyEventInfo &aEvent, + TDecodedKeyInfo& aDecodedKeys) + { + // A press and release of the right-alt (Alt Gr) key should cause + // the S60 symbol selection dialog to appear, if no other keys are + // pressed in between. + + TBool handledEvent = EFalse; + + const TInt KRightAltKey = 0xe6; + + if ((aEvent.iHidKey == KRightAltKey) && + (aEvent.iUsagePage == EUsagePageKeyboard)) + { + if (aEvent.iIsKeyDown && (iNumKeysDown == 1)) + { + iAltGrSequence = ETrue; + } + + if (!aEvent.iIsKeyDown && iAltGrSequence) + { + // We use EKeyApplication2 to indicate to the modified T9 + // FEP that we wish it to produce the symbol selection dialog: + // EKeyApplication2 is not passed to Fep anymore, but + // it is converted to '*' in SendKeyPress() (keyboard.cpp) + aDecodedKeys.iEvent[0] = TTranslatedKey(EKeyApplication2, + EStdKeyApplication2, 0, 0, EFalse); + aDecodedKeys.iCount = 1; + + handledEvent = ETrue; + iAltGrSequence = EFalse; + } + } + else + { + iAltGrSequence = EFalse; + } + + return handledEvent; + } + +// ---------------------------------------------------------------------- + +void CKeyboardDecoder::Reset() + { + iDeadKey.iUnicode = 0; + iAltGrSequence = EFalse; + iNumKeysDown = 0; + } + +// ---------------------------------------------------------------------- + +void CKeyboardDecoder::SetLayout(CKeyboardLayout* aLayout) + { + TRACE_INFO( (_L("[HID]\tCKeyboardDecoder::SetLayout(0x%08x)"), aLayout)); + + iLayout = aLayout; + Reset(); + } + +// ---------------------------------------------------------------------- + +void CKeyboardDecoder::ProcessDeadKeys(TUint16 aUnicodeKey, + TInt aHidKey, TInt aUsagePage, TDecodedKeyInfo &aDecodedKeys) + { + if (iDeadKey.iUnicode == 0) + { + // Check if the current key is a dead key: + // + if (iLayout->IsDeadKey(aUnicodeKey)) + { + // We've received a dead key event, so there's no key press + // to issue -- just record the details for later: + // + TRACE_INFO( (_L("[HID]\tDeadkey 0x%04x (%d:%d)"), + aUnicodeKey, aUsagePage, aHidKey)); + + iDeadKey = TTranslatedKey(aUnicodeKey, + aDecodedKeys.iScanCode, aHidKey, aUsagePage, EFalse); + aDecodedKeys.iCount = 0; + } + else + { + // No dead key processing to do, so just send a + // normal key code: + // + TRACE_INFO( (_L("[HID]\tNo dead key processing, one event"))); + + aDecodedKeys.iEvent[0] = TTranslatedKey(aUnicodeKey, + aDecodedKeys.iScanCode, aHidKey, aUsagePage, + iLayout->IsRepeatingKey(aUnicodeKey)); + aDecodedKeys.iCount = 1; + } + } + else + { + // We've an active dead key, see if the current key produces + // a combination character: + // + TUint16 comboChar = + iLayout->FindCombiningChar(iDeadKey.iUnicode, aUnicodeKey); + + if (comboChar == 0) + { + TRACE_INFO( (_L("[HID]\tNo match for 0x%04x, sending after 0x%04x"), + aUnicodeKey, iDeadKey.iUnicode)); + + // No match, so two key events to send: + + aDecodedKeys.iEvent[0] = iDeadKey; + aDecodedKeys.iEvent[1] = TTranslatedKey(aUnicodeKey, + aDecodedKeys.iScanCode, aHidKey, aUsagePage, + iLayout->IsRepeatingKey(aUnicodeKey)); + aDecodedKeys.iCount = 2; + } + else + { + TRACE_INFO( (_L("[HID]\tFound a match 0x%04x, one combo to send 0x%04x"), + aUnicodeKey, comboChar)); + + // Found a match, so one combo key event to send: + + aDecodedKeys.iEvent[0] = TTranslatedKey(comboChar, + aDecodedKeys.iScanCode, aHidKey, aUsagePage, + iLayout->IsRepeatingKey(comboChar)); + aDecodedKeys.iCount = 1; + } + + // We've finished processing the dead key sequence: + iDeadKey.iUnicode = 0; + } + } + +// ---------------------------------------------------------------------- diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/library.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/library.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include +#include +#include +#include + +#include "hidinterfaces.h" +#include "decode.h" +#include "layout.h" +#include "library.h" +#include "debug.h" + + +CLayoutLibrary* CLayoutLibrary::NewL() + { + CLayoutLibrary* self = new (ELeave) CLayoutLibrary; + + // No two phase construction required + + return self; + } + +CLayoutLibrary::CLayoutLibrary() + : iId(0), iLoaded(EFalse), iLayout(0) + { + // Nothing else to do + } + +CLayoutLibrary::~CLayoutLibrary() + { + TRACE_INFO( (_L("[HID]\t~CLayoutLibrary() 0x%08x"), this)); + delete iLayout; + if (iLoaded) + { + iLoaded = EFalse; + iId = 0; + } + REComSession::FinalClose(); + } + +// ---------------------------------------------------------------------- + +TInt CLayoutLibrary::SetLayout(TInt aId) + { + TInt err = KErrNone; + TBool foundLayout = EFalse; + + // Implementation info array + RImplInfoPtrArray implInfoArray; + + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: id=%d"), aId)); + + if( aId == iId ) + { + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: Same layout id=%d, don't load twice"), aId)); + return KErrNone; + } + + // Plain ignore is enough. If listing leaves, the array is just empty. + TRAP_IGNORE( REComSession::ListImplementationsL( KHidLayoutPluginInterfaceUid, implInfoArray ) ); + + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: %d plugins listed"),implInfoArray.Count() )); + + if ( 0 == implInfoArray.Count()) + { + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: No Drivers found"))); + err = KErrNotFound; + } + else + { + for (TInt i=0; iImplementationUid(); + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: load plugin 0x%08x"),implUid )); + // load driver + // Trap so other drivers will be enumerated even if + // this fails: + CHidLayoutPluginInterface* plugin = NULL; + TRAPD( err, + plugin = CHidLayoutPluginInterface::NewL( implUid ); + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: plugin loaded"))); + ); + + if( err == KErrNone) + { + CKeyboardLayout* layout = reinterpret_cast(plugin); + if (aId == layout->LayoutId()) + { + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: Found layout %d!"), aId)); + foundLayout = ETrue; + // Swap the current layout object: + CKeyboardLayout* tmpLayout = iLayout; + iLayout = layout; + iId = aId; + iLoaded = ETrue; + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: delete old layout"))); + delete tmpLayout; + } + else + { + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: wrong layout, delete plugin"))); + delete plugin; + } + } + else + { + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: plugin creation failed"))); + } + }// end of for loop + } + + if( !foundLayout ) + { + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: NO PLUGIN FOUND"))); + } + TRACE_INFO( (_L("[HID]\tCLayoutLibrary::SetLayout: Plugin listing ready, delete info array"))); + implInfoArray.ResetAndDestroy(); + implInfoArray.Close(); + return err; + } + +// End of file + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/mapping.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/mapping.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include + +#include "hidlayoutids.h" +#include "mapping.h" +#include "layout.h" +#include "debug.h" + +// ---------------------------------------------------------------------- + +const TInt TFindLayoutId::KDefaultLayoutId = EUnitedKingdom; + +// ---------------------------------------------------------------------- +// Map a HID country ID to a keyboard layout ID: +// +const TFindLayoutId::TCountryMapEntry TFindLayoutId::KMapCountryToLayout[] = + { + // HID ID -> Standard layout ID + // + { 2, EBelgian }, // Belgian + { 6, EDanish }, // Danish + { 7, EFinnishSwedish }, // Finnish + { 8, EFrench }, // French + { 9, EGerman }, // German + { 14, EItalian }, // Italian + { 18, EDutch }, // Netherlands/Dutch + { 19, ENorwegian }, // Norwegian + { 22, EPortuguese }, // Portuguese + { 25, ESpanish }, // Spanish + { 26, EFinnishSwedish }, // Swedish + { 32, EUnitedKingdom }, // UK + { 33, EUnitedStates }, // US + // + // Not in requirements, but layouts do exist. (Note that it + // doesn't matter if a layout is listed here but isn't installed, + // as the default layout will be used instead.) + // + { 4, ECanadianFrench }, // Canadian-French + { 3, ECanadianMultilingual }, // Canadian-Bilingual + { 13, EUSInternational }, // International (ISO) + { 17, ELatinAmerican }, // Latin American + { 27, ESwissFrench }, // Swiss/French + { 28, ESwissGerman }, // Swiss/German + }; + +const TInt TFindLayoutId::KCountryMapSize = + (sizeof (KMapCountryToLayout)) / (sizeof (TCountryMapEntry)); + +// ---------------------------------------------------------------------- +// Map a HID country ID (Nokia SU-8) to a keyboard layout ID: +// +const TFindLayoutId::TCountryMapEntry TFindLayoutId::KMapSu8CountryToLayout[] = + { + // HID ID -> Nokia SU-8 layout ID + // + // We don't know what language code the SU-8 keyboards will return, + // so we'll include them all for now: + // + { 33, ESu8USEnglish }, // US + { 7, ESu8FinnishSwedish }, // Finnish + { 26, ESu8FinnishSwedish }, // Swedish + { 6, ESu8DanishNorwegian }, // Danish + { 19, ESu8DanishNorwegian }, // Norwegian + { 9, ESu8German } // German + }; + +const TInt TFindLayoutId::KSu8CountryMapSize = + (sizeof (KMapSu8CountryToLayout)) / (sizeof (TCountryMapEntry)); + +// ---------------------------------------------------------------------- +// Map a TLanguage enum, as returned by User::Language(), to a +// keyboard layout ID: +// +const TFindLayoutId::TLanguageMapEntry TFindLayoutId::KMapLanguageToLayout[] = + { + // TLanguage ID -> Standard layout ID, Nokia SU-8 layout ID + // + { ELangEnglish, EUnitedKingdom, ESu8USEnglish }, + { ELangFrench, EFrench, 0 }, + { ELangGerman, EGerman, ESu8German }, + { ELangSpanish, ESpanish, 0 }, + { ELangItalian, EItalian, 0 }, + { ELangSwedish, EFinnishSwedish, ESu8FinnishSwedish }, + { ELangDanish, EDanish, ESu8DanishNorwegian }, + { ELangNorwegian, ENorwegian, ESu8DanishNorwegian }, + { ELangFinnish, EFinnishSwedish, ESu8FinnishSwedish }, + { ELangAmerican, EUnitedStates, ESu8USEnglish }, + { ELangSwissFrench, ESwissFrench, 0 }, + { ELangSwissGerman, ESwissGerman, 0 }, + { ELangPortuguese, EPortuguese, 0 }, + { ELangIcelandic, EIcelandic, 0 }, + { ELangDutch, EDutch, 0 }, + { ELangBelgianFlemish, EBelgian, 0 }, + { ELangBelgianFrench, EBelgian, 0 }, + { ELangInternationalEnglish, EUSInternational, ESu8USEnglish }, + { ELangCanadianFrench, ECanadianFrench, 0 }, + { ELangLatinAmericanSpanish, ELatinAmerican, 0 }, + { ELangFinlandSwedish, EFinnishSwedish, ESu8FinnishSwedish }, + { ELangRussian, ERussian, ESu8Russian } + + // } + }; + +const TInt TFindLayoutId::KLanguageMapSize = + (sizeof (KMapLanguageToLayout)) / (sizeof (TLanguageMapEntry)); + +// ---------------------------------------------------------------------- + +TFindLayoutId::TFindLayoutId(TInt aHidCountryId, + TInt aVendorId, TInt aProductCode) + { + TRACE_INFO( (_L("TFindLayoutId(Country %d, Vendor %d, Product %d)"), + aHidCountryId, aVendorId, aProductCode)); + + const TInt KNokiaVendorId = 0x5555; + const TInt KSu8ProductCode = 0x00dd; + + iIsNokiaSu8 = (aVendorId == KNokiaVendorId) + && (aProductCode == KSu8ProductCode); + + //Used to identify the NOKIA SU8 PROTOTYPE + if ((aVendorId == 0x5555) && (aProductCode == 0x5555)) + { + iIsNokiaSu8 = ETrue; + } + + iLayout = 0; // 0 = invalid layout ID = "unknown" + + iFoundLayout = EFalse; + + if (aHidCountryId != 0) + { + // Use the look-up table to find the most appropriate keyboard + // layout for this country code: + // + TRACE_INFO( (_L("TFindLayoutId(): country %d"), + aHidCountryId)); + iLayout = CountryToLayout(aHidCountryId, iIsNokiaSu8); + + if (iLayout != 0) + { + iFoundLayout = ETrue; + } + } + + if (iLayout == 0) + { + // Either no country code was specified, or we couldn't find + // an appropriate layout listed in the look-up table. + // Instead, attempt to infer the layout using the current + // phone language setting: + // + TRACE_INFO( (_L("TFindLayoutId(): language %d"), + User::Language())); + iLayout = LanguageToLayout(User::Language(), iIsNokiaSu8); + } + + if (iLayout == 0) + { + iLayout = KDefaultLayoutId; + TRACE_INFO( (_L("TFindLayoutId(): default layout"))); + } + + TRACE_INFO( (_L("TFindLayoutId(): layout is %d"), iLayout)); + } + +// ---------------------------------------------------------------------- + +TInt TFindLayoutId::CountryToLayout(TInt aHidCountryId, TBool aIsNokiaSu8) + { + const TCountryMapEntry* table = + aIsNokiaSu8 ? KMapSu8CountryToLayout : KMapCountryToLayout; + const TInt size = + aIsNokiaSu8 ? KSu8CountryMapSize : KCountryMapSize; + + TInt layout = 0; + + for (TInt i=0; (i + +#include "layoutmgr.h" +#include "server.h" +#include "session.h" +#include "shutdown.h" +#include "library.h" +#include "mapping.h" +#include "debug.h" + + +// ---------------------------------------------------------------------- + +CLayoutServer::CLayoutServer() + : CGenericServer(CActive::EPriorityStandard), + iIsNokiaSu8(EFalse), iFoundLayout(EFalse) + { + // nothing else to do + } + +CLayoutServer::~CLayoutServer() + { + TRACE_FUNC ( _L("[HID]\t~CLayoutServer") ); + delete iLayoutLibrary; + delete iShutdown; + } + +CLayoutServer* CLayoutServer::NewL() + { + CLayoutServer* self = CLayoutServer::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CLayoutServer* CLayoutServer::NewLC() + { + CLayoutServer* self = new (ELeave) CLayoutServer; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ---------------------------------------------------------------------- + +void CLayoutServer::ConstructL() + { + TRACE_FUNC( (_L("[HID]\tCLayoutServer::ConstructL()") )); + // Construct delayed shutdown timer: + iShutdown = CLayoutMgrShutdown::NewL(); + + // Need a keyboard layout library: + iLayoutLibrary = CLayoutLibrary::NewL(); + + // Start the server: + StartL(KLayoutServerName); + + // Shut down after a few seconds unless a client connects: + iShutdown->Start(); + } + +// ---------------------------------------------------------------------- +CSession2* CLayoutServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const + { + // Version number of this server software: + const TVersion KServerVersion(1, 0, 0); + + // Ensure we're compatible with the client: + if (!User::QueryVersionSupported(KServerVersion, aVersion)) + { + User::Leave(KErrNotSupported); + } + + CLayoutSession* session = CLayoutSession::NewL(); + const_cast(this)->SessionAdded(); + + return session; + } + +void CLayoutServer::SessionAdded() + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::SessionAdded() count %d"),iSessionCount+1)); + + ++iSessionCount; + iShutdown->Cancel(); + } + +void CLayoutServer::SessionClosed() + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::SessionClosed(), count %d"),iSessionCount-1)); + + --iSessionCount; + __ASSERT_DEBUG(iSessionCount >= 0, PanicServer(ENegativeSessionCount)); + + if (iSessionCount < 1) + { + iSessionCount = 0; + + // If that was the last session, shut down the server: + iShutdown->Start(); + } + } + +// ---------------------------------------------------------------------- + +// ServiceL() leaves will end up here: +// +TInt CLayoutServer::RunError(TInt aErr) + { + if (aErr == KErrBadDescriptor) + { + PanicClient(Message(), EBadDescriptor); + } + else + { + // Report the error to the client: + Message().Complete(aErr); + } + + // The leave will result in an early return from CServer::RunL(), + // skipping the call to request another message. So we do that now + // in order to keep the server running: + ReStart(); + + return KErrNone; // handled the error fully + } + +// ---------------------------------------------------------------------- +void CLayoutServer::PanicClient(const RMessage2& aMessage, TInt aPanic) + { + __DEBUGGER(); + aMessage.Panic(KLayoutServerPanic, aPanic); + } + +void CLayoutServer::PanicServer(TInt aPanic) + { + __DEBUGGER(); + User::Panic(KLayoutServerPanic, aPanic); + } + +// ---------------------------------------------------------------------- + +void CLayoutServer::ThreadFunctionL(TStartupRequest* /*aStartup*/) + { + // This is a new thread, so we require a new active scheduler: + CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler; + CleanupStack::PushL(activeScheduler); + CActiveScheduler::Install(activeScheduler); + + // Construct our server + CLayoutServer::NewLC(); + + User::RenameThread(KLayoutServerName); + RProcess::Rendezvous(KErrNone); + + // Start handling requests: + CActiveScheduler::Start(); + + // Server finished: + CleanupStack::PopAndDestroy(2, activeScheduler); + } + +TInt CLayoutServer::ThreadFunction(TAny* aThreadArg) + { + __UHEAP_MARK; + + TInt err = KErrNone; + TStartupRequest* startup = static_cast(aThreadArg); + + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + if (cleanupStack) + { + TRAP(err, ThreadFunctionL(startup)); + delete cleanupStack; + + if (err != KErrNone) + { + // Failed, but we must still signal the client or it will + // hang: + RProcess::Rendezvous(err); + } + } + else + { + // Again, failed, but we still need to signal the client: + RProcess::Rendezvous(KErrNoMemory); + } + + __UHEAP_MARKEND; + + return err; + } + +// ---------------------------------------------------------------------- + +void CLayoutServer::SetInitialLayoutL(TInt aCountry, + TInt aVendor, TInt aProduct) + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::SetInitialLayoutL(%d, %d, %d)\n"), + aCountry, aVendor, aProduct)); + + // Select an initial layout ID based on parameters read from the device: + TFindLayoutId findLayout(aCountry, aVendor, aProduct); + iInitialLayout = findLayout.LayoutId(); + iIsNokiaSu8 = findLayout.IsNokiaSu8(); + iFoundLayout = findLayout.FoundLayout(); + + TRACE_INFO( (_L("[HID]\t Layout ID is %d (0x%x)\n"), + iInitialLayout, iInitialLayout)); + + // Set this as the system keyboard layout: + User::LeaveIfError(SetLayout(iInitialLayout)); + } + +// ---------------------------------------------------------------------- + +TInt CLayoutServer::SetLayout(TInt aLayoutId) + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::SetLayout(%d)\n"), aLayoutId) ); + + // Change the single system keyboard layout: + + TInt err = iLayoutLibrary->SetLayout(aLayoutId); + + if (err == KErrNone) + { + // Notify each driver in turn: + TRACE_INFO( (_L("[HID]\t iSessionCount = %d\n"), iSessionCount)); + TDblQueIter sessionList = iSessionIter; + sessionList.SetToFirst(); + + CSession2* session = sessionList++; + + while (session) + { + + // We know that each session is actually a CLayoutSession: + CLayoutSession* lsession = static_cast(session); + lsession->SetLayout(iLayoutLibrary); + session = sessionList++; + } + } + + return err; + } + +TInt CLayoutServer::Layout() const + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::Layout() = %d\n"), + iLayoutLibrary->Id())); + return iLayoutLibrary->Id(); + } + +TInt CLayoutServer::InitialLayout() const + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::InitialLayout() = %d\n"), + iInitialLayout)); + return iInitialLayout; + } + +TBool CLayoutServer::IsNokiaSu8() const + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::IsNokiaSu8() = %d\n"), + iIsNokiaSu8)); + return iIsNokiaSu8; + } + +TBool CLayoutServer::FoundLayout() const + { + TRACE_INFO( (_L("[HID]\tCLayoutServer::FoundLayout() = %d\n"), + iFoundLayout)); + return iFoundLayout; + } + +// ---------------------------------------------------------------------- + +TInt E32Main() + { + TStartupRequest startup; + TInt error = CGenericServer::GetStartupFromCommandLine(startup); + + if (KErrNone == error) + { + error = CLayoutServer::ThreadFunction(&startup); + } + + return error; + } + + +// ---------------------------------------------------------------------- + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/session.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/session.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,179 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include + +#include "layoutmgr.h" +#include "server.h" +#include "session.h" +#include "decode.h" +#include "library.h" +#include "client.h" +#include "debug.h" + +// ---------------------------------------------------------------------- + +CLayoutSession::CLayoutSession() + { + // nothing else to do + } + +CLayoutSession* CLayoutSession::NewL() + { + CLayoutSession* self = CLayoutSession::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CLayoutSession* CLayoutSession::NewLC() + { + CLayoutSession* self = new (ELeave) CLayoutSession; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +void CLayoutSession::ConstructL() + { + iDecoder = CKeyboardDecoder::NewL(); + } + +CLayoutSession::~CLayoutSession() + { + Server()->SessionClosed(); + + delete iDecoder; + iLayoutLibrary = 0; // no ownership + } + +// ---------------------------------------------------------------------- + +void CLayoutSession::ServiceL(const RMESSAGE& aMessage) + { + TRAPD(err, DispatchMessageL(aMessage)); + aMessage.Complete(err); + } + +void CLayoutSession::DispatchMessageL(const RMESSAGE& aMessage) + { + TRACE_INFO( (_L("[HID]\tCLayoutSession::DispatchMessageL(%d)\r\n"), + aMessage.Function())); + + // Extract the service code from the message + TLayoutManagerService service = + static_cast(aMessage.Function()); + + switch (service) + { + case EKeyEvent: + { + TPckgBuf eventPkg; + aMessage.ReadL(0, eventPkg); + TRACE_INFO( ( + _L("[HID]\tKey event message: 0x%04x, 0x%02x, %d, %d"), + eventPkg().iHidKey, eventPkg().iModifiers.Value(), + eventPkg().iLockKeys.iCapsLock, + eventPkg().iLockKeys.iNumLock)); + + TPckgBuf keyPkg; + iDecoder->Event(eventPkg(), keyPkg()); + aMessage.WriteL(1, keyPkg); + } + break; + + case ESetInitialLayout: + { + TRACE_INFO( (_L("[HID]\tSet initial layout message\r\n"))); + Server()->SetInitialLayoutL(aMessage.Int0(), + aMessage.Int1(), aMessage.Int2()); + } + break; + + case ESetLayout: + { + TRACE_INFO( (_L("[HID]\tSet layout ALL message\r\n"))); + User::LeaveIfError(Server()->SetLayout(aMessage.Int0())); + } + break; + + case EGetInitialLayout: + { + TRACE_INFO( (_L("[HID]\tGet initial layout message\r\n"))); + TPckgBuf idPkg(Server()->InitialLayout()); + aMessage.WriteL(0, idPkg); + } + break; + + case EGetLayout: + { + TRACE_INFO( (_L("[HID]\tGet layout message\r\n"))); + TInt layout = Server()->Layout(); + TRACE_INFO( (_L(" Layout library ID is %d\r\n"), layout)); + TPckgBuf idPkg(layout); + aMessage.WriteL(0, idPkg); + } + break; + + case EResetDecoder: + { + TRACE_INFO( (_L("[HID]\tReset decoder message\r\n"))); + iDecoder->Reset(); + } + break; + + case EGetDeviceInfo: + { + TRACE_INFO( (_L("[HID]\tGet device info message\r\n"))); + TPckgBuf isNokiaSu8Pkg(Server()->IsNokiaSu8()); + aMessage.WriteL(0, isNokiaSu8Pkg); + TPckgBuf foundLayoutPkg(Server()->FoundLayout()); + aMessage.WriteL(1, foundLayoutPkg); + } + break; + + default: + { + TRACE_INFO( (_L("[HID]\tUnknown service request %d\r\n"), service)); + CLayoutServer::PanicClient(aMessage, EBadRequest); + break; + } + } + } + +// ---------------------------------------------------------------------- + +void CLayoutSession::SetLayout(CLayoutLibrary* aLayoutLibrary) + { + TRACE_INFO( (_L("[HID]\tCLayoutSession::SetLayout(0x%08x)\n"), + aLayoutLibrary)); + TRACE_INFO( (_L("[HID]\t Layout ID is %d (0x%x)\n"), + aLayoutLibrary->Id())); + + iLayoutLibrary = aLayoutLibrary; + iDecoder->SetLayout(iLayoutLibrary->Layout()); + } + +// ---------------------------------------------------------------------- + +CLayoutServer* CLayoutSession::Server() + { + return const_cast(static_cast + (CSession2::Server())); + } + +// ---------------------------------------------------------------------- diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/shutdown.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/shutdown.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include + +#include "shutdown.h" +#include "debug.h" + +// ---------------------------------------------------------------------- + +const TInt CLayoutMgrShutdown::KShutdownInterval = 2000000; // 2 seconds + +// ---------------------------------------------------------------------- + +CLayoutMgrShutdown* CLayoutMgrShutdown::NewL() + { + TRACE_INFO( (_L("[HID]\tCLayoutMgrShutdown::NewL()"))); + + CLayoutMgrShutdown* self = new (ELeave) CLayoutMgrShutdown; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CLayoutMgrShutdown::ConstructL() + { + TRACE_INFO( (_L("[HID]\tCLayoutMgrShutdown::ConstructL() 0x%08x"), this)); + + CActiveScheduler::Add(this); + User::LeaveIfError(iTimer.CreateLocal()); + } + +CLayoutMgrShutdown::CLayoutMgrShutdown() + : CActive(CActive::EPriorityStandard) + {} + +CLayoutMgrShutdown::~CLayoutMgrShutdown() + { + TRACE_INFO( (_L("[HID]\tCLayoutMgrShutdown::~CLayoutMgrShutdown()"))); + + Cancel(); + iTimer.Close(); + } + +void CLayoutMgrShutdown::Start() + { + iTimer.After(iStatus, KShutdownInterval); + SetActive(); + } + +void CLayoutMgrShutdown::DoCancel() + { + iTimer.Cancel(); + } + +void CLayoutMgrShutdown::RunL() + { + // Timer has expired, so cause the server to close down: + CActiveScheduler::Stop(); + } + +// ---------------------------------------------------------------------- diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/aif/paintcursoraif.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/aif/paintcursoraif.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 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 + +RESOURCE AIF_DATA + { + app_uid=0x2001FE5C; + num_icons=2; + embeddability=KAppNotEmbeddable; + newfile=KAppDoesNotSupportNewFile; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2008 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: +* +*/ + +// RESOURCE IDENTIFIER +NAME PACU // 4 letter ID + +#include +#include +#include +#include "paintcursor.loc" +#include +#include +#include +#include +#include +#include + + +// RESOURCE DEFINITIONS + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf="paintcursor"; } + +RESOURCE EIK_APP_INFO +{ + cba = r_hidmouse_softkeys_exit_hide; +} + + +RESOURCE CBA r_hidmouse_softkeys_exit_hide + { + buttons = + { + CBA_BUTTON {id=EAknSoftkeyExit; txt = qtn_options_exit;}, + CBA_BUTTON {id=EAknSoftkeyBack; txt = qtn_softkey_hide;} + }; + } + +RESOURCE LOCALISABLE_APP_INFO r_paintcursor_localisable_app_info + { + short_caption = qtn_app_short_caption_string; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = qtn_app_caption_string; + number_of_icons = 1; + icon_file = APP_BITMAP_DIR"\\paintcursor_aif.mif"; + }; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor_reg.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2005 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 + +UID2 KUidAppRegistrationResourceFile +UID3 0x2001FE5C //App UID + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "paintcursor"; + localisable_resource_file = APP_RESOURCE_DIR"\\paintcursor"; + localisable_resource_id = R_PAINTCURSOR_LOCALISABLE_APP_INFO; +// hidden = KAppIsHidden; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2008 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 + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXTENSIONS +START EXTENSION s60/mifconv +OPTION TARGETFILE paintcursor.mif +OPTION HEADERFILE paintcursor.mbg +OPTION SOURCEDIR ../aif +OPTION SOURCES -c8,8 qgn_prop_bt_mouse +END + +START EXTENSION s60/mifconv +OPTION TARGETFILE paintcursor_aif.mif +OPTION SOURCES -c8,8 qgn_prop_bt_mouse +END + + +PRJ_MMPFILES +paintcursor.mmp diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/group/icons.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/group/icons.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +TARGETDIR=$(ZDIR)\system\apps\paintcursor +HEADERDIR=\epoc32\include +ICONTARGETFILENAME=$(TARGETDIR)\paintcursor.mif +HEADERFILENAME=$(HEADERDIR)\paintcursor.mbg + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +RESOURCE : + mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ + /c8,8 ..\aif\qgn_wka_cxt_set.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(HEADERFILENAME)&& \ + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/group/icons_aif_scalable_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/group/icons_aif_scalable_dc.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,68 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +# TODO: Configure these +# ---------------------------------------------------------------------------- + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\paintcursor_aif.mif + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# TODO: Configure these. +# +# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by +# MifConv if the mask detph is defined. +# +# NOTE 2: Usually, source paths should not be included in the bitmap +# definitions. MifConv searches for the icons in all icon directories in a +# predefined order, which is currently \s60\icons, \s60\bitmaps2. +# The directory \s60\icons is included in the search only if the feature flag +# __SCALABLE_ICONS is defined. +# ---------------------------------------------------------------------------- + +RESOURCE : + mifconv $(ICONTARGETFILENAME) \ + /c8,8 ..\aif\qgn_wka_cxt_set.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/group/icons_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/group/icons_dc.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,56 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +TARGETDIR=$(ZDIR)\resource\apps +HEADERDIR=\epoc32\include +ICONTARGETFILENAME=$(TARGETDIR)\paintcursor.mif +HEADERFILENAME=$(HEADERDIR)\paintcursor.mbg + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +RESOURCE : + mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ + /c8,8 ..\aif\qgn_wka_cxt_set.svg + + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(HEADERFILENAME)&& \ + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/group/paintcursor.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/group/paintcursor.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2008 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 + +TARGET paintcursor.exe +TARGETTYPE exe + +UID 0x1000008d 0x2001FE5C +CAPABILITY CAP_APPLICATION PowerMgmt + +VENDORID VID_DEFAULT + +USERINCLUDE ../inc +USERINCLUDE ../../Sesame_client/inc +USERINCLUDE ../../../common/inc +USERINCLUDE ../../../inc +USERINCLUDE ../../../loc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../inc + +SOURCEPATH ../../../common/src +SOURCE bthidpskeywatcher.cpp + +SOURCEPATH ../src +SOURCE paintcursorapp.cpp +SOURCE paintcursorappui.cpp +SOURCE paintcursordocument.cpp +SOURCE paintcursorappview.cpp + +// Application Resource +// +START RESOURCE ../data/paintcursor.rss +HEADER +TARGETPATH APP_RESOURCE_DIR +LANGUAGE_IDS +END + +// Application Registeration Resource +// +START RESOURCE ../data/paintcursor_reg.rss +DEPENDS paintcursor.rsg +// Do not change the UID below. +TARGETPATH /private/10003a3f/apps +END + +LIBRARY euser.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY eikcoctl.lib +LIBRARY avkon.lib +LIBRARY bafl.lib +LIBRARY aknskins.lib +LIBRARY apgrfx.lib +LIBRARY ws32.lib +LIBRARY BTMouse_Animation_client.lib +LIBRARY flogger.lib + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursor.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursor.loc Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2008 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: +* +*/ + +#define qtn_app_caption_string "Paint Cursor" + +#define qtn_app_short_caption_string "Paint Cursor" + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorapp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorapp.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 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: +* +*/ +// ---------------------------------------------------------------------- +// +// Project: NOK090 (Bluetooth HID Profile) +// +// "PaintCursorApp.h" - BT Hid Tester Application Header File +// +// +// ---------------------------------------------------------------------- +#ifndef PaintCursorAPP_H +#define PaintCursorAPP_H + +#include + +// UID of the application +const TUid KUidPaintCursor = + { + 0x2001FE5C + }; + +/** + * CPaintCursorApp application class. + * Provides factory to create concrete document object. + * + */ +class CPaintCursorApp : public CAknApplication + { + +public: + // Functions from base classes +private: + + /** + * From CApaApplication, creates CPaintCursorDocument document object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + + /** + * From CApaApplication, returns application's UID (KUidPaintCursor). + * @return The value of KUidPaintCursor. + */ + TUid AppDllUid() const; + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappui.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2004-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: BT Hid Simulator Application UI Header File +* +*/ + + +#ifndef PaintCursorAPPUI_H +#define PaintCursorAPPUI_H + +#include +#include +#include +#include +#include +#include +#include +#include "bthidpskeywatcher.h" + +class CPaintCursorAppView; + +/** + * Application UI class. + * Provides support for the following features: + * - dialog architecture + * + */ +class CPaintCursorAppUi : public CAknAppUi, MMouseCursorStatusObserver + { +public: + // // Constructors and destructor + + /** + * EPOC default constructor. + */ + void ConstructL(); + + /** + * Destructor. + */ + ~CPaintCursorAppUi(); + + //void CenRepDataChanged(TUid& aUid, TUint32 aKey); + void MouseCursorStatusChangedL(TInt aStatus); + +private: + // From MEikMenuObserver + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); + +private: + /** + * From CEikAppUi, takes care of command handling. + * @param aCommand command to be handled + */ + void HandleCommandL(TInt aCommand); + + /** + * From CEikAppUi, handles key events. + * @param aKeyEvent Event to handled. + * @param aType Type of the key event. + * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed). + */ + virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent, + TEventCode aType); + + void SendToBackground(); + + void EndTask(); + +private: + CPaintCursorAppView* iAppView; + CBTMouseCursorStatusObserver* iPsKeyWatcher; + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 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: +* +*/ +// ---------------------------------------------------------------------- +// +// Project: Bluetooth HID Profile +// +// "PaintCursorAppView.h" - BT Hid Simulator Application View Header File +// +// +// ---------------------------------------------------------------------- +#ifndef __PaintCursorAPPVIEW_H__ +#define __PaintCursorAPPVIEW_H__ +#include +#include +#include "mousecursordll.h" +#include "clientimagecommander.h" +_LIT( KMouseCurorSrvName, "\\system\\apps\\animation\\BTCURSOR_SERVER" ); + +/*! + An instance of the CPaintCursorAppView View object for PaintCursor application + */ +class CPaintCursorAppView : public CCoeControl + { +public: + + /*! + Create a CPaintCursorAppView object, which will draw itself to aRect + @param aRect the rectangle this view will be drawn to + @result a pointer to the created instance of CPaintCursorAppView + */ + static CPaintCursorAppView* NewL(const TRect& aRect); + + /*! + Create a CPaintCursorAppView object, which will draw itself to aRect + @param aRect the rectangle this view will be drawn to + @result a pointer to the created instance of CPaintCursorAppView + */ + static CPaintCursorAppView* NewLC(const TRect& aRect); + + /*! + Destroy the object and release all memory objects + */ + ~CPaintCursorAppView(); + +public: + // from CCoeControl + + void SizeChanged(); + + void Draw(const TRect& aRect) const; + + void HideCursor(); + + void ShowCursor(); +private: + + /*! + Perform the second phase construction of a CPaintCursorAppView object + @param aRect the rectangle this view will be drawn to + */ + void ConstructL(const TRect& aRect); + + /*! + Perform the first phase of two phase construction + */ + CPaintCursorAppView(); + + /** + * SetupMouseCursorDllL. + * Setup the mouse cursor animation client Dll. + */ + void SetupMouseCursorDllL(); + /** + * SetupImageCommanderL. + * Setup the animation image commander. + */ + void SetupImageCommanderL(); + +private: + + /** + * iMouseCursorDll + * Mouse cursor Animation client dll. + */ + RMouseCursorDll iMouseCursorDll; + /** + * iClientCommander + * Controls an animation image object. + */ + RImageCommander iClientCommander; + + TBool iMouseInitialized; + }; + +#endif // __PaintCursorAPPVIEW_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursordocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursordocument.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2008 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: +* +*/ + + +#ifndef PaintCursorDOCUMENT_H +#define PaintCursorDOCUMENT_H + +#include + +class CEikAppUi; + +/** + * CPaintCursorDocument application class. + */ +class CPaintCursorDocument : public CAknDocument + { +public: + // Constructors and destructor + /** + * Two-phased constructor. + */ + static CPaintCursorDocument* NewL(CEikApplication& aApp); + + /** + * Destructor. + */ + virtual ~CPaintCursorDocument(); + +private: + + /** + * EPOC default constructor. + */ + CPaintCursorDocument(CEikApplication& aApp); + void ConstructL(); + +private: + + /** + * From CEikDocument, create CPaintCursorAppUi "App UI" object. + */ + CEikAppUi* CreateAppUiL(); + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorapp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorapp.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 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: +* +*/ +// ---------------------------------------------------------------------- +// +// Project: Bluetooth HID Profile +// +// "PaintCursorApp.cpp" - BT Hid PaintCursor Application Source File +// +// +// ---------------------------------------------------------------------- + +#include "paintcursorapp.h" +#include "paintcursordocument.h" + +TUid CPaintCursorApp::AppDllUid() const + { + return KUidPaintCursor; + } + +CApaDocument* CPaintCursorApp::CreateDocumentL() + { + return CPaintCursorDocument::NewL(*this); + } + +#include + +EXPORT_C CApaApplication* NewApplication() + { + return new CPaintCursorApp; + } + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,161 @@ +/* +* Copyright (c) 2008 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 +#include + +#include "paintcursorapp.h" +#include "paintcursorappui.h" +#include "paintcursorapp.h" +#include "paintcursorappview.h" +#include "debug.h" +#include "bthidPsKey.h" + +void CPaintCursorAppUi::ConstructL() + { + TRACE_INFO(_L("[PaintCursor]\t CPaintCursorAppUi::ConstructL()")); + BaseConstructL(); + + iAppView = CPaintCursorAppView::NewL(ClientRect()); + + iAppView->SetMopParent(this); // so view can update scroll bars + + AddToStackL(iAppView); + + + iPsKeyWatcher = CBTMouseCursorStatusObserver::NewL(); + + iPsKeyWatcher->SubscribeMouseCursorStatusL(this); + } + +CPaintCursorAppUi::~CPaintCursorAppUi() + { + + if (iAppView) + { + RemoveFromStack(iAppView); + + delete iAppView; + iAppView = 0; + } + + if (iPsKeyWatcher) + delete iPsKeyWatcher; + } + + + +// ------------------------------------------------------------------------------ +// CPaintCursorAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) +// This function is called by the EIKON framework just before it displays +// a menu pane. Its default implementation is empty, and by overriding it, +// the application can set the state of menu items dynamically according +// to the state of application data. +// ------------------------------------------------------------------------------ +// +void CPaintCursorAppUi::DynInitMenuPaneL( + TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) + {} + +TKeyResponse CPaintCursorAppUi::HandleKeyEventL( + const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/) + { + return EKeyWasNotConsumed; + } + +void CPaintCursorAppUi::HandleCommandL(TInt aCommand) + { + TRACE_INFO((_L("[PaintCursor]\t CPaintCursorAppUi::HandleCommandL(%d)"),aCommand)); + switch ( aCommand ) + { + case EEikCmdExit : + case EAknSoftkeyExit: + { + Exit(); + break; + } + + case EAknSoftkeyBack: + { + SendToBackground(); + break; + } + + default: + break; + } + } + +void CPaintCursorAppUi::SendToBackground() + { + // Construct en empty TApaTask object + // giving it a reference to the Window Server session + TApaTask task(CEikonEnv::Static()->WsSession( )); + + // Initialise the object with the window group id of + // our application (so that it represent our app) + task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); + + // Request window server to bring our application + // to background + task.SendToBackground(); + } + +void CPaintCursorAppUi::MouseCursorStatusChangedL(TInt aStatus) + { + + switch (aStatus) + { + case ECursorShow: + { + iAppView->ShowCursor(); + break; + } + case ECursorHide: + { + iAppView->HideCursor(); + break; + } + case ECursorNotInitialized: + { + EndTask(); + } + default: + { + break; + } + } + } + + +void CPaintCursorAppUi::EndTask() + { + // Construct en empty TApaTask object + // giving it a reference to the Window Server session + TApaTask task(CEikonEnv::Static()->WsSession( )); + + // Initialise the object with the window group id of + // our application (so that it represent our app) + task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); + + // Request window server to end our application + task.EndTask(); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2008 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 "paintcursorappview.h" +#include "pointmsgqueue.h" +#include "debug.h" + + +CPaintCursorAppView* CPaintCursorAppView::NewL(const TRect& aRect) + { + CPaintCursorAppView* self = CPaintCursorAppView::NewLC(aRect); + CleanupStack::Pop(self); + return self; + } + +CPaintCursorAppView* CPaintCursorAppView::NewLC(const TRect& aRect) + { + CPaintCursorAppView* self = new (ELeave) CPaintCursorAppView; + CleanupStack::PushL(self); + self->ConstructL(aRect); + return self; + } + +void CPaintCursorAppView::ConstructL(const TRect& aRect) + { + // Create a window for this application view + CreateWindowL(); + + // Set the windows size + SetRect(aRect); + + // Initialise the RMouseCursorDll class + TRACE_INFO(_L("[HID]\tCHidMouseDriver::Before SetupMouseCursorDllL()")); + SetupMouseCursorDllL(); + TRACE_INFO(_L("[HID]\tCHidMouseDriver::After SetupMouseCursorDllL()")); + // Initialise the RImageCommander class + SetupImageCommanderL(); + + // Activate the window, which makes it ready to be drawn + ActivateL(); + + ShowCursor(); + } + +// ----------------------------------------------------------------------------- +// CMenuAppUi::SetupMouseCursorDllL() +// Setup Mousr Cursor animation client Dll. +// ----------------------------------------------------------------------------- +// + +void CPaintCursorAppView::SetupMouseCursorDllL() + { + TRACE_INFO(_L("[HID]\tCHidMouseDriver::SetupMouseCursorDllL()")); + // Create the server dll filename + TFileName mouseCurorSrv( KMouseCurorSrvName ); + + // Load the animation server, if an error occurs then + // let higher level handle the problem + User::LeaveIfError( iMouseCursorDll.Load( mouseCurorSrv ) ); + } + + +// ----------------------------------------------------------------------------- +// CMenuAppUi::SetupImageCommanderL() +// Setup the animation image commander. +// ----------------------------------------------------------------------------- +// +void CPaintCursorAppView::SetupImageCommanderL() + { + TRACE_INFO(_L("[HID]\tCHidMouseDriver::SetupImageCommanderL()")); + // Tell client to construct a server side object + TSize iconRect(13,23); + iClientCommander.ImageConstructL( CCoeEnv::Static()->RootWin(), + iconRect ); + } + + +CPaintCursorAppView::CPaintCursorAppView() : + iMouseCursorDll( CCoeEnv::Static()->WsSession() ), + iClientCommander( iMouseCursorDll, CCoeEnv::Static()->WsSession() ) + { + // no implementation required + } + + +CPaintCursorAppView::~CPaintCursorAppView() + { + if ( iMouseInitialized ) + { + HideCursor(); + } + + // Close the animation object + iClientCommander.Close (); + + // Close the animation server + iMouseCursorDll.Close(); + } + +void CPaintCursorAppView::SizeChanged() + { + DrawNow(); + } + +void CPaintCursorAppView::Draw(const TRect& aRect) const + { + TRACE_INFO(_L("[PaintCursor]\t CPaintCursorAppView::Draw()")); + TRgb color; + + CWindowGc& gc = SystemGc(); + + // draw background + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + + // get skin text color + AknsUtils::GetCachedColor( skin, color , KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); + gc.SetPenColor( color ); + + MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); + AknsDrawUtils::Background( skin, cc, this, gc, aRect ); + } + +void CPaintCursorAppView::HideCursor() + { + if (iMouseInitialized) + { + iClientCommander.ImageCommand( KStopBTCursorAnim ); + } + + iMouseInitialized = EFalse; + } + +void CPaintCursorAppView::ShowCursor() + { + if (!iMouseInitialized) + { + iClientCommander.ImageCommand( KStartBTCursorAnim ); + } + + iMouseInitialized = ETrue; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursordocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursordocument.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2008 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 "paintcursordocument.h" +#include "paintcursorappui.h" + +CPaintCursorDocument::CPaintCursorDocument(CEikApplication& aApp) + : CAknDocument(aApp) + {} + +CPaintCursorDocument::~CPaintCursorDocument() + {} + +void CPaintCursorDocument::ConstructL() + {} + +CPaintCursorDocument* CPaintCursorDocument::NewL( + CEikApplication& aApp) // CPaintCursorApp reference + { + CPaintCursorDocument* self = new (ELeave) CPaintCursorDocument( aApp ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +CEikAppUi* CPaintCursorDocument::CreateAppUiL() + { + return new (ELeave) CPaintCursorAppUi; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/bwins/BTMouse_Animation_clientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/bwins/BTMouse_Animation_clientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,7 @@ +EXPORTS + ?ImageConstructL@RImageCommander@@QAEXAAVRWindowGroup@@VTSize@@@Z @ 1 NONAME ; void RImageCommander::ImageConstructL(class RWindowGroup &, class TSize) + ??0RMouseCursorDll@@QAE@AAVRWsSession@@@Z @ 2 NONAME ; RMouseCursorDll::RMouseCursorDll(class RWsSession &) + ??0RImageCommander@@QAE@AAVRAnimDll@@AAVRWsSession@@@Z @ 3 NONAME ; RImageCommander::RImageCommander(class RAnimDll &, class RWsSession &) + ??1RImageCommander@@UAE@XZ @ 4 NONAME ; RImageCommander::~RImageCommander(void) + ?ImageCommand@RImageCommander@@QAEXH@Z @ 5 NONAME ; void RImageCommander::ImageCommand(int) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/data/Thumbs.db Binary file bluetoothengine/bthid/mouse/Sesame_client/data/Thumbs.db has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/data/cursor.bmp Binary file bluetoothengine/bthid/mouse/Sesame_client/data/cursor.bmp has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp Binary file bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/eabi/BTMouse_Animation_clientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/eabi/BTMouse_Animation_clientu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,15 @@ +EXPORTS + _ZN15RImageCommander12ImageCommandEi @ 1 NONAME + _ZN15RImageCommander15ImageConstructLER12RWindowGroup5TSize @ 2 NONAME + _ZN15RImageCommanderC1ER8RAnimDllR10RWsSession @ 3 NONAME + _ZN15RImageCommanderC2ER8RAnimDllR10RWsSession @ 4 NONAME + _ZN15RImageCommanderD0Ev @ 5 NONAME + _ZN15RImageCommanderD1Ev @ 6 NONAME + _ZN15RImageCommanderD2Ev @ 7 NONAME + _ZN15RMouseCursorDllC1ER10RWsSession @ 8 NONAME + _ZN15RMouseCursorDllC2ER10RWsSession @ 9 NONAME + _ZTI11CPointQueue @ 10 NONAME ; ## + _ZTI15RImageCommander @ 11 NONAME ; ## + _ZTV11CPointQueue @ 12 NONAME ; ## + _ZTV15RImageCommander @ 13 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/group/animation_client.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/group/animation_client.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2004 - 2006 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 + +TARGET BTMouse_Animation_client.dll +TARGETTYPE dll + +// The second one is the UID of the client, different than main program's UID +UID 0x100039ce 0x2001FE5B + +CAPABILITY CAP_CLIENT_DLL + +VENDORID VID_DEFAULT +SECUREID 0xA000022D +EPOCSTACKSIZE 0x5000 + +USERINCLUDE ../inc +SYSTEMINCLUDE /epoc32/include +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE mousecursordll.cpp clientimagecommander.cpp + +START BITMAP BTMouseBitMaps.mbm +HEADER +TARGETPATH APP_BITMAP_DIR +SOURCEPATH ../data +SOURCE c8 cursor.bmp +SOURCE c8 cursormask.bmp +END + +LIBRARY euser.lib +LIBRARY ws32.lib +LIBRARY cone.lib +LIBRARY fbscli.lib +LIBRARY eikcore.lib + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2004 - 2006 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: +* +*/ + + +PRJ_PLATFORMS + +PRJ_MMPFILES +animation_client.mmp + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/inc/clientimagecommander.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/inc/clientimagecommander.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,215 @@ +/* +* Copyright (c) 2004 - 2006 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: + * +*/ + + +#ifndef __CLIENTIMAGE_COMMANDER_H__ +#define __CLIENTIMAGE_COMMANDER_H__ + +// INCLUDES +#include + +#include "pointmsgqueue.h" +// CLASS DECLARATION + +#define KWakeUpNeeded (5) + +class CPointQueue; + +class MPointHandler + { +public: + /** + * Handle Points from AnimDll + */ + virtual void HandlePointL(const TPoint& aPoint) = 0; + virtual void SendEventL(TPointerEvent::TType aEventType) = 0; + }; + +/** + * RImageCommander + * An instance of RImageCommander is an Animation Client Commander which + * sends commands to the Animation Server + */ +class RImageCommander : public RAnim, public MPointHandler + { +public: + // Constructors + + /** + * RImageCommander. + * Construct an Animation Client object for Animation Client DLL aAnimDll + * @param aAnimDll the Animation Client DLL to use + */ + IMPORT_C RImageCommander(RAnimDll& aAnimDll, RWsSession& aWsSession); + + /** + * ImageConstruct. + * Complete Animation Client construction + */ + IMPORT_C void ImageConstructL(RWindowGroup& aWindowGroup, TSize aSize); + + /** + * ~RImageCommander + */ + IMPORT_C ~RImageCommander(); + +public: + // from MPointHandler + + void HandlePointL(const TPoint& aPoint); + void SendEventL(TPointerEvent::TType aEventType); +private: + TInt SendPointerEvent(TPointerEvent::TType aEventType); + TRawEvent::TType PointerEventToRawEvent(TPointerEvent::TType aEventType); + void CreateSpriteL(TSize aSize, RWindowGroup& aGroup); + void FillInSpriteMember(TSpriteMember& aMember, CFbsBitmap* icon, + CFbsBitmap* iconMask); + TBool CheckCurrentPoint(); + TInt SendWakeUp(); + TBool RestrictPos(); + +public: + // New functions + + /** + * ImageCommand. + * Send aCommand to the Animation Server object; + * aCommand == KChangeCursor implies "change animation cursor". + * Note! Because there is no way to return an error from the server side + * using this method, it is important that any server side code for these + * commands should not be able to fail or leave. + * This command is also buffered and may not be performed immediately. + * @param aCommand the enumerated code for the option selected + */ + IMPORT_C void ImageCommand(TInt aCommand); + +public: + // Enumerations + + /** + * KAnimationTypes. + * Constant used to indicate the animation of a bouncing square should + * be created, enumeration can be expanded + */ + enum KAnimationTypes + { + KAnimationSquare = 1 + }; + + +private: + + RWsSession& iSession; + RWsSprite iSprite; + CFbsBitmap* iBaseBitmap; + CFbsBitmap* iBaseMaskBitmap; + + TPoint iCurrentPoint; + CPointQueue* iPointBufferQueue; + TBool iMouseButtonPressed; + TInt iWakeUpCalculator; + }; + +/** + * Class CPointQueue + * Event message queue. It's an active object. + * + * @since S60 v4.0 + */ + +class CPointQueue : public CActive + { +public: + /** + * factory constructor. + * + * @since S60 v4.0 + * @param aHandler The event handler. + * @param aName The event queue global name + * @return The created messge queue object + */ + static CPointQueue* NewL(MPointHandler* aHandler, const TDesC& aName); + /** + * desstructor. + * + * @since S60 v4.0 + */ + ~CPointQueue(); + + /** + * Request event. + * + * @since S60 v4.0 + */ + void GetPoint(); + +protected: + /** + * 2nd phase constructor. + * + * @since S60 v4.0 + * @aName The message queue name + */ + void ConstructL(const TDesC& aName); + /** + * Default construcotr. + * + * @since S60 v4.0 + * @aHandler The event handler + */ + CPointQueue(MPointHandler* aHandler); + + //From CActive + /** + * From CActive + * Called when there is event in the queue + * + * @since S60 v4.0 + */ + void RunL(); + + /** + * From CActive + * will be called if RunL leaves + * + * @since S60 v4.0 + * @param aError The error number + */ + TInt RunError(TInt aError); + + /** + * From CActive + * will be called when Cancel is issued + * + * @since S60 v4.0 + */ + void DoCancel(); + +private: + /** + * Message buffer queue + */ + RMsgQueue iPointBufQueue; + + /** + * Event handler + */ + MPointHandler* iHandler; + }; + +#endif // __CLIENTIMAGE_COMMANDER_H__ +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/inc/mousecursordll.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/inc/mousecursordll.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2004 - 2006 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: + * +*/ + + +#ifndef __MOUSECURSOR_DLL_H__ +#define __MOUSECURSOR_DLL_H__ + +// INCLUDES +#include + +// CLASS DECLARATION + +/** + * RMouseCursorDll. + * An instance of RMouseCursor is an Animation Client DLL, used to load + * and destroy the Animation Server + */ +class RMouseCursorDll : public RAnimDll + { +public: + + /** + * RMouseCursorDll. + * Construct an Animation Client DLL object for use with the + * aSession window server session. + * @param aSession the window server session to use + */ + IMPORT_C RMouseCursorDll(RWsSession& aSession); + }; + +#endif //__MOUSECURSOR_DLL_H__ +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006-2006 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: Peninput message queue header + * +*/ + +#ifndef __POINT_MSGQUE__ +#define __POINT_MSGQUE__ +#include +#define KPointQueueLen (1000) +#define KPMaxEvent (5) +_LIT(KMsgBTMouseBufferQueue,"BTMouseanimqueue"); + +const TInt KResetBuffer = -1; + +enum + { + KBufferPlainPointer = 0, KBufferPenDown, KBufferPenUp + }; + +/** + * KAnimationCommands. + * Constant used to request a reset of the bouncing square, + * enumeration can be expanded + */ +enum KAnimationCommands + { + KStartBTCursorAnim = 1, + KStopBTCursorAnim = 2, + KChangeCursor = 3, + KSendRawEvent = 4 + }; + +class TPointBuffer + { +public: + TInt iNum; + TInt iType[2 * KPMaxEvent]; + TPoint iPoint[2 * KPMaxEvent]; + }; +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,483 @@ +/* +* Copyright (c) 2004 - 2006 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 FILES + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "clientimagecommander.h" + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +_LIT( KBTMOUSEMBMFileName, "\\resource\\apps\\BTMouseBitMaps.mbm" ); + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RImageCommander::RImageCommander() +// Create a new animation object. +// ----------------------------------------------------------------------------- +// +EXPORT_C RImageCommander::RImageCommander( RAnimDll &aAnimDll, RWsSession& aWsSession ) : + RAnim( aAnimDll ), iSession(aWsSession), + iBaseBitmap(NULL), + iBaseMaskBitmap(NULL), + iMouseButtonPressed(EFalse), + iWakeUpCalculator(0) + { + DBG(RDebug::Print(_L("RImageCommander::RImageCommander"))); + + // No implementation required + } + +EXPORT_C RImageCommander::~RImageCommander( ) + { + iSprite.Close(); + + if ( iPointBufferQueue ) + { + delete iPointBufferQueue; + iPointBufferQueue = NULL; + } + + if ( iBaseBitmap) + { + delete iBaseBitmap; + iBaseBitmap = NULL; + } + + if ( iBaseMaskBitmap ) + { + delete iBaseMaskBitmap; + iBaseMaskBitmap = NULL; + } + RAnim::Close(); + } + +// ----------------------------------------------------------------------------- +// RImageCommander::ImageConstruct() +// Construct a new animation object. +// ----------------------------------------------------------------------------- +// +EXPORT_C void RImageCommander::ImageConstructL( RWindowGroup& aWindowGroup, TSize aSize ) + { + // Send the parameters to the animation server object construction + + DBG(RDebug::Print(_L("RImageCommander::ImageConstructL IN"))); + + iPointBufferQueue = NULL; + iPointBufferQueue = CPointQueue::NewL(this,KMsgBTMouseBufferQueue); + + CreateSpriteL(aSize, aWindowGroup); + + DBG(RDebug::Print(_L("RImageCommander::ImageConstructL Construct Anim"))); + + TPtrC8 des(NULL,0); + RAnim::Construct( iSprite, 0, des ); + + DBG(RDebug::Print(_L("RImageCommander::ImageConstructL OUT"))); + } + +// ---------------------------------------------------------------------------- +// RImageCommander::CreateSpriteL(TSize aSize, RWindowGroup& aGroup) +// ---------------------------------------------------------------------------- +// +void RImageCommander::CreateSpriteL(TSize aSize, RWindowGroup& aGroup) + { + DBG(RDebug::Print(_L("RImageCommander::CreateSpriteL START"))); + TSpriteMember member; + + + DBG(RDebug::Print(_L("RImageCommander::CreateSpriteL size %d,%d"), aSize.iWidth, aSize.iHeight)); + (void)aSize; + + iSprite=RWsSprite(iSession); + TInt error = iSprite.Construct(aGroup, TPoint(),ESpriteNoChildClip|ESpriteNoShadows); + User::LeaveIfError(error); + iBaseBitmap = new (ELeave) CFbsBitmap; + // Drive Letter: + TFileName file(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2)); + // Path and file name: + file.Append( KBTMOUSEMBMFileName ); // always safe + + User::LeaveIfError(iBaseBitmap->Load(file, EMbmBtmousebitmapsCursor)); + iBaseMaskBitmap = new (ELeave) CFbsBitmap; + User::LeaveIfError(iBaseMaskBitmap->Load(file, EMbmBtmousebitmapsCursormask)); + FillInSpriteMember(member, iBaseBitmap, iBaseMaskBitmap); + User::LeaveIfError(iSprite.AppendMember(member)); + + DBG(RDebug::Print(_L("RImageCommander::CreateSpriteL END"))); + + } + +// ---------------------------------------------------------------------------- +// RImageCommander::FillInSpriteMember(TSpriteMember& aMember, CFbsBitmap* icon, CFbsBitmap* iconMask) +// ---------------------------------------------------------------------------- +// +void RImageCommander::FillInSpriteMember(TSpriteMember& aMember, CFbsBitmap* icon, CFbsBitmap* iconMask) + { + DBG(RDebug::Print(_L("RImageCommander::FillInSpriteMember")); + + if ( ( icon == NULL) || ( iconMask == NULL) ) + { + RDebug::Print(_L("RImageCommander::FillInSpriteMember no icons !")); + } + ) + aMember.iBitmap=icon; + aMember.iMaskBitmap=iconMask; + aMember.iInvertMask=EFalse; + aMember.iDrawMode = CGraphicsContext::EDrawModeWriteAlpha; + aMember.iOffset=TPoint(0,0); + + DBG(RDebug::Print(_L("RImageCommander::FillInSpriteMember END"))); + + } + +// ----------------------------------------------------------------------------- +// RImageCommander::ImageCommand() +// Send a command (aCommand) to the animation server object. +// Because there is no way to return an error from the server side using this +// method, it is important that any server side code for these commands should +// not be able to fail or leave. If the operation can fail, then the method +// TInt CommandReply(TInt aOpcode) should be used instead +// ----------------------------------------------------------------------------- +// +EXPORT_C void RImageCommander::ImageCommand( TInt aCommand ) + { + // Could optionally decode the commands here + DBG(RDebug::Print(_L("RImageCommander::ImageCommand %d"), aCommand)); + + RAnim::Command( aCommand ); + + DBG(RDebug::Print(_L("RImageCommander::ImageCommand OUT"))); + + } + +TRawEvent::TType RImageCommander::PointerEventToRawEvent(TPointerEvent::TType aEventType) + { + TRawEvent::TType aType; + switch(aEventType) + { + case TPointerEvent::EButton1Down: + { + aType=TRawEvent::EButton1Down; + break; + } + case TPointerEvent::EButton1Up: + { + aType=TRawEvent::EButton1Up; + break; + } + case TPointerEvent::EMove: + { + aType=TRawEvent::EPointerMove; + break; + } + case TPointerEvent::ESwitchOn: + { + aType=TRawEvent::EPointerSwitchOn; + break; + } + default: + { + aType=TRawEvent::ENone; + break; + } + } + return aType; + } + +TInt RImageCommander::SendPointerEvent(TPointerEvent::TType aEventType) + { + DBG(RDebug::Print(_L("RImageCommander::SendPointerEvent"))); + + TRawEvent rawEvent; + TPoint point(iCurrentPoint); + TRawEvent::TType type = PointerEventToRawEvent(aEventType); + rawEvent.Set(type, point.iX, point.iY, 30); + typedef TPckgBuf< TRawEvent > TRawEventDataPckg; + TRawEventDataPckg rawEventPckg(rawEvent); + RAnim::Command( KSendRawEvent, rawEventPckg ); + return KErrNone; + } + + +TBool RImageCommander::RestrictPos() + { + TBool notInScreen(EFalse); + TPixelsAndRotation sizeAndRotation; + sizeAndRotation.iPixelSize.SetSize(360,640); // Just a guess + CWsScreenDevice* screen(CEikonEnv::Static()->ScreenDevice()); + if (screen) + { + TInt mode(screen->CurrentScreenMode()); + screen->GetScreenModeSizeAndRotation(mode, sizeAndRotation); + } + TRect validRect(sizeAndRotation.iPixelSize); + if (! validRect.Contains(iCurrentPoint)) + { + notInScreen = ETrue; + if (iCurrentPoint.iX<0) + iCurrentPoint.iX=0; + else if (iCurrentPoint.iX>=validRect.iBr.iX) + iCurrentPoint.iX=validRect.iBr.iX-1; + + if (iCurrentPoint.iY<0) + iCurrentPoint.iY=0; + else if (iCurrentPoint.iY>=validRect.iBr.iY) + iCurrentPoint.iY=validRect.iBr.iY-1; + } + return notInScreen; + } + +inline TBool RImageCommander::CheckCurrentPoint() + { + DBG(TPoint pos(iCurrentPoint)); + + TBool outSide(RestrictPos()); + + DBG( + if (outSide) + { + RDebug::Print(_L("RImageCommander::CheckCurrentPoint not in screen (%d,%d)"), pos.iX, pos.iY); + } + ) + return outSide; + } + +TInt RImageCommander::SendWakeUp() + { + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::ESwitchOn); + return UserSvr::AddEvent(rawEvent); + } + +void RImageCommander::HandlePointL(const TPoint& aPoint) + { + DBG(RDebug::Print(_L("RImageCommander::HandlePointL pos (%d,%d)"), + aPoint.iX, aPoint.iY)); + + if ( ( aPoint.iX != 0) || ( aPoint.iY != 0) ) + { + iCurrentPoint += aPoint; + TBool notInScreen(CheckCurrentPoint()); + if (iMouseButtonPressed) + { + // Dragging possible now: + if (notInScreen) + { + SendPointerEvent(TPointerEvent::EButton1Up); + iMouseButtonPressed = EFalse; + } + else + { + SendPointerEvent(TPointerEvent::EMove); + } + } + else + { + typedef TPckgBuf< TPoint > TPointDataPckg; + TPointDataPckg pointPckg(iCurrentPoint); + RAnim::Command( KChangeCursor, pointPckg ); + } + } + iWakeUpCalculator++; + if (iWakeUpCalculator > KWakeUpNeeded) + { + SendWakeUp(); + iWakeUpCalculator = 0; + } + } + +void RImageCommander::SendEventL(TPointerEvent::TType aEventType) + { + DBG(RDebug::Print(_L("RImageCommander::SendEventL (%d)"), aEventType)); + + if (aEventType == TPointerEvent::EButton1Down) + { + iMouseButtonPressed = ETrue; + SendWakeUp(); + } + else if (aEventType == TPointerEvent::EButton1Up) + { + iMouseButtonPressed = EFalse; + } + SendPointerEvent(aEventType); + } + +// ======== class CPointQueue======== +// +// --------------------------------------------------------------------------- +// CPointQueue::CPointQueue +// Constructor. Adds the active object to the active scheduler +// and issues a request for server notification. +// --------------------------------------------------------------------------- +// + +CPointQueue::CPointQueue(MPointHandler* aHandler):CActive( EPriorityHigh ), + iHandler(aHandler) + { + // issue asynchronous request and set this object active + DBG(RDebug::Print(_L("(CCPointQueue::CPointQueue"))); + + CActiveScheduler::Add( this ); + + DBG( RDebug::Print(_L("(CCPointQueue::CPointQueue Out"))); + + } + +// --------------------------------------------------------------------------- +// CPointQueue::NewL +// factory constructor. +// --------------------------------------------------------------------------- +// +CPointQueue* CPointQueue::NewL(MPointHandler* aHandler,const TDesC& aName) + { + DBG(RDebug::Print(_L("(CCPointQueue::NewL"))); + + CPointQueue* queue = new(ELeave)CPointQueue(aHandler); + CleanupStack::PushL(queue); + queue->ConstructL(aName); + CleanupStack::Pop(queue); + // Start receiving: + queue->GetPoint(); + + DBG(RDebug::Print(_L("(CCPointQueue::NewL Out"))); + + return queue; + } + +// --------------------------------------------------------------------------- +// CPointQueue::ConstructL +// 2nd phase constructor +// --------------------------------------------------------------------------- +// +void CPointQueue::ConstructL(const TDesC& aName) + { + (void) aName; + //Open message queue + TInt err = iPointBufQueue.OpenGlobal(KMsgBTMouseBufferQueue); + if (err == KErrNotFound) + { + User::LeaveIfError(iPointBufQueue.CreateGlobal(KMsgBTMouseBufferQueue, KPointQueueLen)); + } + else + { + User::LeaveIfError( err ); + } + } +// --------------------------------------------------------------------------- +// CPointQueue::CPointQueue +// Destructor. Cancels any outstanding requests +// --------------------------------------------------------------------------- +// +CPointQueue::~CPointQueue() + { + Cancel(); + iPointBufQueue.Close(); + } + +// --------------------------------------------------------------------------- +// CPointQueue::DoCancel +// Cancels the notification requests +// --------------------------------------------------------------------------- +// +void CPointQueue::DoCancel() + { + iPointBufQueue.CancelDataAvailable(); + } + +// --------------------------------------------------------------------------- +// CPointQueue::RunL +// --------------------------------------------------------------------------- +// +void CPointQueue::RunL() + { + DBG(RDebug::Print(_L("CCPointQueue::RunL"))); + + TInt ret; + //iHandler is always there. No need to check it + TPointBuffer points; + ret = iPointBufQueue.Receive(points); + DBG(RDebug::Print(_L("CCPointQueue::RunL , ret = %d, points %d"), ret, points.iNum)); + + if (ret == KErrNone) + { + TPoint pos(0,0); + for(TInt ii = 0; ii < points.iNum; ii++) + { + pos += points.iPoint[ii]; + if ( ( points.iType[ii] == KBufferPenDown ) || + ( points.iType[ii] == KBufferPenUp ) ) + { + iHandler->SendEventL( ( points.iType[ii] == KBufferPenDown ) ? + TPointerEvent::EButton1Down : + TPointerEvent::EButton1Up ); + iHandler->HandlePointL(pos); + pos.SetXY(0,0); + } + } + iHandler->HandlePointL(pos); + } + // re-issue request + GetPoint(); + } + +// --------------------------------------------------------------------------- +// CPointQueue::RunError +// --------------------------------------------------------------------------- +// +TInt CPointQueue::RunError(TInt /*aError*/) + { + DBG(RDebug::Print(_L("CCPointQueue::RunError"))); + // re-issue request + GetPoint(); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CPointQueue::GetPoint +// Reissue request for point +// --------------------------------------------------------------------------- +// +void CPointQueue::GetPoint() + { + DBG(RDebug::Print(_L("CCPointQueue::GetPoint"))); + + if(!IsActive()) + { + iPointBufQueue.NotifyDataAvailable(iStatus); + SetActive(); + } + DBG(RDebug::Print(_L("CCPointQueue::GetPoint Out"))); + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_client/src/mousecursordll.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_client/src/mousecursordll.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2004 - 2006 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 FILES +#include "mousecursordll.h" + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RMouseCursorDll::RMouseCursorDll() +// Animation client dll construction code all encapsulated in original class. +// ----------------------------------------------------------------------------- +// +EXPORT_C RMouseCursorDll::RMouseCursorDll( RWsSession& aSession ) + : RAnimDll( aSession ) + { + DBG(RDebug::Print(_L("RMouseCursorDll::RMouseCursorDll"))); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/bwins/btcursor_serveru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/bwins/btcursor_serveru.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,4 @@ +EXPORTS + ?CreateCAnimDllL@@YAPAVCAnimDll@@XZ @ 1 NONAME ; class CAnimDll * CreateCAnimDllL(void) + ?CreateInstanceL@CMouseCursorSrv@@UAEPAVCAnim@@H@Z @ 2 NONAME ; class CAnim * CMouseCursorSrv::CreateInstanceL(int) + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/eabi/btcursor_serveru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/eabi/btcursor_serveru.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,7 @@ +EXPORTS + _Z15CreateCAnimDllLv @ 1 NONAME + _ZTI15CMouseCursorSrv @ 2 NONAME ; ## + _ZTI6CImage @ 3 NONAME ; ## + _ZTV15CMouseCursorSrv @ 4 NONAME ; ## + _ZTV6CImage @ 5 NONAME ; ## + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2004 - 2006 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 + +TARGET BTcursor_server.dll +TARGETTYPE ani + +// The second one is the UID of the server, different than main program's UID +UID 0x10003b22 0x2001FE5A + +CAPABILITY CAP_CLIENT_DLL +VENDORID VID_DEFAULT + +DEFFILE btcursor_server.def + +SECUREID 0xA000022E +EPOCSTACKSIZE 0x5000 + +USERINCLUDE ../../Sesame_client/inc +USERINCLUDE ../inc +SYSTEMINCLUDE /epoc32/include +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE mousecursorsrv.cpp mousecursorimage.cpp + + +LIBRARY euser.lib +LIBRARY fbscli.lib +LIBRARY bitgdi.lib +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2004 - 2006 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: +* +*/ + + + +PRJ_PLATFORMS + +PRJ_MMPFILES +animation_server.mmp + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/inc/animation.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/inc/animation.pan Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2004 - 2006 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: + * +*/ + + +#ifndef __ANIMATION_PAN__ +#define __ANIMATION_PAN__ + +/** Panic Category */ +_LIT( KAnimation, "Animation" ); + +/** Animation application panic codes */ +enum TAnimationPanics + { + EPanicAnimationUi = 100, + EPanicAnimationServer, + EPanicAnimationAnimate + }; + +#endif // __ANIMATION_PAN__ +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorimage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorimage.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2004 - 2006 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: + * +*/ + + +#ifndef __MOUSECURSORIMAGE_H__ +#define __MOUSECURSORIMAGE_H__ + +// INCLUDES +#include +#include "pointmsgqueue.h" + +// CONSTANTS + +// Pixels the animation moves each timer event +static const TInt KStepSize = 15; + +// The timer timeout resolution +#define KTimerPeriod (50000) + +// CLASS DECLARATION + +/** + * CImage. + * An instance of class CImage encapsulates the functionality + * of the bouncing square on the screen. + */ +class CImage : public CSpriteAnim + { + +public: + // Constructors and destructors + + /** + * CImage() + * Construct the object, forced to be public. + */ + CImage(); + + /** + * ~CImage() + * Virtual destructor. + */ + virtual ~CImage(); + +public: + // From CSpriteAnim + + /** + * ConstructL() + * Complete animation server object construction + * (called by windows server). + * @param aArgs any arguments required during construction + * (passed from client through window server) + */ + void ConstructL(TAny* aArgs); + + /** + * CommandReplyL() + * Perform aCommand with optional additional arguments aArgs and + * return a reply (called by windows server). + * Note! This method can return an error, so any actions that can leave + * should use this method and not Command (). + * This command is not buffered and so requests from the client side are + * performed immediately. For these reason these functions should + * not take a long time. + * @param aCommand the command to perform + * @param aArgs any additional arguments required. + */ + TInt CommandReplyL(TInt aCommand, TAny* aArgs); + + /** + * Command() + * Perform aCommand with optional additional arguments aArgs. + * Note! Because there is no way to return an error from this method, it + * is important that these commands should not be able to fail or leave. + * This command is buffered and so may have been requested by the client + * side an unknown period ago. + * @param aCommand the command to perform + * @param aArgs any additional arguments required + */ + void Command(TInt aCommand, TAny* aArgs); + + /** + * Animate() + * Animate the object, normally called by the Windows Server + * at a fixed period + */ + void Animate(TDateTime* aDateTime); + + /** + * FocusChanged() + * Handle the event when the focus changes. + * @param aState TRUE if the Animation Server has focus + */ + void FocusChanged(TBool aState); + + /** + * OfferRawEvent() + * For handling raw events. Not used in this example so return false. + */ + TBool OfferRawEvent(const TRawEvent &aRawEvent); + +private: + void DrawCursor(); + +private: + // Data + CFbsBitmapDevice* iBitmapDevice; + CFbsBitmapDevice* iBitmapMaskDevice; + CFbsBitGc* iSpriteGc; + CFbsBitmap* iCursorBitmap; + CFbsBitmap* iCursorBitmapMask; + }; + +#endif // __MOUSECURSORIMAGE_H__ +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorsrv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorsrv.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2004 - 2006 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: + * +*/ + + +#ifndef __MOUSECURSORSRV_H__ +#define __MOUSECURSORSRV_H__ + +// INCLUDES +#include + +// CLASS DECLARATION + +/** + * CMouseCursorSrv. + * An instance of CMouseCursorSrv is a 'factory' object which creates a new + * instance of CAnim + */ +class CMouseCursorSrv : public CAnimDll + { +public: + // Constructor + + /** + * CMouseCursorSrv. + * Construct an Animation Server dll for mouse cursor + */ + CMouseCursorSrv(); + + // Public destructor not created as this class does not own any data + +public: + // From CAnimDll + /** + * CreateInstanceL. + * Create an instance of the Animation Server image aType. + * @param aType KAnimationSquare implies "construct a bouncing square" + */ + IMPORT_C CAnim* CreateInstanceL(TInt aType); + + }; + +#endif // __MOUSECURSORSRV_H__ +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,212 @@ +/* +* Copyright (c) 2004 - 2006 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 FILES +#include +#include +#include + +#include "mousecursorimage.h" +#include "animation.pan" + + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +// ============================ MEMBER FUNCTIONS =============================== + +// Animation server object class functions. +// These functions are called by the windows server from +// requests made by the client animation dll. + +// ----------------------------------------------------------------------------- +// CImage::CImage() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CImage::CImage() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CImage::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CImage::ConstructL( TAny* /* aArgs */ ) + { + DBG(RDebug::Print(_L(" CImage::ConstructL"))); + // Initialise starting points to the top left hand corner + iFunctions->GetRawEvents( EFalse ); + + TSpriteMember* spriteMember = iSpriteFunctions->GetSpriteMember(0); + + DBG(RDebug::Print(_L(" CImage::ConstructL mainbitmap"))); + if (spriteMember == NULL) + { + DBG(RDebug::Print(_L(" CImage::ConstructL No member !!!!"))); + User::Leave(KErrNotReady); + } + + iBitmapDevice = CFbsBitmapDevice::NewL(spriteMember->iBitmap); + + DBG(RDebug::Print(_L(" CImage::ConstructL maskbitmap"))); + + iBitmapMaskDevice = CFbsBitmapDevice::NewL(spriteMember->iMaskBitmap); + iSpriteGc = CFbsBitGc::NewL(); + + DBG(RDebug::Print(_L(" CImage::ConstructL DuplicateBitmaps"))); + + iCursorBitmap = iFunctions->DuplicateBitmapL(spriteMember->iBitmap->Handle()); + iCursorBitmapMask = iFunctions->DuplicateBitmapL(spriteMember->iMaskBitmap->Handle()); + + iSpriteGc->Reset(); + iSpriteFunctions->SetPosition(TPoint()); + iSpriteFunctions->SizeChangedL(); + + // Set the screen visible + // We are using a timer, not the built in synchronising, so turn it off + iFunctions->SetSync( MAnimGeneralFunctions::ESyncNone ); + + DBG(RDebug::Print(_L(" CImage::ConstructL Done"))); + } + + +// ----------------------------------------------------------------------------- +// CPointerAnim::OfferRawEvent(const TRawEvent& aRawEvent) +// ----------------------------------------------------------------------------- +TBool CImage::OfferRawEvent(const TRawEvent& aRawEvent) + { + (void) aRawEvent; + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CImage::~CImage() +// Destructor. +// ----------------------------------------------------------------------------- +// +CImage::~CImage() + { + delete iBitmapDevice; + delete iBitmapMaskDevice; + delete iSpriteGc; + } + +// ----------------------------------------------------------------------------- +// CImage::FocusChanged() +// Not bothered if the focus has changed. +// ----------------------------------------------------------------------------- +// +void CImage::FocusChanged( TBool /* aState */ ) + {} + +// ----------------------------------------------------------------------------- +// CImage::Animate() +// Animate the animation server object. +// ----------------------------------------------------------------------------- +// +void CImage::Animate( TDateTime* /* aDateTime */ ) + { + } + +// ----------------------------------------------------------------------------- +// CImage::CommandReplyL() +// Function to be used for nonbuffered commands. Not used in this example. +// ----------------------------------------------------------------------------- +// +TInt CImage::CommandReplyL( TInt aOpcode, TAny* /* aArgs */ ) + { + return aOpcode; + } + +void CImage::DrawCursor( ) + { + DBG(RDebug::Print(_L(" CImage::DrawCursor Start"))); + + iSpriteGc->SetPenStyle(CGraphicsContext::ESolidPen); + iSpriteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iSpriteGc->SetBrushColor(TRgb(255,255,255)); + iSpriteGc->SetPenColor(TRgb(255,255,255)); + + if ( (iBitmapDevice) && (iBitmapMaskDevice) ) + { + DBG(RDebug::Print(_L(" CImage::DrawCursor iBitmapMaskDevice"))); + // Draw mask + iSpriteGc->Activate(iBitmapMaskDevice); + iSpriteGc->BitBlt(TPoint(0,0), iCursorBitmapMask); + + DBG(RDebug::Print(_L(" CImage::DrawCursor iBitmapMaskDevice"))); + + // Draw bitmap + iSpriteGc->Activate(iBitmapDevice); + iSpriteGc->BitBlt(TPoint(0,0), iCursorBitmap); + } + DBG(RDebug::Print(_L(" CImage::DrawCursor END"))); + } + +// ----------------------------------------------------------------------------- +// CImage::Command() +// Function for buffered commands and commands that cannot fail/leave. +// ----------------------------------------------------------------------------- +// +void CImage::Command( TInt aOpcode, TAny* aArgs ) + { + DBG(RDebug::Print(_L("CImage::Command %d"), aOpcode )); + + switch ( aOpcode ) + { + case KStartBTCursorAnim: + { + iSpriteFunctions->Activate(ETrue); + DrawCursor(); + } + break; + + case KStopBTCursorAnim: + { + iSpriteFunctions->Activate(EFalse); + } + break; + case KChangeCursor: + { + TPoint pos = *(TPoint *)aArgs; + iSpriteFunctions->SetPosition(pos); + } + break; + case KSendRawEvent: + { + TRawEvent rawEvent = *(TRawEvent *)aArgs; + iSpriteFunctions->SetPosition(rawEvent.Pos()); + iFunctions->PostRawEvent( rawEvent ); + } + break; + default: + User::Panic( KAnimation, EPanicAnimationServer ); + break; + } + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorsrv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorsrv.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2004 - 2006 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 FILES +#include "mousecursorsrv.h" +#include "mousecursorimage.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CMouseCursorSrv::CMouseCursorSrv() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CMouseCursorSrv::CMouseCursorSrv() + : CAnimDll() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CMouseCursorSrv::CreateInstanceL() +// Used to create an instance of animation server object. +// ----------------------------------------------------------------------------- +// +CAnim* CMouseCursorSrv::CreateInstanceL( TInt /* aType */ ) + { + // The aType variable can be used to set what type of animation object + // should be created but this example only has 1 type so it is ignored. + return ( new ( ELeave ) CImage ); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// CreateCAnimDllL() +// Create instance of the animation server dll. Called by windows server +// framework +// ----------------------------------------------------------------------------- +// +EXPORT_C CAnimDll* CreateCAnimDllL() + { + return ( new ( ELeave ) CMouseCursorSrv ); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2008 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 "../hidmousedriver/group/bld.inf" +#include "../Sesame_client/group/bld.inf" +#include "../Sesame_server/group/bld.inf" +#include "../PaintCursor/group/bld.inf" diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/data/hidmouse.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/data/hidmouse.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2008 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: ECOM plugin resource file for mouse driver. +* +*/ + +#include +#include "hiduids.h" + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = MOUSE_UID; + interfaces = + { + INTERFACE_INFO + { + interface_uid = DRIVER_PLUGIN_IF; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = MOUSE_DRIVER_IMP; + version_no = 1; + display_name = "HID Mouse Driver Plugin"; + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2008 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 + +PRJ_MMPFILES +mouse.mmp + +PRJ_PLATFORMS +WINSCW ARMV5 + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/group/mouse.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/group/mouse.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2008 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 "../../../inc/hiduids.h" + +TARGET hidmouse.dll +TARGETTYPE PLUGIN +UID ECOM_UID MOUSE_UID + +CAPABILITY CAP_APPLICATION +VENDORID VID_DEFAULT + + +USERINCLUDE ../inc +USERINCLUDE ../../../inc +USERINCLUDE ../../../common/inc +USERINCLUDE ../../Sesame_client/inc + +SOURCEPATH ../src +SOURCE mouse.cpp +SOURCE finder.cpp +SOURCE hidmousedriverproxy.cpp + + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../../../../inc + +SOURCEPATH ../data +START RESOURCE hidmouse.rss +#ifdef SYMBIAN_SECURE_ECOM +TARGET hidmouse.rsc +#endif +END // ECOM resource definition + +LIBRARY apgrfx.lib +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY ws32.lib +LIBRARY kbdclient.lib +LIBRARY generichid.lib +LIBRARY apparc.lib +DEBUGLIBRARY flogger.lib + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/inc/finder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/inc/finder.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __FINDER_H +#define __FINDER_H + +#include +#include "hidreportroot.h" + +// ---------------------------------------------------------------------- + +/** + * Field finder for the ordinary mouse fields. + */ +class TMouseFinder : public MHidFieldFinder + { +public: + // From MHidFieldFinder + virtual TBool BeginCollection(const CCollection *aCollection); + virtual TBool EndCollection(const CCollection *aCollection); + virtual void Field(const CField* aField); + +public: + /** Constructor */ + TMouseFinder(); + + /** + * Get the field containing the standard keys, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* ButtonsField() const; + /** + * Get the field containing the xy field, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* XYField() const; + /** + * Get the field containing the wheel info, if found. + * @return CField* Pointer to the field, or NULL. + */ + inline const CField* WheelField() const; + /** + * Check whether the required fields have been found. + * @return ETrue if they have. + */ + inline TBool Found() const; + + /** + * Check whether a given field contains the XY Coordinates + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsXY(const CField* aField) const; + /** + * Check whether a given field contains the Buttons. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsButtons(const CField* aField) const; + /** + * Check whether a given field contains a wheel. + * @param aField Pointer to the field to test. + * @return ETrue if it does. + */ + TBool IsWheel(const CField* aField) const; + +private: + /** Pointer to the field containing the XY pointer info. */ + const CField* iXY; + + /** Pointer to the field containing the buttons. */ + const CField* iButtons; + + /** Pointer to the field containing the Wheel info. */ + const CField* iWheel; + + /** Pointer to the top level application collection being searched. */ + const CCollection* iAppCollection; + }; +// ---------------------------------------------------------------------- + +inline TBool TMouseFinder::Found() const + { + // Standard and modifier key fields are always necessary, but the + // Wheel field is optional: + // + return iButtons && iXY; + } + +inline const CField* TMouseFinder::ButtonsField() const + { + return iButtons; + } + +inline const CField* TMouseFinder::XYField() const + { + return iXY; + } + +inline const CField* TMouseFinder::WheelField() const + { + return iWheel; + } + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/inc/mouse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/inc/mouse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,201 @@ +/* +* Copyright (c) 2008 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: Declares main application class. + * +*/ + + +#ifndef __MOUSE_H +#define __MOUSE_H + +#include +#include + +#include +#include +#include "pointmsgqueue.h" + +#include "hidinterfaces.h" + +class CField; +class CHidMouseDriver; + +/*! + HID mouse driver class + */ +class CHidMouseDriver : public CHidDriver //public CHidDriverPluginInterface + { + +private: + /*! Initialisation states */ + enum TMouseDriverState + { + EUninitialised, /*!< Driver has not been initialised */ + EInitialised, /*!< Driver is initialised */ + EDisabled + /*!< The driver will not respond to interrupt data */ + }; + +private: + TMouseDriverState iDriverState; + TInt iConnectionId; + TInt iAppMenuId; + +public: + /*! + Creates an instantiated CHidMouseDriver object. + @param aHid The generic HID layer that requested the driver + @param aFactory aFactory The factory that created the driver + @result A pointer to the instantiated keyboard driver + */ + static CHidMouseDriver* NewL(MDriverAccess* aHid); + /*! + Creates an instantiated CHidMouseDriver object and leaves it on the + cleanup stack. + @param aHid The generic HID layer that requested the driver + @param aFactory aFactory The factory that created the driver + @result A pointer to the instantiated keyboard driver + */ + static CHidMouseDriver* NewLC(MDriverAccess* aHid); + + /*! + Stops driver activity, deletes the key repeat and decode objects and closes + the window server session before the driver is deleted + */ + virtual ~CHidMouseDriver(); + + /*! + Called by the Generic HID layer to see if the driver can is able to use + reports from a newly-connected device + @result ETrue The driver can handle the reports + @result EFalse The driver cannot handle the reports + */ + virtual TInt CanHandleReportL(CReportRoot* aReportRoot); + + /*! + Called by the Generic HID layer when a device has been removed, prior to the + driver being removed. This allows the driver to notify any applications of + disconnection, if required + @param aReason The reason for device disconnection + */ + virtual void Disconnected(TInt aReason); + + /*! + Called by the Generic HID layer when data has been received from the device + handled by this driver. + @param aChannel The channel on which the data was received (as defined by the + transport layer + @param aPayload A pointer to the data buffer + */ + virtual TInt DataIn(CHidTransport::THidChannelType aChannel, + const TDesC8& aPayload); + + /*! + Called by the transport layers to inform the generic HID of the success of + the last Set... command. + @param aConnectionId ID of the device + @param aCmdAck Status of the last Set... command + */ + virtual void CommandResult(TInt aCmdAck); + + /*! + Called after a driver is sucessfully created by the Generic HID, when a + device is connected + */ + virtual void InitialiseL(TInt aConnectionId); + + /*! + Resets the internal state of the driver (any pressed keys are released) and + enables the driver + */ + virtual void StartL(TInt aConnectionId); + /*! + Cancels all pressed keys and disables the driver (so it will not + process interrupt data) + */ + virtual void Stop(); + + virtual TInt SupportedFieldCount(); + + /** + * Set input handling registy + * + * @since S60 v5.0 + * @param aHandlingReg a Input handling registry + */ + virtual void SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg); + +private: + // Constructor taking a pointer to the HID layer requesting the driver + // instance + CHidMouseDriver(MDriverAccess* aHid); + + void ConstructL(); + +private: + // The types of keyboard input report fields that we handle: + enum TKeyFieldType + { + EButtons = 0, + EXY = 1, + EWheel = 2, + EMediaKeys = 3, + EPowerKeys = 4, + KNumInputFieldTypes + }; + +private: + // Called from within DataIn to handle interrupt and control channel data + void InterruptData(const TDesC8& aPayload); + + // Handles the states of the XY (mouse up, down, left, right) + void UpdateXY(TInt aFieldIndex, const TDesC8& aReport); + + // Handles the states of the Buttons (left & right button) + void UpdateButtons(TInt aFieldIndex, const TDesC8& aReport); + + // Handles the states of the wheel + void UpdateWheel(TInt aFieldIndex, const TDesC8& aReport); + + void MoveCursor(const TPoint& aPoint); + TInt PostPointer(const TPoint& aPoint); + TInt SendButtonEvent(TBool aButtonDown); + + void LaunchApplicationL(const TDesC& aName); + //void LaunchApplicationL(TInt aAppUid); + +private: + // The Generic HID layer + MDriverAccess *iGenericHid; + + // Pointers to the fields in the report descriptor containing the + // various types of key: + const CField* iField[KNumInputFieldTypes]; + + //Supported field types count + TInt iSupportedFieldCount; + + CHidInputDataHandlingReg* iInputHandlingReg; + RMsgQueue iPointBufQueue; + TPointBuffer iPointerBuffer; + TBool iButtonDown; + TBool iButton2Down; + + // A window server session, so keypresses can be sent to applications: + RWsSession iWsSession; + }; + +// ---------------------------------------------------------------------- + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/src/finder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/src/finder.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include + +#include "finder.h" + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +// ---------------------------------------------------------------------- + + +TMouseFinder::TMouseFinder() + : iXY(0), iButtons(0), iWheel(0), iAppCollection(0) + { + // Nothing else to do + } + +// ---------------------------------------------------------------------- + +TBool TMouseFinder::BeginCollection(const CCollection *aCollection) + { + TBool examineCollection = ETrue; + + if ((aCollection->IsApplication()) && (iAppCollection == 0)) + { + // Top-level application collection. + + if ((aCollection->UsagePage() == EUsagePageGenericDesktop) + && (aCollection->Usage() == EGenericDesktopUsageMouse)) + { + // Collection is a mouse device: + iAppCollection = aCollection; + iXY = iWheel = iButtons = 0; + } + else + { + // Skip other types of top-level application collection: + examineCollection = EFalse; + } + } + + return examineCollection; + } + +TBool TMouseFinder::EndCollection(const CCollection *aCollection) + { + TBool continueSearch = ETrue; + + DBG(RDebug::Print(_L("[HID]\tTHeadsetFinder::EndCollection"))); + if (aCollection == iAppCollection) + { + // Top-level application(Generic Desktop:Mouse) finished: + // + iAppCollection = 0; + + // Stop if we've found a mouse we can use in this + // application collection: + // + continueSearch = !Found(); + } + + return continueSearch; + } + +void TMouseFinder::Field(const CField* aField) + { + if (iAppCollection) + { + if (IsWheel(aField)) + { + iWheel = aField; + } + + if (IsXY(aField)) + { + iXY = aField; + } + + if (IsButtons(aField)) + { + iButtons = aField; + } + } + } + +// ---------------------------------------------------------------------- + + +TBool TMouseFinder::IsXY(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && + (aField->UsagePage() == EUsagePageGenericDesktop)) + { + + if ( aField->HasUsage(EGenericDesktopUsageX) && + aField->HasUsage(EGenericDesktopUsageY) ) + { + DBG(RDebug::Print(_L("[HID]\tXY field found"))); + found = ETrue; + } + } + + return found; + } + +TBool TMouseFinder::IsButtons(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && + (aField->UsagePage() == EUsagePageButton)) + { + const TInt KMinButtons = 1; + const TInt KMaxButtons = 15; + + // Test for a field containing at least num lock or caps lock + if ( (aField->UsageMin() >= KMinButtons) + && (aField->UsageMax() <= KMaxButtons) ) + { + DBG(RDebug::Print(_L("[HID]\tButtons field found"))); + found = ETrue; + } + } + + return found; + } + + +TBool TMouseFinder::IsWheel(const CField* aField) const + { + TBool found = EFalse; + + if (aField->IsInput() && aField->IsData() && + (aField->UsagePage() == EUsagePageGenericDesktop)) + { + if ( aField->HasUsage( EGenericDesktopUsageWheel ) ) + { + found = ETrue; + } + } + + return found; + } + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/src/hidmousedriverproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/src/hidmousedriverproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2008 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: +* ECOM proxy table for this plugin +* +*/ + + +// System includes +// +#include +#include + +// User includes +// +#include "mouse.h" +#include "hiduids.h" + +// Constants +// +const TImplementationProxy KHidMouseDriverProxy[] = + { + IMPLEMENTATION_PROXY_ENTRY( MOUSE_DRIVER_IMP, CHidMouseDriver::NewL ) + }; + + +// --------------------------------------------------------------------------- +// ImplementationGroupProxy +// Gate/factory function +// +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KHidMouseDriverProxy) + / sizeof(TImplementationProxy); + return KHidMouseDriverProxy; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/mouse/hidmousedriver/src/mouse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/src/mouse.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,479 @@ +/* +* Copyright (c) 2008 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: This is the implementation of application class +* +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "bthidPsKey.h" + +#include "hidtranslate.h" +#include "finder.h" +#include "mouse.h" +#include "debug.h" + + +#ifndef DBG +#ifdef _DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif +#endif + +// Application UIDs for PaintCursor app. +_LIT(KAppName, "PaintCursor.exe"); +// ---------------------------------------------------------------------- + +CHidMouseDriver::CHidMouseDriver(MDriverAccess* aGenericHid) + : iDriverState(EUninitialised), iGenericHid(aGenericHid), + iButtonDown (EFalse), iButton2Down(EFalse) + { + DBG(RDebug::Print( + _L("[HID]\tCHidMouseDriver::CHidMouseDriver ENTER"))); + DBG(RDebug::Print( + _L("[HID]\tCHidMouseDriver::CHidMouseDriver(0x%08x)"), aGenericHid)); + } + +CHidMouseDriver* CHidMouseDriver::NewLC(MDriverAccess* aGenericHid) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::NewLC(0x%08x)"), aGenericHid)); + CHidMouseDriver* self = + new (ELeave) CHidMouseDriver(aGenericHid); + CleanupStack::PushL(self); + self->ConstructL(); + + return self; + } + +CHidMouseDriver* CHidMouseDriver::NewL(MDriverAccess* aGenericHid) + { + CHidMouseDriver* self = + CHidMouseDriver::NewLC(aGenericHid); + CleanupStack::Pop(); + return self; + } + +void CHidMouseDriver::ConstructL() + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver{0x%08x}::ConstructL() BEGIN"), this)); + + User::LeaveIfNull(iGenericHid); + + TInt err = iPointBufQueue.OpenGlobal(KMsgBTMouseBufferQueue); + if (err == KErrNotFound) + { + User::LeaveIfError(iPointBufQueue.CreateGlobal(KMsgBTMouseBufferQueue, KPointQueueLen)); + } + else + { + User::LeaveIfError( err ); + } + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver{0x%08x}::ConstructL() END"), this)); + // Create a session with the window server: + User::LeaveIfError(iWsSession.Connect()); + } + + + + +CHidMouseDriver::~CHidMouseDriver() + { + DBG(RDebug::Print(_L("[HID]\t~CHidMouseDriver() 0x%08x"), this)); + + iPointBufQueue.Close(); + + if (iDriverState == EInitialised || iDriverState == EDisabled ) + { + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + } + + iWsSession.Close(); + } + +void CHidMouseDriver::MoveCursor(const TPoint& aPoint) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::MoveCursor()"))); + PostPointer(aPoint); + } + +// --------------------------------------------------------------------------- +// CHidMouseDriver::PostPointer +// Save the event to the buffer +// --------------------------------------------------------------------------- +// +TInt CHidMouseDriver::PostPointer(const TPoint& aPoint) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::PostPointer()"))); + iPointerBuffer.iPoint[iPointerBuffer.iNum] = aPoint; + iPointerBuffer.iType[iPointerBuffer.iNum] = KBufferPlainPointer; + iPointerBuffer.iNum++; + TInt ret = KErrNone; + + if(iPointerBuffer.iNum > KPMaxEvent) + { + ret = iPointBufQueue.Send(iPointerBuffer); + iPointerBuffer.iNum = 0; + } + return ret; + } + +TInt CHidMouseDriver::SendButtonEvent(TBool aButtonDown) + { + + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::SendButtonEvent() %d"), aButtonDown)); + iPointerBuffer.iPoint[iPointerBuffer.iNum] = TPoint (0,0); + iPointerBuffer.iType[iPointerBuffer.iNum] = aButtonDown ? KBufferPenDown : KBufferPenUp; + iPointerBuffer.iNum++; + TInt ret = iPointBufQueue.Send(iPointerBuffer); + iPointerBuffer.iNum = 0; + return ret; + } + +void CHidMouseDriver::StartL(TInt /*aConnectionId*/) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::StartL()"))); + + // Ready to process mouse events: + iDriverState = EInitialised; + LaunchApplicationL(KAppName); + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorShow ); + } + + + +void CHidMouseDriver::InitialiseL(TInt aConnectionId) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::InitialiseL(%d)"), + aConnectionId)); + + // Store the connection ID: + iConnectionId = aConnectionId; + } + +void CHidMouseDriver::Stop() + { + iDriverState = EDisabled; + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + } + +//---------------------------------------------------------------------------- +// CHidMouseDriver::LaunchApplicationL +//---------------------------------------------------------------------------- +// +void CHidMouseDriver::LaunchApplicationL(const TDesC& aName) + { + //Check if application is already running in the background + TApaTaskList tasks( iWsSession ); + TApaTask task = tasks.FindApp( aName ); + + if ( task.Exists() ) + { + // Application is active, so just bring to foreground + } + else + { + // If application is not running, then create a new one + CApaCommandLine* cmd = CApaCommandLine::NewLC(); + + cmd->SetExecutableNameL(aName); + cmd->SetCommandL(EApaCommandBackground); // EApaCommandRun + + RApaLsSession arcSession; + //connect to AppArc server + User::LeaveIfError(arcSession.Connect()); + CleanupClosePushL(arcSession); + User::LeaveIfError( arcSession.StartApp(*cmd) ); + arcSession.Close(); + + CleanupStack::PopAndDestroy(2); + } + } +// ---------------------------------------------------------------------- +// CHidDriver mandatory functions: + +TInt CHidMouseDriver::DataIn( + CHidTransport::THidChannelType aChannel, const TDesC8& aPayload) + { + TInt err = KErrNone; + switch (aChannel) + { + case CHidTransport::EHidChannelInt: + if (EInitialised == iDriverState) + { + TInt mouseStatus; + TInt err = RProperty::Get( KPSUidBthidSrv, KBTMouseCursorState, mouseStatus ); + if ( !err && (static_cast(mouseStatus) == ECursorHide) ) + { + err = RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorShow ); + } + InterruptData(aPayload); + } + break; + + case CHidTransport::EHidChannelCtrl: + break; + + default: + break; + } + return err; + } + +void CHidMouseDriver::CommandResult(TInt /*aCmdAck*/) + { + // No implementation as we don't issue any requests to be acknowledged + } + +void CHidMouseDriver::Disconnected(TInt aReason) + { + RDebug::Print(_L("[HID]\tCHidMouseDriver::Disconnected(%d)"), aReason); + Stop(); + } + +// ---------------------------------------------------------------------- + +void CHidMouseDriver::InterruptData(const TDesC8& aPayload) + { + // If the report has a report ID, it is in the first byte. + // If not, this value is ignored (see CField::IsInReport()). + // + TInt firstByte = aPayload[0]; + + DBG(for (TInt ii = 0; ii < aPayload.Length(); ii++) + { + TInt nextByte = aPayload[ii]; + DBG(RDebug::Print( + _L("[HID]\tCHidKeyboardDriver::InterruptData() report[%d] = %d"), + ii, nextByte)); + }) + + DBG(RDebug::Print( + _L("[HID]\tCHidMouseDriver::InterruptData(), report %d, length %d"), + firstByte, aPayload.Length())); + + if (iField[EXY] && iField[EXY]->IsInReport(firstByte)) + { + UpdateXY(EXY, aPayload); + } + + if (iField[EButtons] && iField[EButtons]->IsInReport(firstByte)) + { + UpdateButtons(EButtons, aPayload); + } + if (iField[EXY] && iField[EXY]->IsInReport(firstByte)) + { + UpdateWheel(EWheel, aPayload); + } + } + +// ---------------------------------------------------------------------- + +void CHidMouseDriver::UpdateXY(TInt aFieldIndex, + const TDesC8& aReport) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateModifiers()"))); + + // Translate the HID usage values into a boot protocol style + // modifier bitmask: + // + TReportTranslator report(aReport, iField[aFieldIndex]); + + TInt Xvalue = 0; + TInt Yvalue = 0; + + TInt errX = report.GetValue( Xvalue, EGenericDesktopUsageX); + TInt errY = report.GetValue( Yvalue, EGenericDesktopUsageY); + + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateXY (%d,%d)"), Xvalue, Yvalue)); + if ( ( Xvalue != 0 ) || (Yvalue != 0)) + { + MoveCursor(TPoint(Xvalue, Yvalue)); + } + + } + +void CHidMouseDriver::UpdateWheel(TInt aFieldIndex, + const TDesC8& aReport) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateModifiers()"))); + + // Translate the HID usage values into a boot protocol style + // modifier bitmask: + // + TReportTranslator report(aReport, iField[aFieldIndex]); + + TInt Yvalue = 0; + + TInt errY = report.GetValue( Yvalue, EGenericDesktopUsageWheel); + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateWheel (%d)"), Yvalue)); + + TInt absValue(Abs(Yvalue)); + if ( (errY == KErrNone) && (absValue >= 1) ) + { + TRawEvent rawEvent; + for (TInt ii = 0; ii < absValue; ii++) + { + rawEvent.Set(TRawEvent::EKeyDown, (Yvalue > 0) ? EStdKeyUpArrow : EStdKeyDownArrow); + UserSvr::AddEvent(rawEvent); + rawEvent.Set(TRawEvent::EKeyUp, (Yvalue > 0) ? EStdKeyUpArrow : EStdKeyDownArrow); + UserSvr::AddEvent(rawEvent); + } + } + } + +void CHidMouseDriver::UpdateButtons(TInt aFieldIndex, + const TDesC8& aReport) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons()"))); + + // Translate the HID usage values into a boot protocol style + // modifier bitmask: + // + TReportTranslator report(aReport, iField[aFieldIndex]); + + TInt button1 = 0; + TInt button2 = 0; + TInt button3 = 0; + + const TInt KButton1 = 1; + const TInt KButton2 = 2; + const TInt KButton3 = 3; + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() %d, %d, %d"), + iField[aFieldIndex]->UsagePage(), + iField[aFieldIndex]->UsageMin(), + iField[aFieldIndex]->UsageMax())); + + TBool buttonPressed(EFalse); + if (report.GetValue( button1, KButton1) == KErrNone && button1) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button1"))); + buttonPressed = ETrue; + } + + if (report.GetValue( button2, KButton2) == KErrNone && button2) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button2"))); + if (! iButton2Down ) + { + iButton2Down = ETrue; + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyDown, EStdKeyApplication0); + UserSvr::AddEvent(rawEvent); + } + } + else + { + if (iButton2Down ) + { + iButton2Down = EFalse; + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyUp, EStdKeyApplication0); + UserSvr::AddEvent(rawEvent); + } + } + + if (report.GetValue( button3, KButton3) == KErrNone && button3) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button3"))); + buttonPressed = ETrue; + } + + if (buttonPressed) + { + if ( !iButtonDown ) + { + iButtonDown = ETrue; + SendButtonEvent(ETrue);//Send Mouse Button Down + } + } + else + { + if ( iButtonDown ) + { + iButtonDown = EFalse; + SendButtonEvent(EFalse);//Send Mouse Button Up + } + } + } + +TInt CHidMouseDriver::CanHandleReportL(CReportRoot* aReportRoot) + { + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::CanHandleReport(0x%08x)"), + aReportRoot)); + iSupportedFieldCount = 0; + // Look for mouse reports: + + THidFieldSearch search; + + TMouseFinder finder; + search.SearchL(aReportRoot, &finder); + DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::CanHandleReport(): root parsed"))); + iField[EButtons] = finder.ButtonsField(); + iField[EXY] = finder.XYField(); + iField[EWheel] = finder.WheelField(); + + for (TInt i=0; i + +//paintcursor Application(EXE) +S60_APP_EXE(paintcursor) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,paintcursor) +S60_APP_AIF_ICONS(paintcursor) +S60_APP_AIF_RSC(paintcursor) + +file=ABI_DIR\BUILD_DIR\bthidsettings.dll SHARED_LIB_DIR\bthidsettings.dll +file=ABI_DIR\BUILD_DIR\layoutmgr.exe PROGRAMS_DIR\layoutmgr.exe +file=ABI_DIR\BUILD_DIR\kbdclient.dll SHARED_LIB_DIR\kbdclient.dll +file=ABI_DIR\BUILD_DIR\bthidserver.exe PROGRAMS_DIR\bthidserver.exe +file=ABI_DIR\BUILD_DIR\bthidclient.dll SHARED_LIB_DIR\bthidclient.dll +file=ABI_DIR\BUILD_DIR\BTMouse_Animation_client.dll SHARED_LIB_DIR\BTMouse_Animation_client.dll +file=ABI_DIR\BUILD_DIR\BTcursor_server.dll SHARED_LIB_DIR\BTcursor_server.dll +ECOM_PLUGIN(hidkeyboard.dll, hidkeyboard.rsc) +ECOM_PLUGIN(hidmouse.dll, hidmouse.rsc) +ECOM_PLUGIN(kbdlayout.dll, kbdlayout.rsc) +ECOM_PLUGIN(bthidkbdsettings.dll, bthidkbdsettings.rsc) +ECOM_PLUGIN(bthidengplugin.dll, bthidengplugin.rsc) + +data=DATAZ_\APP_BITMAP_DIR\BTMouseBitMaps.mbm APP_BITMAP_DIR\BTMouseBitMaps.mbm + +#endif //BTKeyboard_IBY + +#endif // __BT +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/rom/btkeyboard_resources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/rom/btkeyboard_resources.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2008 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: IBY-file for localized resources. + * +*/ + +#ifdef __BT + +#ifndef BTKEYBOARD_RESOURCES_IBY +#define BTKEYBOARD_RESOURCES_IBY + +data=DATAZ_\RESOURCE_FILES_DIR\BthidResource.rsc RESOURCE_FILES_DIR\BthidResource.rsc +data=DATAZ_\APP_RESOURCE_DIR\PaintCursor.rsc APP_RESOURCE_DIR\PaintCursor.rsc +#endif //BTKEYBOARD_RESOURCES_IBY + +#endif // __BT + +// End Of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/BWINS/ATCodecU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/BWINS/ATCodecU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +EXPORTS + ??0TATParam@@QAE@ABVTDesC8@@W4TATParamType@@@Z @ 1 NONAME ; TATParam::TATParam(class TDesC8 const &, enum TATParamType) + ??0TATParam@@QAE@H@Z @ 2 NONAME ; TATParam::TATParam(int) + ??0TATParam@@QAE@XZ @ 3 NONAME ; TATParam::TATParam(void) + ??1CATBase@@UAE@XZ @ 4 NONAME ; CATBase::~CATBase(void) + ?Des@CATBase@@QBEABVTDesC8@@XZ @ 5 NONAME ; class TDesC8 const & CATBase::Des(void) const + ?Des@TATParam@@QBEABVTDesC8@@XZ @ 6 NONAME ; class TDesC8 const & TATParam::Des(void) const + ?ExternalizeL@CATBase@@QBEXAAVRWriteStream@@@Z @ 7 NONAME ; void CATBase::ExternalizeL(class RWriteStream &) const + ?ExternalizeL@TATParam@@QBEXAAVRWriteStream@@@Z @ 8 NONAME ; void TATParam::ExternalizeL(class RWriteStream &) const + ?Id@CATBase@@QBE?AW4TATId@@XZ @ 9 NONAME ; enum TATId CATBase::Id(void) const + ?Int@TATParam@@QBEHAAH@Z @ 10 NONAME ; int TATParam::Int(int &) const + ?InternalizeL@CATBase@@QAEXAAVRReadStream@@@Z @ 11 NONAME ; void CATBase::InternalizeL(class RReadStream &) + ?InternalizeL@TATParam@@QAEXAAVRReadStream@@@Z @ 12 NONAME ; void TATParam::InternalizeL(class RReadStream &) + ?NewL@CATCommand@@SAPAV1@ABVTDesC8@@@Z @ 13 NONAME ; class CATCommand * CATCommand::NewL(class TDesC8 const &) + ?NewL@CATCommand@@SAPAV1@XZ @ 14 NONAME ; class CATCommand * CATCommand::NewL(void) + ?NewL@CATResult@@SAPAV1@W4TATId@@W4TATType@@PBV?$RArray@VTATParam@@@@@Z @ 15 NONAME ; class CATResult * CATResult::NewL(enum TATId, enum TATType, class RArray const *) + ?NewL@CATResult@@SAPAV1@W4TATId@@W4TATType@@VTATParam@@@Z @ 16 NONAME ; class CATResult * CATResult::NewL(enum TATId, enum TATType, class TATParam) + ?NewL@CATResult@@SAPAV1@XZ @ 17 NONAME ; class CATResult * CATResult::NewL(void) + ?NewLC@CATCommand@@SAPAV1@ABVTDesC8@@@Z @ 18 NONAME ; class CATCommand * CATCommand::NewLC(class TDesC8 const &) + ?NewLC@CATCommand@@SAPAV1@XZ @ 19 NONAME ; class CATCommand * CATCommand::NewLC(void) + ?NewLC@CATResult@@SAPAV1@W4TATId@@W4TATType@@PBV?$RArray@VTATParam@@@@@Z @ 20 NONAME ; class CATResult * CATResult::NewLC(enum TATId, enum TATType, class RArray const *) + ?NewLC@CATResult@@SAPAV1@W4TATId@@W4TATType@@VTATParam@@@Z @ 21 NONAME ; class CATResult * CATResult::NewLC(enum TATId, enum TATType, class TATParam) + ?NewLC@CATResult@@SAPAV1@XZ @ 22 NONAME ; class CATResult * CATResult::NewLC(void) + ?ParamNum@CATBase@@QBEHXZ @ 23 NONAME ; int CATBase::ParamNum(void) const + ?Parameter@CATBase@@QBEHHAAVTATParam@@@Z @ 24 NONAME ; int CATBase::Parameter(int, class TATParam &) const + ?Parameters@CATBase@@QBEABV?$RArray@VTATParam@@@@XZ @ 25 NONAME ; class RArray const & CATBase::Parameters(void) const + ?Set@CATCommand@@QAEHABVTDesC8@@@Z @ 26 NONAME ; int CATCommand::Set(class TDesC8 const &) + ?Set@CATResult@@QAEHW4TATId@@W4TATType@@PBV?$RArray@VTATParam@@@@@Z @ 27 NONAME ; int CATResult::Set(enum TATId, enum TATType, class RArray const *) + ?SetInt@TATParam@@QAEXH@Z @ 28 NONAME ; void TATParam::SetInt(int) + ?SetValue@TATParam@@QAEHABVTDesC8@@W4TATParamType@@@Z @ 29 NONAME ; int TATParam::SetValue(class TDesC8 const &, enum TATParamType) + ?Type@CATBase@@QBE?AW4TATType@@XZ @ 30 NONAME ; enum TATType CATBase::Type(void) const + ?Type@TATParam@@QBE?AW4TATParamType@@XZ @ 31 NONAME ; enum TATParamType TATParam::Type(void) const + ?ATObjArrayCleanupResetAndDestroyPushL@@YAXAAV?$RPointerArray@VCATResult@@@@@Z @ 32 NONAME ; void ATObjArrayCleanupResetAndDestroyPushL(class RPointerArray &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,9 @@ +EXPORTS + ??1CBtmcHandlerApi@@UAE@XZ @ 1 NONAME ; CBtmcHandlerApi::~CBtmcHandlerApi(void) + ?HandleNrecCompletedL@CBtmcHandlerApi@@QAEXH@Z @ 2 NONAME ; void CBtmcHandlerApi::HandleNrecCompletedL(int) + ?HandleProtocolDataL@CBtmcHandlerApi@@QAEXABVTDesC8@@@Z @ 3 NONAME ; void CBtmcHandlerApi::HandleProtocolDataL(class TDesC8 const &) + ?NewL@CBtmcHandlerApi@@SAPAV1@AAVMBtmcObserver@@W4TBtmcProfileId@@ABVTDesC8@@H@Z @ 4 NONAME ; class CBtmcHandlerApi * CBtmcHandlerApi::NewL(class MBtmcObserver &, enum TBtmcProfileId, class TDesC8 const &, int) + ?ActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 5 NONAME ; void CBtmcHandlerApi::ActivateRemoteVolumeControl(void) + ?DeActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 6 NONAME ; void CBtmcHandlerApi::DeActivateRemoteVolumeControl(void) + ?GetRemoteSupportedFeature@CBtmcHandlerApi@@QAEHXZ @ 7 NONAME ; int CBtmcHandlerApi::GetRemoteSupportedFeature(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/common/atcodec.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/common/atcodec.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,333 @@ +/* +* Copyright (c) 2005 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: Parses/Encodes AT ccommands. +* +*/ + + +#ifndef AT_CODEC_H +#define AT_CODEC_H + +// INCLUDES +#include + +enum TATId + { + EUnknownAT,// 0 Not known AT command + EAT, // 1, AT test command + EATA, // 2, answer a call + EATBINP, // 3, Command used for requesting some specific data input from the AG + EATBLDN, // 4, Command used for calling the last phone number dialed + EATBRSF, // 5, Bluetooth Retrieve Supported Features + EATBVRA, // 6, Bluetooth Voice Recognition Activation + EATCCWA, // 7, call waiting notification + EATCHLD, // 8, multiparty handling AT command + EATCHUP, // 9, Hang-up AT command + EATCIND, // 10, standard indicator update AT command (read and test only) + EATCKPD, // 11, Command issued by HS to indicate that the button has been pressed + EATCLCC, // 12, list of current call + EATCLIP, // 13, standard Calling Line Identification notification activation AT command + EATCMEE, // 14, Advanced error code activation + EATCMER, // 15, Standard event reporting activation AT command + EATCNUM, // 16, Subscriber number + EATCOPS, // 17, Operator selection + EATD1, // 18, place a call + EATD2, // 19, speed dial + EATNREC, // 20, Noise Reduction and Echo Canceling + EATVGM, // 21, Microphone volume + EATVGS, // 22, Speaker volume + EATVTS, // 23, Standard DTMF generation AT command + EATCIEV, // 24, notify call status change + EATERROR, // 25, Response Error + EATOK, // 26, Response OK + EATRING, // 27, RING unsolicited response + EATBIA, // 28, Set indicator status + EATCREG, // 29, Network registration + EATCGSN, // 30, Serial Number + EATCSQ, // 31, Signal Strength in dBm + EATCIMI, // 32, Mobile subscriber ID + EATCGMI, // 33, Manufacturer information + EATCGMM, // 34, Model id + EATCGMR, // 35, Revision id + EATCOLP, // 36, Outgoin call number + EMinValidATIdRange = EAT, + EMaxValidATIdRange = EATCOLP, + }; + +enum TATType + { + EATUnkownType = 0, + EATReadCmd = 0x001, // 1, Read format "AT+xxxx?" + EATWriteCmd = 0x002, // 2, Write format "AT+xxxx=1" + EATActionCmd = 0x004, // 4, Action format "AT+xxxx" or "ATx" (e.g. "ATD") + EATTestCmd = 0x008, // 8, Test command "AT+xxxx=?" and "AT" + EATReadResult = 0x010, // 16, Response to read command + EATWriteResult = 0x020, // 32, Response to write command + EATActionResult = 0x040, // 64, Response to action command + EATTestResult = 0x080, // 128, Response to test command + EATUnsolicitedResult = 0x100, // 256, Unsolicited result code + EATErrorResult = 0x200 // 512, error result, OK or ERROR + }; + +enum TATParamType + { + EATNullParam, + EATStringParam, + EATDQStringParam, + EATIntParam + }; + +const TInt KMaxATSize = 512; +const TInt KMaxATParamSize = 256; + +class RReadStream; +class RWriteStream; + +// CLASS DECLARATION +/** +* TATParam represents one AT command parameter. +*/ +NONSHARABLE_CLASS(TATParam) + { +public: + IMPORT_C TATParam(); + + IMPORT_C TATParam(const TDesC8& aValue, TATParamType aType = EATStringParam); + + IMPORT_C TATParam(TInt aValue); + + /** + * Returns the parameter as integer. + * @since 3.0 + * @return error code. + */ + IMPORT_C TInt Int(TInt& aValue) const; + + /** + * Returns the parameter as text. + * @since 3.0 + * @return the non-modifiable pointer descriptor + */ + IMPORT_C const TDesC8& Des() const; + + /** + * Returns the parameter type. + * @since 3.0 + * @param None + * @return Parameter type. + */ + IMPORT_C TATParamType Type() const; + + /** + * Sets the parameter value. + * @since 3.0 + * @param aValue New value. + * @return error code + */ + IMPORT_C TInt SetValue(const TDesC8& aValue, TATParamType aType); + + /** + * Sets the parameter value. + * @since 3.0 + * @param aValue New value. + * @return None + */ + IMPORT_C void SetInt(TInt aValue); + + IMPORT_C void ExternalizeL(RWriteStream& aStream) const; + + IMPORT_C void InternalizeL(RReadStream& aStream); + +private: + void AddDQ(); + +private: + TBuf8 iValue; + TInt iValueInt; + TATParamType iType; + +private: + static const TInt32 KStreamVersion1 = 0x00000001; + }; + +typedef RArray RATParamArray; + +/** +* TATCommand is used for parsing Bluetooth AT commands. +*/ +NONSHARABLE_CLASS(CATBase) : public CBase + { +public: + IMPORT_C virtual ~CATBase(); + + /** + * Returns AT command identification. + * @since 3.0 + * @param None + * @return Id number. + */ + IMPORT_C TATId Id() const; + + /** + * Returns AT command type. + * @since 3.0 + * @param None + * @return Command type. + */ + IMPORT_C TATType Type() const; + + /** + * Returns the number of command parameters. + * @since 3.0 + * @param None + * @return Number of command paramteres. + */ + IMPORT_C TInt ParamNum() const; + + /** + * Returns parameter at given index. + * @since 3.0 + * @param aIndex Index. + * @return the parameter. + */ + IMPORT_C TInt Parameter(TInt aIndex, TATParam& aParam) const; + + /** + * Returns parameters in a string. + * @since 3.0 + * @return the parameter list. + */ + IMPORT_C const RATParamArray& Parameters() const; + + /** + * Gets the descriptor of this AT command or response. + */ + IMPORT_C const TDesC8& Des() const; + + IMPORT_C void ExternalizeL(RWriteStream& aStream) const; + + IMPORT_C void InternalizeL(RReadStream& aStream); + +protected: + CATBase(); + + void Reset(); + +protected: + RBuf8 iText; + TATId iId; + TATType iType; + RATParamArray iParamList; + +private: + static const TInt32 KStreamVersion1 = 0x00000001; + }; + +/** +* TATCommand is used for parsing Bluetooth AT commands. +*/ +NONSHARABLE_CLASS(CATCommand) : public CATBase + { +public: + /** + * Instantiates an uninitialized AT command. + */ + IMPORT_C static CATCommand* NewL(); + + /** + * Instantiates an uninitialized AT command and leaves it in cleanupstack. + */ + IMPORT_C static CATCommand* NewLC(); + + /** + * Instantiates an AT command. + * Function leaves if aCmd is not supported or not valid. + */ + IMPORT_C static CATCommand* NewL(const TDesC8& aCmd); + + /** + * Instantiates an AT command and leaves it in cleanupstack. + * Function leaves if aCmd is not supported or not valid. + */ + IMPORT_C static CATCommand* NewLC(const TDesC8& aCmd); + + /** + * + * @since 3.0 + * @param aText Command string + * @return + */ + IMPORT_C TInt Set(const TDesC8& aText); + +private: + CATCommand(); + + TInt Parse(const TDesC8& aText); + + void ParseCommandType(TPtrC8& aPtrC); + + TInt ParseParams(TPtrC8& aDes, TUint aParamIndex, TUint aTableIndex); + }; + +/** +* TATCommand is used for parsing Bluetooth AT commands. +*/ +NONSHARABLE_CLASS(CATResult) : public CATBase + { +public: + /** + * Instantiates an uninitialized AT command. + */ + IMPORT_C static CATResult* NewL(); + + /** + * Instantiates an uninitialized AT command and leaves it in cleanupstack. + */ + IMPORT_C static CATResult* NewLC(); + + IMPORT_C static CATResult* NewL(TATId aId, TATType aType = EATErrorResult, const RATParamArray* aParams = NULL); + + IMPORT_C static CATResult* NewLC(TATId aId, TATType aType = EATErrorResult, const RATParamArray* aParams = NULL); + + IMPORT_C static CATResult* NewL(TATId aId, TATType aType, const TATParam aParam); + + IMPORT_C static CATResult* NewLC(TATId aId, TATType aType, const TATParam aParam); + + /** + * + */ + IMPORT_C TInt Set(TATId aId, TATType aType = EATErrorResult, const RATParamArray* aParams = NULL); + +private: + CATResult(); + + TInt Parse(TATId aId, TATType aType, const RATParamArray* aParams); + + /** + * Adds carriage return and line feed characters at + * the beginning and the end of the string. + * @since 3.0 + * @param aText String to be modified. + * @return None + */ + static TInt AddCRLF(TDes8& aText); + }; + +typedef RPointerArray RATResultPtrArray; + +IMPORT_C void ATObjArrayCleanupResetAndDestroyPushL(RATResultPtrArray& aArray); + +#endif // AT_CODEC_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/common/btmchandlerapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/common/btmchandlerapi.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTMCHANDLERAPI_H +#define BTMCHANDLERAPI_H + +#include "btmcprofileid.h" +#include "btmcobserver.h" + +// forward declarations +class CBtmcProtocol; + +NONSHARABLE_CLASS(CBtmcHandlerApi) : public CBase + { +public: + + IMPORT_C static CBtmcHandlerApi* NewL( + MBtmcObserver& aObserver, TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated); + + IMPORT_C ~CBtmcHandlerApi(); + + /** + * Handle an AT command from HF or HS unit. + * + */ + IMPORT_C void HandleProtocolDataL(const TDesC8& aData); + + IMPORT_C void HandleNrecCompletedL(TInt aErr); + + IMPORT_C void ActivateRemoteVolumeControl(); + + IMPORT_C void DeActivateRemoteVolumeControl(); + + IMPORT_C TInt GetRemoteSupportedFeature(); + +private: + CBtmcHandlerApi(); + + // 2nd phase construction, called by NewL() + void ConstructL(MBtmcObserver& aObserver, TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated); + +private: + CBtmcProtocol* iHandler; + }; + + +#endif // BTMCHANDLERAPI_H + +// End of File + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/common/btmcobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/common/btmcobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2005 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: +* +* +*/ + + +#ifndef BTMCOBSERVER_H +#define BTMCOBSERVER_H + +#include + +class MBtmcObserver + { + public: + + virtual void SlcIndicateL(TBool aSlc) = 0; + + virtual void SendProtocolDataL(const TDesC8& aData) = 0; + + }; + +#endif // BTMCOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/common/btmcprofileid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/common/btmcprofileid.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef BTMCPROFILEID_H +#define BTMCPROFILEID_H + +#include + +enum TBtmcProfileId + { + EBtmcHFP0105, // HFP version 1.5 + EBtmcHSP // HSP 1.1 + }; + +#endif // BTMCPROFILEID_H + +// End of File + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/common/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/common/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2006 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: Logging definition +* +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + RBuf16 theFinalString; + theFinalString.Create(KMaxLogLineLength); + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + theFinalString.Close(); +#endif + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TOverflowTruncate8 overflow; + RBuf8 buf8; + buf8.Create(KMaxLogLineLength); + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + + RBuf16 buf16; + buf16.Create(KMaxLogLineLength); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + buf8.Close(); + buf16.Close(); +#endif + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + RBuf8 buf; + buf.Create(KMaxLogLineLength); + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + + buf.Close(); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + RBuf8 buf; + buf.Create(KMaxLogLineLength); + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + + buf.Close(); + User::LeaveIfError(aReason); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_FUNC_STATIC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/data/101f4689.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/data/101f4689.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2005-2006 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: Resource definitions for project BTMAC +* +*/ + + + +#include + + +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x101F4689; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x10208972; + implementations = + { + // Info for BTSAC + IMPLEMENTATION_INFO + { + implementation_uid = 0x101FBAEA; + version_no = 1; + display_name = "BT Mono AudioController"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/data/10204DB2.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/data/10204DB2.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 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 + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x10204DB2; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10204546; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x101FBAE9; + version_no = 1; + display_name = "RemConBTAudio"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/eabi/ATCodecu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/eabi/ATCodecu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,39 @@ +EXPORTS + _ZN10CATCommand3SetERK6TDesC8 @ 1 NONAME + _ZN10CATCommand4NewLERK6TDesC8 @ 2 NONAME + _ZN10CATCommand4NewLEv @ 3 NONAME + _ZN10CATCommand5NewLCERK6TDesC8 @ 4 NONAME + _ZN10CATCommand5NewLCEv @ 5 NONAME + _ZN7CATBase12InternalizeLER11RReadStream @ 6 NONAME + _ZN7CATBaseD0Ev @ 7 NONAME + _ZN7CATBaseD1Ev @ 8 NONAME + _ZN7CATBaseD2Ev @ 9 NONAME + _ZN8TATParam12InternalizeLER11RReadStream @ 10 NONAME + _ZN8TATParam6SetIntEi @ 11 NONAME + _ZN8TATParam8SetValueERK6TDesC812TATParamType @ 12 NONAME + _ZN8TATParamC1ERK6TDesC812TATParamType @ 13 NONAME + _ZN8TATParamC1Ei @ 14 NONAME + _ZN8TATParamC1Ev @ 15 NONAME + _ZN8TATParamC2ERK6TDesC812TATParamType @ 16 NONAME + _ZN8TATParamC2Ei @ 17 NONAME + _ZN8TATParamC2Ev @ 18 NONAME + _ZN9CATResult3SetE5TATId7TATTypePK6RArrayI8TATParamE @ 19 NONAME + _ZN9CATResult4NewLE5TATId7TATType8TATParam @ 20 NONAME + _ZN9CATResult4NewLE5TATId7TATTypePK6RArrayI8TATParamE @ 21 NONAME + _ZN9CATResult4NewLEv @ 22 NONAME + _ZN9CATResult5NewLCE5TATId7TATType8TATParam @ 23 NONAME + _ZN9CATResult5NewLCE5TATId7TATTypePK6RArrayI8TATParamE @ 24 NONAME + _ZN9CATResult5NewLCEv @ 25 NONAME + _ZNK7CATBase10ParametersEv @ 26 NONAME + _ZNK7CATBase12ExternalizeLER12RWriteStream @ 27 NONAME + _ZNK7CATBase2IdEv @ 28 NONAME + _ZNK7CATBase3DesEv @ 29 NONAME + _ZNK7CATBase4TypeEv @ 30 NONAME + _ZNK7CATBase8ParamNumEv @ 31 NONAME + _ZNK7CATBase9ParameterEiR8TATParam @ 32 NONAME + _ZNK8TATParam12ExternalizeLER12RWriteStream @ 33 NONAME + _ZNK8TATParam3DesEv @ 34 NONAME + _ZNK8TATParam3IntERi @ 35 NONAME + _ZNK8TATParam4TypeEv @ 36 NONAME + _Z37ATObjArrayCleanupResetAndDestroyPushLR13RPointerArrayI9CATResultE @ 37 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,11 @@ +EXPORTS + _ZN15CBtmcHandlerApi19HandleProtocolDataLERK6TDesC8 @ 1 NONAME + _ZN15CBtmcHandlerApi20HandleNrecCompletedLEi @ 2 NONAME + _ZN15CBtmcHandlerApi4NewLER13MBtmcObserver14TBtmcProfileIdRK6TDesC8i @ 3 NONAME + _ZN15CBtmcHandlerApiD0Ev @ 4 NONAME + _ZN15CBtmcHandlerApiD1Ev @ 5 NONAME + _ZN15CBtmcHandlerApiD2Ev @ 6 NONAME + _ZN15CBtmcHandlerApi27ActivateRemoteVolumeControlEv @ 7 NONAME + _ZN15CBtmcHandlerApi29DeActivateRemoteVolumeControlEv @ 8 NONAME + _ZN15CBtmcHandlerApi25GetRemoteSupportedFeatureEv @ 9 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/group/ATCodec.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/group/ATCodec.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2005-2006 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: Project definition file for ATCodec +* +*/ + + +#include +#include "../inc/atcodec/prjconfig.h" + + +TARGET ATCodec.dll +TARGETTYPE dll +UID 0x1000008d 0x1020897A + +VENDORID VID_DEFAULT + +CAPABILITY CAP_GENERAL_DLL + +SOURCEPATH ../src/ATCodec +SOURCE atccommand.cpp +SOURCE atcparam.cpp + +USERINCLUDE ../inc/atcodec ../common +SYSTEMINCLUDE ../../inc ../../../inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY estor.lib + +#ifdef PRJ_FILE_TRACE +LIBRARY flogger.lib +#endif + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/group/BTMAC.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/group/BTMAC.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2005-2006 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: Project definition file for BTMAC +* +*/ + +#include +#include "../inc/btmac/prjconfig.h" + +TARGET btmac.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x101F4689 + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +START RESOURCE ../data/101f4689.rss +TARGET btmac.rsc +END + + +SOURCEPATH ../src/btmac +SOURCE btmproxy.cpp +SOURCE btmman.cpp +SOURCE btmrfcommsock.cpp +SOURCE btmsyncsock.cpp +SOURCE btmsockobserver.cpp +SOURCE btmactive.cpp +SOURCE btmstate.cpp +SOURCE btmsidle.cpp +SOURCE btmsconnect.cpp +SOURCE btmslisten.cpp +SOURCE btmsinuse.cpp +SOURCE btmsrfcomm.cpp +SOURCE btmsctrl.cpp +SOURCE btmssniffm.cpp +SOURCE btmsopenaudio.cpp +SOURCE btmscloseaudio.cpp +SOURCE btmsaudio.cpp +SOURCE btmstempd.cpp +SOURCE btmsreconnect.cpp +SOURCE btmsdisconnect.cpp + +USERINCLUDE ../inc/btmac ../common +SYSTEMINCLUDE ../../inc ../../../inc /epoc32/include/ecom +MW_LAYER_SYSTEMINCLUDE +LIBRARY ecom.lib +LIBRARY euser.lib +LIBRARY esock.lib +LIBRARY centralrepository.lib + +#ifdef PRJ_USE_STUB +LIBRARY bluetooth_stub.lib +LIBRARY BTMonoCmdHandler_stub.lib +LIBRARY bteng_stub.lib +#else +LIBRARY bluetooth.lib +LIBRARY BTMonoCmdHandler.lib +#endif +LIBRARY atcodec.lib + +LIBRARY btdevice.lib // BT Device +LIBRARY BAFL.lib // Des array +LIBRARY btengdiscovery.lib + +#ifdef PRJ_FILE_TRACE +LIBRARY flogger.lib +#endif + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/group/BTMonoCmdHandler.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/group/BTMonoCmdHandler.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2005-2006 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: Project definition file for BTMonoCmdHandler +* +*/ + + + +#include +#include "../inc/btmonocmdhandler/prjconfig.h" + +VENDORID VID_DEFAULT +CAPABILITY CAP_GENERAL_DLL + +TARGET BTMonoCmdHandler.dll +TARGETTYPE dll +UID 0x1000008d 0x1020897E + +SOURCEPATH ../src/BTMonoCmdHandler +SOURCE btmchandlerapi.cpp +SOURCE btmcprotocol.cpp +SOURCE btmcprotdatabuf.cpp +SOURCE btmcphonestatus.cpp +SOURCE btmccallstatus.cpp +SOURCE btmcvolume.cpp +SOURCE HfpAtCmdhandler.cpp +SOURCE HFPAtEcomListen.cpp +SOURCE HFPAtUrcHandler.cpp + +#ifdef __PROTOCOL_CDMA +SOURCE BTMonoMobileLineCdma.cpp +SOURCE BTMonoCdmaIncomingFlash.cpp +#else +SOURCE btmcmobileline.cpp +#endif +SOURCE btmccallactive.cpp +SOURCE btmcactive.cpp +SOURCE btmcnumber.cpp +SOURCE btmcsignal.cpp +SOURCE btmcbattery.cpp +SOURCE btmcoperator.cpp +SOURCE btmccallinghandler.cpp + +USERINCLUDE ../inc/btmonocmdhandler +USERINCLUDE ../common +USERINCLUDE ../../inc +USERINCLUDE ../../../inc + +APP_LAYER_SYSTEMINCLUDE +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY etel.lib +LIBRARY etelmm.lib +LIBRARY ATCodec.lib +LIBRARY customapi.lib +LIBRARY bluetooth.lib +LIBRARY atextclient.lib + +LIBRARY mmfdevsound.lib +LIBRARY telephonyservice.lib +#ifdef __PROTOCOL_CDMA +LIBRARY etelcdma.lib +#endif +LIBRARY BAFL.lib +LIBRARY btengdiscovery.lib +#ifdef PRJ_FILE_TRACE +LIBRARY flogger.lib +#endif + +SOURCEPATH ../src/BTMonoCmdHandler +SOURCE btmcvoipline.cpp diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2002 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: Provides information for building BTMAC. +* +*/ + + +#include + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/Btmac.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btmac.iby) + +PRJ_MMPFILES +../group/ATCodec.mmp +../group/btmonobearer.mmp +../group/BTMonoCmdHandler.mmp +../group/BTMAC.mmp + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/group/btmonobearer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/group/btmonobearer.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2005-2006 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: Project definition file for BTMonoBearer +* +*/ + + +#include +#include +#include "../inc/btmonobearer/prjconfig.h" + +TARGET btmonobearer.dll +TARGETTYPE PLUGIN +UID 0x10009d8d 0x10204DB2 + +VENDORID VID_DEFAULT + +START RESOURCE ../data/10204DB2.rss +target btmonobearer.rsc +END + +SOURCEPATH ../src/btmonobearer + +SOURCE bmbplugin.cpp +SOURCE bmbmain.cpp +SOURCE bmbcmdlistener.cpp +SOURCE playercontrolistener.cpp + +USERINCLUDE ../inc/btmonobearer ../common +SYSTEMINCLUDE ../../inc ../../../inc /epoc32/include/ecom +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY bluetooth.lib +LIBRARY remconbearerplugin.lib +LIBRARY remcontypes.lib +LIBRARY ATCodec.lib + +#ifdef PRJ_FILE_TRACE +LIBRARY flogger.lib +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/atcodec/ATCodecDefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/atcodec/ATCodecDefs.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2005 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: Contains internal classes. +* +*/ + + +#ifndef ATCODECDEFS_H +#define ATCODECDEFS_H + +// INCLUDES +#include + +class SATNameDef + { + public: + const TATId KId; + const TText8* KName; + }; + +const SATNameDef KATNameTable[] = + { + {EATA, _S8("A"),}, + {EATBINP, _S8("+BINP")}, + {EATBLDN, _S8("+BLDN")}, + {EATBRSF, _S8("+BRSF")}, + {EATBVRA, _S8("+BVRA")}, + {EATCCWA, _S8("+CCWA")}, + {EATCHLD, _S8("+CHLD")}, + {EATCHUP, _S8("+CHUP")}, + {EATCIND, _S8("+CIND")}, + {EATCKPD, _S8("+CKPD")}, + {EATCLCC, _S8("+CLCC")}, + {EATCLIP, _S8("+CLIP")}, + {EATCMEE, _S8("+CMEE")}, + {EATCMER, _S8("+CMER")}, + {EATCNUM, _S8("+CNUM")}, + {EATCOPS, _S8("+COPS")}, + {EATD2, _S8("D>")}, + {EATD1, _S8("D")}, + {EATNREC, _S8("+NREC")}, + {EATVGM, _S8("+VGM")}, + {EATVGS, _S8("+VGS")}, + {EATVTS, _S8("+VTS")}, + {EATCIEV, _S8("+CIEV")}, + {EATERROR, _S8("ERROR")}, + {EATOK, _S8("OK")}, + {EATRING, _S8("RING")}, + {EATBIA, _S8("+BIA")}, + {EATCREG, _S8("+CREG")}, + {EATCGSN, _S8("+CGSN")}, + {EATCSQ, _S8("+CSQ")}, + {EATCIMI, _S8("+CIMI")}, + {EATCGMI, _S8("+CGMI")}, + {EATCGMM, _S8("+CGMM")}, + {EATCGMR, _S8("+CGMR")}, + {EATCOLP, _S8("+COLP")}, + }; + +const TInt KATNameTableSize = (sizeof(KATNameTable) / sizeof(SATNameDef)); + +class SCommandParamDef + { + public: + const TATId KId; + const TATType KType; + const TInt KParamNum; + const TInt* KParamTypes; + }; + +const TInt KIntList1[] = {EATIntParam}; +const TInt KIntList2[] = {EATIntParam, EATIntParam}; +const TInt KIntList3[] = {EATIntParam, EATIntParam, EATIntParam}; +const TInt KIntList4[] = {EATIntParam, EATIntParam, EATIntParam, EATIntParam}; +const TInt KIntList5[] = {EATIntParam, EATIntParam, EATIntParam, EATIntParam, EATIntParam}; +const TInt KIntList8[] = {EATIntParam, EATIntParam, EATIntParam, EATIntParam, EATIntParam, EATIntParam, EATIntParam, EATIntParam}; +const TInt KStrList1[] = {EATStringParam}; +const TInt KDQStrIntList2[] = {EATDQStringParam, EATIntParam}; +const TInt KDQStrIntList3[] = {EATDQStringParam, EATIntParam, EATIntParam}; +const TInt KIntDQStrList3[] = {EATIntParam, EATIntParam, EATDQStringParam}; +const TInt KNilDQStrIntList5[] = {EATNullParam, EATDQStringParam, EATIntParam, EATNullParam, EATIntParam}; + +const SCommandParamDef KCommandParamTable[] = + { + {EATBINP, EATWriteCmd, 1, KIntList1}, + {EATBRSF, EATWriteCmd, 1, KIntList1}, + {EATBVRA, EATWriteCmd, 1, KIntList1}, + {EATCCWA, EATWriteCmd, 1, KIntList1}, + {EATCHLD, EATWriteCmd, 1, KIntList1}, + {EATCKPD, EATWriteCmd, 1, KIntList1}, + {EATCLIP, EATWriteCmd, 1, KIntList1}, + {EATCMEE, EATWriteCmd, 1, KIntList1}, + {EATCMER, EATWriteCmd, 4, KIntList4}, + {EATCOPS, EATWriteCmd, 2, KIntList2}, + {EATD1, EATActionCmd, 1, KStrList1}, + {EATD2, EATActionCmd, 1, KIntList1}, + {EATNREC, EATWriteCmd, 1, KIntList1}, + {EATVGM, EATWriteCmd, 1, KIntList1}, + {EATVGS, EATWriteCmd, 1, KIntList1}, + {EATVTS, EATWriteCmd, 1, KStrList1}, + {EATBIA, EATWriteCmd, 8, KIntList8}, + {EATCREG, EATWriteCmd, 1, KIntList1}, + {EATCOLP, EATWriteCmd, 1, KIntList1}, + }; + +const TInt KCommandParamTableSize = (sizeof(KCommandParamTable) / sizeof(SCommandParamDef)); + + +class SResultCodeParamDef + { + public: + const TATId KId; + const TATType KType; + const TInt KParamNum; + const TInt* KParamTypes; + }; + +const SResultCodeParamDef KResultCodeParamTable[] = + { + {EATBRSF, EATWriteResult, 1, KIntList1}, + {EATBVRA, EATUnsolicitedResult, 1, KIntList1}, + {EATCCWA, EATUnsolicitedResult, 3, KDQStrIntList3}, + {EATCIND, EATReadResult, 3, KIntList3}, + {EATCLCC, EATActionResult, 5, KIntList5}, + {EATCLIP, EATReadResult, 2, KIntList2}, + {EATCLIP, EATUnsolicitedResult, 2, KDQStrIntList2}, + {EATCNUM, EATActionResult, 5, KNilDQStrIntList5}, + {EATCOPS, EATReadResult, 1, KIntDQStrList3}, + {EATVGS, EATUnsolicitedResult, 1, KIntList1}, + {EATCIEV, EATUnsolicitedResult, 2, KIntList2}, + {EATCREG, EATReadResult, 2, KIntList2}, + {EATCREG, EATUnsolicitedResult, 2, KIntList1}, + {EATCGSN, EATReadResult, 1, KStrList1}, + {EATCSQ, EATReadResult, 2, KIntList2}, + {EATCIMI, EATReadResult, 1, KStrList1}, + {EATCGMI, EATReadResult, 1, KStrList1}, + {EATCGMM, EATReadResult, 1, KStrList1}, + {EATCGMR, EATReadResult, 1, KStrList1}, + {EATCOLP, EATReadResult, 1, KIntList1}, + {EATCOLP, EATUnsolicitedResult, 2, KDQStrIntList2}, + }; + +const TInt KResultCodeParamTableSize = (sizeof(KResultCodeParamTable) / sizeof(SResultCodeParamDef)); + + +#endif // ATCODECDEFS_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/atcodec/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/atcodec/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef DEBUGCONFIG_H +#define DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btmac.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[atcdc] "); +_LIT8(KTracePrefix8, "[atcdc] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "ATCodec"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // LOCOD_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/atcodec/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/atcodec/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2005-2006 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: Base Active Object declaration +* +*/ + + +#ifndef C_BTMACTIVE_H +#define C_BTMACTIVE_H + +// INCLUDES +#include +#include "btmactiveobserver.h" + +/** + * The base class of Active Object in BTMAC + * + * This class provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CBtmActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CBtmActive : public CActive + { + +public: + + static CBtmActive* NewL(MBtmActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + virtual ~CBtmActive(); + +public: + + /** + * Indicates a request has been issued and it is now outstanding + * + * @since S60 v3.1 + */ + virtual void GoActive(); + + /** + * Gets the request identifier that this active object is responsible for. + * + * @since S60 v3.1 + * @return the request identifier + */ + TInt RequestId() const; + + /** + * Sets the request identifier that this active object is responsible for. + * + * @since S60 v3.1 + * @param the request identifier + */ + void SetRequestId(TInt aRequestId); + +protected: + + /** + * From CActive. + * cancels the outstanding request. + * + * @since S60 v3.1 + */ + virtual void DoCancel(); + + /** + * From CActive. + * Handles the request completion event. + * + * @since S60 v3.1 + */ + virtual void RunL(); + + /** + * From CActive. + * Handles the leave from RunL(). + * + * @since S60 v3.1 + * @param aError the leave code in RunL() + * @return the error code to Active Scheduler + */ + virtual TInt RunError(TInt aError); + +protected: + + CBtmActive(MBtmActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + MBtmActiveObserver& Observer(); + +private: + + /** + * The observer which is interested in the request handling events. + * Not own. + */ + MBtmActiveObserver& iObserver; + + /** + * The request identifier assigned to this active object. + */ + TInt iRequestId; + + }; + +#endif // C_BTMACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmactiveobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmactiveobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2005-2006 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: The observer of CBtmActive's request events +* +*/ + + +#ifndef M_BTMACTIVEOBSERVER_H +#define M_BTMACTIVEOBSERVER_H + +// INCLUDES +#include + +class CBtmActive; + +/** + * The observer of CBtmActive's request events + * + * This class defines the interface to handle a async request events from CBtmActive. + * + * @since S60 v3.1 + */ +class MBtmActiveObserver + { + +public: + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBtmActive& aActive) = 0; + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtmActive& aActive) = 0; + + }; + +#endif // M_BTMACTIVEOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2005-2006 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: Configuration +* +*/ + + +#ifndef BTMCONFIG_H +#define BTMCONFIG_H + +#ifdef _DEBUG +#define __ENABLE_TRACE__ +#endif + +//#define __FILE_TRACE__ + +//#define __MODULETEST_BUILD__ + +//#define __USE_STUB__ + +#endif // BTMCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmdefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmdefs.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2006 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: type declaration. +* +*/ + + +#ifndef BTMDEFS_H +#define BTMDEFS_H + +#include + +// BT Accessory Types +/* +enum TBtmAccType + { + EBtmHandsfree, + EBtmHeadset, + }; +*/ +class TBtmService + { + public: + TUint iChannel; + TUint iService; + TSdpServRecordHandle iHandle; + }; + +const TInt KPowerSaveTimeout = 8500000; + +const char KCharCr = '\r'; + +//Panic codes +enum TBTPanicCode + { + EBTPanicNullPointer = 33300, + EBTPanicRfcommAlreadyListen, + EBTPanicRfcommSockInuse, + EBTPanicObjectInUse, + EBTPanicObjectUninitialized, + EBTPanicObjectMismatch, + EBTPanicRequestOutstanding, + EBTPanicNullClientRequest, + EBtPanicPubSubError, + EBTPanicFeatureNotSupported, + EBTPanicNullCmdHandler + }; + + +#endif // BTMDEFS_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,321 @@ +/* +* Copyright (c) 2005-2006 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: the entry of this plugin. +* Version : %version: 12.1.6 % +* +*/ + + +#ifndef C_BTMMAN_H +#define C_BTMMAN_H + +#include +#include + +#include +#include +#include +//#include +#include "btmcobserver.h" +#include "btmcprofileid.h" +#include "btmactiveobserver.h" +#include "btmdefs.h" +#include +//#include + +class RSocketServ; +class CBtmState; +class CBtmActive; +class CBtmcHandlerApi; + +/** + * the main class of BTMAC. + * + * It implements plugin API and is the owner of the state machine. + * + * @since S60 v3.1 + */ +class CBtmMan : public CBTAccPlugin, public MBtmcObserver, public MBtmActiveObserver + { +public: + static CBtmMan* NewL(TPluginParams& aParams); + + virtual ~CBtmMan(); + + /** + * State transition + * + * @since S60 v3.1 + * @param aState the next state to be entered. + */ + void ChangeStateL(CBtmState* aNext); + + /** + * Gets the socket server. + * + * @since S60 v3.1 + * @return the socket server. + */ + RSocketServ& SockServ(); + + /** + * Indicates a new connection from a mono accessory. + * + * @since S60 v3.1 + * @param aAddr The acc BD address + * @param aProfile the connected profile + */ + void NewAccessory(const TBTDevAddr& aAddr, TProfiles aProfile); + + /** + * Indicates a disconnection originated from a mono accessory. + * + * @since S60 v3.1 + * @param aAddr The acc BD address + * @param aProfile the disconnected profile + */ + void AccessoryDisconnected(const TBTDevAddr& aAddr, TProfiles aProfile); + + /** + * Indicates a audio link open originated from a mono accessory. + * + * @since S60 v3.1 + * @param aAddr The acc BD address + * @param aProfile the connected profile + */ + void RemoteAudioOpened(const TBTDevAddr& aAddr, TProfiles aProfile); + + /** + * Indicates a audio link close originated from a mono accessory. + * + * @since S60 v3.1 + * @param aAddr The acc BD address + * @param aProfile the connected profile + */ + void RemoteAudioClosed(const TBTDevAddr& aAddr, TProfiles aProfile); + + /** + * Register a BT service (Profile) in SDP server + * + * @since S60 v3.1 + * @param aService the service + * @param aChannel the RFComm channel that the service is registered on + */ + void RegisterServiceL(TUint aService, TUint aChannel); + + /** + * Delete the given registered service from SDP server. + * + * @since S60 v3.1 + * @param aService the service + */ + void DeleteRegisteredService(TUint aService); + + /** + * Delete all registered services from SDP server + * + * @since S60 v3.1 + */ + void DeleteAllRegisteredServices(); + + /** + * Get a last used channel(port) for a specified service + * + * @since S60 v3.2 + */ + TInt GetLastUsedChannel(TUint aService); + + + /** + * Get audio latency + * + * @since S60 v5.0 + */ + TInt AudioLinkLatency(); + + TBool IsTrashBinEmpty(); + + void LoadCmdHandlerL(TBtmcProfileId aProfile, const TBTDevAddr& aAddr, TBool aAccessoryInitiated); + + void DeleteCmdHandler(); + + void NewProtocolDataL(const TDesC8& aData); + + TBool IsAccInuse() const; + + TBool IsEdrSupported() const; + +private: + // From base class CBTAccPlugin + + /** + * Connect to mono accessory. + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + * @param aStatus On completion, will contain an error code + */ + void ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Cancel connect + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + */ + void CancelConnectToAccessory(const TBTDevAddr& aAddr); + + /** + * Disconnect to mono accessory + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + * @param aStatus On completion, will contain an error code + */ + void DisconnectAccessory(const TBTDevAddr& aAddr,TRequestStatus& aStatus); + + /** + * Open audio link + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Close open audio link + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + */ + void CancelOpenAudioLink(const TBTDevAddr& aAddr ); + + /** + * Called by BT Acc Sever to connect to mono or stereo accessory + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + * @param aStatus On completion, will contain an error code + */ + void CloseAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Close audio link + * + * @since S60 v3.1 + * @param aAddr BD address of the remote device + * @param aStatus On completion, will contain an error code + */ + void CancelCloseAudioLink(const TBTDevAddr& aAddr ); + + /** + * Informs accessory is in use. + * + * @since S60 v3.1 + */ + void AccInUse(); + + void AccOutOfUse(); + + /** + * Check which accessory type is supported by this plugin. + * + * @since S60 v3.1 + * @return the supported plugin type. + */ + TProfiles PluginType(); + + void ActivateRemoteVolumeControl(); + + void DeActivateRemoteVolumeControl(); + + TInt GetRemoteSupportedFeature(); + + // From base class CBtmActive + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBtmActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void CancelRequest(CBtmActive& aActive); + +private: + // From MBtmcObserver + void SlcIndicateL(TBool aSlc); + + void SendProtocolDataL(const TDesC8& aData); + + +private: + CBtmMan(TPluginParams& aParams); + + void ConstructL(); + +private: + /** + * The socket server. + */ + RSocketServ iSockServ; + + /** + * the current state. + */ + CBtmState* iState; + + /** + * The place where obsolete state instances are temporarily stored. + */ + RPointerArray iTrashBin; + + CBtmActive* iActive; + + /** + * the property for mono accessory connection state + */ + RProperty iMonoStateProp; + + /** + * the property for connected mono accessory BD address + */ + RProperty iMonoAddrProp; + + /** + * the list of registered service in SDP server. + */ + RArray iServices; + + /* + * at command handler + */ + CBtmcHandlerApi* iCmdHandler; + + TBool iAccInuse; + + TBool iEdr; + + CBTEngDiscovery* iBteng; + }; + +#endif // C_BTMMAN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmrfcommsock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmrfcommsock.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,307 @@ +/* +* Copyright (c) 2005-2006 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: BT RFComm socket. +* +*/ + + +#ifndef C_BTMRFCOMMSOCK_H +#define C_BTMRFCOMMSOCK_H + +#include +#include "btmdefs.h" + +class MBtmSockObserver; +class CDesC8ArrayFlat; + +/** + * RFComm socket. + * + * A RFComm connection. + * + * @since S60 v3.1 + */ +class CBtmRfcommSock : public CBase, public MBluetoothSocketNotifier + { +public: + + static CBtmRfcommSock* NewL(MBtmSockObserver& aObserver, RSocketServ& aServer); + + virtual ~CBtmRfcommSock(); + +public: + + /** + * Makes a RFCOMM connection to a BT device + * + * @since S60 v3.1 + * @param aAddr the BD address of the BT device + */ + void ConnectL(TBTSockAddr& aAddr, TUint aService); + + /** + * Cancel the outstanding connect request + * + * @since S60 v3.1 + */ + void CancelConnect(); + + /** + * Socket accept operation. + * Register a RFComm channel first then register SDP service according the + * given service id then starts socket accept operation. + * + * @since S60 v3.1 + * @param aService The service (profile) + * @param aSec the security requirement of the service + */ + TUint ListenL(TUint aService, const TBTServiceSecurity& aSec, TUint aLastUsedPort); + + /** + * cancels the outstanding accept operation. + * Th reserved channel will be freed and the registered service will be removed. + * + * @since S60 v3.1 + */ + void CancelListen(); + + /** + * Disconnects the socket connection + * + * @since S60 v3.1 + * @param aHow Information about the reason of shutdown. + */ + void Disconnect(RSocket::TShutdown aHow = RSocket::ENormal); + + /** + * Writes a data packet to the connected BT device + * + * @since S60 v3.1 + * @param aDesc the data packet + */ + void WriteL(const TDesC8& aData); + + /** + * Cancel writing + * + * @since S60 v3.1 + */ + void CancelWrite(); + + /** + * Get the connected remote BD address + * + * @since S60 v3.1 + * @return the BD address + */ + const TBTDevAddr& Remote() const; + + /** + * Requests for master role + * + * @since S60 v3.1 + * @return the completion error code + */ + TInt RequestMasterRole(); + + /** + * Activates the notification of baseband events + * + * @since S60 v3.1 + * @param aNotification the interested baseband events + * @return the completion error code + */ + TInt ActivateBasebandEventNotification(TInt aNotification); + + /** + * Sets the socket observer to the specified. + * + * @since S60 v3.1 + * @param aObserver the new observer. + */ + void SetObserver(MBtmSockObserver& aObserver); + + /** + * Gets the service (a RFComm profile) that this connection is for. + * + * @since S60 v3.1 + * @return the service id. + */ + TUint Service() const; + + TInt ActivateSniffRequester(); + + void RequestLinkToActiveMode(); + + TBool IsInSniff() const; + + void SetService(TUint aService); + + TBool AccessoryInitiatedConnection(); + +private: + + // from base class MBluetoothSocketNotifier + + /** + * From MBluetoothSocketNotifier + * Notification of a RFCOMM socket connect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + * @param aType the type (HF or HS) of the accessory if the connection is successful + */ + void HandleConnectCompleteL(TInt aErr); + + /** + * From MBluetoothSocketNotifier + * Notification of a RFCOMM socket accpet completion event. + * + * @since S60 v3.1 + * @param aType the type (HF or HS) of the accessory if the connection is successful + * @param aErr the completion error code + */ + void HandleAcceptCompleteL(TInt aErr); + + /** + * From MBluetoothSocketNotifier + * Notification of a RFCOMM socket shutdown completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleShutdownCompleteL(TInt aErr); + + /** + * From MBluetoothSocketNotifier + * Notification of a RFCOMM socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleSendCompleteL(TInt aErr); + + /** + * From MBluetoothSocketNotifier + * Notification of a RFCOMM socket receive completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleReceiveCompleteL(TInt aErr); + + /** + * From MBluetoothSocketNotifier + * Notification of an ioctl complete event. + * + * @since S60 v3.1 + * @param aErr the returned error + */ + void HandleIoctlCompleteL(TInt aErr); + + /** + * From MBluetoothSocketNotifier + * Notification of a baseband event. + * + * @since S60 v3.1 + * @param aErr the completion error code + * @param TBTBasebandEventNotification Bit(s) set indicate what event has taken place. + */ + void HandleActivateBasebandEventNotifierCompleteL( + TInt aErr, TBTBasebandEventNotification& aEventNotification); + + // From base class CBtmActive + +private: + + void ConstructL(); + + CBtmRfcommSock(MBtmSockObserver& aObserver, RSocketServ& aServer); + + void SendPacketL(); + + /** + * Reads data from the connected BT device + * + * @since S60 v3.1 + * @param aData Contains the received data on completion + */ + void ReceiveL(); + + /** + * Cancel reading + * + * @since S60 v3.1 + */ + void CancelReceive(); + +private: + + /** + * socket event observer. + * Not own. + */ + MBtmSockObserver* iObserver; + + /** + * The socket server session + * Not own. + */ + RSocketServ& iServer; + + /** + * The RFComm connection socket + */ + CBluetoothSocket* iDataSocket; + + /** + * The listening socket + */ + CBluetoothSocket* iListenSocket; + + /** + * the length of data read and written + */ + TSockXfrLength iXfrLength; + + /** + * the baseband event notification + */ + TBTBasebandEvent iEventNotification; + + TInt iBBNotificationMode; + + TBool iInSniff; + + /** + * The service for which the socket connection is served + */ + TUint iService; + + /** + * The remote BD address + */ + TBTDevAddr iRemote; + + TBool iRemoteHasConnected; // who initiated connection + RBuf8 iInData; // owned + RBuf8 iOutData; // owned + CDesC8ArrayFlat* iOutDataQueue; // owned + + TBool iWriting; + + RBTPhysicalLinkAdapter iAda; + }; + +#endif // C_BTMRFCOMMSOCK_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsaudio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsaudio.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2005-2006 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: The audio opened state declaration +* Version : %version: 2.2.3 % +* +*/ + + +#ifndef C_BTMSAUDIO_H +#define C_BTMSAUDIO_H + +#include "btmstate.h" + +#include "btmsinuse.h" + +class CBtmSyncSock; + +/** + * audio opened state + * + * This state indicates a sync socket connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsAudio : public CBtmsInuse + { +public: + + static CBtmsAudio* NewL(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco); + + virtual ~CBtmsAudio(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Close the audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void CloseAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + // From base class CBtmstate + + /* + * Get auido link latency + * + * @since S60 v5.0 + */ + TInt AudioLinkLatency(); + + // From base class MBtmSockObserver + + /** + * Notification of a synchronous socket disconnect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void SyncLinkDisconnectCompleteL(TInt aErr); + +private: + + CBtmsAudio(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco); + +private: + + /** + * sync socket that has a sco connection with a BT device. + * Ownership is possible to be transfered the the next state. + */ + CBtmSyncSock* iSco; + + }; + +#endif // C_BTMSAUDIO_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmscloseaudio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmscloseaudio.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2005-2006 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: The audio closing state declaration +* +*/ + + +#ifndef C_BTMSCLOSEAUDIO_H +#define C_BTMSCLOSEAUDIO_H + +#include "btmsinuse.h" + +class CBtmSyncSock; + +/** + * audio closing state + * + * This state is responsible to release sync socket connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsCloseAudio : public CBtmsInuse + { +public: + + static CBtmsCloseAudio* NewL(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco); + + virtual ~CBtmsCloseAudio(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Cancel the outstanding operation + * + * @since S60 v3.1 + */ + void CancelCloseAudioLinkL(const TBTDevAddr& aAddr); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + // FRom base class MBtmSockObserver + + /** + * Notification of a synchronous socket disconnect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void SyncLinkDisconnectCompleteL(TInt aErr); + +private: + + CBtmsCloseAudio(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco); + + void ConstructL(); + +private: + + /** + * The connected sync Socket. + */ + CBtmSyncSock* iSco; + + }; + +#endif // C_BTMSCLOSEAUDIO_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsconnect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsconnect.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2005-2006 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: The connect state declaration +* +*/ + + +#ifndef C_BTMSCONNECT_H +#define C_BTMSCONNECT_H + +#include +#include +#include "btmstate.h" +#include "btmactiveobserver.h" +#include "btmdefs.h" + +class CBtmActive; +class CBtmRfcommSock; + + +/** + * Connect state + * + * This state is responsible to establish RFComm connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsConnect : public CBtmState, public MBTEngSdpResultReceiver + { +public: + + /** + * @param aParent the state machine + * @param aStatus the request from client of btmac if not null + * @param aAddr the remote device address + * @param aRequestCat the category of the client request + */ + static CBtmsConnect* NewL(CBtmMan& aParent, TRequestStatus* aRequest, + const TBTDevAddr& aAddr, TRequestCategory aRequestCat); + + virtual ~CBtmsConnect(); + + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * From CBtmState + * Cancel the outstanding connecting operation + * + * @since S60 v3.1 + */ + void CancelConnectL(); + + void CancelOpenAudioLinkL(const TBTDevAddr& aAddr); + + // From base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a RFCOMM socket connect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommConnectCompletedL(TInt aErr); + + // From base class CBtmActive + + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void CancelRequest(CBtmActive& aActive); + +public: + // from MBTEngSdpResultReceiver + + void ServiceSearchComplete( const RSdpRecHandleArray& aResult, + TUint aTotalRecordsCount, TInt aErr ); + + void AttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ); + + void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ); + + void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ); +private: + + CBtmsConnect(CBtmMan& aParent, TRequestStatus* aRequest, + const TBTDevAddr& aAddr, TRequestCategory aRequestCat); + + void ConstructL(); + + void DoSockConnectL(TUint aService); + +private: + + /** + * for SDP query. + */ + CBTEngDiscovery* iBteng; + + + /** + * the RFComm channel in the remote device. + */ + TInt iRemoteChannel; + + /** + * RFComm Socket. + * Ownership is possible to be transfered the the next state. + */ + CBtmRfcommSock* iRfcomm; + + /** + * The addr for connecting + */ + TBTSockAddr iSockAddr; + + CBTDevice* iDevice; + + TRequestCategory iRequestCat; + + TInt iSearchState; + }; + +#endif // C_BTMSCONNECT_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsctrl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsctrl.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2005-2006 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: The Control state declaration +* +*/ + + +#ifndef C_BTMSCTRL_H +#define C_BTMSCTRL_H + +#include "btmsinuse.h" +#include "btmactiveobserver.h" +#include "btmdefs.h" + +class CBtmActive; +class CBtmSyncSock; + +const TUint KBTSdpHandsfreeAudioGateway = 0x111F; +const TUint KBTSdpHeadsetAudioGateway = 0x1112; + + +/** + * Connect state + * + * This state is responsible to establish RFComm connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsCtrl : public CBtmsInuse, public MBtmActiveObserver + { +public: + + /** + * @param aParent the state machine + * @param aStatus the request from client of btmac if not null + * @param aRfcomm the rfcomm connection + * @param aSco the sync socket having an outstanding accept operation if not null + * @param aRequestCat the category of the client request + */ + static CBtmsCtrl* NewL( + CBtmMan& aParent, + CBtmRfcommSock* aRfcomm, + CBtmSyncSock* aSco); + + virtual ~CBtmsCtrl(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * From CBtmState + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * From CBtmState + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + // From base class CBtmsInuse + + void AccInUse(); + + TBool CanDisableNrec(); + + // FRom base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a synchronous socket accept completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkAcceptCompleteL(TInt aErr); + + void RfcommLinkInSniffModeL(); + + // From base class CBtmActive + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBtmActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void CancelRequest(CBtmActive& aActive); + + +private: + + CBtmsCtrl(CBtmMan& aParent, + CBtmRfcommSock* aRfcomm, + CBtmSyncSock* aSco); + + void ConstructL(); + +private: + + /** + * sync socket that listens a sco connection from a BT device. + * Ownership is possible to be transfered the the next state. + */ + CBtmSyncSock* iSco; + }; + +#endif // C_BTMSCTRL_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsdisconnect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsdisconnect.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2005-2006 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: The disconnect state declaration +* +*/ + + +#ifndef C_BTMSDISCONNECT_H +#define C_BTMSDISCONNECT_H + +#include "btmsinuse.h" + +class CBtmSyncSock; + +/** + * audio closing state + * + * This state is responsible to release RFComm and sync socket connections with a BT device + * + * @since S60 v3.1 + */ +class CBtmsDisconnect : public CBtmsInuse + { +public: + + static CBtmsDisconnect* NewL(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm); + + virtual ~CBtmsDisconnect(); + + void SetConnectFailReason(TInt aReason); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + +private: + // From base class MBtmSockObserver + + /** + * Notification of a RFCOMM socket shutdown completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommShutdownCompletedL(TInt aErr); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + +private: + + CBtmsDisconnect(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm); + + void ConstructL(); + +private: + + TInt iConnectFailReason; + + }; + +#endif // C_BTMSDISCONNECT_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsidle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsidle.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2006 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: state Idle declaration. +* +*/ + + +#ifndef C_BTMSIDLE +#define C_BTMSIDLE + +#include "btmstate.h" + +/** + * The state Idle + * + * This state indicates there is no connection and no pending socket accept + * operation issued in BTMAC. + * + * @since S60 v3.1 + */ +class CBtmsIdle : public CBtmState + { + +public: + + static CBtmsIdle* NewL(CBtmMan& aParent); + + virtual ~CBtmsIdle(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + */ + void EnterL(); + + /** + * From CBtmState + * Connect to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + +private: + + CBtmsIdle(CBtmMan& aParent); + + }; + +#endif // C_BTMSIDLE + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsinuse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsinuse.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2005-2006 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: The in use state declaration +* +*/ + + +#ifndef C_BTMSINUSE_H +#define C_BTMSINUSE_H + +#include +#include +#include +#include "btmstate.h" +#include + +class CBtmRfcommSock; +class CBtmSyncSock; + +/** + * the in use state. This class is abstract. + * + * @since S60 v3.1 + */ +class CBtmsInuse : public CBtmState + { + +public: + + virtual ~CBtmsInuse(); + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommErrorL(TInt aErr) = 0; + +protected: + + // From CBtmstate + + virtual void ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + virtual void SendProtocolDataL(const TDesC8& aData); + + TBTDevAddr Remote(); + +protected: + + // From base class MBtmSockObserver + + /** + * Notification of a RFCOMM socket connect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommConnectCompletedL(TInt aErr); + + /** + * Notification of a RFCOMM socket accpet completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + * @param aService the connected profile + */ + virtual void RfcommAcceptCompletedL(TInt aErr, TUint aService); + + /** + * Notification of a RFCOMM socket shutdown completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommShutdownCompletedL(TInt aErr); + + /** + * Notification of a RFCOMM socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommSendCompletedL(TInt aErr); + + /** + * Notification of a RFCOMM socket receive completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommReceiveCompletedL(TInt aErr, const TDesC8& aData); + +protected: + + CBtmsInuse(CBtmMan& aParent, TRequestStatus* aRequest, CBtmRfcommSock* aRfcomm); + +protected: + + CBtmRfcommSock* SwapStateRfcommSock(); + + CBtmSyncSock* SwapSyncSock(CBtmSyncSock*& aSyncSock); + +protected: + + /** + * RFComm Socket. + * Ownership is possible to be transfered the the next state. + */ + CBtmRfcommSock* iRfcomm; + + + }; + +#endif // C_BTMSINUSE_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmslisten.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmslisten.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2005-2006 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: The listen state declaration +* +*/ + + +#ifndef C_BTMSLISTEN_H +#define C_BTMSLISTEN_H + +#include "btmstate.h" + +class CBtmRfcommSock; + +/** + * Connect state + * + * This state is responsible to establish RFComm connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsListen : public CBtmState + { + +public: + + static CBtmsListen* NewL(CBtmMan& aParent); + + virtual ~CBtmsListen(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * From CBtmState + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + CBtmState* ErrorOnEntryL(TInt aReason); + + /** + * From CBtmState + * Starts bt audio listener + * @since S60 v3.2 + */ + void StartListenerL(); + + /** + * From CBtmState + * Connect to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * From CBtmState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + // From base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a RFCOMM socket accpet completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + * @param aService the connected profile + */ + void RfcommAcceptCompletedL(TInt aErr, TUint aService); + +private: + + CBtmsListen(CBtmMan& aParent); + + void ConstructL(); + +private: + + /** + * Sock to listen HFP. + * Ownership will be transfered the the next state if + * accept is completed with KErrNone. Otherwise owned. + */ + CBtmRfcommSock* iHfpSock; + + /** + * Sock to listen HSP. + * Ownership will be transfered the the next state if + * accept is completed with KErrNone. Otherwise owned. + */ + CBtmRfcommSock* iHspSock; + + }; + +#endif // C_BTMSLISTEN_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsockobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsockobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2005-2006 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: BT socket event observer declaration. +* +*/ + + +#ifndef M_BTMSOCKOBSERVER_H +#define M_BTMSOCKOBSERVER_H + +// INCLUDES +#include + +/** + * BT socket event observer + * + * This class defines the interfaces o receive events from a Bluetooth socket + * + * @since S60 v3.1 + */ +class MBtmSockObserver + { +public: + + /** + * Notification of a RFCOMM socket connect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommConnectCompletedL(TInt aErr); + + /** + * Notification of a RFCOMM socket accpet completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + * @param aService the connected profile + */ + virtual void RfcommAcceptCompletedL(TInt aErr, TUint aService); + + /** + * Notification of a RFCOMM socket shutdown completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommShutdownCompletedL(TInt aErr); + + /** + * Notification of a RFCOMM socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommSendCompletedL(TInt aErr); + + /** + * Notification of a RFCOMM socket receive completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void RfcommReceiveCompletedL(TInt aErr, const TDesC8& aData); + + /** + * Notification of an ioctl complete event. + * + * @since S60 v3.1 + * @param aErr the returned error + */ + virtual void RfcommIoctlCompleteL(TInt aErr); + + virtual void RfcommLinkInActiveModeL(); + + virtual void RfcommLinkInSniffModeL(); + + /** + * Notification of a synchronous socket setup completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkSetupCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket disconnect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkDisconnectCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket accept completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkAcceptCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkSendCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkReceiveCompleteL(TInt aErr); + + }; + +#endif // M_BTMSOCKOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsopenaudio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsopenaudio.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2005-2006 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: The audio opening state declaration +* +*/ + + +#ifndef C_BTMSOPENAUDIO_H +#define C_BTMSOPENAUDIO_H + +#include "btmsinuse.h" + +class CBtmSyncSock; + +// enum for eSCO parameter negotiation, same as Symbian eSCO packet types + +enum EESCOParam + { + EEV3 = 0x20008, + EEV4 = 0x20010, + EEV5 = 0x20020, + ENoeSCO = 0 + }; + + +/** + * audio opening state + * + * This state is responsible to establish sync socket connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsOpenAudio : public CBtmsInuse + { +public: + + static CBtmsOpenAudio* NewL(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco, TBool aUseEsco = ETrue, EESCOParam aESCOParameter = EEV5); + + virtual ~CBtmsOpenAudio(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void Disconnect(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + + /** + * Cancel openning audio + * + * @since S60 v3.1 + */ + void CancelOpenAudioLinkL(const TBTDevAddr& aAddr); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + // FRom base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a synchronous socket setup completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void SyncLinkSetupCompleteL(TInt aErr); + + /** + * From MBtmSockObserver + * Notification of a synchronous socket accept completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void SyncLinkAcceptCompleteL(TInt aErr); + +private: + + CBtmsOpenAudio(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco, TBool aType, EESCOParam aESCOParameter); + + void ConstructL(); + +private: + + /** + * sync Socket used for accepting SCO. + * Ownership is possible to be transfered the the next state. + */ + CBtmSyncSock* iAcceptSco; + + TBool iUseEsco; + /** + * sync Socket used for establishing SCO. + * Ownership is possible to be transfered the the next state. + */ + CBtmSyncSock* iSetupSco; + + EESCOParam iESCOParameter; + + }; + +#endif // C_BTMSOPENAUDIO_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsreconnect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsreconnect.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2005-2006 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: The reconnect state declaration +* +*/ + + +#ifndef C_BTMRESCONNECT_H +#define C_BTMRESCONNECT_H + +#include +#include + +#include "btmsinuse.h" +#include "btmactiveobserver.h" +#include "btmdefs.h" + +class CBtmActive; +class CBtmRfcommSock; + +/** + * Reconnect state + * + * This state is responsible to reconnect HSP RFComm connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsReconnect : public CBtmsInuse, MBTEngSdpResultReceiver + { +public: + + static CBtmsReconnect* NewL(CBtmMan& aParent, TRequestStatus* aRequest, const TBTDevAddr& aAddr); + + virtual ~CBtmsReconnect(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Cancel openning audio + * + * @since S60 v3.1 + */ + void CancelOpenAudioLinkL(const TBTDevAddr& aAddr); + + // From CBtmsInuse + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + // From base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a RFCOMM socket connect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommConnectCompletedL(TInt aErr); + + +public: + // from MBTEngSdpResultReceiver + + void ServiceSearchComplete( const RSdpRecHandleArray& aResult, + TUint aTotalRecordsCount, TInt aErr ); + + void AttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, TInt aErr ); + + void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ); + + void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ); +private: + + CBtmsReconnect(CBtmMan& aParent, TRequestStatus* aRequest, const TBTDevAddr& aAddr); + + void ConstructL(); + + void DoSockConnectL(TUint aService); + +private: + + /** + * for SDP query. + */ + CBTEngDiscovery* iBteng; + + + /** + * the RFComm channel in the remote device. + */ + TInt iRemoteChannel; + + /** + * The addr for connecting + */ + TBTSockAddr iSockAddr; + }; + +#endif // C_BTMSCONNECT_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsrfcomm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsrfcomm.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2005-2006 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: The RFCOMM connected state declaration +* +*/ + + +#ifndef C_BTMSRFCOMM_H +#define C_BTMSRFCOMM_H + +#include "btmsinuse.h" +#include "btmactiveobserver.h" +#include "btmdefs.h" + +class CBtmActive; + +/** + * Connect state + * + * This state is responsible to establish RFComm connection with a BT device + * + * @since S60 v3.1 + */ +class CBtmsRfcomm : public CBtmsInuse + { +public: + + /** + * @param aParent the state machine + * @param aStatus the request from client of btmac if not null + * @param aRfcomm the rfcomm connection + * @param aRequestCat the category of the client request + */ + static CBtmsRfcomm* NewL( + CBtmMan& aParent, + TRequestStatus* aStatus, + CBtmRfcommSock* aRfcomm, + TRequestCategory aRequestCat = ERequestNone); + + virtual ~CBtmsRfcomm(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + void CancelConnectL(); + + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * From CBtmState + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void CancelOpenAudioLinkL(const TBTDevAddr& aAddr); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + // From base class CBtmsInuse + + /** + * + * + * @since S60 v3.1 + * @param + */ + void SlcIndicateL(TBool aSlc); + + TBool CanDisableNrec(); + +private: + + CBtmsRfcomm(CBtmMan& aParent, + TRequestStatus* aStatus, + CBtmRfcommSock* aRfcomm, + TRequestCategory aRequestCat); + + void ConstructL(); + +private: + + TRequestCategory iRequestCat; + }; + +#endif // C_BTMSRFCOMM_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmssniffm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmssniffm.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,153 @@ +/* +* Copyright (c) 2005-2006 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: The sniff mode state declaration +* +*/ + + +#ifndef C_BTMSSNIFFM_H +#define C_BTMSSNIFFM_H + +#include "btmsinuse.h" +#include "btmdefs.h" + +class CBtmSyncSock; + +/** + * Sniff mode state + * + * + * @since S60 v3.1 + */ +class CBtmsSniffm : public CBtmsInuse, public MBtmActiveObserver + { +public: + /** + * @param aParent the state machine + * @param aRfcomm the rfcomm connection + * @param aSco the sync socket having an outstanding accept operation if not null + */ + static CBtmsSniffm* NewL(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco); + + virtual ~CBtmsSniffm(); + +private: + + // From base class CBtmState + + /** + * From CBtmState + * Entry of this state. + * + * @since S60 v3.1 + */ + void EnterL(); + + /** + * From CBtmState + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * From CBtmState + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void CancelOpenAudioLinkL(const TBTDevAddr& aAddr); + + // From base class CBtmsInuse + + /** + * The interface for subclasses to handle RFComm error situations. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void RfcommErrorL(TInt aErr); + + void AccInUse(); + + TBool CanDisableNrec(); + + + // FRom base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a synchronous socket accept completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + virtual void SyncLinkAcceptCompleteL(TInt aErr); + + void RfcommLinkInActiveModeL(); + + // From base class CBtmActive + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBtmActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void CancelRequest(CBtmActive& aActive); + +private: + + CBtmsSniffm(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco); + + void ConstructL(); + +private: + + /** + * AO for active mode request timer. + */ + CBtmActive* iActive; + + /** + * Power save timer + */ + RTimer iTimer; + + /** + * sync socket that listens a sco connection from a BT device. + * Ownership is possible to be transfered the the next state. + */ + CBtmSyncSock* iSco; + + TInt iLinkActivateRetries; + }; + +#endif // C_BTMSSNIFFM_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmstate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmstate.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2005-2006 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: The base state declaration +* Version : %version: 2.2.5 % +* +* Copyright © 2005-2006 Nokia. All rights reserved. +*/ + + +#ifndef C_BTMSTATE_H +#define C_BTMSTATE_H + +#include +#include +#include +#include +#include "btmman.h" +#include "btmsockobserver.h" + +enum TNotifyItem + { + ENotifyNone = 0, + ENotifyAudioClosedByRemote, + ENotifyAudioOpenedByRemote, + }; + +enum TRequestCategory + { + ERequestNone, + ERequestConnect, + ERequestOpenAudio, + }; + + +/** + * the base class of the state machine + * + * @since S60 v3.1 + */ +class CBtmState : public CBase, public MBtmSockObserver + { +public: + + virtual ~CBtmState(); + + void SetNotifyItemAtEntry(TNotifyItem aNotify); + + TNotifyItem NotifyItem(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + virtual void EnterL() = 0; + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + virtual CBtmState* ErrorOnEntryL(TInt aReason); + + /** + * Starts bt audio listner + * @since S60 v3.2 + */ + virtual void StartListenerL(); + + /** + * Connect to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Cancel the outstanding connecting operation + * + * @since S60 v3.1 + */ + virtual void CancelConnectL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Cancel the outstanding operation + * + * @since S60 v3.1 + */ + virtual void CancelOpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * Close the audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void CloseAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Cancel closing audio link + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + */ + virtual void CancelCloseAudioLinkL(const TBTDevAddr& aAddr); + + /** + * Called when accessory is in use (attached to AccessoryServer). + * + * @since S60 v3.1 + */ + virtual void AccInUse(); + + /* + * Defaults from observer base + */ + virtual void SlcIndicateL(TBool aSlc); + + virtual void SendProtocolDataL(const TDesC8& aData); + + virtual TBool CanDisableNrec(); + + virtual TBTDevAddr Remote(); + + virtual TInt AudioLinkLatency(); + +protected: + + CBtmState(CBtmMan& aParent, TRequestStatus* aRequest); + + /** + * Gets the owner of the state machine + * + * @since S60 v3.1 + * @return the state machine owner + */ + CBtmMan& Parent(); + + /** + * Completes the pending request in this state with specified error code + * and then zero the pointer. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void CompleteStateRequest(TInt aErr); + + /** + * Completes the give pending request with specified error code.. + * + * @since S60 v3.1 + * @param aRequest the request to be completed + * @param aErr the completion error code + */ + void CompleteRequest(TRequestStatus* aRequest, TInt aErr); + + TRequestStatus* StateRequest(); + + void SetStateRequest(TRequestStatus& aStatus); + + TRequestStatus* SwapStateRequest(); + +private: + + /** + * the owner of the state machine + * Not own. + */ + CBtmMan& iParent; + + /** + * Possible to be NULL. + * A not NULL iRequest means the async request performed in this state machine. + * It must be completed when state machine will transfer to another state. + */ + TRequestStatus* iRequest; + + TNotifyItem iNotify; + + }; + +#endif // C_BTMSTATE_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmstempd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmstempd.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2005-2006 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: The temporarily disconncted state declaration +* +*/ + + +#ifndef C_BTMSHSTEMPD_H +#define C_BTMSHSTEMPD_H + +#include "btmsinuse.h" + +class CBtmSyncSock; + +/** + * audio closing state + * + * This state is responsible to release RFComm and sync socket connections with a BT device + * + * @since S60 v3.1 + */ +class CBtmsHsTempd : public CBtmsInuse + { +public: + + static CBtmsHsTempd* NewL(CBtmMan& aParent, const TBTDevAddr& aConnectedAddr); + + virtual ~CBtmsHsTempd(); + +private: + + // From base class CBtmState + + void EnterL(); + + void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + // From base CBtmsInuse + + void RfcommErrorL(TInt aErr); + + // From base class MBtmSockObserver + + /** + * From MBtmSockObserver + * Notification of a RFCOMM socket accpet completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + * @param aService the connected profile + */ + void RfcommAcceptCompletedL(TInt aErr, TUint aService); + +private: + CBtmsHsTempd(CBtmMan& aParent, const TBTDevAddr& aConnectedAddr); + +private: + TBTDevAddr iConnectedAddr; + }; + +#endif // C_BTMSDISCONNECT_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/btmsyncsock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/btmsyncsock.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,210 @@ +/* +* Copyright (c) 2005-2006 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: BT sync socket. +* Version : %version: 7 % +* +*/ + + +#ifndef BTMACSCOLINKER_H +#define BTMACSCOLINKER_H + +#include +#include +#include + +class MBtmSockObserver; + +const TInt KEscoPacketTypeSpec = TBTSyncPackets::ESyncPacketsEV5 | + TBTSyncPackets::ESyncPacketsEV3 | + TBTSyncPackets::ESyncPacketsEV4; + +const TInt KScoPacketTypeSpec = TBTSyncPackets::ESyncAnySCOPacket; + +const TInt KMaxLatencySpec = 16; + + +/** + * Sync socket. + * + * @since S60 v3.1 + */ +class CBtmSyncSock : public CBase, public MBluetoothSynchronousLinkNotifier + { + +public: + + static CBtmSyncSock* NewL(MBtmSockObserver& aObserver, RSocketServ& aSockServ); + + virtual ~CBtmSyncSock(); + + void SetupL(const TBTDevAddr& aAddr, const TBTSyncPackets& aPackets); + + + void CancelSetup(); + + /** + * Disconnects a sync socket. + * + * @since S60 v3.1 + */ + void DisconnectL(); + + /** + * Listens to incoming sync sock connection. + * + * @since S60 v3.1 + */ + void AcceptL(TBool aAllowEsco); + + /** + * Cancel the accept operation. + * + * @since S60 v3.1 + */ + void CancelAccept(); + + void SetMaxLatency(TUint16 aLatency); + + void SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort); + + /** + * Zero the owned pointers in this object. + * + * @since S60 v3.1 + */ + void Reset(); + + /** + * Sets the socket observer to the specified. + * + * @since S60 v3.1 + * @param aObserver the new observer. + */ + void SetObserver(MBtmSockObserver& aObserver); + + /** + * Return audio link latency + * + * @since S60 5.0 + * @return latency. + */ + TInt Latency(); + +private: + + // From base class MBluetoothSynchronousLinkNotifier + + /** + * Notification of a synchronous socket setup completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleSetupConnectionCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket disconnect completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleDisconnectionCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket accept completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleAcceptConnectionCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleSendCompleteL(TInt aErr); + + /** + * Notification of a synchronous socket send completion event. + * + * @since S60 v3.1 + * @param aErr the completion error code + */ + void HandleReceiveCompleteL(TInt aErr); + +private: + + CBtmSyncSock(MBtmSockObserver& aObserver, RSocketServ& aSockServ); + + void ConstructL(); + +private: + + class TScoAcceptor; + + void AcceptRedirectL(TInt aErr, TScoAcceptor& aAcceptor); + + class TScoAcceptor : public MBluetoothSynchronousLinkNotifier + { + public: + TScoAcceptor(); + TScoAcceptor(CBtmSyncSock* aParent); + private: + CBtmSyncSock* iParent; + private: + void HandleSetupConnectionCompleteL(TInt aErr); + void HandleDisconnectionCompleteL(TInt aErr); + void HandleAcceptConnectionCompleteL(TInt aErr); + void HandleSendCompleteL(TInt aErr); + void HandleReceiveCompleteL(TInt aErr); + + friend void CBtmSyncSock::AcceptRedirectL(TInt aErr, TScoAcceptor& aAcceptor); + }; + +private: // Data + + /** + * socket event observer. + * Not own. + */ + MBtmSockObserver* iObserver; + + /** + * The socket server session + * Not own. + */ + RSocketServ& iServer; + + /** + * The BT SCO link for setup connection and SCO accept + */ + CBluetoothSynchronousLink* iSco; + + /** + * The BT Sync link for ESCO accept + */ + CBluetoothSynchronousLink* iEScoLink; + + TScoAcceptor iScoAcceptor; + + TScoAcceptor iESco_Acceptor; + + CBluetoothSynchronousLink* iConnectedLink; // pointer to either iSco or iEScoLink or none. +}; + +#endif // BTMACSCOLINKER_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef DEBUGCONFIG_H +#define DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btmac.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTMAC] "); +_LIT8(KTracePrefix8, "[BTMAC] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTMAC"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // LOCOD_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmac/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmac/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/bmbcmdlistener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/bmbcmdlistener.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2005-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: Remote connection observer interface declaration. +* +*/ + + +#ifndef BMBDATALISTENER_H +#define BMBDATALISTENER_H + + +#include +#include +#include "bmbplugin.h" + + + +class CBmbCmdListener : public CActive + { + public: + /** + * Two-phased constructor. + */ + static CBmbCmdListener* NewL(CBmbPlugin& aParent); + + /** + * Destructor. + */ + ~CBmbCmdListener(); + + /** + * Be informed of the completion of command handling. + * + * @param aResp the response to be sent to client who + * request this command handling. + */ + void HandlingDataCompleted( const TDesC8& aResp ); + + private: + /** + * C++ default constructor. + */ + CBmbCmdListener(CBmbPlugin& aParent); + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Starts listening AT commands published by btmoncmdhandler. + * @param None + * @return None + */ + void Subscribe(); + + private: + /** + * From CActive. Called when asynchronous request completes. + * @param None + * @return None + */ + void RunL(); + + /** + * From CActive. Cancels asynchronous request. + * @param None + * @return None + */ + void DoCancel(); + + private: + + CBmbPlugin& iParent; + + // for receiving AT commands from btmonocmdhandler and sending the responses + RProperty iProperty; + + // At command buffer + TBuf8 iAtCmdBuf; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/bmbpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/bmbpanic.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,31 @@ +// Copyright (c) 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: +// + +#ifndef BMBPANIC_H +#define BMBPANIC_H + +_LIT(KBmbPanicCategory, "BTMonoBearer"); + +enum TBmbPanicCode + { + EBmbPanicCmdListenerBadState, + }; + +inline void Panic(TBmbPanicCode aPanic) + { + User::Panic(KBmbPanicCategory, aPanic); + } + +#endif // BMBPANIC_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/bmbplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/bmbplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2005-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: Remote connection observer interface declaration. +* +*/ + + +#ifndef BTASBAUDIOSERVICEPLUGIN_H +#define BTASBAUDIOSERVICEPLUGIN_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include "atcodec.h" +#include "playercontrolistener.h" + +// FORWARD DECLARATIONS + +class CBmbCmdListener; + +/** +* RemCon bearer plugin implementation for BT Audio Service. +*/ +class CBmbPlugin +: public CRemConBearerPlugin, + public MRemConBearerInterface, + public MBmbPlayerControl + { + public: + /** + * Two-phased constructor. + * @param aParams + */ + static CBmbPlugin* NewL(TBearerParams& aParams); + ~CBmbPlugin(); + + void DataFromRemote(const TDesC8& aATCmd); + + + private: // from CRemConBearerPlugin + + /** + * Called by RemCon server to get a pointer to an object which implements the + * bearer API with UID aUid. This is a mechanism for allowing future change + * to the bearer API without breaking BC in existing (non-updated) bearer + * plugins. + * @return the pointer of this implementation + */ + TAny* GetInterface(TUid aUid); + + private: // from MRemConBearerInterface + + /** + * Called by RemCon to retrieve a response on a connection. Must only be + * called as a result of a NewResponse upcall. + * @param aInterfaceUid The UID of the outer-layer client API specifying the + * response. + * @param aId The command identifier used as a cookie for command/response + * matching. + * @param aOperationId The ID of the response operation in the outer-layer + * client API. + * @param aData API-specific message data. On success, ownership is + * returned. + * @param aAddr The connection. + */ + TInt GetResponse( + TUid& aInterfaceUid, + TUint& aTransactionId, + TUint& aOperationId, + RBuf8& aData, + TRemConAddress& aAddr); + + /** + * Called by RemCon to send a command on a connection. Must only be + * called as a result of a NewCommand upcall. + * @param aInterfaceUid The UID of the outer-layer client API specifying the + * command. + * @param aId The command identifier used as a cookie for command/response + * matching. + * @param aOperationId The ID of the command operation in the outer-layer + * client API. + * @param aData API-specific message data. On success, ownership is + * returned. + * @param aAddr The connection. + */ + TInt SendCommand( + TUid aInterfaceUid, + TUint aCommand, + TUint aTransactionId, + RBuf8& aData, + const TRemConAddress& aAddr); + + /** + * Called by RemCon to retrieve a command on a connection. The connection is not + * assumed to exist- the bearer is responsible for bringing up the requested + * connection if necessary. + * @param aInterfaceUid The UID of the outer-layer client API specifying the + * command. + * @param aOperationId The ID of the command operation in the outer-layer + * client API. + * @param aId The command identifier used as a cookie for command/response + * matching. + * @param aData API-specific message data. On success, ownership is passed. + * @param aAddr The connection. + * @return Error. This request is synchronous. It should be completed by the + * bearer when it has taken responsibility for sending the message. This will + * involve checking that the message is well-formed, and possibly actually + * trying to send it, or adding it to a queue. + */ + TInt GetCommand( + TUid& aInterfaceUid, + TUint& aTransactionId, + TUint& aCommand, + RBuf8& aData, + TRemConAddress& aAddr); + + /** + * Called by RemCon to send a response on a connection. The connection is not + * assumed to exist- the bearer is responsible for bringing up the requested + * connection if necessary. + * @param aInterfaceUid The UID of the outer-layer client API specifying the + * response. + * @param aOperationId The ID of the response operation in the outer-layer + * client API. + * @param aId The command identifier used as a cookie for command/response + * matching + * @param aData API-specific message data. On success, ownership is passed. + * @param aAddr The connection. + * @return Error. This request is synchronous. It should be completed by the + * bearer when it has taken responsibility for sending the message. This will + * involve checking that the message is well-formed, and possibly actually + * trying to send it, or adding it to a queue. + */ + TInt SendResponse( + TUid aInterfaceUid, + TUint aOperationId, + TUint aTransactionId, + RBuf8& aData, + const TRemConAddress& aAddr); + + /** + * Called by RemCon to establish a bearer-level connection to another party. + * Completion is signalled back in ConnectConfirm. + * @param aAddr The RemCon address to connect to. + */ + void ConnectRequest(const TRemConAddress& aAddr); + + /** + * Called by RemCon to destroy a bearer-level connection to another party. + * Completion is signalled back in DisconnectConfirm. + * @param aAddr The RemCon address to disconnect from. + */ + void DisconnectRequest(const TRemConAddress& aAddr); + + /** + * Called by RemCon when either (a) the number of controller clients changes + * from 0 to 1 or from 1 to 0, or (b) the number of target clients changes + * from 0 to 1 or from 1 to 0. + */ + void ClientStatus(TBool aControllerPresent, TBool aTargetPresent); + + /** + * Called by RemCon to get the capabilities required to make/destroy + * connections over the bearer, and to send and receive messages over the + * bearer. + @return The bearer's security policy. + */ + TSecurityPolicy SecurityPolicy() const; + + private: + // From MBmbPlayerControl + void Pause(); + void Play(); + + private: + + /** + * C++ default constructor. + */ + CBmbPlugin(TBearerParams& aParams); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + private: // owned + + // Last received and corrected-decoded message. + TBuf8 iInData; + TUid iInterfaceUid; + TUint iTransactionId; + TUint iOperationId; + TRemConMessageType iMsgType; + TRemConAddress iRemConAddress; + CBTAudioPlayerControlListener *iPlayerControlListener; + CBmbCmdListener *iListener; + + TBool iConnIndicated; + }; + + +#endif // BTASBAUDIOSERVICEPLUGIN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/bmbserviceuid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/bmbserviceuid.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef BTAUDIOSERVICEUID_H +#define BTAUDIOSERVICEUID_H + +#include + +/** +The implementation UID of the BT audio service bearer plugin. +*/ +const TInt KBTAudioServiceUid = 0x101FBAE9; + +_LIT8(KBTAudioServiceName, "BTAS0x101FBAE9"); + +#endif // BTAUDIOSERVICEUID_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef DEBUGCONFIG_H +#define DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btmac.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTMnBr] "); +_LIT8(KTracePrefix8, "[BTMnBr] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTMonoBearer"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // LOCOD_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/playercontrolistener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/playercontrolistener.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2005 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: Declaration of P&S listener. +* +*/ + + +#ifndef BTAUDIOPLAYERCONTROLLISTENER_H +#define BTAUDIOPLAYERCONTROLLISTENER_H + +#include +#include + +class MBmbPlayerControl + { +public: + virtual void Pause() = 0; + virtual void Play() = 0; + }; + +class CBTAudioPlayerControlListener : public CActive + { + public: + /** + * Two-phased constructor. + */ + static CBTAudioPlayerControlListener* NewL(MBmbPlayerControl& aControl); + + /** + * Destructor. + */ + ~CBTAudioPlayerControlListener(); + + private: + /** + * C++ default constructor. + */ + CBTAudioPlayerControlListener(MBmbPlayerControl& aControl); + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + public: + /** + * Starts asynchronous command handling + * @param None + * @return None + */ + void Start(); + + private: + /** + * From CActive. Called when asynchronous request completes. + * @param None + * @return None + */ + void RunL(); + + /** + * From CActive. Cancels asynchronous request. + * @param None + * @return None + */ + void DoCancel(); + + public: + /** + * Returns the class status. + * @param None + * @return Status code. + * @since 2.5 + */ + TInt Status() const; + + private: + MBmbPlayerControl& iControl; + + RProperty iProperty; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonobearer/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonobearer/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/BTMonoCdmaIncomingFlash.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/BTMonoCdmaIncomingFlash.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2005 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: +* +*/ + + +#ifndef BTMONOCDMACALLMONITOR_H +#define BTMONOCDMACALLMONITOR_H + +// INCLUDES +#include +#include +#include +#include "BTMonoActive.h" + +NONSHARABLE_CLASS(CBTMonoCdmaIncomingFlash) : public CBTMonoActive + { + public: //Constructors and descructor + + /** + * Two-phased constructor. + */ + static CBTMonoCdmaIncomingFlash* NewL( + MBTMonoActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName ); + + /** + * Two-phased constructor. + */ + static CBTMonoCdmaIncomingFlash* NewLC( + MBTMonoActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName ); + + /** + * Destructor. + */ + virtual ~CBTMonoCdmaIncomingFlash(); + + void GoActive(); + + protected: // From CActive + /** + * Cancels asyncronous request(s). + * + * @return None. + */ + void DoCancel(); + + /** + * Informs object that asyncronous request is ready. + * + * @return None. + */ + void RunL(); + + TInt RunError(TInt aErr); + + + private: + + /** + * C++ default constructor can NOT contain any code, that might leave + */ + CBTMonoCdmaIncomingFlash( + MBTMonoActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(); + + private: + + // needed for opening RMobileCall + RMobileLine& iCdmaLine; // unowned + + // handle to CDMA Phone + RCdmaMobileCall iCdmaCall; // owned + + // stores the call name + TName iCallName; + + // call waiting information package + RCdmaMobileCall::TMobileCallIncomingFlashMessageV1Pckg iFlashMessagePckg; + }; + +#endif // BTMONOCDMACALLMONITOR_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/HFPAtEcomListen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/HFPAtEcomListen.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,195 @@ +/* +* Copyright (c) 2008 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: ECom plugin install/uninstall/version listener +* +*/ + + +#ifndef C_CHFPATECOMLISTEN_H +#define C_CHFPATECOMLISTEN_H + +#include +#include + + +/** + * Notification interface class for ECOM plugin interface status changes + * + * @lib HFPatext.lib + * @since S60 v5.0 + */ + + enum THFPState + { + EHFPStateIdle, + EHFPStateAtCmdHandling, // ATEXT state for AT command handling + EHFPStateAtUrcHandling, // ATEXT state for URC handling + EHFPStateEcomListening // ATEXT state for ECOM change listening + }; + +NONSHARABLE_CLASS( MHFPAtEcomListen ) + { + +public: + + /** + * Notifies about new plugin installation + * + * @since S60 5.0 + * @param aPluginUid UID of installed plugin + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt NotifyPluginInstallation( TUid& aPluginUid ) = 0; + + /** + * Notifies about existing plugin uninstallation + * + * @since S60 5.0 + * @param aPluginUid UID of uninstalled plugin + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt NotifyPluginUninstallation( TUid& aPluginUid ) = 0; + + }; + +/** + * Class for ECom plugin install/uninstall/version listener + * + * @lib HFPatext.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CHFPAtEcomListen ) : public CActive + { + +public: + + /** + * Two-phased constructor. + * @param aAtCmdExt Pointer to AT command extension + * @param aCallback Callback to mode status change + * @return Instance of self + */ + static CHFPAtEcomListen* NewL( RATExt* aAtCmdExt, + MHFPAtEcomListen* aCallback ); + + /** + * Two-phased constructor. + * @param aAtCmdExt Pointer to AT command extension + * @param aCallback Callback to mode status change + * @return Instance of self + */ + static CHFPAtEcomListen* NewLC( RATExt* aAtCmdExt, + MHFPAtEcomListen* aCallback ); + + /** + * Destructor. + */ + virtual ~CHFPAtEcomListen(); + + /** + * Resets data to initial values + * + * @since S60 5.0 + * @return None + */ + void ResetData(); + + /** + * Starts waiting for ECom plugin install/uninstall/version status changes + * + * @since S60 5.0 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt IssueRequest(); + + /** + * Stops waiting for Ecom plugin install/uninstall/version status changes + * + * @since S60 5.0 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt Stop(); + +private: + + CHFPAtEcomListen( RATExt* aAtCmdExt, + MHFPAtEcomListen* aCallback ); + + void ConstructL(); + + /** + * Initializes this class + * + * @since S60 5.0 + * @return None + */ + void Initialize(); + +// from base class CActive + + /** + * From CActive. + * Gets called when plugin installed, uninstalled or changed + * + * @since S60 5.0 + * @return None + */ + void RunL(); + + /** + * From CActive. + * Gets called on cancel + * + * @since S60 5.0 + * @return None + */ + void DoCancel(); + +private: // data + + /** + * AT command extension + * Not own. + */ + RATExt* iAtCmdExt; + + /** + * Callback to call when plugin installed, uninstalled or changed + * Not own. + */ + MHFPAtEcomListen* iCallback; + + /** + * Current state of ECom interface listening: active or inactive + */ + THFPState iEcomListenState; + + /** + * UID of the installed, uninstalled or changed plugin + */ + TUid iPluginUid; + + /** + * Package for plugin UID + */ + TPckg iPluginUidPckg; + + /** + * Package for ECOM type + */ + TPckg iEcomTypePckg; + + }; + +#endif // C_CHFPATECOMLISTEN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/HFPAtUrcHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/HFPAtUrcHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2008 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: AT command URC handler +* +*/ + + +#ifndef C_CHFPATURCHANDLER_H +#define C_CHFPATURCHANDLER_H + +#include +#include "HfpAtCmdHandler.h" +#include "HFPAtEcomListen.h" + +/** + * Class for AT command URC handler + * + * @lib HFPatext.lib + * @since S60 v5.0 + */ +class MATExtObserver; + +NONSHARABLE_CLASS( CHFPAtUrcHandler ) : public CActive + { + +public: + + /** + * Two-phased constructor. + * @param aAtCmdExt Pointer to AT command extension + * @param aStreamCallback Callback to stream + * @return Instance of self + */ + static CHFPAtUrcHandler* NewL( RATExt* aAtCmdExt, + MATExtObserver& aObserver ); + + /** + * Two-phased constructor. + * @param aAtCmdExt Pointer to AT command extension + * @param aStreamCallback Callback to stream + * @return Instance of self + */ + static CHFPAtUrcHandler* NewLC( RATExt* aAtCmdExt, + MATExtObserver& aObserver ); + + /** + * Destructor. + */ + virtual ~CHFPAtUrcHandler(); + + /** + * Resets data to initial values + * + * @since S60 5.0 + * @return None + */ + void ResetData(); + + /** + * Starts waiting for an incoming URC message + * + * @since S60 5.0 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt IssueRequest(); + + /** + * Stops waiting for an incoming URC message + * + * @since S60 5.0 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt Stop(); + + /** + * UID of the owning plugin + * + * @since S60 5.0 + * @return UID of the owning plugin + */ + TUid OwnerUid(); + +private: + + CHFPAtUrcHandler( RATExt* aAtCmdExt, + MATExtObserver& aObserver ); + + void ConstructL(); + + /** + * Initializes this class + * + * @since S60 3.2 + * @return None + */ + void Initialize(); + +// from base class CActive + + /** + * From CActive. + * Gets called when URC command received + * + * @since S60 3.2 + * @return None + */ + void RunL(); + + /** + * From CActive. + * Gets called on cancel + * + * @since S60 3.2 + * @return None + */ + void DoCancel(); + + +private: // data + + /** + * AT command extension + * Not own. + */ + RATExt* iAtCmdExt; + + MATExtObserver& iObserver; + + /** + * Current state of URC message handling: active or inactive + */ + THFPState iUrcHandleState; + + /** + * Buffer for receiving + */ + TBuf8 iRecvBuffer; + + /** + * UID of the responsible ATEXT plugin + */ + TUid iOwnerUid; + + /** + * Package for owner UID + */ + TPckg iOwnerUidPckg; + + /** + * Flag to indicate start of receiving (for ownership marking) + */ + TBool iStarted; + + }; + +#endif // C_CHFPATURCHANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/HfpAtCmdHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/HfpAtCmdHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2007 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: AT extension API +* +*/ + + +#ifndef BTATEXTAGENT_H +#define BTATEXTAGENT_H + +// INCLUDES +#include +#include +#include "btmcactive.h" +#include "HFPAtEcomListen.h" +#include "HFPAtUrcHandler.h" + +class CBtmcActive; + +class MATExtObserver + { +public: + virtual void ATExtHandleCommandCompletedL(TInt aErr, const TDesC8& aReply) = 0; + + virtual void UnsolicitedResultFromATExtL(TInt aErr, const TDesC8& aAT) = 0; + }; + +NONSHARABLE_CLASS( CHFPAtCmdHandler ) : public CBase, + public MBtmcActiveObserver, + public MHFPAtEcomListen + { +public: + + static CHFPAtCmdHandler* NewL(MATExtObserver& aObserver); + +public: + + ~CHFPAtCmdHandler(); + + void HandleCommand(const TDesC8& aAT, const TDesC8& aReply = KNullDesC8); + + + +private: + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + TInt HandleRunError(TInt aErr); + + + +private: + + CHFPAtCmdHandler(MATExtObserver& aObserver); + + /** + * Creates plugin handlers for this class + * + * @since S60 5.0 + * @return None + */ + void CreatePluginHandlersL(); + + /** + * Instantiates one URC message handling class instance and adds it to + * the URC message handler array + * + * @since S60 3.2 + * @return None + */ + CHFPAtUrcHandler* AddOneUrcHandlerL(); + + /** + * Deletes all instantiated URC message handlers + * + * @since S60 5.0 + * @return None + */ + void DeletePluginHandlers(); + + // from base class MHFPAtEcomListen + + /** + * From MHFPAtEcomListen. + * Notifies about new plugin installation + * + * @since S60 5.0 + * @return None + */ + TInt NotifyPluginInstallation( TUid& aPluginUid ); + + /** + * From MHFPAtEcomListen. + * Notifies about existing plugin uninstallation + * + * @since S60 5.0 + * @return None + */ + TInt NotifyPluginUninstallation( TUid& aPluginUid ); + + /** + * Starts URC message handling + * + * @since S60 5.0 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt StartUrc(); + + /** + * Stops URC message handling + * + * @since S60 3.2 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt StopUrc(); + + void ConstructL(); + +private: + MATExtObserver& iObserver; + + RATExt iATExtClient; + TBuf8 iCmdBuffer; + TBuf8 iRecvBuffer; + TBuf8 iReplyBuffer; + TBuf8<512> iSystemReply; + + TInt iRemainingReplyLength; + TPckg iRemainingReplyLengthPckg; + TATExtensionReplyType iReplyType; + TPckg iReplyTypePckg; + CBtmcActive* iCommander; // for command handling + + /** + * URC message handlers + * Own. + */ + RPointerArray iUrcHandlers; + + /** + * ECOM plugin interface status change listener + * Own. + */ + CHFPAtEcomListen* iEcomListen; + }; + +#endif // BTATEXTAGENT_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmc_defs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmc_defs.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2005 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: +* Extended Phone RemCon API. +* +*/ + + +#ifndef BTMCDEFS_H +#define BTMCDEFS_H + +#include + +enum TBTMonoATVoiceRecognition + { + EBTMonoATVoiceRecognitionOff = 0, + EBTMonoATVoiceRecognitionOn = 1, + }; + +enum TBTMonoVoiceRecognitionInitiator + { + EBTMonoVoiceRecognitionDefaultInitiator = 0, // phone + EBTMonoVoiceRecognitionActivatedByRemote, + EBTMonoVoiceRecognitionDeactivatedByRemote, + }; + +enum TBTMonoATPhoneIndicatorId + { + EBTMonoATNetworkIndicator = 1, + EBTMonoATCallIndicator = 2, + EBTMonoATCallSetupIndicator = 3, + EBTMonoATCall_SetupIndicator = 4, + EBTMonoATCallHeldIndicator = 5, + EBTMonoATSignalStrengthIndicator = 6, + EBTMonoATRoamingIndicator = 7, + EBTMonoATBatteryChargeIndicator = 8 + }; + +enum TBTMonoATNetworkStatus + { + EBTMonoATNetworkUnavailable = 0, + EBTMonoATNetworkAvailable = 1 + }; + +enum TBTMonoATRoamingStatus + { + EBTMonoATRoamingInactive = 0, + EBTMonoATRoamingActive = 1 + }; + +enum TBTMonoATCallStatus + { + EBTMonoATNoCall = 0, + EBTMonoATCallActive = 1 + }; + +enum TBTMonoATCallSetupStatus + { + EBTMonoATNoCallSetup = 0, + EBTMonoATCallRinging = 1, + EBTMonoATCallDialling = 2, + EBTMonoATCallConnecting = 3 + }; + +enum TBTMonoATCallHeldStatus + { + EBTMonoATNoCallHeld = 0, + EBTMonoATCallHeldAndActive = 1, + EBTMonoATCallHeldOnly = 2 + }; + + +enum TBTMonoATPhoneNumberType + { + EBTMonoATPhoneNumberUnavailable = 128, + EBTMonoATPhoneNumberNational = 129, + EBTMonoATPhoneNumberInternational = 145 + }; + +// mandatory indicators including call, call setup and call held: +const TInt KMandatoryInds = 0x00000001; + +// "service" indicator: +const TInt KIndServiceBit = 0x00000002; + +// "signal" indicator: +const TInt KIndSignalBit = 0x00000004; + +// "roam" indicator: +const TInt KIndRoamBit = 0x00000008; + +// "battchg" indicator: +const TInt KIndChargeBit = 0x00000010; + +// value to enable all indicators (when CMER=3,0,0,1 is received): +const TInt KIndAllActivated = KMandatoryInds | + KIndServiceBit | + KIndSignalBit | + KIndRoamBit | + KIndChargeBit; + +// value to disable all indicators: +const TInt KIndAllDeActivated = 0; + +enum TBTMonoATCallerIdNotif + { + EBTMonoATCallerIdNotifDisabled = 0, + EBTMonoATCallerIdNotifEnabled = 1, + }; + +enum TBTMonoATCallWaitingNotif + { + EBTMonoATCallWaitingNotifDisabled = 0, + EBTMonoATCallWaitingNotifEnabled = 1, + }; + +enum TBTMonoATCallerIdNetworkServiceStatus + { + EBTMonoATCallerIdNetworkServiceUnavailable = 0, + EBTMonoATCallerIdNetworkServiceAvailable = 1, + EBTMonoATCallerIdNetworkServiceUnknown = 2 + }; + +enum TBTMonoATCregN + { + EBTMonoCregDisable = 0, + EBTMonoCregEnableUnsolicited = 1, + EBTMonoCregEnableAll = 2, + }; +enum TBTMonoATCregServiceStatus + { + EBTMonoCregNetworkServiceNotRegistered = 0, + EBTMonoCregNetworkServiceHomeNetwork = 1, + EBTMonoCregNetworkServiceNotRegisteredSearching = 2, + EBTMonoCregNetworkServiceRegistrationDenied = 3, + EBTMonoCregNetworkServiceUnknown = 4, + EBTMonoCregNetworkServiceRegisteredRoaming = 5, + }; + +const TInt KBTAGSupportedFeatureV10 = 0x2f; +const TInt KBTAGSupportedFeatureV15 = 0xef; + +const TInt KRingInterval = 5 * 1000* 1000; // 5 sec + +const TInt KSlcTimeout = 20 * 1000 * 1000; // 20 sec + +const TInt KFirstHspCkpdTimeout = 1 * 1000 * 1000; // 1 sec + +const TInt KCallDiallingBit = 0x00000001; +const TInt KCallRingingBit = 0x00000010; +const TInt KCallAnsweringBit = 0x00000100; +const TInt KCallConnectingBit = 0x00001000; +const TInt KCallConnectedBit = 0x00010000; +const TInt KCallHoldBit = 0x00100000; +const TInt KActiveCallMask = 0x00110000; +const TInt KCallAllStatusMask = 0x00111111; + +const TInt KHfFeatureBitVoiceRecognition = 0x08; +const TInt KHfFeatureBitVolumeControl = 0x10; + +_LIT8(KDesTestCodeCINDv15, "(\"service\",(0,1)),(\"call\",(0,1)),(\"callsetup\",(0-3)),(\"call_setup\",(0-3)),(\"callheld\",(0-2)),(\"signal\",(0-5)),(\"roam\",(0-1)),(\"battchg\",(0-5))"); + +_LIT8(KDesTestCodeCHLDv15, "(0,1,1x,2,2x,3,4)"); + +_LIT8(KDesTestCodeBVRA, "(0,1)"); +_LIT8(KDesTestCodeCLIP, "(0,1)"); +_LIT8(KDesTestCodeCCWA, "(0,1)"); + +#endif // BTMCDEFS_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2005 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: Notify phone ring and caller ID +* +*/ + + +#ifndef BTMCACTIVE_H +#define BTMCACTIVE_H + +// INCLUDES +#include +#include "btmc_defs.h" + +class CBtmcActive; + +class MBtmcActiveObserver + { + public: + virtual void RequestCompletedL(CBtmcActive& aActive, TInt aErr) = 0; + + virtual void CancelRequest(TInt aServiceId) = 0; + }; + +/** +* CBtmcActive generates RING for incoming call. +*/ +NONSHARABLE_CLASS(CBtmcActive) : public CActive + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcActive* NewL(MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aServiceId); + + static CBtmcActive* NewLC(MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aServiceId); + + /** + * Destructor. + */ + ~CBtmcActive(); + + public: + + virtual void GoActive(); + + TInt ServiceId() const; + + void SetServiceId(TInt aServiceId); + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + virtual void RunL(); + + virtual void DoCancel(); + + protected: + + /** + * C++ default constructor. + */ + CBtmcActive(MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aServiceId); + + MBtmcActiveObserver& Observer(); + + private: + MBtmcActiveObserver& iObserver; + TInt iServiceId; + }; + +#endif // BTMCACTIVE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcbattery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcbattery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2005 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: Gets the Signal strength indications +* +*/ + + +#ifndef BTMCBATTERY_H +#define BTMCBATTERY_H + +#include +#include +#include +#include + +class CBtmcPhoneStatus; + +/** +* CBtmcBattery for getting signal strength. +*/ +NONSHARABLE_CLASS(CBtmcBattery) : public CActive + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcBattery* NewL( + CBtmcPhoneStatus& aParent); + + static CBtmcBattery* NewLC( + CBtmcPhoneStatus& aParent); + + /** + * Destructor. + */ + ~CBtmcBattery(); + + void GoActive(); + + /* + * returns current battery charge + */ + TInt GetBatteryCharge(); + + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + void RunL(); + + void DoCancel(); + + TInt RunError(TInt aErr); + + private: + + /** + * C++ default constructor. + */ + CBtmcBattery( + CBtmcPhoneStatus& aParent); + + void ConstructL(); + + void ConvertToHFPScale(TInt &aStrength); + + private: + CBtmcPhoneStatus& iParent; + RTimer iTimer; + RProperty iProperty; + EPSHWRMBatteryLevel iBatteryStrength; + TInt iCharge; + }; + + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmccallactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmccallactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2005 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: Notify phone ring and caller ID +* +*/ + + +#ifndef BTMCCALLACTIVE_H +#define BTMCCALLACTIVE_H + +// INCLUDES +#include +#include +#include "btmcactive.h" + +/** +* CBtmcCallActive monitoring a call status. +*/ +NONSHARABLE_CLASS(CBtmcCallActive) : public CBtmcActive + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcCallActive* NewL( + MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName); + + static CBtmcCallActive* NewLC( + MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName); + + /** + * Destructor. + */ + ~CBtmcCallActive(); + + void GoActive(); + + /** + * Gets call name + * @param TDes& + * @return None + */ + const TDesC& CallName() const; + + /** + * Gets remote's phone number + * @param aText Phone number + * @return TInt Error code + */ + const TDesC& RemotePartyNumber() const; + + /** + * Returns call status + * @param None + * @return TInt + */ + RMobileCall::TMobileCallStatus CallStatus() const; + + /** + * Returns call info + * @param info RMobileCall::TMobileCallInfoV1 resulting call info + * @param RMobileCall::TMobileCallRemotePartyInfoV1& remote remote side info + * @return none + */ + void GetCallInfo(RMobileCall::TMobileCallInfoV1& info); + + /** + * Returns the emergency call status of this object + * @param None + * @return TBool + */ + TBool IsEmergencyCall() const; + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + void RunL(); + + void DoCancel(); + + TInt RunError(TInt aErr); + + private: + + /** + * C++ default constructor. + */ + CBtmcCallActive( + MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName); + + void ConstructL(); + + private: + RMobileLine& iLine; + RMobileCall iCall; + + // stores current call status + RMobileCall::TMobileCallStatus iCallStatus; + RMobileCall::TMobileCallStatus iPrevCallStatus; + // stores call name + TName iName; + + // remote party's phone number + TBuf iRemoteNumber; + + TBool iEmergency; + }; + +#endif // BTMCCALLACTIVE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmccallinghandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmccallinghandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2002 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: Calling command handler +* +*/ + + +#ifndef C_BTMCCALLINGHANDLER_H +#define C_BTMCCALLINGHANDLER_H + + +// INCLUDES +#include +#include +#include "btmcactive.h" + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CBtmcProtocol; +class CATCommand; + +// CLASS DECLARATION + +/** +* CBtmcCallingHandler listens call state events (from RMobileCall) +* and passes them to MBtmcPhoneStatusObserver +*/ +NONSHARABLE_CLASS(CBtmcCallingHandler) : public CBase, public MBtmcActiveObserver + { +public: + + /** + * Two-phased constructor. + */ + static CBtmcCallingHandler* NewL(CBtmcProtocol& aProtocol); + + /** + * Destructor. + */ + ~CBtmcCallingHandler(); + + void HandleCallingCmdL(const CATCommand& aCmd); + + TBool ActiveCmdHandling() const; + + /** + * Tells if AT+CHLD command handling is in progress + */ + TBool ActiveChldHandling() const; + +private: // From MBtmcActiveObserver + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + +private: + + CBtmcCallingHandler(CBtmcProtocol& aProtocol); + + void ConstructL(); + +private: + CBtmcProtocol& iProtocol; // unowned + + CBtmcActive* iActive; + + RProperty iCmdProperty; + + TBool iBusy; + + TInt iCmdId; +}; + +#endif // C_BTMCCALLINGHANDLER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmccallstatus.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmccallstatus.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTMCCALLSTATUS_H +#define BTMCCALLSTATUS_H + +#include +#include +#include "btmcprofileid.h" +#include "btmccallactive.h" +#include "btmcline.h" +#include "btmcvoipline.h" +// forward declarations +class CBtmcMobileLine; +class CATResult; +class CBtmcProtocol; +class MCall; + +NONSHARABLE_CLASS(CBtmcCallStatus) : public CBase, public MBtmcActiveObserver + { + public: + static CBtmcCallStatus* NewL( + CBtmcProtocol& aProtocol, + RMobilePhone& aPhone, + TBtmcProfileId aProfile ); + + ~CBtmcCallStatus(); + + /** + * returns the bit mask + */ + TInt CallStatusL() const; + + void ReportCallStatusL(); + + /** + * responds to CLCC + **/ + + void HandleClccL(); + + private: // From MBtmcActiveObserver + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + + private: + CBtmcCallStatus(CBtmcProtocol& aProtocol); + + // 2nd phase construction, called by NewL() + void ConstructL(RMobilePhone& aPhone, TBtmcProfileId aProfile); + + CATResult* MakeClccL(RMobileCall::TMobileCallInfoV1& info, + RMobileCall::TMobileCallRemotePartyInfoV1& remote, TInt aConferenceCallCount); + + CATResult* MakeVoIPClccL(const MCall& info); + + void HandleMobileCallEventL( + const TName& aCallName, + const TDesC& aRemotePartyName, + RMobileCall::TMobileCallStatus aStatus, TBool aOutgoingCall = EFalse); + + void ReportCallEventL(TInt aPrevStatus, TInt aNewStatus, TBool aOutgoing = EFalse); + + void ReportRingAndClipL(TBool aColp = EFalse); + + void StartTimerL(TInt aService, TInt aTimeout); + + void StopTimer(TInt aService); + + void ReportCallIndicatorL(TBTMonoATPhoneIndicatorId aIndicator, TInt aValue); + + // aNum returns the currently ringing number + void GetRingingNumL(TDes8& aNum); + void GetOutgoingNumL(TDes8& aNum); + + TBTMonoATPhoneNumberType NumberType( const TDesC8& aNum ); + + private: + CBtmcProtocol& iProtocol; + RTimer iTimer;// owned + CBtmcActive* iTimerActive; // owned, ringing timer + TBuf8 iRemoteTelNum; + + RPointerArray iLines; // owned + + friend class CBtmcMobileLine; + friend class CBtmcVoIPLine; + }; + +#endif // BTMCCALLSTATUS_H + +// End of File + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcdummy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcdummy.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2007-2008 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: Dummy implementation of MCall +* +*/ + +#ifndef BTMCDUMMY_H_ +#define BTMCDUMMY_H_ + +#include + +class MBtmcDummy : public MCall +{ +public: + + MBtmcDummy() {}; + ~MBtmcDummy() {}; + + TInt CallIndex() const { return 0; }; + + /** + * Call type getter + * + * @since S60 v5.1 + * @return the call type + */ + CCPCall::TCallType CallType() const {return CCPCall::ECallTypeCSVoice; }; + + + /** + * Call state getter + * + * @since S60 v5.1 + * @return the call state + */ + CCPCall::TCallState CallState() const { return CCPCall::EStateIdle; }; + /** + * Getter for the service ID of the call. + * + * @since S60 v5.1 + * @return the service ID of the call + */ + TUint32 ServiceId() const { return 0; }; + + /** + * Call direction getter + * + * @since S60 v5.1 + * @return the call direction + */ + CCPCall::TCallDirection CallDirection() const { return CCPCall::EDirectionUnknown; }; + + /** + * Returns information whether call is an emergency call. + * @since S60 v5.2 + * @param None. + * @return TBool ETrue call is emergency call else EFalse. + */ + TBool IsEmergency() const { return EFalse; }; + +}; + + +#endif /* BTMCDUMMY_H_ */ diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcline.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcline.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2007-2008 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: Interface class for mobile and voip lines. +* +*/ + +#ifndef BTMCLINE_H_ +#define BTMCLINE_H_ + +#include +#include + +class CBtmcCallActive; + +class MBtmcLine +{ + public: + virtual TInt CallStatusL() const = 0; + virtual const RPointerArray& ActiveCalls() const = 0; + virtual RMobilePhone& Phone() = 0; + virtual ~MBtmcLine() { /**/ }; + virtual const MCall& CallInformationL() = 0; + virtual TBool IsVoip() = 0; +}; + + +#endif /* BTMCLINE_H_ */ diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcmobileline.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcmobileline.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2002 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: A mobile line +* +*/ + + +#ifndef BTMCMOBILELINE_H +#define BTMCMOBILELINE_H + + +// INCLUDES +#include +#include // for etel +#include // for etel + +#include "btmccallactive.h" +#include "btmcline.h" + +// FORWARD DECLARATIONS +class CBtmcCallStatus; + +/** +* CBtmcMobileLine listens call state events (from RMobileCall) +* and passes them to MBtmcMobileLineObserver +*/ +NONSHARABLE_CLASS(CBtmcMobileLine) : public CBase, public MBtmcLine, public MBtmcActiveObserver + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcMobileLine* NewL( + CBtmcCallStatus& aParent, RMobilePhone& aPhone, const TDesC& aLineName); + + /** + * Two-phased constructor. + */ + static CBtmcMobileLine* NewLC( + CBtmcCallStatus& aParent, RMobilePhone& aPhone, const TDesC& aLineName); + + /** + * Destructor. + */ + ~CBtmcMobileLine(); + + /** + * returns the bit mask + */ + TInt CallStatusL() const; + + const MCall& CallInformationL(); + + /** + * returns active call container + */ + const RPointerArray& ActiveCalls() const; + + /** + * Returns call status + * @param None + * @return the call status + */ + //RMobileCall::TMobileCallStatus CallStatus(const TName& aCallName) const; + + /** + * Accessor for phone + **/ + RMobilePhone& Phone(); + + /* From MBtmcLine + * Returns the type of call + * @return ETrue for Voip and EFalse otherwise + * + */ + TBool IsVoip(); + + private: // From MBtmcActiveObserver + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + private: + /** + * C++ default constructor. + */ + CBtmcMobileLine( + CBtmcCallStatus& aParent, RMobilePhone& aPhone, const TDesC& aLineName); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: + CBtmcCallStatus& iParent; + + // needed for opening RMobileLine + RMobilePhone& iPhone; // unowned + + RMobileLine iLine; // owned + + RPointerArray iCallActives; + + CBtmcActive* iLineIncomingActive; + CBtmcActive* iLineOutgoingActive; + + TBuf iLineName; + + // passed to RMobileLine::NotifyCallAdded + TName iName; + + }; +#endif // BTMCMOBILELINE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2005 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: Gets the MSISDN +* +*/ + + +#ifndef BTMCNUMBER_H +#define BTMCNUMBER_H + +// INCLUDES +#include +#include +#include "btmcactive.h" +#include "btmcobserver.h" + +class CBtmcProtocol; + +/** +* CBtmcNumber for getting MSISDN number. +*/ +NONSHARABLE_CLASS(CBtmcNumber) : public CBtmcActive + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcNumber* NewL( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId); + + /** + * Destructor. + */ + ~CBtmcNumber(); + + void GoActive(); + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + void RunL(); + + void DoCancel(); + + TInt RunError(TInt aErr); + + private: + + /** + * C++ default constructor. + */ + CBtmcNumber( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId); + + void ConstructL(); + + private: + CBtmcProtocol& iProtocol; + RTelServer iServer; + RMobilePhone iPhone; + RMobileONStore iStore; + RMobileONStore::TMobileONEntryV1 iEntry; + RMobileONStore::TMobileONEntryV1Pckg iPckg; + }; + + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcoperator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcoperator.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2005 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: Gets the MSISDN +* +*/ + + +#ifndef BTMCOPERATOR_H +#define BTMCOPERATOR_H + +// INCLUDES +#include +#include +#include +#include "btmcactive.h" + +class CBtmcProtocol; + +/** +* CBtmcOperator for getting MSISDN number. +*/ +NONSHARABLE_CLASS(CBtmcOperator) : public CBtmcActive + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcOperator* NewL( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId); + + /** + * Destructor. + */ + ~CBtmcOperator(); + + void GoActive(); + + /** + * Gets the subscriber number + */ + const TDesC& GetName() const; + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + void RunL(); + + void DoCancel(); + + TInt RunError(TInt aErr); + + private: + + /** + * C++ default constructor. + */ + CBtmcOperator( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId); + + void ConstructL(); + + private: + CBtmcProtocol& iProtocol; + RTelServer iServer; + RMobilePhone iPhone; + RMobileONStore iStore; + RMmCustomAPI iCustomApi; + RMmCustomAPI::TOperatorNameInfo iInfo; + }; + + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcphonestatus.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcphonestatus.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2002 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: Phone status monitor and notification +* +*/ + + +#ifndef BTMCPHONESTATUS_H +#define BTMCPHONESTATUS_H + + +// INCLUDES +#include +#include +#include +#include "btmcactive.h" +#include "btmcprofileid.h" +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CBtmcProtocol; +class RMobilePhone; +class CBtmcVolume; +class CBtmcSignal; +class CBtmcBattery; + +// CLASS DECLARATION + +/** +* CBtmcPhoneStatus listens call state events (from RMobileCall) +* and passes them to MBtmcPhoneStatusObserver +*/ +NONSHARABLE_CLASS(CBtmcPhoneStatus) : public CBase, public MBtmcActiveObserver + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcPhoneStatus* NewL( + CBtmcProtocol& aProtocol, RMobilePhone& aPhone, TBtmcProfileId aProfile); + + /** + * Two-phased constructor. + */ + static CBtmcPhoneStatus* NewLC( + CBtmcProtocol& aProtocol, RMobilePhone& aPhone, TBtmcProfileId aProfile); + + /** + * Destructor. + */ + ~CBtmcPhoneStatus(); + + RMobilePhone::TMobilePhoneRegistrationStatus NetworkStatus() const; + + void SetVolumeControlFeatureL(TBool aEnabled); + + void SetVoiceRecognitionControlL(TBool aEnabled); + + void SetSpeakerVolumeL(TInt aHfVol); + + void ActivateRemoteVolumeControl(); + + void DeActivateRemoteVolumeControl(); + + TInt GetSignalStrength(); + + TInt GetRssiStrength(); + + TInt GetVolumeStatus(); + + TInt GetBatteryCharge(); + + void SetRecognitionInitiator(TBTMonoVoiceRecognitionInitiator aInitiator); + + void HandleNetworkRegistrationEventL( + RMobilePhone::TMobilePhoneRegistrationStatus aOldStatus, + RMobilePhone::TMobilePhoneRegistrationStatus aNewStatus); + + void HandleSpeakerVolumeEventL(TInt aVol); + + void HandleVoiceDialEventL(TInt aEnabled); + + void HandleNetworkStrengthChangeL(TInt8 aStrength); + + void HandleBatteryChangeL(TInt aLevel); + + private: // From MBtmcActiveObserver + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + private: + /** + * C++ default constructor. + */ + CBtmcPhoneStatus(CBtmcProtocol& aProtocol, RMobilePhone& aPhone); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(TBtmcProfileId aProfile); + + void ReportIndicatorL(TBTMonoATPhoneIndicatorId aIndicator, TInt aValue); + + private: + CBtmcProtocol& iProtocol; // unowned + RMobilePhone& iPhone; // unowned + + RPointerArray iActives; // owned, Network and speed dial subscribe + + // for storing current network status + RMobilePhone::TMobilePhoneRegistrationStatus iNetworkStatus; + // for storing new network status + RMobilePhone::TMobilePhoneRegistrationStatus iNewNetworkStatus; + + // Volume control + CBtmcVolume* iVol; + + // Voice dial + RProperty iVoiceDialProperty; + + TBool iVoiceRecognitionEnabled; + TBTMonoVoiceRecognitionInitiator iVoiceRecogInitiator; + + CBtmcSignal* iSignal; // owned + CBtmcBattery* iBattery; // owned + }; + +#endif // BTMCPHONESTATUS_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotdatabuf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotdatabuf.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTMCPROTDATABUF_H +#define BTMCPROTDATABUF_H + +#include "atcodec.h" + +NONSHARABLE_CLASS(TBtmcProtDataBuf) + { + public: + + void Reset(); + + /** + * Extracts the first AT command in buffer. + * @param aText decriptor where the command will be stored. + * @return Error code. + */ + TInt NextCommand(TDes8& aData); + + /** + * Appends the given command to buffer. + * @param aText Text to be appended. + * @return Error code. + */ + TInt Append(const TDesC8& aData); + + private: + + TBuf8 iBuf; + }; + + +#endif // BTMCPROTDATABUF_H + +// End of File + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocol.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocol.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTMCPROTOCOL_H +#define BTMCPROTOCOL_H + +#include +#include +#include +#include "btmcactive.h" +#include "btmcprofileid.h" +#include "btmcprotdatabuf.h" +#include "HfpAtCmdHandler.h" + +// forward declarations +class CATCommand; +class CATResult; +class TBtmcProtocolStatus; +class MBtmcObserver; +class MATExtObserver; +class CBtmcMobileLine; +class CBtmcPhoneStatus; +class CBtmcCallStatus; +class CBtmcNumber; +class CBtmcOperator; +class CBtmcCallingHandler; +class TBtmcProtDataBuf; +class CDesC8ArrayFlat; + + +const TUint KBTHSRemoteAudioVolumeControl = 0x0302; + +NONSHARABLE_CLASS(CBtmcProtocol) : public CBase, + public MBtmcActiveObserver, + public MBTEngSdpResultReceiver, + public MATExtObserver + { + public: + static CBtmcProtocol* NewL( + MBtmcObserver& aObserver, + TBtmcProfileId aProfile, + const TDesC8& aBTDevAddr, + TBool aAccessoryInitiated); + + ~CBtmcProtocol(); + + /** + * Handle an AT command from HF or HS unit. + * + */ + void NewProtocolDataL(const TDesC8& aData); + + void SendResponseL(const CATResult& aResult); + + void SendResponseL(const RPointerArray& aResults); + + void SendUnsoltResultL(const CATResult& aResult); + + void CmdHandlingCompletedL(); + + TBtmcProtocolStatus& ProtocolStatus(); + + void VoiceRecognitionError(); + + void HandleNrecCompletedL(TInt aErr); + + void ActivateRemoteVolumeControl(); + + void DeActivateRemoteVolumeControl(); + + TInt GetRemoteSupportedFeature(); + + /** + * Tells if AT+CHLD command handling is in progress + */ + TBool ActiveChldHandling() const; + + private: + // from MBTEngSdpResultReceiver + void ServiceSearchComplete( const RSdpRecHandleArray& /*aResult*/, + TUint /*aTotalRecordsCount*/, TInt /*aErr*/ ) {} + + void AttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, + const RSdpResultArray& /*aAttr*/, TInt /*aErr*/ ) {} + + void ServiceAttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, + const RSdpResultArray& /*aAttr*/, + TInt /*aErr*/ ); + + void DeviceSearchComplete( CBTDevice* /*aDevice*/, TInt /*aErr*/ ) {} + + + // From MBtmcActiveObserver + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + // From MATExtObserver + + void ATExtHandleCommandCompletedL(TInt aErr, const TDesC8& aReply); + + void UnsolicitedResultFromATExtL(TInt aErr, const TDesC8& aAT); + + private: + CBtmcProtocol(MBtmcObserver& aObserver); + + // 2nd phase construction, called by NewL() + void ConstructL(TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated); + + void DoHandleCommandL(); + + void HandleTestCommandL(const CATCommand& aCmd); + + void HandleReadCommandL(const CATCommand& aCmd); + + void HandleWriteCommandL(const CATCommand& aCmd); + + void HandleActionCommandL(const CATCommand& aCmd); + + void DoSendProtocolDataL(); + + void StartTimerL(TInt aService, TInt aTimeout); + + void StopTimer(TInt aService); + + TBool ServiceLevelConnected() const; + + void SetIndicatorL(TInt aIndicator, TInt aValue); + + private: + MBtmcObserver& iObserver; // unowned + TBtmcProtocolStatus* iProtocolStatus; // owned + RTelServer iServer; // owned + RMobilePhone iPhone; // owned + CBtmcPhoneStatus* iPhoneStatus;// owned + CBtmcCallStatus* iCallStatus;// owned + + CBtmcNumber* iNumber; // owned + CBtmcOperator* iOperator; // owned + + CBtmcCallingHandler* iCallingHandler; + + // Service Level Connection + TInt iSlcMask; + + RTimer iTimer;// owned + CBtmcActive* iTimerActive; // owned, SLC + + CBtmcActive* iEtelQuery; // owned + + CBtmcActive* iCmdHanldingActive; + + CHFPAtCmdHandler* iAtExt; + + // buffer of incoming At commands + TBtmcProtDataBuf iInDataBuf; + TBool iHandleCmdPending; + CDesC8ArrayFlat* iOutgoPacketQueue; // owned + TInt iCredit; // How many commands are allowed to acc + TBool iVolumeSyncFromAccessory; + CBTEngDiscovery* iBteng; // for volume query + TBool iAccessoryInitiated; // who initiated the connection + RMobilePhone::TMobilePhoneIdentityV1 iIdentity; // holds IMEI etc + RMobilePhone::TMobilePhoneSubscriberId iId; // holds id + }; + +#endif // BTMCPROTOCOL_H + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocolstatus.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocolstatus.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2005 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: +* +* +*/ + + +#ifndef BTMCSTATE_H +#define BTMCSTATE_H + +#include +#include + +#include "btmc_defs.h" +#include "btmcprofileid.h" + +class TBtmcProtocolStatus + { + public: + TBtmcProtocolStatus(); + TInt iAGSupportedFeature; + TInt iAccSupportedFeature; + TInt iAdvancedErrorCode; + TBtmcProfileId iProfile; + TInt iIndicatorNotif; + TBTMonoATCallerIdNotif iCallerIdNotif; + TBTMonoATCallWaitingNotif iCallWaitingNotif; + TInt iCallBits; + TBool iSlc; + TBool iNetworkRegStatusNotif; + TBool iOutgoingCallNotif; + }; + +inline TBtmcProtocolStatus::TBtmcProtocolStatus() + : iAGSupportedFeature(KBTAGSupportedFeatureV10), iAccSupportedFeature(0), + iAdvancedErrorCode(0), iProfile(EBtmcHFP0105), iIndicatorNotif(KIndAllDeActivated), + iCallerIdNotif(EBTMonoATCallerIdNotifDisabled), iCallWaitingNotif(EBTMonoATCallWaitingNotifDisabled), + iCallBits(0), iSlc(EFalse), iOutgoingCallNotif(EFalse) + { + } + +#endif // BTMCSTATE_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcsignal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcsignal.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2005 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: Gets the Signal strength indications +* +*/ + + +#ifndef BTMCSIGNAL_H +#define BTMCSIGNAL_H + +// INCLUDES +#include +#include + +class CBtmcPhoneStatus; + +const TInt KSignalTimerTimeout = 2000000; +/** +* CBtmcSignal for getting signal strength. +*/ +NONSHARABLE_CLASS(CBtmcSignal) : public CActive + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcSignal* NewL(CBtmcPhoneStatus& aParent); + + static CBtmcSignal* NewLC(CBtmcPhoneStatus& aParent); + + /** + * Destructor. + */ + ~CBtmcSignal(); + + void GoActive(); + + /* + * Returns current signal strength + */ + TInt GetSignalStrength(); + + TInt GetRssiStrength(); + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + void RunL(); + + void DoCancel(); + + TInt RunError(TInt aErr); + + private: + + /** + * C++ default constructor. + */ + CBtmcSignal(CBtmcPhoneStatus& aParent); + + void ConstructL(); + + void ConvertToHFPScale(TInt8 &aSignal); + + private: + CBtmcPhoneStatus& iParent; + RTelServer iServer; + RMobilePhone iPhone; + TInt32 iDbm; + TInt8 iBars; + TInt8 iPreviousBars; + }; + + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcvoipline.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcvoipline.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2002 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: A VoIP line +* +*/ + +#ifndef BTMCVOIPLINE_H_ +#define BTMCVOIPLINE_H_ + +#include "btmccallstatus.h" +#include +#include + +#include "btmcactive.h" +#include "btmccallactive.h" +#include "btmcline.h" +#include +#include +#include + +// FORWARD DECLARATIONS +class CBtmcCallStatus; +class MCCPCall; +class MCCPObserver; + +NONSHARABLE_CLASS(CBtmcVoIPLine) : public CBase , public MBtmcLine, public MCallInformationObserver + { + public: + + /** + * Two-phased constructor. + */ + static CBtmcVoIPLine* NewL(CBtmcCallStatus& aParent, RMobilePhone& aPhone); + + /** + * Two-phased constructor. + */ + static CBtmcVoIPLine* NewLC(CBtmcCallStatus& aParent, RMobilePhone& aPhone); + + /** + * Destructor. + */ + ~CBtmcVoIPLine(); + + public: //From MBtmcLine + + /* From MBtmcLine; Returns the current call status + * @return Bit mask + */ + TInt CallStatusL() const; + + /* From MBtmcLine; method which returns array of active calls + * @return Array of active calls + */ + const RPointerArray& ActiveCalls() const; + + /* From MBtmcLine; method which returns reference + * to RMobilePhone. Used only by MobileLine + * @return Reference to RMobilePhone + */ + RMobilePhone& Phone(); + + /* From MBtmcLine; method which returns reference + * to the call of type: ECallTypePS. Used only by VoipLine + * @return Reference to MCall + */ + const MCall& CallInformationL(); + + /* From MBtmcLine + * Returns the type of line + * @return ETrue for Voip and EFalse otherwise + * + */ + TBool IsVoip(); + + private: + + // From MCallInformationObserver + + /** + * Signals that there are changes in ongoing calls. + * + * @return void + */ + void CallInformationChanged(); + + private: + /** + * C++ default constructor. + */ + CBtmcVoIPLine(CBtmcCallStatus& aParent, RMobilePhone& aPhone); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Leavable version of CallInformationChanged + * + * @return void + */ + void CallInformationChangedL(); + + //Members + private: + CBtmcCallStatus& iParent; + CCallInformation* iInfo; + RPointerArray iCallActives; + RMobilePhone& iPhone; // + }; + +#endif /* BTMCVOIPLINE_H_ */ diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/btmcvolume.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcvolume.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2005 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: volume handling +* +*/ + + +#ifndef BTMCVOLUME_H +#define BTMCVOLUME_H + +// INCLUDES +#include +#include +#include "btmcactive.h" + +class CBtmcPhoneStatus; + +/** +* CBtmcVolume listens network status events (from RMobilePhone). +*/ +NONSHARABLE_CLASS(CBtmcVolume) : public CBase, public MBtmcActiveObserver + { + public: + /** + * Two-phased constructor. + */ + static CBtmcVolume* NewL(CBtmcPhoneStatus& aParent); + + /** + * Destructor. + */ + ~CBtmcVolume(); + + void SetSpeakerVolumeL(TInt aHfVol); + + void SetMicrophoneVolumeL(TInt aHfVol); + + TInt GetVolume(); + + void ActivateRemoteVolumeControl(); + + void DeActivateRemoteVolumeControl(); + + private: // From MBtmcActiveObserver + + void RequestCompletedL(CBtmcActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + private: + + /** + * C++ default constructor. + */ + CBtmcVolume(CBtmcPhoneStatus& aParent); + + /** + * C++ default constructor. + */ + void ConstructL(); + + void DoSetSpeakerVolL( TInt aPrevPhVol ); + + /** + * Converts volume level (0..15 to 0..10). + * @param aVolume Volume level + * @return TInt + */ + TInt HfToPhoneVolScale(TInt aHfVol); + + /** + * Converts volume level (0..10 to 0..15). + * @param aVolume Volume level + * @return TInt + */ + TInt PhoneToHfVolScale(TInt aPhoneVol); + + TInt GetNewPhoneVol(); + + private: + enum TVolSyncAction + { + ESpeakerVolSubscribe, + ESpeakerVolSet, + }; + + private: + CBtmcPhoneStatus& iParent; + + CBtmcActive* iActive; // owned + + RProperty iVolLevelProperty; // owned + RProperty iVolKeyEventProperty; // owned + + // current volume level of speaker + TInt iPhnSpkrVol; // phone speaker volume + TInt iAccSpkrVol; // Acc speaker volume in phone side scale + TInt iMaxSpkrVol; // Maximum volume level of the phone + TInt iStep; + TVolSyncAction iAction; + + TBool iVolCtrlActivated; + }; + + +#endif // BTMCVOLUME_H + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef DEBUGCONFIG_H +#define DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btmac.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTMnCmdH] "); +_LIT8(KTracePrefix8, "[BTMnCmdH] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTMonoCmdHandler"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // LOCOD_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/inc/btmonocmdhandler/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/rom/Btmac.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/rom/Btmac.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2005-2006 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: Image description file for project BTMAC +* +*/ + + +#ifndef BTMAC_IBY +#define BTMAC_IBY + +#if defined(__BT) && defined(__BT_AUDIO) + +#include + +ECOM_PLUGIN(btmac.dll, btmac.rsc) +ECOM_PLUGIN(btmonobearer.dll, btmonobearer.rsc) +file=ABI_DIR\BUILD_DIR\atcodec.dll SHARED_LIB_DIR\atcodec.dll +file=ABI_DIR\BUILD_DIR\BTMonoCmdHandler.dll SHARED_LIB_DIR\BTMonoCmdHandler.dll + +#endif + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/ATCodec/atccommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/ATCodec/atccommand.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,590 @@ +/* +* Copyright (c) 2006 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: Parses/Encodes AT ccommands. +* +*/ + + +// INCLUDE FILES + +#include +#include "atcodec.h" +#include "ATCodecDefs.h" +#include "debug.h" + +const TUint KDelimiterComma = (TUint) ','; + +_LIT8(KDesEqualQuestion, "=?"); +_LIT8(KDesEqual, "="); +_LIT8(KDesQuestion, "?"); +_LIT8(KDesSemicolon, ";"); +_LIT8(KDesAT, "AT"); +_LIT8(KDesColon, ": "); +_LIT8(KDesComma, ","); + +_LIT8(KCRLFFormat, "\r\n%S\r\n"); +const TInt KCRLFSize = 4; + +// ================= MEMBER FUNCTIONS ======================= + +// Destructor +EXPORT_C CATBase::~CATBase() + { + TRACE_FUNC + iText.Close(); + iParamList.Close(); + } + +// ----------------------------------------------------------------------------- +// CATBase::Id +// ----------------------------------------------------------------------------- +// +EXPORT_C TATId CATBase::Id() const + { + return iId; + } + +// ----------------------------------------------------------------------------- +// CATBase::Type +// ----------------------------------------------------------------------------- +// +EXPORT_C TATType CATBase::Type() const + { + return iType; + } + +// ----------------------------------------------------------------------------- +// CATBase::ParamNum +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CATBase::ParamNum() const + { + return iParamList.Count(); + } + +// ----------------------------------------------------------------------------- +// CATBase::Parameter +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CATBase::Parameter(TInt aIndex, TATParam& aParam) const + { + if (aIndex < 0 || aIndex >= iParamList.Count()) + { + return KErrArgument; + } + aParam = iParamList[aIndex]; + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CATBase::GetParameters +// ----------------------------------------------------------------------------- +// +EXPORT_C const RATParamArray& CATBase::Parameters() const + { + return iParamList; + } + +// ----------------------------------------------------------------------------- +// CATBase::Des +// ----------------------------------------------------------------------------- +// +EXPORT_C const TDesC8& CATBase::Des() const + { + return iText; + } + +EXPORT_C void CATBase::ExternalizeL(RWriteStream& aStream) const + { + aStream << iText; + aStream.WriteInt32L(KStreamVersion1); + aStream.WriteInt32L(iId); + aStream.WriteInt32L(iType); + TInt count = iParamList.Count(); + aStream.WriteInt32L(count); + for (TInt i = 0; i < count; i++) + { + aStream << iParamList[i]; + } + } + +EXPORT_C void CATBase::InternalizeL(RReadStream& aStream) + { + TInt32 version = aStream.ReadInt32L(); + + if (version == KStreamVersion1) + { + iText.CreateL(KMaxATSize); + aStream >> iText; + iId = static_cast(aStream.ReadInt32L()); + iType = static_cast(aStream.ReadInt32L()); + TInt count = aStream.ReadInt32L(); + for (TInt i = 0; i < count; i++) + { + TATParam param; + aStream >> param; + iParamList.AppendL(param); + } + } + } + +// ---------------------------------------------------------------------------- +// CATBase::CATBase +// ---------------------------------------------------------------------------- +// +CATBase::CATBase() + { + TRACE_FUNC + } + + +void CATBase::Reset() + { + iId = EUnknownAT; + iType = EATUnkownType; + iText.Close(); + iParamList.Reset(); + } + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CATCommand::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CATCommand* CATCommand::NewL() + { + CATCommand* self = CATCommand::NewLC(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATCommand::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CATCommand* CATCommand::NewLC() + { + CATCommand* self = new (ELeave) CATCommand; + CleanupStack::PushL(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATCommand::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CATCommand* CATCommand::NewL(const TDesC8& aCmd) + { + CATCommand* self = CATCommand::NewLC(aCmd); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATCommand::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CATCommand* CATCommand::NewLC(const TDesC8& aCmd) + { + CATCommand* self = new (ELeave) CATCommand; + CleanupStack::PushL(self); + TInt err = self->Set(aCmd); + LEAVE_IF_ERROR(err); + return self; + } + +// ---------------------------------------------------------------------------- +// CATCommand::Set +// Only supports commands sent from BT audio accessory +// ---------------------------------------------------------------------------- +// +EXPORT_C TInt CATCommand::Set(const TDesC8& aText) + { + TRACE_FUNC_ENTRY; + TRACE_INFO((_L8("'%S'"), &aText)) + Reset(); + TInt err = Parse(aText); + if (err) + { + TRACE_INFO((_L("ret %d"), err)) + Reset(); + } + TRACE_FUNC_EXIT; + return err; + } + +// ---------------------------------------------------------------------------- +// CATCommand::CATCommand +// ---------------------------------------------------------------------------- +// +CATCommand::CATCommand() + { + TRACE_FUNC; + Reset(); + } + +// ---------------------------------------------------------------------------- +// CATCommand::Parse +// ---------------------------------------------------------------------------- +// +TInt CATCommand::Parse(const TDesC8& aText) + { + TRACE_FUNC; + TInt err = iText.Create(aText); + TRACE_INFO((_L("iText.Length(): %d"), iText.Length())); + + if (err != KErrNone) + { + return err; + } + + iText.Trim(); + TPtrC8 at(KDesAT); + if (iText.FindF(at) == 0) + { + // Command AT + if (iText.CompareF(at) == 0) + { + iId = EAT; + iType = EATTestCmd; + return KErrNone; + } + TPtrC8 x; + x.Set(iText.Mid(at.Length())); + for (TInt i = 0; i < KATNameTableSize; i++) + { + TPtrC8 name(KATNameTable[i].KName); + if (x.FindF(name) == 0) + { + iId = KATNameTable[i].KId; + TRACE_INFO((_L("ATId %d"), iId)) + x.Set(x.Mid(name.Length())); + ParseCommandType(x); + TRACE_INFO((_L("ATType %d"), iType)) + if (iType == EATWriteCmd || iType == EATActionCmd) + { + for (TInt j = 0; j < KCommandParamTableSize; j++) + { + if (iId == KCommandParamTable[j].KId && iType == KCommandParamTable[j].KType) + { + return ParseParams(x, 0, j); + } + } + return x.Length(); + } + else + { + return x.Length(); + } + } + } + } + return KErrArgument; + } + +// ----------------------------------------------------------------------------- +// CATCommand::ParseCommandType +// ----------------------------------------------------------------------------- +// +void CATCommand::ParseCommandType(TPtrC8& aPtrC) + { + if (aPtrC.Find(KDesEqualQuestion) == 0) + { + aPtrC.Set(aPtrC.Mid(2)); + iType = EATTestCmd; + } + else if (aPtrC.Find(KDesEqual) == 0) + { + aPtrC.Set(aPtrC.Mid(1)); + iType = EATWriteCmd; + } + else if (aPtrC.Find(KDesQuestion) == 0) + { + aPtrC.Set(aPtrC.Mid(1)); + iType = EATReadCmd; + } + else + { + iType = EATActionCmd; + } + } + +// ----------------------------------------------------------------------------- +// CATCommand::ParseParamNum +// ----------------------------------------------------------------------------- +// +TInt CATCommand::ParseParams(TPtrC8& aDes, TUint aParamIndex, TUint aTableIndex) + { + TInt ret = KErrNone; + while( !(aParamIndex > KCommandParamTable[aTableIndex].KParamNum || + aDes.Length() == 0 || aDes.Find(KDesSemicolon) == 0) ) + { + TBuf8 paramDes(aDes); + TInt pos = aDes.Locate(KDelimiterComma); + if (pos < 0) + { + pos = aDes.Find(KDesSemicolon); + } + if (pos > 0) + { + paramDes = aDes.Left(pos); + } + paramDes.Trim(); + if (paramDes.Length()) + { + TATParamType type = EATNullParam; + type = (TATParamType) KCommandParamTable[aTableIndex].KParamTypes[aParamIndex]; + TATParam param; + ret = param.SetValue(paramDes, type); + if (ret) + { + break; + } + ret = iParamList.Append(param); + if (ret) + { + break; + } + } + if (pos == KErrNotFound || pos == aDes.Length() - 1) + { + break; + } + else + { + aDes.Set(aDes.Mid(++pos)); + aParamIndex++; + } + } + return ret; + } + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CATResult::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CATResult* CATResult::NewL() + { + CATResult* self = CATResult::NewLC(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATResult::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CATResult* CATResult::NewLC() + { + CATResult* self = new (ELeave) CATResult; + CleanupStack::PushL(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATResult::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CATResult* CATResult::NewL(TATId aId, TATType aType, const RATParamArray* aParams) + { + CATResult* self = CATResult::NewLC(aId, aType, aParams); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATResult::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CATResult* CATResult::NewLC(TATId aId, TATType aType, const RATParamArray* aParams) + { + CATResult* self = new (ELeave) CATResult; + CleanupStack::PushL(self); + TInt err = self->Set(aId, aType, aParams); + LEAVE_IF_ERROR(err); + return self; + } + +// ----------------------------------------------------------------------------- +// CATResult::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CATResult* CATResult::NewL(TATId aId, TATType aType, const TATParam aParam) + { + CATResult* self = CATResult::NewLC(aId, aType, aParam); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CATResult::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CATResult* CATResult::NewLC(TATId aId, TATType aType, const TATParam aParam) + { + CATResult* self = new (ELeave) CATResult; + CleanupStack::PushL(self); + RATParamArray array; + TInt err = array.Append(aParam); + if (!err) + { + err = self->Set(aId, aType, &array); + } + array.Close(); + LEAVE_IF_ERROR(err); + return self; + } + + +// ---------------------------------------------------------------------------- +// CATResult::Set +// Only supports result code sent from BT audio gateway +// ---------------------------------------------------------------------------- +// +EXPORT_C TInt CATResult::Set(TATId aId, TATType aType, const RATParamArray* aParams) + { + TRACE_FUNC_ENTRY; + Reset(); + TInt err = Parse(aId, aType, aParams); + if (err) + { + TRACE_INFO((_L("ret %d"), err)) + Reset(); + } + else + { + AddCRLF(iText); + } + TRACE_FUNC_EXIT; + return err; + } + +// ---------------------------------------------------------------------------- +// CATResult::CATResult +// ---------------------------------------------------------------------------- +// +CATResult::CATResult() + { + TRACE_FUNC; + Reset(); + } + +// ---------------------------------------------------------------------------- +// CATResult::Set +// Only supports result code sent from BT audio gateway +// ---------------------------------------------------------------------------- +// +TInt CATResult::Parse(TATId aId, TATType aType, const RATParamArray* aParams) + { + TRACE_FUNC + TInt err = iText.Create(KMaxATSize); + + if (err != KErrNone) + { + return err; + } + + TRACE_INFO((_L("ATId %d, ATType %d"), aId, aType)) + for (TInt i = 0; i < KATNameTableSize; i++) + { + if (aId == KATNameTable[i].KId) + { + // Validate parameters + for (TInt j = 0; j < KResultCodeParamTableSize; j++) + { + if (KResultCodeParamTable[j].KId == aId && KResultCodeParamTable[j].KType == aType) + { + if (!aParams || aParams->Count() < KResultCodeParamTable[j].KParamNum) + { + return KErrArgument; + } + else + { + for (TInt k = 0; k < KResultCodeParamTable[j].KParamNum; k++) + { + if ((*aParams)[k].Type() != KResultCodeParamTable[j].KParamTypes[k]) + { + return KErrArgument; + } + } + } + } + } + + + iId = aId; + iType = aType; + iText.Copy(KATNameTable[i].KName); + if (aParams && aParams->Count()) + { + TPtrC8 colon(KDesColon); + TPtrC8 comma(KDesComma); + iText.Append(colon); + for (TInt j = 0; j < aParams->Count(); j++) + { + TInt err = iParamList.Append((*aParams)[j]); + if (err) + { + return err; + } + if (iText.Length() + (*aParams)[j].Des().Length() > KMaxATSize) + { + return KErrArgument; + } + iText.Append((*aParams)[j].Des()); + if (j != aParams->Count() - 1) + { + if (iText.Length() + comma.Length() > KMaxATSize) + { + return KErrArgument; + } + iText.Append(KDelimiterComma); + } + } + } + return KErrNone; + } + } + return KErrArgument; + } + + +TInt CATResult::AddCRLF(TDes8& aText) + { + if (aText.Length() + KCRLFSize > KMaxATSize) + { + return KErrOverflow; + } + TBuf8 buf(aText); + aText.Format(KCRLFFormat, &buf); + return KErrNone; + } + +void ATCmdArrayResetAndDestroyAndClose(TAny* aPtr) + { + reinterpret_cast(aPtr)->ResetAndDestroy(); + reinterpret_cast(aPtr)->Close(); + } + +EXPORT_C void ATObjArrayCleanupResetAndDestroyPushL(RATResultPtrArray& aArray) + { + TCleanupItem item(ATCmdArrayResetAndDestroyAndClose, &aArray); + CleanupStack::PushL(item); + } + + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/ATCodec/atcparam.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/ATCodec/atcparam.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,179 @@ +/* +* Copyright (c) 2005 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: The parameter of an AT command. +* +*/ + + +// INCLUDE FILES + +#include +#include "atcodec.h" +#include "debug.h" + +const TUint KCharDoubleQuote = (TUint) '"'; +_LIT8(KDesDoubleQuote, "\""); + +// ================= MEMBER FUNCTIONS ======================= + +EXPORT_C TATParam::TATParam() + : iValue(KNullDesC8), iValueInt(0), iType(EATNullParam) + { + } + +EXPORT_C TATParam::TATParam(const TDesC8& aValue, TATParamType aType) + : iValueInt(0), iType(aType) + { + iValue.Copy(aValue.Left(iValue.MaxLength())); // to prevent panic for exceeding iValue length + iValue.Trim(); + if (EATDQStringParam == aType) + AddDQ(); + TRACE_INFO((_L8("param type %d, '%S'"), iType, &iValue)) + } + +EXPORT_C TATParam::TATParam(TInt aValue) + : iValueInt(aValue), iType(EATIntParam) + { + iValue.Num(aValue, EDecimal); + TRACE_INFO((_L8("param type %d, '%S'"), iType, &iValue)) + } + +// ----------------------------------------------------------------------------- +// TATParam::Int +// ----------------------------------------------------------------------------- +EXPORT_C TInt TATParam::Int(TInt& aValue) const + { + if (iType == EATIntParam) + { + aValue = iValueInt; + return KErrNone; + } + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// TATParam::Str +// ----------------------------------------------------------------------------- +EXPORT_C const TDesC8& TATParam::Des() const + { + return iValue; + } + +// ----------------------------------------------------------------------------- +// TATParam::Type +// ----------------------------------------------------------------------------- +EXPORT_C TATParamType TATParam::Type() const + { + return iType; + } + +// ----------------------------------------------------------------------------- +// TATParam::SetValue +// ----------------------------------------------------------------------------- +EXPORT_C TInt TATParam::SetValue(const TDesC8& aValue, TATParamType aType) + { + if (aValue.Length() > KMaxATParamSize) + { + return KErrArgument; + } + + iType = aType; + TInt err = KErrNone; + switch (iType) + { + case EATNullParam: + { + iValue.Zero(); + break; + } + case EATIntParam: + { + TLex8 lex(aValue); + err = lex.Val(iValueInt); + if (!err) + { + iValue.Copy(aValue); + iValue.Trim(); + } + break; + } + case EATStringParam: + { + iValue.Copy(aValue); + iValue.Trim(); + break; + } + case EATDQStringParam: + { + iValue.Copy(aValue); + iValue.Trim(); + AddDQ(); + break; + } + } + TRACE_INFO((_L8("param type %d, '%S'"), iType, &iValue)) + return err; + } + +// ----------------------------------------------------------------------------- +// TATParam::SetValue +// ----------------------------------------------------------------------------- +EXPORT_C void TATParam::SetInt(TInt aValue) + { + iValueInt = aValue; + iValue.Num(aValue, EDecimal); + iType = EATIntParam; + } + +EXPORT_C void TATParam::ExternalizeL(RWriteStream& aStream) const + { + aStream << iValue; + aStream.WriteInt32L(KStreamVersion1); + aStream.WriteInt32L(iValueInt); + aStream.WriteInt32L(iType); + } + +EXPORT_C void TATParam::InternalizeL(RReadStream& aStream) + { + TInt32 version = aStream.ReadInt32L(); + + if (version == KStreamVersion1) + { + aStream >> iValue; + iValueInt = aStream.ReadInt32L(); + iType = static_cast(aStream.ReadInt32L()); + } + } + +void TATParam::AddDQ() + { + if (iValue.Length()) + { + if (iValue[0] != KCharDoubleQuote) + { + iValue.Insert(0, KDesDoubleQuote); + } + if (iValue[iValue.Length() - 1] != KCharDoubleQuote) + { + iValue.Append(KDesDoubleQuote); + } + } + else + { + iValue.Append(KDesDoubleQuote); + iValue.Append(KDesDoubleQuote); + } + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/BTMonoCdmaIncomingFlash.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/BTMonoCdmaIncomingFlash.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2005 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: General Active Object offering asynchronous service +* +*/ + + +#include "BTMonoCdmaIncomingFlash.h" +#include "BTMonoCallActive.h" +#include "Debug.h" + +_LIT(KDefaultRemoteNumber, "n/a"); + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::NewL +// ----------------------------------------------------------------------------- +// +CBTMonoCdmaIncomingFlash* CBTMonoCdmaIncomingFlash::NewL( + MBTMonoActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName) + { + CBTMonoCdmaIncomingFlash * self = + CBTMonoCdmaIncomingFlash::NewLC(aObserver, aPriority, aServiceId, aLine, aName); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::NewLC +// ----------------------------------------------------------------------------- +CBTMonoCdmaIncomingFlash* CBTMonoCdmaIncomingFlash::NewLC( + MBTMonoActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName) + { + CBTMonoCdmaIncomingFlash* self = + new (ELeave) CBTMonoCdmaIncomingFlash(aObserver, aPriority, aServiceId, aLine, aName); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// Destructor +CBTMonoCdmaIncomingFlash::~CBTMonoCdmaIncomingFlash() + { + Cancel(); + iCdmaCall.Close(); + TRACE_FUNC_THIS + } + +void CBTMonoCdmaIncomingFlash::GoActive() + { + if (!IsActive()) + { + iCdmaCall.NotifyIncomingNetworkFlashWithInfo(iStatus, iFlashMessagePckg); + SetActive(); + } + TRACE_FUNC_THIS + } + +// ----------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTMonoCdmaIncomingFlash::DoCancel() + { + iCdmaCall.CancelAsyncRequest(ECdmaMobileCallNotifyIncomingNetworkFlashWithInfo); + } + +// ----------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::RunL +// +// ----------------------------------------------------------------------------- +// +void CBTMonoCdmaIncomingFlash::RunL() + { + TRACE_FUNC_ENTRY_THIS + Observer().RequestCompletedL(*this, iStatus.Int()); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::RunError +// ------------------------------------------------------------------------------- +TInt CBTMonoCdmaIncomingFlash::RunError(TInt /*aErr*/) + { + Cancel(); + iCdmaCall.Close(); + TRACE_FUNC_THIS + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::CBTMonoCdmaIncomingFlash +// ----------------------------------------------------------------------------- +// +CBTMonoCdmaIncomingFlash::CBTMonoCdmaIncomingFlash( + MBTMonoActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName) + : CBTMonoActive(aObserver, aPriority, aServiceId), + iCdmaLine(aLine), + iCallName(aName), + iFlashMessagePckg(RCdmaMobileCall::TMobileCallIncomingFlashMessageV1()) + { + } + +// ----------------------------------------------------------------------------- +// CBTMonoCdmaIncomingFlash::ConstructL +// ----------------------------------------------------------------------------- +// +void CBTMonoCdmaIncomingFlash::ConstructL() + { + LEAVE_IF_ERROR(iCdmaCall.OpenExistingCall(iCdmaLine, iCallName)) + TRACE_FUNC_THIS + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/BTMonoMobileLineCdma.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/BTMonoMobileLineCdma.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,211 @@ +/* +* Copyright (c) 2005 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: call status handling. +* +*/ + + +// INCLUDE FILES + +#include "BTMonoMobileLine.h" +#include "BTMonoCdmaIncomingFlash.h" +#include "BTMonoEventObserver.h" +#include "BTMonoCmdHandlerDefs.h" +#include "Debug.h" + +const TInt KMobileLineActiveService = 1; +const TInt KMobileCallActiveService = 2; +const TInt KMobileCdmaActiveService = 3; + +// ----------------------------------------------------------------------------- +// CBTMonoMobileLine::NewL +// ----------------------------------------------------------------------------- +CBTMonoMobileLine* CBTMonoMobileLine::NewL( + MBTMonoEventObserver& aObserver, RMobilePhone& aPhone, const TDesC& aLineName) + { + CBTMonoMobileLine* self = CBTMonoMobileLine::NewLC(aObserver, aPhone, aLineName); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTMonoMobileLine::NewLC +// ----------------------------------------------------------------------------- +CBTMonoMobileLine* CBTMonoMobileLine::NewLC( + MBTMonoEventObserver& aObserver, RMobilePhone& aPhone, const TDesC& aLineName) + { + CBTMonoMobileLine* self = new(ELeave) CBTMonoMobileLine(aObserver, aPhone, aLineName); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTMonoMobileLine::~CBTMonoMobileLine +// ----------------------------------------------------------------------------- +CBTMonoMobileLine::~CBTMonoMobileLine() + { + TRACE_FUNC_ENTRY_THIS + iCallActives.ResetAndDestroy(); + iCallActives.Close(); + iCdmaActives.ResetAndDestroy(); + iCdmaActives.Close(); + delete iLineActive; + iLine.Close(); + } + +TInt CBTMonoMobileLine::ActiveCallCount() const + { + TInt count = iCallActives.Count(); + TInt activecount = 0; + RMobileCall::TMobileCallStatus sta; + for (TInt i = 0; i < count; i++) + { + sta = iCallActives[i]->CallStatus(); + if (sta == RMobileCall::EStatusConnected || sta == RMobileCall::EStatusHold) + { + activecount++; + } + } + return activecount; + } + +RMobileCall::TMobileCallStatus CBTMonoMobileLine::CallStatus(const TName& aCallName) const + { + TInt count = iCallActives.Count(); + for (TInt i = 0; i < count; i++) + { + if (iCallActives[i]->CallName().Compare(aCallName) == 0) + { + return iCallActives[i]->CallStatus(); + } + } + return RMobileCall::EStatusUnknown; + } + + +void CBTMonoMobileLine::RequestCompletedL(CBTMonoActive& aActive, TInt aErr) + { + switch (aActive.ServiceId()) + { + case KMobileLineActiveService: + { + if (aErr == KErrNone) + { + CBTMonoCallActive* callActive = CBTMonoCallActive::NewLC( + *this, CActive::EPriorityStandard, KMobileCallActiveService, + iLine, iName); + iCallActives.AppendL(callActive); + + CBTMonoCdmaIncomingFlash* cdmaActive = CBTMonoCdmaIncomingFlash::NewLC( + *this, CActive::EPriorityStandard, KMobileCdmaActiveService, + iLine, iName); + iCdmaActives.AppendL(cdmaActive); + iObserver.HandleMobileCallEventL(iName, callActive->CallStatus()); + callActive->GoActive(); + cdmaActive->GoActive(); + CleanupStack::Pop(callActive); + CleanupStack::Pop(cdmaActive); + } + iLine.NotifyCallAdded(aActive.iStatus, iName); + aActive.GoActive(); + break; + } + case KMobileCallActiveService: + { + CBTMonoCallActive& calla = reinterpret_cast(aActive); + iObserver.HandleMobileCallEventL(calla.CallName(), calla.CallStatus()); + RMobileCall::TMobileCallStatus status = calla.CallStatus(); + if (status == RMobileCall::EStatusIdle) + { + TInt idx = iCallActives.Find(&calla); + if (idx >= 0) + { + delete iCallActives[idx]; + iCallActives.Remove(idx); + delete iCdmaActives[idx]; + iCdmaActives.Remove(idx); + } + } + else + { + aActive.GoActive(); + } + break; + } + case KMobileCdmaActiveService: + { + iObserver.HandleCdmaIncomingFlashEventL(); + aActive.GoActive(); + break; + } + default: + break; + } + } + +void CBTMonoMobileLine::CancelRequest(TInt aServiceId) + { + if (aServiceId == KMobileLineActiveService) + { + iLine.NotifyCallAddedCancel(); + } + } + +// ----------------------------------------------------------------------------- +// CBTMonoMobileLine::CBTMonoMobileLine +// ----------------------------------------------------------------------------- +CBTMonoMobileLine::CBTMonoMobileLine( + MBTMonoEventObserver& aObserver, RMobilePhone& aPhone, const TDesC& aLineName) + : iObserver(aObserver), iPhone(aPhone), iLineName(aLineName) + { + } + +// ----------------------------------------------------------------------------- +// CBTMonoMobileLine::ConstructL +// ----------------------------------------------------------------------------- +void CBTMonoMobileLine::ConstructL() + { + LEAVE_IF_ERROR(iLine.Open(iPhone, iLineName)) + + TInt count = 0; + LEAVE_IF_ERROR(iLine.EnumerateCall(count)) + + for (TInt i = 0; i < count; i++) + { + RLine::TCallInfo info; + LEAVE_IF_ERROR(iLine.GetCallInfo(i, info)) + CBTMonoCallActive* callActive = CBTMonoCallActive::NewLC( + *this, CActive::EPriorityStandard, KMobileCallActiveService, + iLine, info.iCallName); + iCallActives.AppendL(callActive); + + CBTMonoCdmaIncomingFlash* cdmaActive = CBTMonoCdmaIncomingFlash::NewLC( + *this, CActive::EPriorityStandard, KMobileCdmaActiveService, + iLine, info.iCallName); + iCdmaActives.AppendL(cdmaActive); + + callActive->GoActive(); + cdmaActive->GoActive(); + CleanupStack::Pop(callActive); + CleanupStack::Pop(cdmaActive); + } + + iLineActive = CBTMonoActive::NewL(*this, CActive::EPriorityStandard, KMobileLineActiveService); + iLine.NotifyCallAdded(iLineActive->iStatus, iName); + iLineActive->GoActive(); + TRACE_FUNC_THIS + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/HFPAtEcomListen.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/HFPAtEcomListen.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2008 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: ECom plugin install/uninstall/version listener +* +*/ + + +#include "HFPAtEcomListen.h" +#include "debug.h" + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CHFPAtEcomListen* CHFPAtEcomListen::NewL( + RATExt* aAtCmdExt, + MHFPAtEcomListen* aCallback ) + { + CHFPAtEcomListen* self = NewLC( aAtCmdExt, aCallback ); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CHFPAtEcomListen* CHFPAtEcomListen::NewLC( + RATExt* aAtCmdExt, + MHFPAtEcomListen* aCallback ) + { + CHFPAtEcomListen* self = new (ELeave) CHFPAtEcomListen( aAtCmdExt, + aCallback ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CHFPAtEcomListen::~CHFPAtEcomListen() + { + TRACE_INFO( _L("CHFPAtEcomListen::~CHFPAtEcomListen()") ); + ResetData(); + TRACE_INFO( _L("CHFPAtEcomListen::~CHFPAtEcomListen() complete") ); + } + +// --------------------------------------------------------------------------- +// Resets data to initial values +// --------------------------------------------------------------------------- +// +void CHFPAtEcomListen::ResetData() + { + TRACE_INFO( _L("CHFPAtEcomListen::ResetData()") ); + // APIs affecting this: + // IssueRequest() + Stop(); + // Internal + Initialize(); + TRACE_INFO( _L("CHFPAtEcomListen::ResetData() complete") ); + } + +// --------------------------------------------------------------------------- +// Starts waiting for ECom plugin install/uninstall/version status changes +// --------------------------------------------------------------------------- +// +TInt CHFPAtEcomListen::IssueRequest() + { + TRACE_INFO( _L("CHFPAtEcomListen::IssueRequest()") ); + if ( iEcomListenState != EHFPStateIdle ) + { + TRACE_INFO( _L("CHFPAtEcomListen::IssueRequest() (not ready) complete") ); + return KErrNotReady; + } + iStatus = KRequestPending; + iAtCmdExt->ReceiveEcomPluginChange( iStatus, iPluginUidPckg, iEcomTypePckg ); + SetActive(); + iEcomListenState = EHFPStateEcomListening; + TRACE_INFO( _L("CHFPAtEcomListen::IssueRequest() complete") ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Stops waiting for Ecom plugin install/uninstall/version status changes +// --------------------------------------------------------------------------- +// +TInt CHFPAtEcomListen::Stop() + { + TRACE_INFO( _L("CHFPAtEcomListen::Stop()") ); + if ( iEcomListenState != EHFPStateEcomListening ) + { + TRACE_INFO( _L("CHFPAtEcomListen::Stop() (not ready) complete" )); + return KErrNotReady; + } + iAtCmdExt->CancelReceiveEcomPluginChange(); + Cancel(); + iEcomListenState = EHFPStateIdle; + TRACE_INFO( _L("CHFPAtEcomListen::Stop() complete") ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CHFPAtEcomListen::CHFPAtEcomListen +// --------------------------------------------------------------------------- +// +CHFPAtEcomListen::CHFPAtEcomListen( RATExt* aAtCmdExt, + MHFPAtEcomListen* aCallback ) : + CActive( EPriorityHigh ), + iAtCmdExt( aAtCmdExt ), + iCallback( aCallback ), + iPluginUidPckg( iPluginUid ), + iEcomTypePckg( EEcomTypeUninstall ) + { + Initialize(); + } + +// --------------------------------------------------------------------------- +// CHFPAtEcomListen::ConstructL +// --------------------------------------------------------------------------- +// +void CHFPAtEcomListen::ConstructL() + { + TRACE_INFO( _L("CHFPAtEcomListen::ConstructL()") ); + if ( !iAtCmdExt || !iCallback ) + { + User::Leave( KErrGeneral ); + } + CActiveScheduler::Add( this ); + TRACE_INFO( _L("CHFPAtEcomListen::ConstructL() complete") ); + } + +// --------------------------------------------------------------------------- +// Initializes this class +// --------------------------------------------------------------------------- +// +void CHFPAtEcomListen::Initialize() + { + // Don't initialize iAtCmdExt here (it is set through NewL) + // Don't initialize iCallback here (it is set through NewL) + iEcomListenState = EHFPStateIdle; + iPluginUid = TUid::Null(); + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Gets called when plugin installed, uninstalled or changed +// --------------------------------------------------------------------------- +// +void CHFPAtEcomListen::RunL() + { + TRACE_INFO( _L("CHFPAtEcomListen::RunL()") ); + iEcomListenState = EHFPStateIdle; + TInt retTemp = iStatus.Int(); + if ( retTemp != KErrNone ) + { + //TRACE_INFO( _L("CHFPAtEcomListen::RunL() (ERROR) complete (%d)"), retTemp ); + return; + } + IssueRequest(); + // Now the operation is either unintall or install of plugin + // Notify parent and ATEXT + if ( iEcomTypePckg() == EEcomTypeUninstall ) + { + iCallback->NotifyPluginUninstallation( iPluginUid ); + } + else if ( iEcomTypePckg() == EEcomTypeInstall ) + { + iCallback->NotifyPluginInstallation( iPluginUid ); + } + else + { + TRACE_INFO( _L("CHFPAtEcomListen::RunL() (not supported) complete") ); + } + TRACE_INFO( _L("CHFPAtEcomListen::RunL() complete") ); + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Gets called on cancel +// --------------------------------------------------------------------------- +// +void CHFPAtEcomListen::DoCancel() + { + TRACE_INFO( _L("CHFPAtEcomListen::DoCancel()") ); + TRACE_INFO( _L("CHFPAtEcomListen::DoCancel() complete") ); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/HFPAtUrcHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/HFPAtUrcHandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2008 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: AT command URC handler +* +*/ + + +#include +#include "HfpAtCmdHandler.h" +#include "HFPAtUrcHandler.h" +#include "debug.h" + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CHFPAtUrcHandler* CHFPAtUrcHandler::NewL( + RATExt* aAtCmdExt, + MATExtObserver& aObserver ) + { + CHFPAtUrcHandler* self = NewLC( aAtCmdExt, aObserver ); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CHFPAtUrcHandler* CHFPAtUrcHandler::NewLC( + RATExt* aAtCmdExt, + MATExtObserver& aObserver ) + { + CHFPAtUrcHandler* self = new (ELeave) CHFPAtUrcHandler( aAtCmdExt, + aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CHFPAtUrcHandler::~CHFPAtUrcHandler() + { + TRACE_INFO( _L("CHFPAtUrcHandler::~CHFPAtUrcHandler()") ); + ResetData(); + TRACE_INFO( _L("CHFPAtUrcHandler::~CHFPAtUrcHandler() complete") ); + } + +// --------------------------------------------------------------------------- +// Resets data to initial values +// --------------------------------------------------------------------------- +// +void CHFPAtUrcHandler::ResetData() + { + TRACE_INFO( _L("CHFPAtUrcHandler::ResetData()") ); + // APIs affecting this: + // IssueRequest() + Stop(); + // Don't close iAtCmdExt here (it is done in CHFPAtCmdHandler)! + // Internal + Initialize(); + TRACE_INFO( _L("CHFPAtUrcHandler::ResetData() complete") ); + } + +// --------------------------------------------------------------------------- +// Starts waiting for an incoming URC message +// --------------------------------------------------------------------------- +// +TInt CHFPAtUrcHandler::IssueRequest() + { + TRACE_INFO( _L("CHFPAtUrcHandler::IssueRequest()") ); + if ( iUrcHandleState != EHFPStateIdle ) + { + TRACE_INFO( _L("CHFPAtUrcHandler::IssueRequest() (not ready) complete") ); + return KErrNotReady; + } + iStatus = KRequestPending; + iAtCmdExt->ReceiveUnsolicitedResult( iStatus, iRecvBuffer, iOwnerUidPckg ); + SetActive(); + iUrcHandleState = EHFPStateAtUrcHandling; + // Next mark ownership + if ( !iStarted ) + { + TInt retTemp = iAtCmdExt->MarkUrcHandlingOwnership( iOwnerUid ); + if ( retTemp != KErrNone ) + { + TRACE_INFO( _L("CHFPAtUrcHandler::IssueRequest() (not owned) complete") ); + return KErrGeneral; + } + } + iStarted = ETrue; + TRACE_INFO( _L("CHFPAtUrcHandler::IssueRequest() complete") ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Stops waiting for an incoming URC message +// --------------------------------------------------------------------------- +// +TInt CHFPAtUrcHandler::Stop() + { + TRACE_INFO( _L("CHFPAtUrcHandler::Stop()") ); + if ( iUrcHandleState != EHFPStateAtUrcHandling ) + { + TRACE_INFO( _L("CHFPAtUrcHandler::Stop() (not ready) complete" ) ); + return KErrNotReady; + } + iAtCmdExt->CancelReceiveUnsolicitedResult( iOwnerUid ); + Cancel(); + iUrcHandleState = EHFPStateIdle; + TRACE_INFO( _L("CHFPAtUrcHandler::Stop() complete") ); + // Note: Don't mark iStarted to EFalse here as it is used to get the UID + return KErrNone; + } + +// --------------------------------------------------------------------------- +// UID of the owning plugin +// --------------------------------------------------------------------------- +// +TUid CHFPAtUrcHandler::OwnerUid() + { + return iOwnerUid; + } + +// --------------------------------------------------------------------------- +// CHFPAtUrcHandler::CHFPAtUrcHandler +// --------------------------------------------------------------------------- +// +CHFPAtUrcHandler::CHFPAtUrcHandler( RATExt* aAtCmdExt, MATExtObserver& aObserver ) : + CActive( EPriorityHigh ), + iAtCmdExt( aAtCmdExt ), + iObserver( aObserver ), + iOwnerUidPckg( iOwnerUid ) + + { + Initialize(); + } + +// --------------------------------------------------------------------------- +// CHFPAtUrcHandler::ConstructL +// --------------------------------------------------------------------------- +// +void CHFPAtUrcHandler::ConstructL() + { + TRACE_INFO( _L("CHFPAtUrcHandler::ConstructL()") ); + if ( !iAtCmdExt ) + { + User::Leave( KErrGeneral ); + } + CActiveScheduler::Add( this ); + TRACE_INFO( _L("CHFPAtUrcHandler::ConstructL() complete") ); + } + +// --------------------------------------------------------------------------- +// Initializes this class +// --------------------------------------------------------------------------- +// +void CHFPAtUrcHandler::Initialize() + { + iUrcHandleState = EHFPStateIdle; + iOwnerUid = TUid::Null(); + iStarted = EFalse; + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Gets called when URC command received +// --------------------------------------------------------------------------- +// +void CHFPAtUrcHandler::RunL() + { + TRACE_INFO( _L("CHFPAtUrcHandler::RunL()") ); + iUrcHandleState = EHFPStateIdle; + TInt err = iStatus.Int(); + + // Send received URC message + if (err == KErrNone) + { + if ( iRecvBuffer.Length() == 0 ) + { + TRACE_INFO( _L("CHFPAtUrcHandler::RunL() (empty buffer) complete") ); + iObserver.UnsolicitedResultFromATExtL(err, KNullDesC8); + } + iObserver.UnsolicitedResultFromATExtL(err, iRecvBuffer); + + IssueRequest(); + } + else + { + //TRACE_INFO( _L("CHFPAtUrcHandler::RunL() (ERROR) complete (%d)"), err)); + iObserver.UnsolicitedResultFromATExtL(err, KNullDesC8); + } + + TRACE_INFO( _L("CHFPAtUrcHandler::RunL() complete") ); + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Gets called on cancel +// --------------------------------------------------------------------------- +// +void CHFPAtUrcHandler::DoCancel() + { + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/HfpAtCmdhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/HfpAtCmdhandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,318 @@ +/* +* Copyright (c) 2007 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: BT HFP AT extension API +* +*/ + + +// INCLUDE FILES +#include "HfpAtCmdHandler.h" +#include "debug.h" + +enum TActiveRequestId + { + EHandleCommandRequest = 1, + EReceiveEventRequest, + }; + +CHFPAtCmdHandler* CHFPAtCmdHandler::NewL(MATExtObserver& aObserver) + { + CHFPAtCmdHandler* self = new (ELeave) CHFPAtCmdHandler(aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CHFPAtCmdHandler::~CHFPAtCmdHandler() + { + TRACE_FUNC + delete iCommander; + + DeletePluginHandlers(); + + delete iEcomListen; + iEcomListen = NULL; + + if ( iATExtClient.Handle() ) + { + iATExtClient.Close(); + } +} + +void CHFPAtCmdHandler::HandleCommand(const TDesC8& aAT, const TDesC8& aReply) + { + TRACE_INFO((_L8("default reply '%S'"), &aReply)) + iCmdBuffer.Copy(aAT); + iReplyBuffer.Zero(); + if (aReply.Length()) + { + iReplyBuffer.Copy(aReply); + iSystemReply.Copy(aReply); + } + iATExtClient.HandleCommand(iCommander->iStatus, + iCmdBuffer, iReplyBuffer, iRemainingReplyLengthPckg, iReplyTypePckg); + iCommander->GoActive(); + } + +void CHFPAtCmdHandler::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + TRACE_FUNC_ENTRY + TInt err = aErr; + switch (aActive.ServiceId()) + { + case EHandleCommandRequest: + { + if(err == KErrNone) + { + if (iRemainingReplyLengthPckg()) + { + /*RBuf8 reply2; + reply2.CreateL(iRemainingReplyLengthPckg() + iReplyBuffer.Length()); + err = iATExtClient.GetNextPartOfReply(reply2, iRemainingReplyLengthPckg); + if (!err) + { + reply2.Insert(0, iReplyBuffer); + } + TRACE_INFO((_L8("reply '%S'"), &reply2)) + iObserver.ATExtHandleCommandCompletedL(err, reply2); + reply2.Close();*/ + iATExtClient.GetNextPartOfReply( iRecvBuffer, + iRemainingReplyLength ); + } + else + { + TRACE_INFO((_L8("reply '%S'"), &iReplyBuffer)) + iObserver.ATExtHandleCommandCompletedL(err, iReplyBuffer); + } + } + else + { + iObserver.ATExtHandleCommandCompletedL(err, iSystemReply); + } + break; + } + } + TRACE_FUNC_EXIT + } + +void CHFPAtCmdHandler::CancelRequest(TInt aServiceId) + { + switch (aServiceId) + { + case EHandleCommandRequest: + { + iATExtClient.CancelHandleCommand(); + break; + } + } + } + +TInt CHFPAtCmdHandler::HandleRunError(TInt /*aErr*/) + { + return KErrNone; + } + +CHFPAtCmdHandler::CHFPAtCmdHandler(MATExtObserver& aObserver) + : iObserver(aObserver), + iRemainingReplyLengthPckg(iRemainingReplyLength), + iReplyTypePckg( iReplyType ) + { + TRACE_FUNC + } + +_LIT8(KHFPAtCmd, "HFP"); + +void CHFPAtCmdHandler::ConstructL() + { + TRACE_FUNC_ENTRY + + CleanupClosePushL( iATExtClient ); + TInt err = iATExtClient.Connect(EHfpATExtension, KHFPAtCmd); + LEAVE_IF_ERROR(err) + + // Create the plugin handlers + CreatePluginHandlersL(); + // Create the listeners + CHFPAtEcomListen* ecomListen = CHFPAtEcomListen::NewLC( &iATExtClient, this ); + ecomListen->IssueRequest(); + + CleanupStack::Pop( ecomListen ); + CleanupStack::Pop( &iATExtClient ); + iEcomListen = ecomListen; + + StartUrc(); + iCommander = CBtmcActive::NewL(*this, CActive::EPriorityStandard, EHandleCommandRequest); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Creates plugin handlers for this class +// --------------------------------------------------------------------------- +// +void CHFPAtCmdHandler::CreatePluginHandlersL() + { + TRACE_INFO( _L("CHFPAtCmdHandler::CreatePluginHandlersL()") ); + if ( !iATExtClient.Handle() ) + { + TRACE_INFO(_L("CHFPAtCmdHandler::CreatePluginHandlersL() complete") ); + User::Leave( KErrGeneral ); + } + + // Next create the URC handlers + TInt i; + TInt numOfPlugins = iATExtClient.NumberOfPlugins(); + for ( i=0; iIssueRequest(); + if ( retTemp != KErrNone ) + { + TRACE_INFO( _L("CHFPAtCmdHandler::NotifyPluginInstallation() (issuerequest) complete" ) ); + return retTemp; + } + TUid ownerUid = urcHandler->OwnerUid(); + iATExtClient.ReportListenerUpdateReady( ownerUid, EEcomTypeInstall ); + + if ( retTemp != KErrNone ) + { + TRACE_INFO( _L("CHFPAtCmdHandler::NotifyPluginInstallation() (recreate) complete" )); + return retTemp; + } + TRACE_INFO( _L("CHFPAtCmdHandler::NotifyPluginInstallation() complete" ) ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// From class MHFPAtEcomListen. +// Notifies about existing plugin uninstallation +// --------------------------------------------------------------------------- +// +TInt CHFPAtCmdHandler::NotifyPluginUninstallation( TUid& aPluginUid ) + { + TRACE_INFO( _L("CHFPAtCmdHandler::NotifyPluginUninstallation()" ) ); + TInt i; + TInt count = iUrcHandlers.Count(); + for ( i=count-1; i>=0; i-- ) + { + TUid ownerUid = iUrcHandlers[i]->OwnerUid(); + if ( ownerUid == aPluginUid ) + { + delete iUrcHandlers[i]; + iUrcHandlers.Remove( i ); + iATExtClient.ReportListenerUpdateReady( ownerUid, + EEcomTypeUninstall ); + } + } + + TRACE_INFO( _L("CHFPAtCmdHandler::NotifyPluginUninstallation() complete" ) ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Instantiates one URC message handling class instance and adds it to the URC +// message handler array +// --------------------------------------------------------------------------- +// +CHFPAtUrcHandler* CHFPAtCmdHandler::AddOneUrcHandlerL() + { + TRACE_INFO( _L("CHFPAtCmdHandler::AddOneUrcHandlerL()") ); + CHFPAtUrcHandler* urcHandler = CHFPAtUrcHandler::NewLC( &iATExtClient, + iObserver ); + iUrcHandlers.AppendL( urcHandler ); + CleanupStack::Pop( urcHandler ); + TRACE_INFO( _L("CHFPAtCmdHandler::AddOneUrcHandlerL() complete") ); + return urcHandler; + } + +// --------------------------------------------------------------------------- +// Starts URC message handling +// --------------------------------------------------------------------------- +// +TInt CHFPAtCmdHandler::StartUrc() + { + TRACE_INFO( _L("CHFPAtCmdHandler::StartUrc()") ); + TInt i; + TInt count = iUrcHandlers.Count(); + for ( i=0; iIssueRequest(); + if ( retTemp!=KErrNone && retTemp!=KErrNotReady ) + { + TRACE_INFO( _L("CHFPAtCmdHandler::StartUrc() (ERROR) complete") ); + return retTemp; + } + } + TRACE_INFO( _L("CHFPAtCmdHandler::StartUrc() complete") ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Stops URC message handling +// --------------------------------------------------------------------------- +// +TInt CHFPAtCmdHandler::StopUrc() + { + TRACE_INFO( _L("CHFPAtCmdHandler::StopUrc()") ); + TInt i; + TInt retVal = KErrNone; + TInt count = iUrcHandlers.Count(); + for ( i=0; iStop(); + } + TRACE_INFO( _L("CHFPAtCmdHandler::StopUrc() complete") ); + return retVal; + } + +// --------------------------------------------------------------------------- +// Deletes all instantiated URC message handlers +// --------------------------------------------------------------------------- +// +void CHFPAtCmdHandler::DeletePluginHandlers() + { + TRACE_INFO( _L("CHFPAtCmdHandler::DeletePluginHandlers()") ); + TInt i; + TInt count = iUrcHandlers.Count(); + for ( i=0; i + +const TInt8 KMaxPhoneStrength = 7; +const TInt8 KMaxHFPStrength = 5; + +// ----------------------------------------------------------------------------- +// CBtmcBattery::NewL +// ----------------------------------------------------------------------------- +CBtmcBattery* CBtmcBattery::NewL(CBtmcPhoneStatus& aParent) + { + CBtmcBattery* self = CBtmcBattery::NewLC(aParent); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcBattery::NewLC +// ----------------------------------------------------------------------------- +CBtmcBattery* CBtmcBattery::NewLC(CBtmcPhoneStatus& aParent) + { + CBtmcBattery* self = new (ELeave) CBtmcBattery(aParent); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcBattery::~CBtmcBattery +// ----------------------------------------------------------------------------- +CBtmcBattery::~CBtmcBattery() + { + TRACE_FUNC_ENTRY + Cancel(); + iProperty.Close(); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcBattery::GoActive +// ------------------------------------------------------------------------------- +void CBtmcBattery::GoActive() + { + TRACE_ASSERT(!IsActive(), KErrGeneral); + iProperty.Subscribe(iStatus); + SetActive(); + TRACE_FUNC + } + + +// ------------------------------------------------------------------------------- +// CBtmcBattery::RunL +// ------------------------------------------------------------------------------- +void CBtmcBattery::RunL() + { + TRACE_FUNC_ENTRY + if (iStatus == KErrNone) + { + TInt temp = 0; + TInt err = iProperty.Get(temp); + if (!err) + { + ConvertToHFPScale(temp); + iCharge = temp; + TRACE_INFO((_L("iStatus %d, battery strength %d"), iStatus.Int(), temp)) + iParent.HandleBatteryChangeL(temp); + } + GoActive(); + } + else + { + TRACE_ERROR((_L("ERROR %d"), iStatus.Int())) + } + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcBattery::DoCancel +// ------------------------------------------------------------------------------- +void CBtmcBattery::DoCancel() + { + iProperty.Cancel(); + TRACE_FUNC + } + + +// ------------------------------------------------------------------------------- +// CBtmcBattery::RunError +// ------------------------------------------------------------------------------- +TInt CBtmcBattery::RunError(TInt /*aErr*/) + { + iProperty.Close(); + TRACE_FUNC + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtmcBattery::CBtmcBattery +// ----------------------------------------------------------------------------- +CBtmcBattery::CBtmcBattery(CBtmcPhoneStatus& aParent) + : CActive(EPriorityNormal), iParent(aParent) + { + CActiveScheduler::Add(this); + } + +void CBtmcBattery::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iProperty.Attach(KPSUidHWRMPowerState, KHWRMBatteryLevel)); + LEAVE_IF_ERROR(iProperty.Get(iCharge)); + ConvertToHFPScale(iCharge); + TRACE_FUNC_EXIT + } + +void CBtmcBattery::ConvertToHFPScale(TInt &aStrength) + { + TReal result; + Math::Round( result, TReal(TReal(KMaxHFPStrength)/TReal(KMaxPhoneStrength) *TReal(aStrength)),0); + aStrength = TInt8(result); + } + +TInt CBtmcBattery::GetBatteryCharge() + { + return iCharge; + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2005 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: General Active Object offering asynchronous service +* +*/ + + +#include "btmccallactive.h" +#include "debug.h" + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::NewL +// ----------------------------------------------------------------------------- +CBtmcCallActive* CBtmcCallActive::NewL( + MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName) + { + CBtmcCallActive* self = CBtmcCallActive::NewLC(aObserver, aPriority, aServiceId, aLine, aName); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::NewLC +// ----------------------------------------------------------------------------- +CBtmcCallActive* CBtmcCallActive::NewLC( + MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName) + { + CBtmcCallActive* self = new (ELeave) CBtmcCallActive(aObserver, aPriority, aServiceId, aLine, aName); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::~CBtmcCallActive +// ----------------------------------------------------------------------------- +CBtmcCallActive::~CBtmcCallActive() + { + TRACE_FUNC_ENTRY + Cancel(); + iCall.Close(); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcCallActive::GoActive +// ------------------------------------------------------------------------------- +void CBtmcCallActive::GoActive() + { + TRACE_ASSERT(!IsActive(), KErrGeneral); + iCall.NotifyMobileCallStatusChange(iStatus, iCallStatus); + SetActive(); + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::CallName +// +// Gets call name. +// ----------------------------------------------------------------------------- +// +const TDesC& CBtmcCallActive::CallName() const + { + return iName; + } + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::RemotePartyNumber +// +// Get caller's phone number. +// ----------------------------------------------------------------------------- +// +const TDesC& CBtmcCallActive::RemotePartyNumber() const + { + return iRemoteNumber; + } + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::CallStatus +// +// ----------------------------------------------------------------------------- +// +RMobileCall::TMobileCallStatus CBtmcCallActive::CallStatus() const + { + return iCallStatus; + } + +// ------------------------------------------------------------------------------- +// CBtmcCallActive::RunL +// ------------------------------------------------------------------------------- +void CBtmcCallActive::RunL() + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("ao status %d"), iStatus.Int())) + TRACE_INFO((_L("name '%S' new status %d, old status %d"), &iName, iCallStatus, iPrevCallStatus)) + + if(iCallStatus != iPrevCallStatus) + { + iPrevCallStatus = iCallStatus; + if( iCallStatus != RMobileCall::EStatusIdle && + !iEmergency ) + { + RMobileCall::TMobileCallInfoV1 myInfo; + GetCallInfo( myInfo ); + if ( myInfo.iValid & RMobileCall::KCallEmergency && + myInfo.iEmergency ) + { + TRACE_INFO((_L("Emergency call object detected"))) + iEmergency = ETrue; + } + } + + Observer().RequestCompletedL(*this, iStatus.Int()); + } + else if( iCallStatus == RMobileCall::EStatusIdle ) + { + Observer().RequestCompletedL(*this, iStatus.Int()); + } + else + { + GoActive(); + } + + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcCallActive::DoCancel +// ------------------------------------------------------------------------------- +void CBtmcCallActive::DoCancel() + { + iCall.CancelAsyncRequest(EMobileCallNotifyMobileCallStatusChange); + TRACE_FUNC + } + +// ------------------------------------------------------------------------------- +// CBtmcCallActive::RunError +// ------------------------------------------------------------------------------- +TInt CBtmcCallActive::RunError(TInt /*aErr*/) + { + Cancel(); + iCall.Close(); + TRACE_FUNC + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtmcCallActive::CBtmcCallActive +// ----------------------------------------------------------------------------- +CBtmcCallActive::CBtmcCallActive( + MBtmcActiveObserver& aObserver, + CActive::TPriority aPriority, + TInt aServiceId, + RMobileLine& aLine, + const TName& aName) + : CBtmcActive(aObserver, aPriority, aServiceId), iLine(aLine) + { + iName.Copy(aName); + } + +void CBtmcCallActive::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iCall.OpenExistingCall(iLine, iName)) + LEAVE_IF_ERROR(iCall.GetMobileCallStatus(iCallStatus)) + iPrevCallStatus = iCallStatus; + TRACE_INFO((_L("name '%S' status %d"), &iName, iCallStatus)) + + RMobileCall::TMobileCallInfoV1 info; + RMobileCall::TMobileCallInfoV1Pckg package(info); + LEAVE_IF_ERROR(iCall.GetMobileCallInfo(package)) + iCall.GetMobileCallInfo(package); + if ((info.iValid & RMobileCall::KCallRemoteParty) && + info.iRemoteParty.iRemoteIdStatus == RMobileCall::ERemoteIdentityAvailable) + { + iRemoteNumber.Copy(info.iRemoteParty.iRemoteNumber.iTelNumber); + } + else if (info.iValid & RMobileCall::KCallDialledParty) + { + //number for outgoing call + iRemoteNumber.Copy(info.iDialledParty.iTelNumber); + } + + TRACE_INFO((_L("remote party '%S' "), &iRemoteNumber)) + + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTMonoCallActive::GetCallInfo +// ----------------------------------------------------------------------------- +void CBtmcCallActive::GetCallInfo(RMobileCall::TMobileCallInfoV1& info) + { + RMobileCall::TMobileCallInfoV1Pckg package(info); + iCall.GetMobileCallInfo(package); + } + +// ----------------------------------------------------------------------------- +// CBTMonoCallActive::IsEmergencyCall +// ----------------------------------------------------------------------------- +TBool CBtmcCallActive::IsEmergencyCall() const + { + return iEmergency; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallinghandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallinghandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2005 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: call cmd handling. +* +*/ + + +// INCLUDE FILES + +#include "atcodec.h" +#include "btengprivatepskeys.h" +#include "btmccallinghandler.h" +#include "btmcprotocol.h" +#include "debug.h" + +const TInt KCallingResponse = 30; + +// ----------------------------------------------------------------------------- +// CBtmcCallingHandler::NewL +// ----------------------------------------------------------------------------- +CBtmcCallingHandler* CBtmcCallingHandler::NewL(CBtmcProtocol& aProtocol) + { + CBtmcCallingHandler* self = new(ELeave) CBtmcCallingHandler(aProtocol); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcCallingHandler::~CBtmcCallingHandler +// ----------------------------------------------------------------------------- +CBtmcCallingHandler::~CBtmcCallingHandler() + { + TRACE_FUNC_ENTRY + delete iActive; + iCmdProperty.Close(); + TRACE_FUNC_EXIT + } + + +void CBtmcCallingHandler::HandleCallingCmdL(const CATCommand& aCmd) + { + TRACE_FUNC_ENTRY + TRACE_ASSERT(!iBusy, KErrInUse) + TInt err = iCmdProperty.Set(aCmd.Des()); + if (err) + { + TRACE_INFO((_L8("PS set returned %d"), err)) + CATResult* nok = CATResult::NewLC(EATERROR); + iProtocol.SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + iProtocol.CmdHandlingCompletedL(); + } + else + { + iBusy = ETrue; + iCmdId = aCmd.Id(); + iActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KCallingResponse); + iCmdProperty.Subscribe(iActive->iStatus); + iActive->GoActive(); + } + TRACE_FUNC_EXIT + } + +TBool CBtmcCallingHandler::ActiveCmdHandling() const + { + return iBusy; + } + +TBool CBtmcCallingHandler::ActiveChldHandling() const + { + return iBusy && ( iCmdId == EATCHLD ); + } + +void CBtmcCallingHandler::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + switch (aActive.ServiceId()) + { + case KCallingResponse: + { + delete iActive; + iActive = NULL; + if (!iBusy) + { + break; + } + iBusy = EFalse; + TInt result = KErrNone; + if (!aErr) + { + TBuf8 buf; + aErr = iCmdProperty.Get(buf); + if (!aErr && buf.Length() >= sizeof(TInt)) + { + const TUint8* ptr = buf.Ptr(); + result = *((const TInt*)ptr); + } + } + TRACE_INFO((_L("resp %d"), result)) + TATId atid = EATOK; + if (aErr || result) + { + atid = EATERROR; + if (iCmdId == EATBVRA) + { + iProtocol.VoiceRecognitionError(); + } + } + + CATResult* nok = CATResult::NewLC(atid); + iProtocol.SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + iProtocol.CmdHandlingCompletedL(); + break; + } + default: + break; + } + } + +void CBtmcCallingHandler::CancelRequest(TInt aServiceId) + { + switch (aServiceId) + { + case KCallingResponse: + { + iCmdProperty.Cancel(); + break; + } + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CBtmcCallingHandler::CBtmcCallingHandler +// ----------------------------------------------------------------------------- +CBtmcCallingHandler::CBtmcCallingHandler(CBtmcProtocol& aProtocol) + : iProtocol(aProtocol) + { + } + +// ----------------------------------------------------------------------------- +// CBtmcCallingHandler::ConstructL +// ----------------------------------------------------------------------------- +void CBtmcCallingHandler::ConstructL() + { + TRACE_FUNC + iCmdProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTATCodec); + TRACE_FUNC_EXIT + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallstatus.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallstatus.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,807 @@ +/* +* Copyright (c) 2005 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 "atcodec.h" +#include "btmcprotocol.h" +#include "btmcprotocolstatus.h" +#include "btmccallstatus.h" +#include "btmcmobileline.h" +#include "btmcvoipline.h" +#include "debug.h" + +const TInt KRingTimerService = 10; + +CBtmcCallStatus* CBtmcCallStatus::NewL( + CBtmcProtocol& aProtocol, + RMobilePhone& aPhone, + TBtmcProfileId aProfile) + { + CBtmcCallStatus* self=new (ELeave) CBtmcCallStatus(aProtocol); + CleanupStack::PushL(self); + self->ConstructL(aPhone, aProfile); + CleanupStack::Pop(self); + return self; + } + +// ========================================================== +// CBtmcCallStatus::~CBtmcCallStatus +// +// ========================================================== +// +CBtmcCallStatus::~CBtmcCallStatus() + { + TRACE_FUNC_ENTRY + delete iTimerActive; + iTimer.Close(); + + iLines.ResetAndDestroy(); + iLines.Close(); + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::CallStatus +// +// ========================================================== +// +TInt CBtmcCallStatus::CallStatusL() const + { + TRACE_FUNC + TInt mask = 0; + TInt count = iLines.Count(); + for (TInt i = 0; i < count; i++) + { + mask |= iLines[i]->CallStatusL(); + } + TRACE_INFO((_L(" overall CALL STATUS 0x%08x"), mask)) + return mask; + } + +// ========================================================== +// CBtmcCallStatus::ReportCallStatusL +// +// ========================================================== +// +void CBtmcCallStatus::ReportCallStatusL() + { + TInt callBits = CallStatusL(); + ReportCallEventL(iProtocol.ProtocolStatus().iCallBits, callBits); + iProtocol.ProtocolStatus().iCallBits = callBits; + } + +// ========================================================== +// CBtmcCallStatus::RequestCompleted +// +// ========================================================== +// +void CBtmcCallStatus::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + TRACE_FUNC_ENTRY + switch (aActive.ServiceId()) + { + case KRingTimerService: + { + if (aErr == KErrNone) + { + ReportRingAndClipL(); + iTimer.After(aActive.iStatus, KRingInterval); + aActive.GoActive(); + } + break; + } + default: + break; + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::CancelRequest +// Constructor +// ========================================================== +// +void CBtmcCallStatus::CancelRequest(TInt aServiceId) + { + TRACE_FUNC_ENTRY + if (aServiceId == KRingTimerService) + { + iTimer.Cancel(); + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::CBtmcCallStatus +// Constructor +// ========================================================== +// +CBtmcCallStatus::CBtmcCallStatus(CBtmcProtocol& aProtocol) : iProtocol(aProtocol) + { + } + +// ========================================================== +// CBtmcCallStatus::ConstructL +// +// ========================================================== +// +void CBtmcCallStatus::ConstructL( + RMobilePhone& aPhone, + TBtmcProfileId aProfile) + { + TRACE_FUNC_ENTRY + CBtmcMobileLine* voiceline = CBtmcMobileLine::NewLC(*this, aPhone, KMmTsyVoice1LineName); + iLines.AppendL(voiceline); + CleanupStack::Pop(voiceline); + CBtmcVoIPLine *voipline = NULL; + TRAPD(err, voipline = CBtmcVoIPLine::NewL(*this, aPhone)); + if(!err) + { + CleanupStack::PushL(voipline); + iLines.AppendL(voipline); + CleanupStack::Pop(voipline); + } + + TRAP(err, voiceline = CBtmcMobileLine::NewL(*this, aPhone, KMmTsyVoice2LineName)); + if (!err) + { + CleanupStack::PushL(voiceline); + iLines.AppendL(voiceline); + CleanupStack::Pop(voiceline); + } + + if (aProfile == EBtmcHFP0105 ) + { + CBtmcMobileLine* dataline = CBtmcMobileLine::NewLC(*this, aPhone, KMmTsyDataLineName); + iLines.AppendL(dataline); + CleanupStack::Pop(dataline); + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::HandleClccL +// +// ========================================================== +// +void CBtmcCallStatus::HandleClccL() + { + TRACE_FUNC_ENTRY + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + + if(CallStatusL() & KCallAllStatusMask) + { + TInt count = iLines.Count(); + for(TInt i=0; iIsVoip() ) + { + const RPointerArray& calls = iLines[i]->ActiveCalls(); + TInt count2 = calls.Count(); + RMobileConferenceCall myConf; + User::LeaveIfError(myConf.Open(iLines[i]->Phone())); + CleanupClosePushL(myConf); + TInt confcount; + User::LeaveIfError(myConf.EnumerateCalls(confcount)); + RMobileCall::TMobileCallInfoV1 info; + RMobileCall::TMobileCallRemotePartyInfoV1 remote; + for(TInt j=0; jGetCallInfo(info); + if (info.iStatus != RMobileCall::EStatusIdle) + { + remote = info.iRemoteParty; + CATResult* cmd = MakeClccL(info, remote, confcount); + resarr.AppendL(cmd); + } + } + CleanupStack::PopAndDestroy(&myConf); + } + else // VoIP case + { + const MCall& callInfo = iLines[i]->CallInformationL(); + if(&callInfo != NULL) + { + CATResult* cmd = MakeVoIPClccL(callInfo); + resarr.AppendL(cmd); + } + } + } + } + CATResult* ok = CATResult::NewL(EATOK); + CleanupStack::PushL(ok); + resarr.AppendL(ok); + CleanupStack::Pop(ok); + iProtocol.SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + iProtocol.CmdHandlingCompletedL(); + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::GetRingingNumL +// +// ========================================================== +// +void CBtmcCallStatus::GetRingingNumL(TDes8& aNum) + { + TRACE_FUNC_ENTRY + if(CallStatusL() & KCallRingingBit) + { + TInt count = iLines.Count(); + for(TInt i=0; iIsVoip()) + { + const RPointerArray& calls = iLines[i]->ActiveCalls(); + TInt count2 = calls.Count(); + RMobileConferenceCall myConf; + User::LeaveIfError(myConf.Open(iLines[i]->Phone())); + CleanupClosePushL(myConf); + RMobileCall::TMobileCallInfoV1 info; + RMobileCall::TMobileCallRemotePartyInfoV1 remote; + + for(TInt j=0; jGetCallInfo(info); + if (info.iStatus == RMobileCall::EStatusRinging + && (info.iValid & RMobileCall::KCallRemoteParty) + && info.iRemoteParty.iRemoteIdStatus == RMobileCall::ERemoteIdentityAvailable) + { + aNum.Copy(info.iRemoteParty.iRemoteNumber.iTelNumber); + break; + } + } + CleanupStack::PopAndDestroy(&myConf); + } + } + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::GetOutgoingNumL +// +// ========================================================== +// +void CBtmcCallStatus::GetOutgoingNumL(TDes8& aNum) + { + TRACE_FUNC_ENTRY + TInt count = iLines.Count(); + for(TInt i=0; i& calls = iLines[i]->ActiveCalls(); + TInt count2 = calls.Count(); + RMobileCall::TMobileCallInfoV1 info; + RMobileCall::TMobileCallRemotePartyInfoV1 remote; + + for(TInt j=0; jGetCallInfo(info); + if (info.iStatus == RMobileCall::EStatusDialling + && (info.iValid & RMobileCall::KCallDialledParty)) + { + TPtrC tempPtrC(KNullDesC); + tempPtrC.Set(info.iDialledParty.iTelNumber); + aNum.Copy(tempPtrC); + break; + } + } + } + TRACE_FUNC_EXIT + } + +TBTMonoATPhoneNumberType CBtmcCallStatus::NumberType( const TDesC8& aNum ) + { + if (aNum.Length() == 0) + { + return EBTMonoATPhoneNumberUnavailable; + } + if(aNum.Locate('+') == 0) + { + return EBTMonoATPhoneNumberInternational; + } + return EBTMonoATPhoneNumberNational; + } + +// ========================================================== +// CBtmcCallStatus::MakeClccL +// +// ========================================================== +// +CATResult* CBtmcCallStatus::MakeClccL(RMobileCall::TMobileCallInfoV1& info, + RMobileCall::TMobileCallRemotePartyInfoV1& remote, TInt aConferenceCallCount) + { + TRACE_FUNC_ENTRY + RArray params; + CleanupClosePushL(params); + if(info.iValid & RMobileCall::KCallId) + { + LEAVE_IF_ERROR(params.Append(TATParam(info.iCallId))) // Index number + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam())) + } + + if(remote.iDirection == RMobileCall::EMobileOriginated) // outgoing + { + LEAVE_IF_ERROR(params.Append(TATParam(0))) + } + else // unknown or incoming + { + LEAVE_IF_ERROR(params.Append(TATParam(1))) + } + + switch(info.iStatus) // status + { + case RMobileCall::EStatusDialling: + { + LEAVE_IF_ERROR(params.Append(TATParam(2))) + break; + } + case RMobileCall::EStatusRinging: + { + TInt status = CallStatusL(); + if(status & KActiveCallMask) + { + LEAVE_IF_ERROR(params.Append(TATParam(5))) + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam(4))) + } + break; + } + case RMobileCall::EStatusAnswering: + { + LEAVE_IF_ERROR(params.Append(TATParam(5))) + break; + } + case RMobileCall::EStatusConnecting: + { + LEAVE_IF_ERROR(params.Append(TATParam(3))) + break; + } + case RMobileCall::EStatusConnected: + { + LEAVE_IF_ERROR(params.Append(TATParam(0))) + break; + } + case RMobileCall::EStatusHold: + { + LEAVE_IF_ERROR(params.Append(TATParam(1))) + break; + } + default: + LEAVE_IF_ERROR(params.Append(TATParam(0))) + } + + switch(info.iService) // mode + { + case RMobilePhone::EVoiceService: + { + LEAVE_IF_ERROR(params.Append(TATParam(0))) + break; + } + case RMobilePhone::ECircuitDataService: + case RMobilePhone::EPacketDataService: + { + LEAVE_IF_ERROR(params.Append(TATParam(1))) + break; + } + case RMobilePhone::EFaxService: + { + LEAVE_IF_ERROR(params.Append(TATParam(2))) + break; + } + default: + LEAVE_IF_ERROR(params.Append(TATParam(0))) + } + + // multiparty + TATParam param; + if(aConferenceCallCount) + LEAVE_IF_ERROR(params.Append(TATParam(1))) + else + LEAVE_IF_ERROR(params.Append(TATParam(0))) + + // number (optional) + TPtrC tempPtrC(KNullDesC); + if ((info.iValid & RMobileCall::KCallRemoteParty) && + info.iRemoteParty.iRemoteIdStatus == RMobileCall::ERemoteIdentityAvailable) + { + tempPtrC.Set(info.iRemoteParty.iRemoteNumber.iTelNumber); + } + else if (info.iValid & RMobileCall::KCallDialledParty) + { + //append number for outgoing call + tempPtrC.Set(info.iDialledParty.iTelNumber); + } + + if(tempPtrC != KNullDesC) + { + TBuf8<100> tempBuf8; + tempBuf8.Copy(tempPtrC); // conversion to 8 bit + LEAVE_IF_ERROR(params.Append(TATParam(tempBuf8, EATDQStringParam))) + + // type (optional) + TBTMonoATPhoneNumberType numType = NumberType( tempBuf8 ); + params.AppendL(TATParam(numType)); + } + + CATResult* clcc = CATResult::NewL(EATCLCC, EATActionResult, ¶ms); + CleanupStack::PopAndDestroy(¶ms); + TRACE_FUNC_EXIT + return clcc; + } + +// ========================================================== +// CBtmcCallStatus::MakeVoIPClccL +// +// ========================================================== +// +CATResult* CBtmcCallStatus::MakeVoIPClccL(const MCall &callinfo) + { + TRACE_FUNC_ENTRY + RArray params; + CleanupClosePushL(params); + LEAVE_IF_ERROR(params.Append(TATParam(1))) // Index number + + if(callinfo.CallDirection() == CCPCall::EMobileOriginated) // outgoing + { + LEAVE_IF_ERROR(params.Append(TATParam(0))) + } + else // unknown or incoming + { + LEAVE_IF_ERROR(params.Append(TATParam(1))) + } + + switch(callinfo.CallState()) // status + { + case CCPCall::EStateDialling: + { + LEAVE_IF_ERROR(params.Append(TATParam(2))) + break; + } + case CCPCall::EStateRinging: + { + TInt status = CallStatusL(); + if(status & KActiveCallMask) + { + LEAVE_IF_ERROR(params.Append(TATParam(5))) + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam(4))) + } + break; + } + case CCPCall::EStateAnswering: + { + LEAVE_IF_ERROR(params.Append(TATParam(5))) + break; + } + case CCPCall::EStateConnecting: + { + LEAVE_IF_ERROR(params.Append(TATParam(3))) + break; + } + case CCPCall::EStateConnected: + { + LEAVE_IF_ERROR(params.Append(TATParam(0))) + break; + } + case CCPCall::EStateHold: + { + LEAVE_IF_ERROR(params.Append(TATParam(1))) + break; + } + default: + LEAVE_IF_ERROR(params.Append(TATParam(0))) + } + + LEAVE_IF_ERROR(params.Append(TATParam(1))) + + // multiparty + LEAVE_IF_ERROR(params.Append(TATParam(0))) + + CATResult* clcc = CATResult::NewL(EATCLCC, EATActionResult, ¶ms); + CleanupStack::PopAndDestroy(¶ms); + TRACE_FUNC_EXIT + return clcc; + } + +// Sending Call Waiting notification +// if incoming call starts ringing and there is active call already. +// <+CCWA: "nnn", 129, 1> when calling number is national +// <+CCWA: "nnn", 145, 1> when calling number is international (first char is '+') +// <+CCWA: "", 128, 1> when calling number is not available + +// RING is started in the following cases: +// +// 1. call is ringing (RMobileCall::EStatusRinging) and no active calls exist. +// 2. call is terminating (RMobileCall::EStatusIdle) and ringing call exists. + + +// Call status notification +// +CIEV: 2,0 is generated if last active(Connected or Hold)call disconnects +// +CIEV: 2,1 is generated if first call becomes active +// + +// Call setup status notification +// +CIEV: 3,0 if call set up state ends +// +CIEV: 3,1 if an incoming call set up is ongoing +// +CIEV: 3,2 if an outgoing call set up is ongoing +// +CIEV: 3,3 if remote party being alerted in an outgoing call + +void CBtmcCallStatus::HandleMobileCallEventL( + const TName& aName, + const TDesC& aRemotePartyName, + RMobileCall::TMobileCallStatus aStatus, TBool aOutgoingCall) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("INDICATOR STATUS: CIEV 0x%08x, CLI %d, CCWA %d, previous CALL BITS 0x%08x, OutgoingCall %d"), + iProtocol.ProtocolStatus().iIndicatorNotif, iProtocol.ProtocolStatus().iCallerIdNotif, iProtocol.ProtocolStatus().iCallWaitingNotif, + iProtocol.ProtocolStatus().iCallBits, iProtocol.ProtocolStatus().iOutgoingCallNotif)) + + TRACE_INFO((_L("NAME '%S', REMOTE PARTY '%S', STATUS %d"), + &aName, &aRemotePartyName, aStatus)); (void) aName; (void) aStatus; + + (void) aRemotePartyName; + + TInt callBits = CallStatusL(); + //Before SLC, no event will be reported + if (iProtocol.ProtocolStatus().iSlc) + { + ReportCallEventL(iProtocol.ProtocolStatus().iCallBits, callBits, aOutgoingCall); + } + iProtocol.ProtocolStatus().iCallBits = callBits; + TRACE_FUNC_EXIT + } + +void CBtmcCallStatus::ReportRingAndClipL(TBool aColp) + { + TRACE_FUNC_ENTRY + CATResult* event = CATResult::NewLC(EATRING, EATUnsolicitedResult); + RArray params; + CleanupClosePushL(params); + + if(!aColp) + { + iProtocol.SendUnsoltResultL(*event); + } + + if (iProtocol.ProtocolStatus().iCallerIdNotif == EBTMonoATCallerIdNotifEnabled && !aColp) + { + TRACE_INFO((_L("CLIP"))) + GetRingingNumL( iRemoteTelNum ); + TBTMonoATPhoneNumberType numType = NumberType( iRemoteTelNum ); + params.AppendL(TATParam(iRemoteTelNum, EATDQStringParam)); + params.AppendL(TATParam(numType)); + LEAVE_IF_ERROR(event->Set(EATCLIP, EATUnsolicitedResult, ¶ms)) + iProtocol.SendUnsoltResultL(*event); + } + else if( iProtocol.ProtocolStatus().iOutgoingCallNotif && aColp ) // COLP + { + TRACE_INFO((_L("COLP"))) + GetOutgoingNumL(iRemoteTelNum); + TBTMonoATPhoneNumberType numType = NumberType( iRemoteTelNum ); + params.AppendL(TATParam(iRemoteTelNum, EATDQStringParam)); + params.AppendL(TATParam(numType)); + LEAVE_IF_ERROR(event->Set(EATCOLP, EATUnsolicitedResult, ¶ms)) + iProtocol.SendUnsoltResultL(*event); + } + + CleanupStack::PopAndDestroy(¶ms); + CleanupStack::PopAndDestroy(event); + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::ReportCallEventL +// +// ========================================================== +// +void CBtmcCallStatus::ReportCallEventL(TInt aPrevStatus, TInt aNewStatus, TBool /*aOutgoing*/) + { + TRACE_FUNC_ENTRY + // CCWA + if (iProtocol.ProtocolStatus().iCallWaitingNotif == EBTMonoATCallWaitingNotifEnabled && + (!(aPrevStatus & KCallRingingBit) && (aNewStatus & KCallRingingBit)) && + ((aNewStatus & KCallConnectedBit) || + (aNewStatus & KCallHoldBit))) + { + StopTimer(KRingTimerService); + GetRingingNumL( iRemoteTelNum ); + TBTMonoATPhoneNumberType numType = NumberType( iRemoteTelNum ); + RArray params; + CleanupClosePushL(params); + params.AppendL(TATParam(iRemoteTelNum, EATDQStringParam)); + params.AppendL(TATParam(numType)); + params.AppendL(TATParam(1)); + CATResult* ccwa = CATResult::NewLC(EATCCWA, EATUnsolicitedResult, ¶ms); + iProtocol.SendUnsoltResultL(*ccwa); + CleanupStack::PopAndDestroy(ccwa); + CleanupStack::PopAndDestroy(¶ms); + } + + // Call and setup status + if (iProtocol.ProtocolStatus().iIndicatorNotif) + { + TInt presta = 0; + presta |= (aPrevStatus & KCallConnectedBit) | (aPrevStatus & KCallHoldBit); + + TInt newsta = 0; + newsta |= (aNewStatus & KCallConnectedBit) | (aNewStatus & KCallHoldBit); + + TRACE_INFO((_L("call (Active and Held): presta 0x%08x, newsta 0x%08x"), presta, newsta)) + + // Call status + // If an active call is terminated by AT+CHLD=1, we should not send NoCall indication. + if (presta && !newsta && + !(iProtocol.ActiveChldHandling() && ( aNewStatus & KCallRingingBit ) ) ) + { + ReportCallIndicatorL(EBTMonoATCallIndicator, EBTMonoATNoCall); + } + else if (!presta && newsta) + { + ReportCallIndicatorL(EBTMonoATCallIndicator, EBTMonoATCallActive); + } + + // Call setup status + presta = 0; + presta |= (aPrevStatus & KCallDiallingBit) | + (aPrevStatus & KCallRingingBit) | + (aPrevStatus & KCallAnsweringBit) | + (aPrevStatus & KCallConnectingBit); + + newsta = 0; + newsta |= (aNewStatus & KCallDiallingBit) | + (aNewStatus & KCallRingingBit) | + (aNewStatus & KCallAnsweringBit) | + (aNewStatus & KCallConnectingBit); + TRACE_INFO((_L("call setup: presta 0x%08x, newsta 0x%08x"), presta, newsta)) + + if (presta != newsta && !(aNewStatus & KCallAnsweringBit)) + { + TInt callSetupInd = EBTMonoATNoCallSetup; + + if (newsta & KCallRingingBit) + { + callSetupInd = EBTMonoATCallRinging; + } + else if (newsta & KCallDiallingBit) + { + callSetupInd = EBTMonoATCallDialling; + } + else if (newsta & KCallConnectingBit) + { + callSetupInd = EBTMonoATCallConnecting; + } + ReportCallIndicatorL(EBTMonoATCallSetupIndicator, callSetupInd); + ReportCallIndicatorL(EBTMonoATCall_SetupIndicator, callSetupInd); + // COLP + if( (newsta & KCallDiallingBit) && iProtocol.ProtocolStatus().iOutgoingCallNotif) + ReportRingAndClipL(ETrue); + } + + // Call Held status + if ((aPrevStatus & KCallHoldBit) && !(aNewStatus & KCallHoldBit)) + { + ReportCallIndicatorL(EBTMonoATCallHeldIndicator, EBTMonoATNoCallHeld); + } + else if (!(aPrevStatus & KCallHoldBit) && (aNewStatus & KCallHoldBit)) + { + if ((aNewStatus & KCallConnectedBit)) + { + ReportCallIndicatorL(EBTMonoATCallHeldIndicator, EBTMonoATCallHeldAndActive); + } + else if (!(aNewStatus & KCallConnectedBit) && !(aNewStatus & KCallRingingBit)) + { + ReportCallIndicatorL(EBTMonoATCallHeldIndicator, EBTMonoATCallHeldOnly); + } + } + else if ((aPrevStatus & KCallHoldBit) && (aNewStatus & KCallHoldBit)) + { + if ((aPrevStatus & KCallConnectedBit) && !(aNewStatus & KCallConnectedBit)) + { + ReportCallIndicatorL(EBTMonoATCallHeldIndicator, EBTMonoATCallHeldOnly); + } + else if (!(aPrevStatus & KCallConnectedBit) && (aNewStatus & KCallConnectedBit)) + { + ReportCallIndicatorL(EBTMonoATCallHeldIndicator, EBTMonoATCallHeldAndActive); + } + } + } + + // Ring + // We can not send RING when the active call is ended and + // waiting call answered by AT+CHLD=1. + if (!(aNewStatus & KCallConnectedBit) && + !(aNewStatus & KCallHoldBit) && + (aNewStatus & KCallRingingBit) && + !iProtocol.ActiveChldHandling() ) + { + ReportRingAndClipL(); + StartTimerL(KRingTimerService, KRingInterval); + } + else + { + StopTimer(KRingTimerService); + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcCallStatus::StartTimerL +// +// ========================================================== +// +void CBtmcCallStatus::StartTimerL(TInt aService, TInt aTimeout) + { + if (!iTimerActive) + { + TRACE_FUNC_ENTRY + iTimerActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, aService); + iTimer.CreateLocal(); + iTimer.After(iTimerActive->iStatus, aTimeout); + iTimerActive->GoActive(); + TRACE_FUNC_EXIT + } + else + { + TRACE_WARNING(_L("WARNING, timer is active already")) + } + } +// ========================================================== +// CBtmcCallStatus::StopTimer +// +// ========================================================== +// +void CBtmcCallStatus::StopTimer(TInt aService) + { + if (iTimerActive && iTimerActive->ServiceId() == aService) + { + TRACE_FUNC_ENTRY + delete iTimerActive; + iTimerActive = NULL; + iTimer.Close(); + TRACE_FUNC_EXIT + } + } +// ========================================================== +// CBtmcCallStatus::ReportCallIndicatorL +// +// ========================================================== +// +void CBtmcCallStatus::ReportCallIndicatorL(TBTMonoATPhoneIndicatorId aIndicator, TInt aValue) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("indicator %d, value %d"), aIndicator, aValue)) + RArray params; + CleanupClosePushL(params); + params.AppendL(TATParam(aIndicator)); + params.AppendL(TATParam(aValue)); + CATResult* ciev = CATResult::NewLC(EATCIEV, EATUnsolicitedResult, ¶ms); + iProtocol.SendUnsoltResultL(*ciev); + CleanupStack::PopAndDestroy(ciev); + CleanupStack::PopAndDestroy(¶ms); + TRACE_FUNC_EXIT + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmchandlerapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmchandlerapi.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2005 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: Extended Phone RemCon Handler +* +*/ + + +#include "btmchandlerapi.h" +#include "btmcprotocol.h" +#include "debug.h" + +EXPORT_C CBtmcHandlerApi* CBtmcHandlerApi::NewL( + MBtmcObserver& aObserver, TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated) + { + CBtmcHandlerApi* self=new (ELeave) CBtmcHandlerApi(); + CleanupStack::PushL(self); + self->ConstructL(aObserver, aProfile, aBTDevAddr, aAccessoryInitiated); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CBtmcHandlerApi::~CBtmcHandlerApi() + { + TRACE_FUNC_ENTRY + delete iHandler; + TRACE_FUNC_EXIT + } + +EXPORT_C void CBtmcHandlerApi::HandleProtocolDataL(const TDesC8& aData) + { + TRACE_FUNC_ENTRY + iHandler->NewProtocolDataL(aData); + TRACE_FUNC_EXIT + } + +EXPORT_C void CBtmcHandlerApi::HandleNrecCompletedL(TInt aErr) + { + iHandler->HandleNrecCompletedL(aErr); + } + +EXPORT_C void CBtmcHandlerApi::ActivateRemoteVolumeControl() + { + iHandler->ActivateRemoteVolumeControl(); + } + +EXPORT_C void CBtmcHandlerApi::DeActivateRemoteVolumeControl() + { + iHandler->DeActivateRemoteVolumeControl(); + } + +EXPORT_C TInt CBtmcHandlerApi::GetRemoteSupportedFeature() + { + return iHandler->GetRemoteSupportedFeature(); + } + +CBtmcHandlerApi::CBtmcHandlerApi() + { + } + +void CBtmcHandlerApi::ConstructL(MBtmcObserver& aObserver, TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated) + { + TRACE_FUNC_ENTRY + iHandler = CBtmcProtocol::NewL(aObserver, aProfile, aBTDevAddr, aAccessoryInitiated); + TRACE_FUNC_EXIT + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcmobileline.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcmobileline.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,274 @@ +/* +* Copyright (c) 2005 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: call status handling. +* +*/ + + +// INCLUDE FILES +#include "btmcprotocol.h" +#include "btmcmobileline.h" +#include "btmc_defs.h" +#include "debug.h" +#include "btmccallstatus.h" +#include "btmcdummy.h" + +const TInt KMobileLineActiveService = 30; +const TInt KMobileCallActiveService = 31; + +// ========================================================== +// CBtmcMobileLine::NewL +// ========================================================== +CBtmcMobileLine* CBtmcMobileLine::NewL( + CBtmcCallStatus& aParent, RMobilePhone& aPhone, const TDesC& aLineName) + { + CBtmcMobileLine* self = CBtmcMobileLine::NewLC(aParent, aPhone, aLineName); + CleanupStack::Pop(self); + return self; + } + +// ========================================================== +// CBtmcMobileLine::NewLC +// ========================================================== +CBtmcMobileLine* CBtmcMobileLine::NewLC( + CBtmcCallStatus& aParent, RMobilePhone& aPhone, const TDesC& aLineName) + { + CBtmcMobileLine* self = new(ELeave) CBtmcMobileLine(aParent, aPhone, aLineName); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ========================================================== +// CBtmcMobileLine::~CBtmcMobileLine +// ========================================================== +CBtmcMobileLine::~CBtmcMobileLine() + { + TRACE_FUNC_ENTRY + iCallActives.ResetAndDestroy(); + iCallActives.Close(); + delete iLineIncomingActive; + delete iLineOutgoingActive; + iLine.Close(); + } + +// ========================================================== +// CBtmcMobileLine::CallInformationL +// ========================================================== +const MCall& CBtmcMobileLine::CallInformationL() + { + MBtmcDummy dummy = MBtmcDummy(); + const MCall& fakeCall (dummy); + return fakeCall; + } + +// ========================================================== +// CBtmcMobileLine::CallStatusL +// ========================================================== +TInt CBtmcMobileLine::CallStatusL() const + { + TRACE_FUNC_ENTRY + TInt mask = 0; + TInt count = iCallActives.Count(); + for (TInt i = 0; i < count; i++) + { + switch (iCallActives[i]->CallStatus()) + { + case RMobileCall::EStatusDialling: + { + mask |= KCallDiallingBit; + break; + } + case RMobileCall::EStatusRinging: + { + mask |= KCallRingingBit; + break; + } + case RMobileCall::EStatusAnswering: + { + mask |= KCallAnsweringBit; + break; + } + case RMobileCall::EStatusConnecting: + { + mask |= KCallConnectingBit; + break; + } + case RMobileCall::EStatusConnected: + { + mask |= KCallConnectedBit; + break; + } + case RMobileCall::EStatusHold: + { + mask |= KCallHoldBit; + break; + } + default: + break; + } + } + TRACE_INFO((_L("Line '%S', CALL STATUS 0x%08x"), &iLineName, mask)) + TRACE_FUNC_EXIT + return mask; + } +// ========================================================== +// CBtmcMobileLine::RequestCompletedL +// ========================================================== +void CBtmcMobileLine::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("MOBILE LINE '%S'"), &iLineName)) + switch (aActive.ServiceId()) + { + case KMobileLineActiveService: + { + if (aErr == KErrNone) + { + CBtmcCallActive* callActive = CBtmcCallActive::NewLC( + *this, CActive::EPriorityStandard, KMobileCallActiveService, + iLine, iName); + iCallActives.AppendL(callActive); + iParent.HandleMobileCallEventL(iName, callActive->RemotePartyNumber(), callActive->CallStatus()); + callActive->GoActive(); + CleanupStack::Pop(callActive); + } + + if(&aActive == iLineOutgoingActive) + iLine.NotifyCallAdded(aActive.iStatus, iName); + else + iLine.NotifyIncomingCall(aActive.iStatus, iName); + + aActive.GoActive(); + break; + } + case KMobileCallActiveService: + { + if (aErr == KErrNone) + { + CBtmcCallActive& calla = reinterpret_cast(aActive); + RMobileCall::TMobileCallStatus status = calla.CallStatus(); + if(status != RMobileCall::EStatusDisconnecting) + iParent.HandleMobileCallEventL(calla.CallName(), calla.RemotePartyNumber(), calla.CallStatus()); + if (status == RMobileCall::EStatusIdle) + { + if ( calla.IsEmergencyCall() ) + { + TRACE_INFO((_L("Emergency call object going to idle state, not deleting"))) + aActive.GoActive(); + break; + } + + TInt idx = iCallActives.Find(&calla); + if (idx >= 0) + { + delete iCallActives[idx]; + iCallActives.Remove(idx); + } + } + else + { + aActive.GoActive(); + } + } + break; + } + default: + break; + } + TRACE_FUNC_EXIT + } +// ========================================================== +// CBtmcMobileLine::CancelRequest +// ========================================================== +void CBtmcMobileLine::CancelRequest(TInt aServiceId) + { + TRACE_FUNC_ENTRY + if (aServiceId == KMobileLineActiveService) + { + iLine.NotifyCallAddedCancel(); + iLine.NotifyIncomingCallCancel(); + } + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcMobileLine::CBtmcMobileLine +// ========================================================== +CBtmcMobileLine::CBtmcMobileLine( + CBtmcCallStatus& aParent, RMobilePhone& aPhone, const TDesC& aLineName) + : iParent(aParent), iPhone(aPhone), iLineName(aLineName) + { + } + +// ========================================================== +// CBtmcMobileLine::ConstructL +// ========================================================== +void CBtmcMobileLine::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iLine.Open(iPhone, iLineName)) + + TInt count = 0; + LEAVE_IF_ERROR(iLine.EnumerateCall(count)) + + for (TInt i = 0; i < count; i++) + { + RLine::TCallInfo info; + LEAVE_IF_ERROR(iLine.GetCallInfo(i, info)) + + CBtmcCallActive* callActive = CBtmcCallActive::NewLC( + *this, CActive::EPriorityStandard, KMobileCallActiveService, + iLine, info.iCallName); + iCallActives.AppendL(callActive); + callActive->GoActive(); + CleanupStack::Pop(callActive); + } + + iLineIncomingActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KMobileLineActiveService); + iLineOutgoingActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KMobileLineActiveService); + iLine.NotifyCallAdded(iLineOutgoingActive->iStatus, iName); + iLine.NotifyIncomingCall(iLineIncomingActive->iStatus, iName); + iLineOutgoingActive->GoActive(); + iLineIncomingActive->GoActive(); + + TRACE_INFO((_L("MOBILE LINE '%S' constructed"), &iLineName)) + TRACE_FUNC_EXIT + } + +// ========================================================== +// CBtmcMobileLine::ActiveCalls() +// ========================================================== +const RPointerArray& CBtmcMobileLine::ActiveCalls() const + { + return iCallActives; + } + +// ========================================================== +// CBtmcMobileLine::Phone() +// ========================================================== +RMobilePhone& CBtmcMobileLine::Phone() + { + return iPhone; + } + +// ========================================================== +// CBtmcMobileLine::IsVoip() +// ========================================================== +TBool CBtmcMobileLine::IsVoip() + { + return EFalse; + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,164 @@ +/* +* Copyright (c) 2005 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: General Active Object offering asynchronous service +* +*/ + +#include "atcodec.h" +#include "btmcprotocol.h" +#include "btmcnumber.h" +#include +#include "debug.h" + +// ----------------------------------------------------------------------------- +// CBtmcNumber::NewL +// ----------------------------------------------------------------------------- +CBtmcNumber* CBtmcNumber::NewL( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId) + { + CBtmcNumber* self = new (ELeave) CBtmcNumber(aObserver, aProtocol, aPriority, aServiceId); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcNumber::~CBtmcNumber +// ----------------------------------------------------------------------------- +CBtmcNumber::~CBtmcNumber() + { + TRACE_FUNC_ENTRY + Cancel(); + iStore.Close(); + iPhone.Close(); + iServer.UnloadPhoneModule(KMmTsyModuleName); + iServer.Close(); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcNumber::GoActive +// ------------------------------------------------------------------------------- +void CBtmcNumber::GoActive() + { + TRACE_ASSERT(!IsActive(), KErrGeneral); + iEntry.iIndex = 1; + iStore.Read(iStatus, iPckg); + SetActive(); + TRACE_FUNC + } + +// ------------------------------------------------------------------------------- +// CBtmcNumber::RunL +// ------------------------------------------------------------------------------- +void CBtmcNumber::RunL() + { + TRACE_FUNC_ENTRY + + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + CATResult* okerr = NULL; + if (iStatus == KErrNone) + { + TBuf8 nameBuf; + nameBuf.Copy(iEntry.iNumber.iTelNumber); + + TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &nameBuf)) + RATParamArray params; + CleanupClosePushL(params); + LEAVE_IF_ERROR(params.Append(TATParam())) + LEAVE_IF_ERROR(params.Append(TATParam(nameBuf, EATDQStringParam))) + + TBTMonoATPhoneNumberType numType; + if (nameBuf.Length() == 0) + { + numType = EBTMonoATPhoneNumberUnavailable; + } + else if(nameBuf.Locate('+') == 0) + { + numType = EBTMonoATPhoneNumberInternational; + } + else + { + numType = EBTMonoATPhoneNumberNational; + } + LEAVE_IF_ERROR(params.Append(TATParam(numType))) + LEAVE_IF_ERROR(params.Append(TATParam())) + LEAVE_IF_ERROR(params.Append(TATParam(4))) + CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, ¶ms); + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + CleanupStack::PopAndDestroy(¶ms); + okerr = CATResult::NewL(EATOK); + } + else + { + okerr = CATResult::NewL(EATERROR); + } + CleanupStack::PushL(okerr); + resarr.AppendL(okerr); + CleanupStack::Pop(okerr); + iProtocol.SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + Observer().RequestCompletedL(*this, iStatus.Int()); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcNumber::DoCancel +// ------------------------------------------------------------------------------- +void CBtmcNumber::DoCancel() + { + iStore.CancelAsyncRequest(EMobilePhoneStoreRead); + TRACE_FUNC + } + + +// ------------------------------------------------------------------------------- +// CBtmcNumber::RunError +// ------------------------------------------------------------------------------- +TInt CBtmcNumber::RunError(TInt /*aErr*/) + { + TRACE_FUNC + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtmcNumber::CBtmcNumber +// ----------------------------------------------------------------------------- +CBtmcNumber::CBtmcNumber( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId) + : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry) + { + } + +void CBtmcNumber::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iServer.Connect()); + iServer.LoadPhoneModule(KMmTsyModuleName); + LEAVE_IF_ERROR(iPhone.Open(iServer, KMmTsyPhoneName)); + LEAVE_IF_ERROR(iStore.Open(iPhone));//, KETelIccMsisdnPhoneBook)); + TRACE_FUNC_EXIT + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcoperator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcoperator.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2005 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: General Active Object offering asynchronous service +* +*/ + +#include "atcodec.h" +#include "btmcoperator.h" +#include "btmcprotocol.h" +#include +#include "debug.h" + +// ----------------------------------------------------------------------------- +// CBtmcOperator::NewL +// ----------------------------------------------------------------------------- +CBtmcOperator* CBtmcOperator::NewL( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId) + { + CBtmcOperator* self = new (ELeave) CBtmcOperator(aObserver, aProtocol, aPriority, aServiceId); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcOperator::~CBtmcOperator +// ----------------------------------------------------------------------------- +CBtmcOperator::~CBtmcOperator() + { + TRACE_FUNC_ENTRY + Cancel(); + iCustomApi.Close(); + iPhone.Close(); + iServer.UnloadPhoneModule(KMmTsyModuleName); + iServer.Close(); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcOperator::GoActive +// ------------------------------------------------------------------------------- +void CBtmcOperator::GoActive() + { + TRACE_ASSERT(!IsActive(), KErrGeneral); + iInfo.iType = RMmCustomAPI::EOperatorNameNitzShort; + iCustomApi.GetOperatorName(iStatus, iInfo); + SetActive(); + TRACE_FUNC + } + +// ------------------------------------------------------------------------------- +// CBtmcOperator::GetName +// ------------------------------------------------------------------------------- +const TDesC& CBtmcOperator::GetName() const + { + TRACE_FUNC + return iInfo.iName; + } + +// ------------------------------------------------------------------------------- +// CBtmcOperator::RunL +// ------------------------------------------------------------------------------- +void CBtmcOperator::RunL() + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("ao status %d, operator '%S'"), iStatus.Int(), &(iInfo.iName))) + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + + RATParamArray params; + CleanupClosePushL(params); + LEAVE_IF_ERROR(params.Append(TATParam(0))); + + if (iStatus == KErrNone) + { + LEAVE_IF_ERROR(params.Append(TATParam(0))); + TBuf8 buf8; + buf8.Copy(iInfo.iName); // need Unicode convert? + LEAVE_IF_ERROR(params.Append(TATParam(buf8, EATDQStringParam))); + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam())); + LEAVE_IF_ERROR(params.Append(TATParam())); + } + + CATResult* code = CATResult::NewL(EATCOPS, EATReadResult, ¶ms); + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + CleanupStack::PopAndDestroy(¶ms); + + CATResult* ok = CATResult::NewL(EATOK); + CleanupStack::PushL(ok); + resarr.AppendL(ok); + CleanupStack::Pop(ok); + iProtocol.SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + //in this case this function call actually can't leave + Observer().RequestCompletedL(*this, iStatus.Int()); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcOperator::DoCancel +// ------------------------------------------------------------------------------- +void CBtmcOperator::DoCancel() + { + TRACE_FUNC + iStore.CancelAsyncRequest(EMobilePhoneStoreRead); + } + +// ------------------------------------------------------------------------------- +// CBtmcOperator::RunError +// ------------------------------------------------------------------------------- +TInt CBtmcOperator::RunError(TInt aErr) + { + TRACE_FUNC + //this is called here so that the command handling tries to continue + //in this case this function call actually can't leave, ignoring it + TInt err; + TRAP( err, Observer().RequestCompletedL(*this, aErr); ) + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtmcOperator::CBtmcOperator +// ----------------------------------------------------------------------------- +CBtmcOperator::CBtmcOperator( + MBtmcActiveObserver& aObserver, + CBtmcProtocol& aProtocol, + CActive::TPriority aPriority, + TInt aServiceId) + : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol) + { + } + +void CBtmcOperator::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iServer.Connect()); + iServer.LoadPhoneModule(KMmTsyModuleName); + LEAVE_IF_ERROR(iPhone.Open(iServer, KMmTsyPhoneName)); + LEAVE_IF_ERROR(iCustomApi.Open(iPhone)); + TRACE_FUNC_EXIT + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcphonestatus.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcphonestatus.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,372 @@ +/* +* Copyright (c) 2005 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: call status handling. +* +*/ + + +// INCLUDE FILES + +#include "btmcphonestatus.h" +#include +#include +#include "atcodec.h" +#include "btmcprotocol.h" +#include "btmcprotocolstatus.h" +#include "btmc_defs.h" +#include "btmcvolume.h" +#include "btmcsignal.h" +#include "btmcbattery.h" + +#include "debug.h" + +const TInt KNetworkRegistrationSubscribe = 20; +const TInt KVoiceDialSubscribe = 21; + + +// ----------------------------------------------------------------------------- +// CBtmcPhoneStatus::NewL +// ----------------------------------------------------------------------------- +CBtmcPhoneStatus* CBtmcPhoneStatus::NewL( + CBtmcProtocol& aProtocol, RMobilePhone& aPhone, TBtmcProfileId aProfile) + { + CBtmcPhoneStatus* self = CBtmcPhoneStatus::NewLC(aProtocol, aPhone, aProfile); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcPhoneStatus::NewLC +// ----------------------------------------------------------------------------- +CBtmcPhoneStatus* CBtmcPhoneStatus::NewLC( + CBtmcProtocol& aProtocol, RMobilePhone& aPhone, TBtmcProfileId aProfile) + { + CBtmcPhoneStatus* self = new(ELeave) CBtmcPhoneStatus(aProtocol, aPhone); + CleanupStack::PushL(self); + self->ConstructL(aProfile); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcPhoneStatus::~CBtmcPhoneStatus +// ----------------------------------------------------------------------------- +CBtmcPhoneStatus::~CBtmcPhoneStatus() + { + TRACE_FUNC_ENTRY + iActives.ResetAndDestroy(); + iActives.Close(); + iVoiceDialProperty.Close(); + delete iVol; + delete iSignal; + delete iBattery; + + TRACE_FUNC_EXIT + } + +RMobilePhone::TMobilePhoneRegistrationStatus CBtmcPhoneStatus::NetworkStatus() const + { + return iNetworkStatus; + } + +void CBtmcPhoneStatus::SetVolumeControlFeatureL(TBool aSupported) + { + TRACE_FUNC_ENTRY + if (aSupported && !iVol) + { + iVol = CBtmcVolume::NewL(*this); + } + else if (!aSupported) + { + delete iVol; + iVol = NULL; + } + TRACE_FUNC_EXIT + } + +void CBtmcPhoneStatus::SetVoiceRecognitionControlL(TBool aEnabled) + { + TRACE_FUNC_ENTRY + if (aEnabled && !iVoiceRecognitionEnabled) + { + // AO for Voice Dial + LEAVE_IF_ERROR(iVoiceDialProperty.Attach(KSINDUID, ERecognitionState)) + CBtmcActive* ao = CBtmcActive::NewLC(*this, CActive::EPriorityStandard, KVoiceDialSubscribe); + iActives.AppendL(ao); + iVoiceDialProperty.Subscribe(ao->iStatus); + ao->GoActive(); + CleanupStack::Pop(ao); + iVoiceRecognitionEnabled = ETrue; + } + + TRACE_FUNC_EXIT + } + +void CBtmcPhoneStatus::SetSpeakerVolumeL(TInt aHfVol) + { + if (this && iVol) + { + TRACE_FUNC_ENTRY + iVol->SetSpeakerVolumeL(aHfVol); + TRACE_FUNC_EXIT + } + } + +void CBtmcPhoneStatus::ActivateRemoteVolumeControl() + { + TRACE_FUNC + if (iVol) + iVol->ActivateRemoteVolumeControl(); + } + +void CBtmcPhoneStatus::DeActivateRemoteVolumeControl() + { + TRACE_FUNC + if (iVol) + iVol->DeActivateRemoteVolumeControl(); + } + +TInt CBtmcPhoneStatus::GetSignalStrength() + { + return iSignal->GetSignalStrength(); + } + +TInt CBtmcPhoneStatus::GetBatteryCharge() + { + return iBattery->GetBatteryCharge(); + } + +void CBtmcPhoneStatus::SetRecognitionInitiator(TBTMonoVoiceRecognitionInitiator aInitiator) + { + iVoiceRecogInitiator = aInitiator; + } + +// Send unsolicited network status responses: +// +CIEV: 1,0 is generated when Home/Roam network becomes unavailable +// +CIEV: 1,1 generated when Home/Roam network becomes available +// For HFP1.5 +CIEV: 6, 1 when roaming is active, +CIEV: 6,0 when roaming is not active + +void CBtmcPhoneStatus::HandleNetworkRegistrationEventL( + RMobilePhone::TMobilePhoneRegistrationStatus aOldStatus, + RMobilePhone::TMobilePhoneRegistrationStatus aNewStatus) + { + if ( iProtocol.ProtocolStatus().iIndicatorNotif & KIndServiceBit ) + { + if ((aOldStatus == RMobilePhone::ERegisteredOnHomeNetwork || + aOldStatus == RMobilePhone::ERegisteredRoaming) && + (aNewStatus != RMobilePhone::ERegisteredOnHomeNetwork && + aNewStatus != RMobilePhone::ERegisteredRoaming)) + { + ReportIndicatorL(EBTMonoATNetworkIndicator, EBTMonoATNetworkUnavailable); + } + else if ((aOldStatus != RMobilePhone::ERegisteredOnHomeNetwork && + aOldStatus != RMobilePhone::ERegisteredRoaming) && + (aNewStatus == RMobilePhone::ERegisteredOnHomeNetwork || + aNewStatus == RMobilePhone::ERegisteredRoaming)) + { + ReportIndicatorL(EBTMonoATNetworkIndicator, EBTMonoATNetworkAvailable); + } + } + + // Roaming status + if( iProtocol.ProtocolStatus().iIndicatorNotif & KIndRoamBit ) + { + if(aOldStatus != RMobilePhone::ERegisteredRoaming && aNewStatus == RMobilePhone::ERegisteredRoaming) + { + ReportIndicatorL(EBTMonoATRoamingIndicator, EBTMonoATRoamingActive); + } + else if(aOldStatus == RMobilePhone::ERegisteredRoaming && aNewStatus != RMobilePhone::ERegisteredRoaming) + { + ReportIndicatorL(EBTMonoATRoamingIndicator, EBTMonoATRoamingInactive); + } + } + } + +void CBtmcPhoneStatus::HandleSpeakerVolumeEventL(TInt aVol) + { + TRACE_FUNC_ENTRY + CATResult* event = CATResult::NewLC(EATVGS, EATUnsolicitedResult, TATParam(aVol)); + iProtocol.SendUnsoltResultL(*event); + CleanupStack::PopAndDestroy(event); + TRACE_FUNC_EXIT + } + +void CBtmcPhoneStatus::HandleVoiceDialEventL(TInt aEnabled) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("Voice dial Initiator %d, Voice dial event %d"), iVoiceRecogInitiator, aEnabled)) + TBTMonoATVoiceRecognition value = EBTMonoATVoiceRecognitionOff; + + if (iVoiceRecogInitiator != EBTMonoVoiceRecognitionActivatedByRemote && aEnabled == ERecognitionStarted) + {// phone activated or headset deactivated voice recognition, informs headset status change + value = EBTMonoATVoiceRecognitionOn; + } + else if(aEnabled == KErrNotFound) + {// headset or phone ui deactivated voice recognition, inform headset status change + value = EBTMonoATVoiceRecognitionOff; + } + else + { + return; + } + iVoiceRecogInitiator = EBTMonoVoiceRecognitionDefaultInitiator; + CATResult* event = CATResult::NewLC(EATBVRA, EATUnsolicitedResult, TATParam(value)); + iProtocol.SendUnsoltResultL(*event); + CleanupStack::PopAndDestroy(event); + TRACE_FUNC_EXIT + } + +void CBtmcPhoneStatus::HandleNetworkStrengthChangeL(TInt8 aStrength) + { + if(iProtocol.ProtocolStatus().iIndicatorNotif && + (iProtocol.ProtocolStatus().iIndicatorNotif & KIndSignalBit)) + ReportIndicatorL(EBTMonoATSignalStrengthIndicator, TInt(aStrength)); + } + +void CBtmcPhoneStatus::HandleBatteryChangeL(TInt aLevel) + { + TRACE_FUNC_ENTRY + if(iProtocol.ProtocolStatus().iIndicatorNotif && + (iProtocol.ProtocolStatus().iIndicatorNotif & KIndChargeBit)) + ReportIndicatorL(EBTMonoATBatteryChargeIndicator, aLevel); + TRACE_FUNC_EXIT + } + + +void CBtmcPhoneStatus::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + switch (aActive.ServiceId()) + { + case KNetworkRegistrationSubscribe: + { + if (!aErr) + { + HandleNetworkRegistrationEventL(iNetworkStatus, iNewNetworkStatus); + iNetworkStatus = iNewNetworkStatus; + iPhone.NotifyNetworkRegistrationStatusChange(aActive.iStatus, iNewNetworkStatus); + aActive.GoActive(); + } + break; + } + case KVoiceDialSubscribe: + { + if (!aErr || aErr == KErrNotFound) + { + iVoiceDialProperty.Subscribe(aActive.iStatus); + aActive.GoActive(); + + TInt value = aErr; + if (!aErr) + { + TInt err = iVoiceDialProperty.Get(value); + if (err != KErrNone) + { + value = err; + } + } + HandleVoiceDialEventL(value); + } + break; + } + default: + break; + } + } + +void CBtmcPhoneStatus::CancelRequest(TInt aServiceId) + { + switch (aServiceId) + { + case KNetworkRegistrationSubscribe: + { + iPhone.CancelAsyncRequest(EMobilePhoneNotifyNetworkRegistrationStatusChange); + break; + } + case KVoiceDialSubscribe: + { + iVoiceDialProperty.Cancel(); + break; + } + default: + break; + } + } + +TInt CBtmcPhoneStatus::GetVolumeStatus() + { + if(iVol) + return iVol->GetVolume(); + else + return 0; + } + +// ----------------------------------------------------------------------------- +// CBtmcPhoneStatus::CBtmcPhoneStatus +// ----------------------------------------------------------------------------- +CBtmcPhoneStatus::CBtmcPhoneStatus( + CBtmcProtocol& aProtocol, RMobilePhone& aPhone) + : iProtocol(aProtocol), + iPhone(aPhone), + iNetworkStatus(RMobilePhone::ERegistrationUnknown) + { + } + +// ----------------------------------------------------------------------------- +// CBtmcPhoneStatus::ConstructL +// ----------------------------------------------------------------------------- +void CBtmcPhoneStatus::ConstructL(TBtmcProfileId aProfile) + { + TRACE_FUNC + // HSP profile doesn't need these functions: + if ( aProfile == EBtmcHFP0105 ) + { + iBattery = CBtmcBattery::NewL(*this); + iBattery->GoActive(); + iSignal = CBtmcSignal::NewL(*this); + iSignal->GoActive(); + TRequestStatus sta = KRequestPending; + iPhone.GetNetworkRegistrationStatus(sta, iNetworkStatus); + User::WaitForRequest(sta); + TRACE_INFO((_L(" Network status %d"), iNetworkStatus)) + // AO for Network status + CBtmcActive* ao = + CBtmcActive::NewLC(*this, CActive::EPriorityStandard, KNetworkRegistrationSubscribe); + iActives.AppendL(ao); + iPhone.NotifyNetworkRegistrationStatusChange(ao->iStatus, iNewNetworkStatus); + ao->GoActive(); + CleanupStack::Pop(ao); + } + TRACE_FUNC_EXIT + } + +void CBtmcPhoneStatus::ReportIndicatorL(TBTMonoATPhoneIndicatorId aIndicator, TInt aValue) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("indicator %d, value %d"), aIndicator, aValue)) + RArray params; + CleanupClosePushL(params); + params.AppendL(TATParam(aIndicator)); + params.AppendL(TATParam(aValue)); + CATResult* ciev = CATResult::NewLC(EATCIEV, EATUnsolicitedResult, ¶ms); + iProtocol.SendUnsoltResultL(*ciev); + CleanupStack::PopAndDestroy(ciev); + CleanupStack::PopAndDestroy(¶ms); + TRACE_FUNC_EXIT + } + +TInt CBtmcPhoneStatus::GetRssiStrength() + { + return iSignal->GetRssiStrength(); + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotdatabuf.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotdatabuf.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2005 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: Extended Phone RemCon Handler +* +*/ + + +#include "btmcprotdatabuf.h" +#include "debug.h" + +void TBtmcProtDataBuf::Reset() + { + iBuf.Zero(); + } + +TInt TBtmcProtDataBuf::NextCommand(TDes8& aText) + { + TRACE_FUNC + + const TChar KCharReturn = '\r'; + + TInt pos = iBuf.Locate(KCharReturn); + + if (pos == KErrNotFound) + { + return KErrNotFound; + } + aText.Copy(iBuf.Left(pos)); + iBuf.Delete(0, pos + 1); + iBuf.TrimLeft(); + return KErrNone; + } + +// ------------------------------------------------------------------------------- +// TBTAspATRemoteDataBuffer::Append +// +// Appends AT command characters to buffer. If buffer overflows, it is emptied +// and function returns KErrOverflow. +//------------------------------------------------------------------------------- +// +TInt TBtmcProtDataBuf::Append(const TDesC8& aText) + { + TRACE_FUNC + if ( (aText.Length() + iBuf.Length()) > iBuf.MaxLength() ) + { + iBuf = KNullDesC8; + return KErrOverflow; + } + iBuf.Append(aText); + return KErrNone; + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1275 @@ +/* +* Copyright (c) 2005 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 "atcodec.h" +#include // for etel +#include +#include +#include +#include "btmcprotocol.h" +#include "btmccallinghandler.h" +#include "btmcphonestatus.h" +#include "btmccallstatus.h" +#include "btmcprotocolstatus.h" +#include "btmcobserver.h" +#include "btmcmobileline.h" +#include "btmcnumber.h" +#include "btmcoperator.h" + +#include "debug.h" + +// Service Level Monitoring +const TInt KCmerFromHF = 0x01; +const TInt KCmerFromAG = 0x02; +const TInt KSLC_No3WayCalling = KCmerFromHF | KCmerFromAG; + +const TInt KChldFromHF = 0x04; +const TInt KChldFromAG = 0x08; + +const TInt KSLC_3WayCalling = KChldFromHF | KChldFromAG; + +const TInt KBerUnknown = 99; + +const TInt KServiceSlcTimer = 1; +const TInt KServiceSdpQuery = 2; +const TInt KServiceGetSubscriber = 3; +const TInt KServiceGetOperator = 4; +const TInt KServiceCmdHandling = 5; + +const TInt KQueryIMEI = 6; +const TInt KQueryIMSI = 7; + +const TInt KServiceFirstHspCkpdTrap = 8; + +CBtmcProtocol* CBtmcProtocol::NewL( + MBtmcObserver& aObserver, TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated) + { + CBtmcProtocol* self=new (ELeave) CBtmcProtocol(aObserver); + CleanupStack::PushL(self); + self->ConstructL(aProfile, aBTDevAddr, aAccessoryInitiated); + CleanupStack::Pop(self); + return self; + } + +CBtmcProtocol::~CBtmcProtocol() + { + TRACE_FUNC_ENTRY + delete iCallingHandler; + + delete iCmdHanldingActive; + delete iAtExt; + + delete iTimerActive; + iTimer.Close(); + + delete iProtocolStatus; + delete iCallStatus; + delete iPhoneStatus; + + delete iNumber; + delete iOperator; + + delete iEtelQuery; + delete iBteng; + + iPhone.Close(); + iServer.UnloadPhoneModule(KMmTsyModuleName); + iServer.Close(); + delete iOutgoPacketQueue; + TRACE_FUNC_EXIT + } + +void CBtmcProtocol::NewProtocolDataL(const TDesC8& aData) + { + TRACE_FUNC + TInt err = iInDataBuf.Append(aData); + if (err) + { + CATResult* nok = CATResult::NewLC(EATERROR); + SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + } + else if (!iCmdHanldingActive->IsActive()) + { + TRequestStatus* sta = &iCmdHanldingActive->iStatus; + *sta = KRequestPending; + User::RequestComplete(sta, KErrNone); + iCmdHanldingActive->GoActive(); + } + } + +void CBtmcProtocol::SendResponseL(const CATResult& aResult) + { + TRACE_FUNC + iOutgoPacketQueue->InsertL(0, aResult.Des()); + iCredit = iOutgoPacketQueue->MdcaCount(); + DoSendProtocolDataL(); + } + +void CBtmcProtocol::SendResponseL(const RPointerArray& aResults) + { + TRACE_FUNC + TInt count = aResults.Count(); + for (TInt i = 0; i < count; i++) + { + iOutgoPacketQueue->InsertL(i, aResults[i]->Des()); + } + iCredit = iOutgoPacketQueue->MdcaCount(); + DoSendProtocolDataL(); + } + +void CBtmcProtocol::SendUnsoltResultL(const CATResult& aResult) + { + TRACE_FUNC_ENTRY + if (aResult.Id() == EATVGS) + { + iOutgoPacketQueue->InsertL(0, aResult.Des()); + iCredit++; + } + else + { + iOutgoPacketQueue->AppendL(aResult.Des()); + if (!iCallingHandler->ActiveCmdHandling() && !iHandleCmdPending) + { + iCredit++; + } + } + DoSendProtocolDataL(); + TRACE_FUNC_EXIT + } + +void CBtmcProtocol::CmdHandlingCompletedL() + { + TRACE_FUNC + iHandleCmdPending = EFalse; + TRequestStatus* sta = &iCmdHanldingActive->iStatus; + *sta = KRequestPending; + User::RequestComplete(sta, KErrNone); + iCmdHanldingActive->GoActive(); + } + +TBtmcProtocolStatus& CBtmcProtocol::ProtocolStatus() + { + return *iProtocolStatus; + } + +void CBtmcProtocol::VoiceRecognitionError() + { + iPhoneStatus->SetRecognitionInitiator(EBTMonoVoiceRecognitionDefaultInitiator); + } + +void CBtmcProtocol::HandleNrecCompletedL(TInt aErr) + { + TATId id = aErr ? EATERROR : EATOK; + CATResult* nok = CATResult::NewLC(id); + SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + CmdHandlingCompletedL(); + } + + +void CBtmcProtocol::ActivateRemoteVolumeControl() + { + TRACE_FUNC + if (iPhoneStatus) + iPhoneStatus->ActivateRemoteVolumeControl(); + else + { + TRACE_INFO(_L("WARNING, null vol handler!")) + } + } + +void CBtmcProtocol::DeActivateRemoteVolumeControl() + { + TRACE_FUNC + if (iPhoneStatus) + iPhoneStatus->DeActivateRemoteVolumeControl(); + else + { + TRACE_INFO(_L("WARNING, null vol handler!")) + } + } + +TInt CBtmcProtocol::GetRemoteSupportedFeature() + { + return iProtocolStatus->iAccSupportedFeature; + } + +TBool CBtmcProtocol::ActiveChldHandling() const + { + return iCallingHandler->ActiveChldHandling(); + } + +void CBtmcProtocol::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + TRACE_FUNC_ENTRY + switch (aActive.ServiceId()) + { + case KServiceSlcTimer: + { + if (aErr == KErrNone) + { + StopTimer(KServiceSlcTimer); + iObserver.SlcIndicateL(EFalse); + } + break; + } + case KServiceSdpQuery: + { + } + case KServiceGetSubscriber: + { + delete iNumber; + iNumber = NULL; + CmdHandlingCompletedL(); + break; + } + case KServiceGetOperator: + { + delete iOperator; + iOperator = NULL; + CmdHandlingCompletedL(); + break; + } + case KServiceCmdHandling: + { + TRAPD(err, DoHandleCommandL()); + if (err) + { + CATResult* nok = CATResult::NewLC(EATERROR); + SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + CmdHandlingCompletedL(); + } + break; + } + case KQueryIMSI: + { + TBuf8 buf; + buf.Copy(iId); + CATResult* cimi = CATResult::NewLC(EATCIMI, EATReadResult, TATParam(buf)); + SendResponseL(*cimi); + CleanupStack::PopAndDestroy(cimi); + CATResult* ok = CATResult::NewLC(EATOK); + SendResponseL(*ok); + CleanupStack::PopAndDestroy(ok); + CmdHandlingCompletedL(); + break; + } + case KServiceFirstHspCkpdTrap: + { + // No handling here. From now on, any incoming CKPD command + // will be processed normally. + TRACE_INFO((_L("CKPD trapper terminated"))); + break; + } + default: + break; + } + TRACE_FUNC_EXIT + } + +void CBtmcProtocol::CancelRequest(TInt aServiceId) + { + TRACE_FUNC_ENTRY + if (aServiceId == KServiceSlcTimer || aServiceId == KServiceFirstHspCkpdTrap ) + { + iTimer.Cancel(); + } + else if (aServiceId == KServiceSdpQuery) + { + iBteng->CancelRemoteSdpQuery(); + } + TRACE_FUNC_EXIT + } + +CBtmcProtocol::CBtmcProtocol(MBtmcObserver& aObserver) + : iObserver(aObserver), + iSlcMask(0x00) + { + } + +void CBtmcProtocol::ConstructL(TBtmcProfileId aProfile, const TDesC8& aBTDevAddr, TBool aAccessoryInitiated) + { + TRACE_FUNC_ENTRY + iProtocolStatus = new (ELeave) TBtmcProtocolStatus(); + iProtocolStatus->iProfile = aProfile; + iAccessoryInitiated = aAccessoryInitiated; + iProtocolStatus->iAGSupportedFeature = KBTAGSupportedFeatureV15; + + LEAVE_IF_ERROR(iServer.Connect()) + TInt err = iServer.LoadPhoneModule(KMmTsyModuleName); + if (err != KErrNone && err != KErrAlreadyExists) + LEAVE(err); + LEAVE_IF_ERROR(iPhone.Open(iServer, KMmTsyPhoneName)) + + iCallStatus = CBtmcCallStatus::NewL(*this, iPhone, aProfile); + iProtocolStatus->iCallBits = iCallStatus->CallStatusL(); + + iEtelQuery = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KQueryIMEI); + + iPhone.GetPhoneId(iEtelQuery->iStatus, iIdentity); + iEtelQuery->GoActive(); + + switch (aProfile) + { + case EBtmcHFP0105: + { + TRACE_INFO((_L("constructing option HFP 1.5"))) + iPhoneStatus = CBtmcPhoneStatus::NewL(*this, iPhone, aProfile); + StartTimerL(KServiceSlcTimer, KSlcTimeout); + break; + } + case EBtmcHSP: + { + TRACE_INFO((_L("constructing option HSP"))) + if (aBTDevAddr.Length() != KBTDevAddrSize) + { + LEAVE(KErrBadDescriptor); + } + iProtocolStatus->iSlc = ETrue; + iBteng = CBTEngDiscovery::NewL(this); + iBteng->RemoteSdpQuery(TBTDevAddr(aBTDevAddr), TUUID(EBTProfileHSP), KBTHSRemoteAudioVolumeControl); + if ( iAccessoryInitiated && ( iProtocolStatus->iCallBits & KCallConnectedBit ) ) + { + TRACE_INFO((_L("Incoming HSP connected, start CKPD trapper"))); + // In case of incoming HSP connection during a voice call, + // start timer to trap the CKPD command as part of the audio transfer of HSP. + // If the first CKPD command is received during this period, it will be ignored. + StartTimerL(KServiceFirstHspCkpdTrap, KFirstHspCkpdTimeout); + } + break; + } + default: + LEAVE(KErrArgument); + } + TRAP_IGNORE(iAtExt = CHFPAtCmdHandler::NewL(*this)); + iOutgoPacketQueue = new (ELeave) CDesC8ArrayFlat(1); + iCallingHandler = CBtmcCallingHandler::NewL(*this); + iCmdHanldingActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KServiceCmdHandling); + if (iProtocolStatus->iSlc) + { + iCallStatus->ReportCallStatusL(); + } + iVolumeSyncFromAccessory = EFalse; + TRACE_FUNC_EXIT + } + +void CBtmcProtocol::DoHandleCommandL() + { + TRACE_FUNC + if (iHandleCmdPending) + { + return; + } + TBuf8 cmddes; + if (iInDataBuf.NextCommand(cmddes)) + { + return; + } + if (cmddes.Length() == 0) + { + return; + } + TRACE_INFO_SEG( + { + TBuf8 buf; + buf = cmddes; + buf.Trim(); + Trace(_L8("[HFP] [I] %S"), &buf); + }) + + CATCommand* cmd = NULL; + TRAPD(err, cmd = CATCommand::NewL(cmddes)); + if (err) + { + if(iAtExt) + { + iAtExt->HandleCommand(cmddes, _L8("\n\rERROR\n\r")); + return; + } + CATResult* nok = CATResult::NewLC(EATERROR); + SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + return; + } + CleanupStack::PushL(cmd); + iHandleCmdPending = ETrue; + TATId id = cmd->Id(); + if (id == EATA || + id == EATD2 || + id == EATD1 || + (id == EATCHLD && cmd->Type() != EATTestCmd)|| + id == EATCHUP || + id == EATVTS || + (id == EATBVRA && cmd->Type() == EATWriteCmd) || + id == EATBLDN ) + { + if (id == EATBVRA) + { + TRACE_ASSERT(cmd->ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(cmd->Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + TBTMonoVoiceRecognitionInitiator initor; + initor = (value) ? EBTMonoVoiceRecognitionActivatedByRemote + : EBTMonoVoiceRecognitionDeactivatedByRemote; + iPhoneStatus->SetRecognitionInitiator(initor); + } + iCallingHandler->HandleCallingCmdL(*cmd); + } + else if ( id == EATCKPD ) + { + if ( iTimerActive && iTimerActive->IsActive() ) + { + // incoming HSP was just connected and the first CKPD is received, + // ignore this command as audio establishment will be done via Acc FW + StopTimer( KServiceFirstHspCkpdTrap ); + TRACE_INFO((_L("First CKPD, do nothing"))); + CATResult* nok = CATResult::NewLC( EATOK ); + SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + CmdHandlingCompletedL(); + } + else + { + iCallingHandler->HandleCallingCmdL(*cmd); + } + } + else if (id == EATNREC && cmd->Type() == EATWriteCmd) + { + TRACE_ASSERT(cmd->ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(cmd->Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + if (!value && + ServiceLevelConnected() ) + { + //Always respond OK to +NREC=0 + HandleNrecCompletedL(0); + } + else + { + LEAVE(KErrArgument); + } + } + else + { + // for HSP profile we support only VGS & VGM commands + // CKPD is handled elsewhere + if(iProtocolStatus->iProfile == EBtmcHSP && + ((cmd->Id() != EATVGS && + cmd->Id() != EATVGM)) ) + { + LEAVE(KErrNotSupported); + } + + switch (cmd->Type()) + { + case EATTestCmd: + { + HandleTestCommandL(*cmd); + break; + } + case EATReadCmd: + { + HandleReadCommandL(*cmd); + break; + } + case EATWriteCmd: + { + HandleWriteCommandL(*cmd); + break; + } + case EATActionCmd: + { + HandleActionCommandL(*cmd); + break; + } + default: + LEAVE(KErrNotSupported); + } + } + CleanupStack::PopAndDestroy(cmd); + + if (!iProtocolStatus->iSlc && ServiceLevelConnected()) + { + StopTimer(KServiceSlcTimer); + if(iPhoneStatus) + { + iPhoneStatus->SetVolumeControlFeatureL(iProtocolStatus->iAccSupportedFeature & KHfFeatureBitVolumeControl); + iPhoneStatus->SetVoiceRecognitionControlL(iProtocolStatus->iAccSupportedFeature & KHfFeatureBitVoiceRecognition); + } + iProtocolStatus->iSlc = ETrue; + iCallStatus->ReportCallStatusL(); + iObserver.SlcIndicateL(ETrue); + } + } + +// ----------------------------------------------------------------------------- +// CBtmcProtocol::HandleTestCommand +// +// Test Command handled by this method: +// CHLD, BVRA, CIND, CCWA, CLIP +// ----------------------------------------------------------------------------- +// +void CBtmcProtocol::HandleTestCommandL(const CATCommand& aCmd) + { + TRACE_FUNC + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + + TATParam param; + switch (aCmd.Id()) + { + case EAT: + { + break; + } + case EATCHLD: + { + param = TATParam(KDesTestCodeCHLDv15); + iSlcMask = KSLC_3WayCalling; + break; + } + case EATBVRA: + { + param = TATParam(KDesTestCodeBVRA); + break; + } + case EATCIND: + { + param = TATParam(KDesTestCodeCINDv15); + break; + } + case EATCCWA: + { + param = TATParam(KDesTestCodeCCWA); + break; + } + case EATCLIP: + { + param = TATParam(KDesTestCodeCLIP); + break; + } + case EATCREG: + { + param = TATParam(KDesTestCodeCCWA); // it is the same (0,1) + break; + } + case EATCOLP: + { + param = TATParam(KDesTestCodeCCWA); // it is the same (0,1) + break; + } + default: + LEAVE(KErrNotFound); + } + if (param.Type() != EATNullParam) + { + CATResult* code = CATResult::NewL(aCmd.Id(), EATTestResult, param); + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + } + CATResult* ok = CATResult::NewL(EATOK); + CleanupStack::PushL(ok); + resarr.AppendL(ok); + CleanupStack::Pop(ok); + SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + CmdHandlingCompletedL(); + } + +// ----------------------------------------------------------------------------- +// CBtmcProtocol::HandleReadCommand +// +// Read Command handled by this method: +// CIND, CLIP, COPS +// ----------------------------------------------------------------------------- +// +void CBtmcProtocol::HandleReadCommandL(const CATCommand& aCmd) + { + TRACE_FUNC + CATResult* code = NULL; + RArray params; + CleanupClosePushL(params); + TBool response = EFalse; + switch (aCmd.Id()) + { + case EATCIND: + { + // Network status + if(!iPhoneStatus) + { + LEAVE(KErrNotSupported); + } + + RMobilePhone::TMobilePhoneRegistrationStatus net = + iPhoneStatus->NetworkStatus(); + + if (net == RMobilePhone::ERegisteredOnHomeNetwork || + net == RMobilePhone::ERegisteredRoaming) + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoATNetworkAvailable))) + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoATNetworkUnavailable))) + } + + // call status + if ((iProtocolStatus->iCallBits & KCallConnectedBit) || + (iProtocolStatus->iCallBits & KCallHoldBit)) + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoATCallActive))) + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoATNoCall))) + } + + // Call setup status + TInt callSetupInd = EBTMonoATNoCallSetup; + + if (iProtocolStatus->iCallBits & KCallRingingBit) + { + callSetupInd = EBTMonoATCallRinging; + } + else if (iProtocolStatus->iCallBits & KCallDiallingBit) + { + callSetupInd = EBTMonoATCallDialling; + } + else if (iProtocolStatus->iCallBits & KCallConnectingBit) + { + callSetupInd = EBTMonoATCallConnecting; + } + LEAVE_IF_ERROR(params.Append(TATParam(callSetupInd))) + // call_setup == callsetup + LEAVE_IF_ERROR(params.Append(TATParam(callSetupInd))) + + // Call held status + TInt callHeldInd = EBTMonoATNoCallHeld; + if( (iProtocolStatus->iCallBits & KCallHoldBit) && (iProtocolStatus->iCallBits & KCallConnectedBit) ) + { + callHeldInd = EBTMonoATCallHeldAndActive; + } + else if(iProtocolStatus->iCallBits & KCallHoldBit) + { + callHeldInd = EBTMonoATCallHeldOnly; + } + LEAVE_IF_ERROR(params.Append(TATParam(callHeldInd))) + // signal status + LEAVE_IF_ERROR(params.Append(TATParam(iPhoneStatus->GetSignalStrength()))) + // roaming status + if(net == RMobilePhone::ERegisteredRoaming) + { + LEAVE_IF_ERROR(params.Append(TATParam(1))) + } + else + { + LEAVE_IF_ERROR(params.Append(TATParam(0))) + } + // battery charge + LEAVE_IF_ERROR(params.Append(TATParam(iPhoneStatus->GetBatteryCharge()))) + + code = CATResult::NewL(EATCIND, EATReadResult, ¶ms); + response = ETrue; + break; + } + case EATCLIP: + { + LEAVE_IF_ERROR(params.Append(TATParam(iProtocolStatus->iCallerIdNotif))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoATCallerIdNetworkServiceUnknown))) + code = CATResult::NewL(EATCLIP, EATReadResult, ¶ms); + response = ETrue; + break; + } + case EATCOPS: + { + iOperator = CBtmcOperator::NewL(*this, *this, CActive::EPriorityStandard, KServiceGetOperator); + iOperator->GoActive(); + break; + } + case EATCREG: + { + if(!iPhoneStatus) + { + LEAVE(KErrNotSupported); + } + + RMobilePhone::TMobilePhoneRegistrationStatus net = + iPhoneStatus->NetworkStatus(); + response = ETrue; + switch(net) + { + case RMobilePhone::ERegistrationUnknown: + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregEnableUnsolicited))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregNetworkServiceUnknown))) + code = CATResult::NewL(EATCREG, EATReadResult, ¶ms); + break; + } + case RMobilePhone::ENotRegisteredEmergencyOnly: + case RMobilePhone::ENotRegisteredNoService: + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregEnableUnsolicited))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregNetworkServiceNotRegistered))) + code = CATResult::NewL(EATCREG, EATReadResult, ¶ms); + break; + } + case RMobilePhone::ENotRegisteredSearching: + case RMobilePhone::ERegisteredBusy: + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregEnableUnsolicited))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregNetworkServiceNotRegisteredSearching))) + code = CATResult::NewL(EATCREG, EATReadResult, ¶ms); + break; + } + case RMobilePhone::ERegisteredOnHomeNetwork: + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregEnableUnsolicited))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregNetworkServiceHomeNetwork))) + code = CATResult::NewL(EATCREG, EATReadResult, ¶ms); + break; + } + case RMobilePhone::ERegistrationDenied: + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregEnableUnsolicited))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregNetworkServiceRegistrationDenied))) + code = CATResult::NewL(EATCREG, EATReadResult, ¶ms); + break; + } + case RMobilePhone::ERegisteredRoaming: + { + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregEnableUnsolicited))) + LEAVE_IF_ERROR(params.Append(TATParam(EBTMonoCregNetworkServiceRegisteredRoaming))) + code = CATResult::NewL(EATCREG, EATReadResult, ¶ms); + break; + } + default: + TRACE_INFO(_L("Error: default in CREG")); + break; + }; + break; + } + case EATCSQ: + { + TRACE_INFO(_L("Requesting Signal strength")); + response = ETrue; + LEAVE_IF_ERROR(params.Append(TATParam(iPhoneStatus->GetRssiStrength()))) + LEAVE_IF_ERROR(params.Append(TATParam(KBerUnknown))) + code = CATResult::NewL(EATCSQ, EATReadResult, ¶ms); + TRACE_INFO(_L("done")); + break; + } + + case EATCGSN: + { + response = ETrue; + TBuf8 buf; + buf.Copy(iIdentity.iSerialNumber); + LEAVE_IF_ERROR(params.Append(TATParam(buf))) + code = CATResult::NewL(EATCGSN, EATReadResult, ¶ms); + break; + } + case EATCGMI: + { + response = ETrue; + TBuf8 buf; + buf.Copy(iIdentity.iManufacturer); + LEAVE_IF_ERROR(params.Append(TATParam(buf))) + code = CATResult::NewL(EATCGMI, EATReadResult, ¶ms); + break; + } + case EATCGMM: + { + response = ETrue; + TBuf8 buf; + buf.Copy(iIdentity.iModel); + LEAVE_IF_ERROR(params.Append(TATParam(buf))) + code = CATResult::NewL(EATCGMM, EATReadResult, ¶ms); + break; + } + case EATCGMR: + { + response = ETrue; + TBuf8 buf; + buf.Copy(iIdentity.iRevision); + LEAVE_IF_ERROR(params.Append(TATParam(buf))) + code = CATResult::NewL(EATCGMR, EATReadResult, ¶ms); + break; + } + case EATCIMI: + { + iEtelQuery->SetServiceId(KQueryIMSI); + iPhone.GetSubscriberId(iEtelQuery->iStatus, iId); + iEtelQuery->GoActive(); + break; + } + case EATCOLP: + { + response = ETrue; + LEAVE_IF_ERROR(params.Append(TATParam(TInt(iProtocolStatus->iOutgoingCallNotif)))) + code = CATResult::NewL(EATCOLP, EATReadResult, ¶ms); + break; + } + default: + LEAVE(KErrNotSupported); + } + CleanupStack::PopAndDestroy(¶ms); + if (response) + { + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + CATResult* ok = CATResult::NewL(EATOK); + CleanupStack::PushL(ok); + resarr.AppendL(ok); + CleanupStack::Pop(ok); + SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + CmdHandlingCompletedL(); + } + } + +// ----------------------------------------------------------------------------- +// CBtmcProtocol::HandleWriteCommand +// +// Write Command handled by this method: +// CHLD BVRA, CCWA, CLIP, VGS, VGM, CMEE, COPS +// ----------------------------------------------------------------------------- +// +void CBtmcProtocol::HandleWriteCommandL(const CATCommand& aCmd) + { + TRACE_FUNC + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + CATResult* code = NULL; + switch (aCmd.Id()) + { + case EATCMER: + { + TRACE_ASSERT(aCmd.ParamNum() >= 4, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + if (value == 3) + { + param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(3, param)) + LEAVE_IF_ERROR(param.Int(value)) + iProtocolStatus->iIndicatorNotif = (value == 1) ? + KIndAllActivated : KIndAllDeActivated; + TRACE_INFO((_L("Indicators enabled: %d"), value)) + } + iSlcMask = KSLC_No3WayCalling; + break; + } + case EATBRSF: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + iProtocolStatus->iAccSupportedFeature = value; + code = CATResult::NewL(EATBRSF, EATWriteResult, + TATParam(iProtocolStatus->iAGSupportedFeature)); + break; + } + case EATCCWA: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + iProtocolStatus->iCallWaitingNotif = (TBTMonoATCallWaitingNotif)value; + break; + } + case EATCLIP: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + iProtocolStatus->iCallerIdNotif = (TBTMonoATCallerIdNotif) value ; + break; + } + case EATVGS: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + if (!iPhoneStatus) + { + iPhoneStatus = CBtmcPhoneStatus::NewL(*this, iPhone, iProtocolStatus->iProfile); + iPhoneStatus->SetVolumeControlFeatureL(ETrue); + } + if(iVolumeSyncFromAccessory) + { + iPhoneStatus->SetSpeakerVolumeL(value); + } + break; + } + case EATVGM: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + break; + } + case EATCMEE: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + iProtocolStatus->iAdvancedErrorCode = value; + break; + } + case EATCOPS: + { + break; + } + case EATBIA: + { + for(TInt i=0; iiNetworkRegStatusNotif = TBool(value); + break; + } + case EATCOLP: + { + TRACE_ASSERT(aCmd.ParamNum() == 1, KErrArgument); + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + iProtocolStatus->iOutgoingCallNotif = TBool(value); + break; + } + default: + LEAVE(KErrNotSupported); + } + + if (code) + { + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + } + CATResult* ok = CATResult::NewL(EATOK); + CleanupStack::PushL(ok); + resarr.AppendL(ok); + CleanupStack::Pop(ok); + SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + + // solution to volume sync - phone will always send its volume status back to accessory + + if( (aCmd.Id() == EATVGS) && (iVolumeSyncFromAccessory == EFalse) ) + { + iVolumeSyncFromAccessory = ETrue; + TInt vol(KErrNotFound); + + if(iPhoneStatus) + { + vol = iPhoneStatus->GetVolumeStatus(); + } + + if(vol > KErrNotFound) // volume exists + { + TATParam param = TATParam(); + LEAVE_IF_ERROR(aCmd.Parameter(0, param)) + TInt value; + LEAVE_IF_ERROR(param.Int(value)) + if(value != vol) + { + CATResult* event = CATResult::NewLC(EATVGS, EATUnsolicitedResult, vol); + SendUnsoltResultL(*event); + CleanupStack::PopAndDestroy(event); + } + } + } + CmdHandlingCompletedL(); + } + + +// ----------------------------------------------------------------------------- +// CBtmcProtocol::HandleActionCommandL +// +// Action Command handled by this method: +// CLCC CNUM +// ----------------------------------------------------------------------------- +// +void CBtmcProtocol::HandleActionCommandL(const CATCommand& aCmd) + { + TRACE_FUNC + + switch (aCmd.Id()) + { + case EATCNUM: + { + iNumber = CBtmcNumber::NewL(*this, *this, CActive::EPriorityStandard, KServiceGetSubscriber); + iNumber->GoActive(); + break; + } + case EATCLCC: + { + iCallStatus->HandleClccL(); + break; + } + case EATCGSN: + { + CATResult* code = NULL; + RArray params; + CleanupClosePushL(params); + TBuf8 buf; + buf.Copy(iIdentity.iSerialNumber); + LEAVE_IF_ERROR(params.Append(TATParam(buf))) + code = CATResult::NewL(EATCGSN, EATActionResult, ¶ms); + CleanupStack::PopAndDestroy(¶ms); + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + CATResult* ok = CATResult::NewL(EATOK); + CleanupStack::PushL(ok); + resarr.AppendL(ok); + CleanupStack::Pop(ok); + SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + CmdHandlingCompletedL(); + break; + } + default: + LEAVE(KErrNotSupported); + } + } + +void CBtmcProtocol::DoSendProtocolDataL() + { + TRACE_INFO((_L("credit %d"), iCredit)) + TInt count = iOutgoPacketQueue->MdcaCount(); + for (TInt i = 0; iCredit >0 && i < count; i++) + { + iCredit--; + TBuf8 buf; + buf.Copy(iOutgoPacketQueue->MdcaPoint(0)); + iObserver.SendProtocolDataL(buf); + iOutgoPacketQueue->Delete(0); + } + } + +void CBtmcProtocol::StartTimerL(TInt aService, TInt aTimeout) + { + if (!iTimerActive) + { + TRACE_FUNC_ENTRY + iTimerActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, aService); + iTimer.CreateLocal(); + iTimer.After(iTimerActive->iStatus, aTimeout); + iTimerActive->GoActive(); + TRACE_FUNC_EXIT + } + else + { + TRACE_WARNING(_L("WARNING, timer is active already")) + } + } + +void CBtmcProtocol::StopTimer(TInt aService) + { + if (iTimerActive && iTimerActive->ServiceId() == aService) + { + TRACE_FUNC_ENTRY + delete iTimerActive; + iTimerActive = NULL; + iTimer.Close(); + TRACE_FUNC_EXIT + } + } + +// ----------------------------------------------------------------------------- +// CBtmcProtocol::IsServiceLevelEstablished +// ----------------------------------------------------------------------------- +// +TBool CBtmcProtocol::ServiceLevelConnected() const + { + TRACE_FUNC + TRACE_INFO((_L("SLC 0x%02x"), iSlcMask)) + if ((iProtocolStatus->iAccSupportedFeature & 0x02) && + (iProtocolStatus->iAGSupportedFeature & 0x01) && + (iSlcMask == KSLC_3WayCalling)) + { + return ETrue; + } + if ((!(iProtocolStatus->iAccSupportedFeature & 0x02) || + !(iProtocolStatus->iAGSupportedFeature & 0x01)) && + (iSlcMask == KSLC_No3WayCalling)) + { + return ETrue; + } + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CBtmcProtocol::ServiceAttributeSearchComplete +// ----------------------------------------------------------------------------- +// +void CBtmcProtocol::ServiceAttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, + const RSdpResultArray& aAttr, + TInt aErr ) + { + TRACE_FUNC + if((aErr == KErrNone || aErr == KErrEof) && aAttr.Count() && aAttr[0].iAttrValue.iValNumeric) + { + TRACE_INFO((_L("Remote volume control supported"))) + TInt err = KErrNone; + if (!iPhoneStatus) + { + TRAP(err, iPhoneStatus = CBtmcPhoneStatus::NewL(*this, iPhone, iProtocolStatus->iProfile)); + } + + if (err == KErrNone) + { + TRAP_IGNORE(iPhoneStatus->SetVolumeControlFeatureL(ETrue)); + iPhoneStatus->ActivateRemoteVolumeControl(); + } + } + + if(aErr) + { + delete iBteng; + iBteng = NULL; + } + } + +void CBtmcProtocol::SetIndicatorL(TInt aIndicator, TInt aValue) + { + TInt indBit( 0 ); + switch(aIndicator) + { + case EBTMonoATNetworkIndicator: + indBit = KIndServiceBit; + break; + case EBTMonoATCallIndicator: + case EBTMonoATCallSetupIndicator: + case EBTMonoATCall_SetupIndicator: + case EBTMonoATCallHeldIndicator: + // call, call setup, call held indicators are mandatory. + break; + case EBTMonoATSignalStrengthIndicator: + indBit = KIndSignalBit; + break; + case EBTMonoATRoamingIndicator: + indBit = KIndRoamBit; + break; + case EBTMonoATBatteryChargeIndicator: + indBit = KIndChargeBit; + break; + default: + LEAVE(KErrArgument) + } + if ( indBit ) + { + if ( aValue ) + { + iProtocolStatus->iIndicatorNotif |= indBit; + } + else + { + iProtocolStatus->iIndicatorNotif &= ~indBit; + } + } + } +void CBtmcProtocol::UnsolicitedResultFromATExtL(TInt aErr, const TDesC8& aAT) + { + TRACE_FUNC + if(aErr) + { + delete iAtExt; + iAtExt = NULL; + } + else + { + iOutgoPacketQueue->AppendL(aAT); + if (!iCallingHandler->ActiveCmdHandling() && !iHandleCmdPending) + { + iCredit++; + } + DoSendProtocolDataL(); + } + } + +void CBtmcProtocol::ATExtHandleCommandCompletedL(TInt aErr, const TDesC8& aReply) + { + TRACE_FUNC + if(aErr) + { + CATResult* nok = CATResult::NewLC(EATERROR); + SendResponseL(*nok); + CleanupStack::PopAndDestroy(nok); + } + else + { + iOutgoPacketQueue->AppendL(aReply); + if (!iCallingHandler->ActiveCmdHandling() && !iHandleCmdPending) + { + iCredit++; + } + DoSendProtocolDataL(); + } + } + + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcsignal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcsignal.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2005 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: General Active Object offering asynchronous service +* +*/ + +#include "atcodec.h" +#include "btmcphonestatus.h" +#include "btmcsignal.h" +#include "debug.h" +#include +#include + +const TInt8 KMaxPhoneSignal = 7; +const TInt8 KMaxHFPSignal = 5; + +// ----------------------------------------------------------------------------- +// CBtmcSignal::NewL +// ----------------------------------------------------------------------------- +CBtmcSignal* CBtmcSignal::NewL(CBtmcPhoneStatus& aParent) + { + CBtmcSignal* self = CBtmcSignal::NewLC(aParent); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcSignal::NewLC +// ----------------------------------------------------------------------------- +CBtmcSignal* CBtmcSignal::NewLC(CBtmcPhoneStatus& aParent) + { + CBtmcSignal* self = new (ELeave) CBtmcSignal(aParent); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcSignal::~CBtmcSignal +// ----------------------------------------------------------------------------- +CBtmcSignal::~CBtmcSignal() + { + TRACE_FUNC_ENTRY + Cancel(); + iPhone.Close(); + iServer.UnloadPhoneModule(KMmTsyModuleName); + iServer.Close(); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcSignal::GoActive +// ------------------------------------------------------------------------------- +void CBtmcSignal::GoActive() + { + if (!IsActive()) + { + iPhone.NotifySignalStrengthChange(iStatus, iDbm, iBars); + SetActive(); + } + TRACE_FUNC + } + + +// ------------------------------------------------------------------------------- +// CBtmcSignal::RunL +// ------------------------------------------------------------------------------- +void CBtmcSignal::RunL() + { + TRACE_FUNC_ENTRY + TInt err = iStatus.Int(); + TRACE_INFO((_L("err %d"), err)) + if (!err) + { + ConvertToHFPScale(iBars); + } + else + { + iBars = 0; + } + if (iPreviousBars != iBars) + { + iParent.HandleNetworkStrengthChangeL(iBars); + iPreviousBars = iBars; + } + if (err != KErrServerTerminated) + { + GoActive(); + } + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcSignal::DoCancel +// ------------------------------------------------------------------------------- +void CBtmcSignal::DoCancel() + { + iPhone.CancelAsyncRequest(EMobilePhoneNotifySignalStrengthChange); + TRACE_FUNC + } + + +// ------------------------------------------------------------------------------- +// CBtmcSignal::RunError +// ------------------------------------------------------------------------------- +TInt CBtmcSignal::RunError(TInt /*aErr*/) + { + iPhone.Close(); + iServer.UnloadPhoneModule(KMmTsyModuleName); + iServer.Close(); + TRACE_FUNC + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtmcSignal::CBtmcSignal +// ----------------------------------------------------------------------------- +CBtmcSignal::CBtmcSignal(CBtmcPhoneStatus& aParent) + : CActive(EPriorityNormal), iParent(aParent), iPreviousBars(0) + { + CActiveScheduler::Add(this); + } + +void CBtmcSignal::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iServer.Connect()); + iServer.LoadPhoneModule(KMmTsyModuleName); + LEAVE_IF_ERROR(iPhone.Open(iServer, KMmTsyPhoneName)); + iPhone.GetSignalStrength(iStatus, iDbm, iBars); + SetActive(); + TRACE_FUNC_EXIT + } + +void CBtmcSignal::ConvertToHFPScale(TInt8 &aSignal) + { + TReal result; + Math::Round( result, TReal(TReal(KMaxHFPSignal)/TReal(KMaxPhoneSignal) *TReal(aSignal)),0); + aSignal = TInt8(result); + } + +TInt CBtmcSignal::GetSignalStrength() + { + return iBars; + } + +TInt CBtmcSignal::GetRssiStrength() + { + return iDbm; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvoipline.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvoipline.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,283 @@ +/* +* Copyright (c) 2005 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: VoIP call status handling. +* +*/ + +#include "btmcvoipline.h" +#include "btmc_defs.h" +#include "debug.h" +#include "btmccallstatus.h" +#include +#include +#include +#include + +// ========================================================== +// CBtmcVoIPLine::NewL +// +// ========================================================== +// +CBtmcVoIPLine* CBtmcVoIPLine::NewL(CBtmcCallStatus& aParent, RMobilePhone& aPhone) + { + CBtmcVoIPLine* self = new (ELeave) CBtmcVoIPLine(aParent, aPhone); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ========================================================== +// CBtmcVoIPLine::ConstructL +// +// ========================================================== +// +void CBtmcVoIPLine::ConstructL() + { + iInfo = CCallInformation::NewL(); + iInfo->NotifyCallInformationChanges(*this); + } + +// ========================================================== +// CBtmcVoIPLine::Phone +// +// ========================================================== +// +RMobilePhone& CBtmcVoIPLine::Phone() + { + iPhone.Close(); + return iPhone; + } + +// ========================================================== +// CBtmcVoIPLine::CallInformationL +// +// ========================================================== +// +const MCall& CBtmcVoIPLine::CallInformationL() + { + TRACE_FUNC_ENTRY + CCallInfoIter& iter = iInfo->GetCallsL(); + MCall *returnValue = NULL; + for( iter.First(); !iter.IsDone(); iter.Next() ) + { + const MCall& call( iter.Current() ); + if(call.CallType() == CCPCall::ECallTypePS) + { + returnValue = const_cast (&call); + break; + } + } + TRACE_FUNC_EXIT + return *returnValue; + } + +// ========================================================== +// CBtmcVoIPLine::CallStatus +// +// ========================================================== +// +TInt CBtmcVoIPLine::CallStatusL() const + { + TRACE_FUNC_ENTRY + CCallInfoIter& iter = iInfo->GetCallsL(); + TInt mask = 0; + for( iter.First(); !iter.IsDone(); iter.Next() ) + { + const MCall& call( iter.Current() ); + if(call.CallType() == CCPCall::ECallTypePS) + { + TInt tempState = call.CallState(); + switch(call.CallState()) + { + /** Indicates initial call state after call creation. Basic state. */ + case CCPCall::EStateIdle: + break; + /** Indicates that the MT call is ringing but not answered yet by the local user. Basic state.*/ + case CCPCall::EStateRinging: + { + mask |= KCallRingingBit; + break; + } + /** MO Call: the network notifies to the MS that the remote party is now ringing. Basic state.*/ + case CCPCall::EStateConnecting: + { + mask |= KCallConnectingBit; + break; + } + /** Indicates that call is connected and active. Basic state.*/ + case CCPCall::EStateConnected: + { + mask |= KCallConnectedBit; + break; + } + /** Indicates that call is disconnecting. Basic state.*/ + case CCPCall::EStateDisconnecting: + break; + + /** Indicates that the call is connected but on hold. Basic state.*/ + case CCPCall::EStateHold: + { + mask |= KCallHoldBit; + break; + } + /** Call is transfering. Optional state.*/ + case CCPCall::EStateTransferring: + /** MO call is being forwarded at receiver end. Optional state. */ + case CCPCall::EStateForwarding: + /** Call is queued locally. Optional state. */ + case CCPCall::EStateQueued: + break; + /** Indicates that the local user has answered the MT call but the network has not + acknowledged the call connection yet. Must be sent after MCCPCall::Answer method has been completed. */ + case CCPCall::EStateAnswering: + { + mask |= KCallAnsweringBit; + break; + } + + /** Indicates that the call is dialing. Must be sent after MCCPCall::Dial method has been completed. */ + case CCPCall::EStateDialling: + { + mask |= KCallDiallingBit; + break; + } + } + } + } + TRACE_INFO((_L("Voip line, CALL STATUS 0x%08x"), mask)) + TRACE_FUNC_EXIT + return mask; + } + +// ========================================================== +// CBtmcVoIPLine::~CBtmcVoIPLine +// Destructor +// ========================================================== +// +CBtmcVoIPLine::~CBtmcVoIPLine() + { + if (iInfo != NULL) + { + iInfo->CancelNotification(); + delete iInfo; + } + } + +// ========================================================== +// CBtmcVoIPLine::ActiveCalls +// Destructor +// ========================================================== +// +const RPointerArray& CBtmcVoIPLine::ActiveCalls() const + { + TRACE_FUNC + return iCallActives; + } + +// ========================================================== +// CBtmcVoIPLine::CallInformationChanged +// Callback +// ========================================================== +// +void CBtmcVoIPLine::CallInformationChanged() + { + TRACE_FUNC + TRAP_IGNORE( CallInformationChangedL() ); + } + +// ========================================================== +// CBtmcVoIPLine::CBtmcVoIPLine +// Constructor +// ========================================================== +// +CBtmcVoIPLine::CBtmcVoIPLine(CBtmcCallStatus& aParent, RMobilePhone& aPhone) : iParent(aParent), iPhone(aPhone) + { + } + +// ========================================================== +// CBtmcVoIPLine::IsVoIP +// Returns always ETrue +// ========================================================== +// +TBool CBtmcVoIPLine::IsVoip() + { + return ETrue; + } + +// ========================================================== +// CBtmcVoIPLine::CallInformationChangedL +// Pass the call status change to the owner of this if necessary +// ========================================================== +// +void CBtmcVoIPLine::CallInformationChangedL() + { + TRACE_FUNC_ENTRY + _LIT(KVoip, "VoIP"); + _LIT(KVoipCall, "VoIP Call"); + TPtrC voipPtr(KVoip); + + CCallInfoIter& iter = iInfo->GetCallsL(); + for( iter.First(); !iter.IsDone(); iter.Next() ) + { + const MCall& call( iter.Current() ); + if(call.CallType() == CCPCall::ECallTypePS) + { + switch(call.CallState()) + { + /** Indicates initial call state after call creation. Basic state. */ + case CCPCall::EStateIdle: + iParent.HandleMobileCallEventL( voipPtr , KVoipCall, RMobileCall::EStatusIdle); + break; + /** Indicates that the MT call is ringing but not answered yet by the local user. Basic state.*/ + case CCPCall::EStateRinging: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusRinging); + break; + /** MO Call: the network notifies to the MS that the remote party is now ringing. Basic state.*/ + case CCPCall::EStateConnecting: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusConnecting); + break; + /** Indicates that call is connected and active. Basic state.*/ + case CCPCall::EStateConnected: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusConnected); + break; + /** Indicates that call is disconnecting. Basic state.*/ + case CCPCall::EStateDisconnecting: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusDisconnecting); + break; + /** Indicates that the call is connected but on hold. Basic state.*/ + case CCPCall::EStateHold: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusHold); + break; + /** Call is transfering. Optional state.*/ + case CCPCall::EStateTransferring: + /** MO call is being forwarded at receiver end. Optional state. */ + case CCPCall::EStateForwarding: + /** Call is queued locally. Optional state. */ + case CCPCall::EStateQueued: + break; + /** Indicates that the local user has answered the MT call but the network has not + acknowledged the call connection yet. Must be sent after MCCPCall::Answer method has been completed. */ + case CCPCall::EStateAnswering: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusAnswering); + break; + /** Indicates that the call is dialing. Must be sent after MCCPCall::Dial method has been completed. */ + case CCPCall::EStateDialling: + iParent.HandleMobileCallEventL(voipPtr, KVoipCall, RMobileCall::EStatusDialling); + break; + } + } + } + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,316 @@ +/* +* Copyright (c) 2005 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: call status handling. +* +*/ + + +// INCLUDE FILES +#include "btmcphonestatus.h" +#include "btmcvolume.h" +#include // for volume pubsub +#include +#include // for current volume pubsub +#include +#include + +#include "debug.h" + + +const TInt KNoAudioStreaming = -1; +const TInt KMaxHfVol = 15; +const TInt KSpeakerVolumeSubscribeService = 30; +const TInt KDefaultStep = 1000; + +// ----------------------------------------------------------------------------- +// CBtmcVolume::NewL +// ----------------------------------------------------------------------------- +CBtmcVolume* CBtmcVolume::NewL(CBtmcPhoneStatus& aParent) + { + CBtmcVolume* self = new(ELeave) CBtmcVolume(aParent); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtmcVolume::~CBtmcVolume +// ----------------------------------------------------------------------------- +CBtmcVolume::~CBtmcVolume() + { + TRACE_FUNC_ENTRY + delete iActive; + iVolLevelProperty.Close(); + iVolKeyEventProperty.Close(); + TRACE_FUNC_EXIT + } + +void CBtmcVolume::SetSpeakerVolumeL(TInt aHfVol) + { + TRACE_FUNC + TRACE_INFO((_L("phone vol %d, acc vol %d"), iPhnSpkrVol, iAccSpkrVol)) + iAccSpkrVol = HfToPhoneVolScale(aHfVol); + if (iVolCtrlActivated) + { + TRACE_INFO((_L("to new vol %d"), iAccSpkrVol)) + TInt vol = GetNewPhoneVol(); + if (vol != KNoAudioStreaming) + { + TInt prevPhVol = iPhnSpkrVol; + iPhnSpkrVol = vol; + DoSetSpeakerVolL( prevPhVol ); + } + } + else + { + TRACE_INFO((_L("volume control inactive!"))) + } + } + +void CBtmcVolume::SetMicrophoneVolumeL(TInt /*aHfVol*/) + { + return; + } + +void CBtmcVolume::ActivateRemoteVolumeControl() + { + if (!iVolCtrlActivated) + { + TRACE_FUNC + iVolLevelProperty.Subscribe(iActive->iStatus); + iActive->GoActive(); + + iVolCtrlActivated = ETrue; + TInt vol = GetNewPhoneVol(); + TRACE_INFO((_L("current phone vol %d, acc vol %d"), vol, iAccSpkrVol)) + if (vol != KNoAudioStreaming) + { + iPhnSpkrVol = vol; + if (iAccSpkrVol != vol) + { + TRAP_IGNORE(iParent.HandleSpeakerVolumeEventL(PhoneToHfVolScale(iPhnSpkrVol))); + iAccSpkrVol = iPhnSpkrVol; + } + } + } + } + +void CBtmcVolume::DeActivateRemoteVolumeControl() + { + if (iVolCtrlActivated) + { + iVolCtrlActivated = EFalse; + iActive->Cancel(); + } + TRACE_FUNC + } + +void CBtmcVolume::RequestCompletedL(CBtmcActive& aActive, TInt aErr) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("aErr %d, INTERNAL ACTION STATE %d"), aErr, iAction)) + switch (aActive.ServiceId()) + { + case KSpeakerVolumeSubscribeService: + { + if(!aErr) + { + iVolLevelProperty.Subscribe(aActive.iStatus); + aActive.GoActive(); + + TInt vol = GetNewPhoneVol(); + TRACE_INFO((_L("new phone vol %d, acc vol %d"), vol, iAccSpkrVol)) + if (vol != KNoAudioStreaming) + { + TInt prevPhVol = iPhnSpkrVol; + iPhnSpkrVol = vol; + if (iAction == ESpeakerVolSubscribe && iPhnSpkrVol != iAccSpkrVol) + { + iParent.HandleSpeakerVolumeEventL(PhoneToHfVolScale(iPhnSpkrVol)); + iAccSpkrVol = iPhnSpkrVol; + } + else if (iAction == ESpeakerVolSet) + { + DoSetSpeakerVolL( prevPhVol ); + } + } + } + break; + } + default: + break; + } + TRACE_FUNC_EXIT + } + +void CBtmcVolume::CancelRequest(TInt aServiceId) + { + switch (aServiceId) + { + case KSpeakerVolumeSubscribeService: + { + iVolLevelProperty.Cancel(); + break; + } + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CBtmcVolume::CBtmcVolume +// ----------------------------------------------------------------------------- +CBtmcVolume::CBtmcVolume(CBtmcPhoneStatus& aParent) + : iParent(aParent), iAccSpkrVol(KNoAudioStreaming), iStep(KDefaultStep) + { + } + +// ----------------------------------------------------------------------------- +// CBtmcVolume::ConstructL +// ----------------------------------------------------------------------------- +void CBtmcVolume::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iVolLevelProperty.Attach(KPSUidMediaStreamProperties, KMediaStreamCurrentVolume)) + LEAVE_IF_ERROR(iVolKeyEventProperty.Attach(KPSUidMediaKeysEventNotifier, KMediaKeysAccessoryVolumeEvent)) + CMMFDevSound* devSound = CMMFDevSound::NewL(); + iMaxSpkrVol = devSound->MaxVolume(); + TRACE_INFO((_L("Maximum volume is %d"), iMaxSpkrVol)) + delete devSound; + iPhnSpkrVol = GetNewPhoneVol(); + iActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KSpeakerVolumeSubscribeService); + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBtmcVolume::DoSetSpeakerVolL +// ----------------------------------------------------------------------------- +// +void CBtmcVolume::DoSetSpeakerVolL( TInt aPrevPhVol ) + { + TRACE_FUNC_ENTRY + TInt volClick( 0 ); + TInt diff1; + TInt diff2; + + if( ( aPrevPhVol >= iAccSpkrVol && iPhnSpkrVol <= iAccSpkrVol ) || + ( aPrevPhVol <= iAccSpkrVol && iPhnSpkrVol >= iAccSpkrVol ) ) + { + diff1 = Abs( aPrevPhVol - iAccSpkrVol ); + diff2 = Abs( iPhnSpkrVol - iAccSpkrVol ); + + if( diff2 >= diff1 ) + { + // the previous phone volume is closer to current headset volume setting + volClick = ( aPrevPhVol < iPhnSpkrVol ) ? KPSVolumeDownClicked : KPSVolumeUpClicked; + } + // otherwise we have roughly synchronized vol in both ends. + } + else if( iAccSpkrVol != iPhnSpkrVol ) + { + TInt step = Abs( iPhnSpkrVol - aPrevPhVol ); + if( step ) + { + // Only update step value if it is not equal to zero + iStep = step; + } + diff1 = Abs( iPhnSpkrVol - iAccSpkrVol ); + if( iAccSpkrVol > iPhnSpkrVol ) + { + // We are going upward + diff2 = Abs( (iPhnSpkrVol + iStep) - iAccSpkrVol ); + } + else + { + // We are going downward + diff2 = Abs( (iPhnSpkrVol - iStep) - iAccSpkrVol ); + } + if( diff2 <= diff1 ) + { + volClick = (iAccSpkrVol > iPhnSpkrVol) ? KPSVolumeUpClicked : KPSVolumeDownClicked; + } + } + + if( volClick ) + { + iAction = ESpeakerVolSet; + TInt err = iVolKeyEventProperty.Set( volClick ); + if( err ) + { + iAction = ESpeakerVolSubscribe; + TRACE_ERROR((_L("Set KMediaKeysVolumeKeyEvent err %d"), err)); + } + } + else + { + iAction = ESpeakerVolSubscribe; + } + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcVolume::HfToPhoneVolScale +// Converts volume level scale used in AT command VGS (0-15) into one used in +// DevSound Audio (0-MaxVol). +// ------------------------------------------------------------------------------- +TInt CBtmcVolume::HfToPhoneVolScale(TInt aHfVol) + { + TReal tgt; + TReal src(aHfVol); + TReal maxAG(iMaxSpkrVol); + TReal maxHF(KMaxHfVol); + TReal scale = maxAG/maxHF; + Math::Round( tgt, src*scale, 0); + TRACE_INFO((_L("HfToPhoneVolScale: HF %d is AG %d"), aHfVol, TInt(tgt))) + return TInt(tgt); + + } + +// ------------------------------------------------------------------------------- +// CBtmcVolume::PhoneToHfVolScale +// +// Converts volume level scale used in DevSound Audio (0-10) into one used in AT command +// VGS (0-15). +// ------------------------------------------------------------------------------- +TInt CBtmcVolume::PhoneToHfVolScale(TInt aPhoneVol) + { + TReal tgt; + TReal src(aPhoneVol); + TReal maxAG(iMaxSpkrVol); + TReal maxHF(KMaxHfVol); + TReal scale = maxHF/maxAG; + Math::Round( tgt, src*scale, 0); + TRACE_INFO((_L("PhoneToHfVolScale: HF %d is AG %d"), TInt(tgt), aPhoneVol)) + return TInt(tgt); + + } + +TInt CBtmcVolume::GetNewPhoneVol() + { + TInt vol = KNoAudioStreaming; + iVolLevelProperty.Get(vol); + TRACE_INFO((_L("phone vol P&S %d"), vol)) + return vol; + } + +TInt CBtmcVolume::GetVolume() + { + iPhnSpkrVol = GetNewPhoneVol(); + if (iPhnSpkrVol != KNoAudioStreaming) + return PhoneToHfVolScale(iPhnSpkrVol); + return iPhnSpkrVol; + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2005-2006 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: The BTMAC base Active Object definition +* +*/ + + +#include "btmactive.h" +#include "btmdefs.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmActive* CBtmActive::NewL(MBtmActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CBtmActive* self = new (ELeave) CBtmActive(aObserver, aPriority, aRequestId); + return self; + } + +CBtmActive::~CBtmActive() + { + Cancel(); + TRACE_FUNC + } + +void CBtmActive::GoActive() + { + TRACE_ASSERT(!IsActive(), EBTPanicRequestOutstanding); + SetActive(); + TRACE_FUNC + } + +TInt CBtmActive::RequestId() const + { + return iRequestId; + } + +void CBtmActive::SetRequestId(TInt aRequestId) + { + iRequestId = aRequestId; + } + +void CBtmActive::DoCancel() + { + iObserver.CancelRequest(*this); + TRACE_INFO((_L("Service %d cancelled"), iRequestId)) + } + +void CBtmActive::RunL() + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("Service %d completed with %d"), iRequestId, iStatus.Int())) + iObserver.RequestCompletedL(*this); + TRACE_FUNC_EXIT + } + +TInt CBtmActive::RunError(TInt aError) + { + TRACE_INFO((_L("Service %d RunError with %d"), iRequestId, aError)) + (void) aError; + return KErrNone; + } + +CBtmActive::CBtmActive(MBtmActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + : CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) + { + CActiveScheduler::Add(this); + TRACE_FUNC + } + +MBtmActiveObserver& CBtmActive::Observer() + { + return iObserver; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,442 @@ +/* +* Copyright (c) 2005-2006 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: CBtmMan definition +* Version : %version: 15.1.7 % +* +*/ + + +#include +#include +#include +#include +#include +#include "btmchandlerapi.h" +#include "btmman.h" +#include "btmactive.h" +#include "btmstate.h" +#include "btmslisten.h" +#include "debug.h" + + +// CONSTANTS +#ifdef _DEBUG // only used in traces +const TInt KBTDevAddrReadable = KBTDevAddrSize * 2; +#endif + +const TInt KDestroyObsoleteStateOneShot = 20; + +void CompleteRequest(TRequestStatus* aStatus, TInt aErr) + { + User::RequestComplete(aStatus, aErr); + } + +// ======== MEMBER FUNCTIONS ======== + +CBtmMan* CBtmMan::NewL(TPluginParams& aParams) + { + CBtmMan* self = new (ELeave) CBtmMan(aParams); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBtmMan::~CBtmMan() + { + TRACE_FUNC_ENTRY + delete iActive; + delete iCmdHandler; + iTrashBin.ResetAndDestroy(); + iTrashBin.Close(); + delete iState; + iMonoStateProp.Close(); + iMonoAddrProp.Close(); + iSockServ.Close(); + DeleteAllRegisteredServices(); + delete iBteng; + iServices.Close(); + TRACE_FUNC_EXIT + } + +void CBtmMan::ChangeStateL(CBtmState* aState) + { + TRACE_FUNC_ENTRY + TRACE_ASSERT(!!aState, EBTPanicNullPointer); + if (iState) + { + iTrashBin.AppendL(iState); + } + + iState = aState; + TInt err = KErrNone; + TRAP(err, iState->EnterL()); + if (err) + { + ChangeStateL(iState->ErrorOnEntryL(err)); + } + + if (iTrashBin.Count()) + { + if (!iActive) + { + iActive = CBtmActive::NewL(*this, CActive::EPriorityStandard, KDestroyObsoleteStateOneShot); + } + if (!iActive->IsActive()) + { + iActive->iStatus = KRequestPending; + iActive->GoActive(); + TRequestStatus* sta = &(iActive->iStatus); + CompleteRequest(sta, KErrNone); + } + } + TRACE_FUNC_EXIT + } + +RSocketServ& CBtmMan::SockServ() + { + return iSockServ; + } + +void CBtmMan::NewAccessory(const TBTDevAddr& aAddr, TProfiles aProfile) + { + Observer().NewAccessory(aAddr, aProfile); + } + +void CBtmMan::AccessoryDisconnected(const TBTDevAddr& aAddr, TProfiles aProfile) + { + Observer().AccessoryDisconnected(aAddr, aProfile); + } + +void CBtmMan::RemoteAudioOpened(const TBTDevAddr& aAddr, TProfiles aProfile) + { + Observer().RemoteAudioOpened(aAddr, aProfile); + } + +void CBtmMan::RemoteAudioClosed(const TBTDevAddr& aAddr, TProfiles aProfile) + { + Observer().RemoteAudioClosed(aAddr, aProfile); + } + +void CBtmMan::RegisterServiceL(TUint aService, TUint aChannel) + { + TRACE_FUNC_ENTRY + TInt count = iServices.Count(); + + for (TInt i = count - 1; i >= 0; i--) + { + if (iServices[i].iService == aService) + { + if (iServices[i].iChannel == aChannel) + { + TRACE_INFO((_L("Profile 0x%04X already registered at Channel %d"), aService, aChannel)) + return; + } + else + { + iBteng->DeleteSdpRecord(iServices[i].iHandle); + iServices.Remove(i); + break; + } + } + } + + TSdpServRecordHandle handle; + TInt err = iBteng->RegisterSdpRecord(aService, aChannel, handle); + LEAVE_IF_ERROR(err); + TBtmService record; + record.iChannel = aChannel; + record.iService = aService; + record.iHandle = handle; + iServices.AppendL(record); + + + + TRACE_INFO((_L("Profile 0x%04X new registered at Channel %d"), aService, aChannel)) + TRACE_FUNC_EXIT + } + +TInt CBtmMan::GetLastUsedChannel(TUint aService) + { + TInt count = iServices.Count(); + for (TInt i = count - 1; i >= 0; i--) + { + if (iServices[i].iService == aService) + { + return iServices[i].iChannel; + } + } + + return KErrNotFound; + } + +TInt CBtmMan::AudioLinkLatency() + { + return iState->AudioLinkLatency(); + } +TBool CBtmMan::IsTrashBinEmpty() + { + return iTrashBin.Count() == 0 ? ETrue : EFalse; + } + +void CBtmMan::DeleteRegisteredService(TUint aService) + { + TRACE_FUNC_ENTRY + TInt count = iServices.Count(); + for (TInt i = count - 1; i >= 0; i--) + { + if (iServices[i].iService == aService) + { + iBteng->DeleteSdpRecord(iServices[i].iHandle); + iServices.Remove(i); + break; + } + } + TRACE_FUNC_EXIT + } + +void CBtmMan::DeleteAllRegisteredServices() + { + TInt count = iServices.Count(); + if (count > 0) + { + TRACE_FUNC_ENTRY + for (TInt i = 0; i < count; i++) + { + iBteng->DeleteSdpRecord(iServices[i].iHandle); + } + iServices.Reset(); + TRACE_FUNC_EXIT + } + } + +void CBtmMan::LoadCmdHandlerL(TBtmcProfileId aProfile, const TBTDevAddr& aAddr, TBool aAccessoryInitiated) + { + if (!iCmdHandler) + { + iCmdHandler = CBtmcHandlerApi::NewL(*this, aProfile, aAddr.Des(), aAccessoryInitiated); + } + } + +void CBtmMan::DeleteCmdHandler() + { + delete iCmdHandler; + iCmdHandler = NULL; + } + +void CBtmMan::NewProtocolDataL(const TDesC8& aData) + { + if(iCmdHandler) + { + iCmdHandler->HandleProtocolDataL(aData); + } + else + { + // Panic in udeb builds only, disconnect remote in urel + __ASSERT_DEBUG(EFalse, PANIC(EBTPanicNullCmdHandler)); + LEAVE(KErrNotReady); + } + } + +TBool CBtmMan::IsAccInuse() const + { + return iAccInuse; + } + +TBool CBtmMan::IsEdrSupported() const + { + return iEdr; + } + +void CBtmMan::ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + TRAPD(err, iState->ConnectL(aAddr, aStatus)); + if (err) + { + CompleteRequest(&aStatus, err); + } + TRACE_FUNC_EXIT + } + +void CBtmMan::CancelConnectToAccessory(const TBTDevAddr& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + TRAP_IGNORE(iState->CancelConnectL()); + (void) aAddr; + TRACE_FUNC_EXIT + } + +void CBtmMan::DisconnectAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}); + TRAPD(err, iState->DisconnectL(aAddr, aStatus)); + if (err) + { + CompleteRequest(&aStatus, err); + } + TRACE_FUNC_EXIT + } + +void CBtmMan::OpenAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); + Trace(_L("Request to open audio to BT Addr %S"), &buf);}) + TRAPD(err, iState->OpenAudioLinkL(aAddr, aStatus)); + if (err) + { + CompleteRequest(&aStatus, err); + } + TRACE_FUNC_EXIT + } + +void CBtmMan::CancelOpenAudioLink(const TBTDevAddr& aAddr) + { + TRAP_IGNORE(iState->CancelOpenAudioLinkL(aAddr)); + } + +void CBtmMan::CloseAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + TRAPD(err, iState->CloseAudioLinkL(aAddr, aStatus)); + if (err) + { + CompleteRequest(&aStatus, err); + } + TRACE_FUNC_EXIT + } + +void CBtmMan::CancelCloseAudioLink(const TBTDevAddr& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + TRAP_IGNORE(iState->CancelCloseAudioLinkL(aAddr)); + TRACE_FUNC_EXIT + } + +void CBtmMan::AccInUse() + { + TRACE_FUNC_ENTRY + iAccInuse = ETrue; + iState->AccInUse(); + TRACE_FUNC_EXIT + } + +void CBtmMan::AccOutOfUse() + { + TRACE_FUNC + iAccInuse = EFalse; + } + +TProfiles CBtmMan::PluginType() + { + return EAnyMonoAudioProfiles; + } + + +void CBtmMan::ActivateRemoteVolumeControl() + { + TRACE_FUNC + if(iCmdHandler) + iCmdHandler->ActivateRemoteVolumeControl(); + else + { + TRACE_INFO((_L("Null cmd handler"))) + } + } + +void CBtmMan::DeActivateRemoteVolumeControl() + { + if (iCmdHandler) + iCmdHandler->DeActivateRemoteVolumeControl(); + } + +TInt CBtmMan::GetRemoteSupportedFeature() + { + if (iCmdHandler) + return iCmdHandler->GetRemoteSupportedFeature(); + return 0; + } + +CBtmMan::CBtmMan(TPluginParams& aParams) + : CBTAccPlugin(aParams) + { + TRACE_FUNC + } + +void CBtmMan::RequestCompletedL(CBtmActive& /*aActive*/) + { + TRACE_FUNC + TRACE_INFO((_L("TRASHBIN SIZE: %d"), iTrashBin.Count())) + iTrashBin.ResetAndDestroy(); + if( iState ) + { + iState->StartListenerL(); + } + + } + +void CBtmMan::CancelRequest(CBtmActive& /*aActive*/) + { + } + +void CBtmMan::SlcIndicateL(TBool aSlc) + { + if (iState) + iState->SlcIndicateL(aSlc); + } + +void CBtmMan::SendProtocolDataL(const TDesC8& aData) + { + if (iState) + iState->SendProtocolDataL(aData); + } + +void CBtmMan::ConstructL() + { + TRACE_FUNC_ENTRY + LEAVE_IF_ERROR(iSockServ.Connect()); + TInt edr = EBTEScoNotSupported; + CRepository* cenrep = NULL; + TRAP_IGNORE(cenrep = CRepository::NewL(KCRUidBluetoothEngine)); + if (cenrep) + { + cenrep->Get(KBTEScoSupportedLV, edr); + delete cenrep; + } + iEdr = (edr == EBTEScoSupported) ? ETrue : EFalse; + TRACE_INFO((_L("EDR feature %d"), iEdr)) + iBteng = CBTEngDiscovery::NewL(); + CBtmState* state = CBtmsListen::NewL(*this); + CleanupStack::PushL(state); + ChangeStateL(state); + CleanupStack::Pop(state); + TRACE_FUNC_EXIT + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2005-2006 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: the Plugin entry. +* +*/ + + +#ifndef BTMPROXY_H +#define BTMPROXY_H + +#include + +#include +#include "btmman.h" + +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x101FBAEA, CBtmMan::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif // BTMPROXY_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,450 @@ +/* +* Copyright (c) 2005-2006 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: BT RFComm socket +* +*/ + + +#include +#include "btmrfcommsock.h" +#include "btmsockobserver.h" +#include "debug.h" + +// Constant for listening queue size +const TInt KListenQueSize = 1; + +// ======== MEMBER FUNCTIONS ======== + +CBtmRfcommSock* CBtmRfcommSock::NewL(MBtmSockObserver& aObserver, RSocketServ& aServer) + { + CBtmRfcommSock* self = new (ELeave) CBtmRfcommSock(aObserver, aServer); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmRfcommSock::~CBtmRfcommSock() + { + TRACE_FUNC_ENTRY + iAda.Close(); + delete iDataSocket; + delete iListenSocket; + iInData.Close(); + iOutData.Close(); + delete iOutDataQueue; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBtmRfcommSock::Connect +// --------------------------------------------------------- +// +void CBtmRfcommSock::ConnectL(TBTSockAddr& aAddr, TUint aService) + { + TRACE_FUNC_ENTRY + TProtocolDesc pInfo; + LEAVE_IF_ERROR(iServer.FindProtocol(TProtocolName(KRFCOMMDesC), pInfo)); + if (!iDataSocket) + { + iDataSocket = CBluetoothSocket::NewL(*this, iServer, pInfo.iSockType, pInfo.iProtocol); + } + LEAVE_IF_ERROR(iDataSocket->Connect(aAddr)); + iService = aService; + iRemote = TBTDevAddr(); + iRemoteHasConnected = EFalse; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBtmRfcommSock::CancelActiveConnectSocket +// --------------------------------------------------------- +// +void CBtmRfcommSock::CancelConnect() + { + if (iDataSocket) + { + TRACE_FUNC_ENTRY + iDataSocket->CancelConnect(); + TRACE_FUNC_EXIT + } + } + +TBool CBtmRfcommSock::AccessoryInitiatedConnection() + { + return iRemoteHasConnected; + } + + +TUint CBtmRfcommSock::ListenL(TUint aService, const TBTServiceSecurity& aSec, TUint aLastUsedPort) + { + TRACE_FUNC_ENTRY + TRACE_ASSERT(!iListenSocket, EBTPanicRfcommAlreadyListen) + TRACE_ASSERT(!iDataSocket, EBTPanicRfcommSockInuse) + TProtocolDesc pInfo; + LEAVE_IF_ERROR(iServer.FindProtocol(TProtocolName(KRFCOMMDesC), pInfo)); + iListenSocket = CBluetoothSocket::NewL(*this, iServer, pInfo.iSockType, pInfo.iProtocol); + TRfcommSockAddr addr; + addr.SetSecurity(aSec); + + TRACE_INFO((_L("Trying lastused port %d"), aLastUsedPort)) + addr.SetPort(aLastUsedPort); + TInt error = iListenSocket->Bind(addr); + if ( error ) + { + TRACE_INFO((_L("Trying KRfcommPassiveAutoBind"))) + addr.SetPort(KRfcommPassiveAutoBind); + LEAVE_IF_ERROR(iListenSocket->Bind(addr)); + } + LEAVE_IF_ERROR(iListenSocket->Listen(KListenQueSize)); + iDataSocket = CBluetoothSocket::NewL(*this, iServer); + LEAVE_IF_ERROR(iListenSocket->Accept(*iDataSocket)); + iService = aService; + TRACE_FUNC_EXIT + iRemote = TBTDevAddr(); + return iListenSocket->LocalPort(); + } + +void CBtmRfcommSock::CancelListen() + { + if (iListenSocket) + { + TRACE_FUNC_ENTRY + iListenSocket->CancelAccept(); + TRACE_FUNC_EXIT + } + } + +void CBtmRfcommSock::Disconnect(RSocket::TShutdown aHow) + { + TRACE_FUNC_ENTRY + if (iDataSocket) + { + iAda.ActivateActiveRequester(); + iDataSocket->CancelWrite(); + iDataSocket->CancelRecv(); + iDataSocket->CancelIoctl(); + iDataSocket->Shutdown(aHow); + } + iRemote = TBTDevAddr(); + TRACE_FUNC_EXIT + } + +void CBtmRfcommSock::WriteL(const TDesC8& aData) + { + TRACE_FUNC_ENTRY + TRACE_ASSERT(iDataSocket != NULL, EBTPanicObjectUninitialized) + if (!iOutDataQueue) + { + iOutDataQueue = new (ELeave) CDesC8ArrayFlat(1); + } + iOutDataQueue->AppendL(aData); + SendPacketL(); + TRACE_FUNC_EXIT + } + +void CBtmRfcommSock::CancelWrite() + { + if (iDataSocket) + { + TRACE_FUNC_ENTRY + iDataSocket->CancelWrite(); + iOutDataQueue->Reset(); + TRACE_FUNC_EXIT + } + } + +const TBTDevAddr& CBtmRfcommSock::Remote() const + { + return iRemote; + } + +TInt CBtmRfcommSock::RequestMasterRole() + { + TRACE_FUNC + TRACE_ASSERT(iDataSocket, EBTPanicNullPointer) + TUint32 basebandState = 0; + TInt err = iDataSocket->PhysicalLinkState( basebandState ); + if (!err && (basebandState & ENotifySlave)) + { + err = iDataSocket->RequestMasterRole(); + } + return err; + } + +TBool CBtmRfcommSock::IsInSniff() const + { + return iInSniff; + } + +TInt CBtmRfcommSock::ActivateBasebandEventNotification(TInt aNotification) + { + TRACE_FUNC + TRACE_ASSERT(iDataSocket, EBTPanicNullPointer) + iBBNotificationMode = aNotification; + return iDataSocket->ActivateBasebandEventNotifier(aNotification); + } + +void CBtmRfcommSock::SetObserver(MBtmSockObserver& aObserver) + { + TRACE_FUNC + iObserver = &aObserver; + } + +TUint CBtmRfcommSock::Service() const + { + return iService; + } + +TInt CBtmRfcommSock::ActivateSniffRequester() + { + if (iDataSocket) + return iAda.ActivateSniffRequester(); + else + return KErrGeneral; + } + +void CBtmRfcommSock::RequestLinkToActiveMode() + { + if (iDataSocket) + { + TInt err = iAda.ActivateActiveRequester(); + TRACE_INFO((_L("ada.ActivateActiveRequester err %d"), err)) + } + TRACE_FUNC + } + +void CBtmRfcommSock::HandleConnectCompleteL(TInt aErr) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("err %d"), aErr)) + + // Process the connect complete before issuing a receive request to ensure that + // we are ready to process the data when it is received. + iObserver->RfcommConnectCompletedL(aErr); + + if (!aErr) + { + TBTSockAddr sockAddr; + iDataSocket->RemoteName(sockAddr); + iRemote = sockAddr.BTAddr(); + iInData.ReAllocL(256); + RequestMasterRole(); + TInt err = iAda.Open(iServer, iRemote); + TRACE_INFO((_L("ada.Open err %d"), err)) + iDataSocket->ActivateBasebandEventNotifier(ENotifyAnyPowerMode | ENotifyAnyRole | + ENotifySCOLinkUp | ENotifySCOLinkDown | + ENotifySCOLinkError | ENotifyPhysicalLinkUp | + ENotifyPhysicalLinkDown | ENotifyPhysicalLinkError); + ReceiveL(); + } + TRACE_FUNC_EXIT + } + +void CBtmRfcommSock::HandleAcceptCompleteL(TInt aErr) + { + TRACE_FUNC_ENTRY + + iRemoteHasConnected = ETrue; + + // Process the accept complete before issuing a receive request to ensure that + // we are ready to process the data when it is received. + iObserver->RfcommAcceptCompletedL(aErr, iService); + + if (!aErr) + { + TBTSockAddr sockAddr; + iDataSocket->RemoteName(sockAddr); + iRemote = sockAddr.BTAddr(); + iInData.ReAllocL(256); + RequestMasterRole(); + TInt err = iAda.Open(iServer, iRemote); + TRACE_INFO((_L("ada.Open err %d"), err)) + iDataSocket->ActivateBasebandEventNotifier(ENotifyAnyPowerMode | ENotifyAnyRole | + ENotifySCOLinkUp | ENotifySCOLinkDown | + ENotifySCOLinkError | ENotifyPhysicalLinkUp | + ENotifyPhysicalLinkDown | ENotifyPhysicalLinkError); + ReceiveL(); + } + TRACE_FUNC_EXIT + } + +void CBtmRfcommSock::HandleShutdownCompleteL(TInt aErr) + { + TRACE_FUNC + iObserver->RfcommShutdownCompletedL(aErr); + } + +void CBtmRfcommSock::HandleSendCompleteL(TInt aErr) + { + TRACE_FUNC + TRACE_INFO((_L("err %d"), aErr)) + iWriting = EFalse; + if (!aErr) + { + SendPacketL(); + } + else + { + iObserver->RfcommSendCompletedL(aErr); + } + } + +void CBtmRfcommSock::HandleReceiveCompleteL(TInt aErr) + { + TRACE_FUNC + TRACE_INFO((_L("err %d"), aErr)) + + iObserver->RfcommReceiveCompletedL(aErr, iInData); + if (!aErr) + { + ReceiveL(); + } + } + +void CBtmRfcommSock::HandleIoctlCompleteL(TInt aErr) + { + TRACE_FUNC + TRACE_INFO((_L("KL2CAPEchoRequestIoctl callback code: %d"), aErr )) + + if (aErr) + { + iObserver->RfcommSendCompletedL(aErr); + } + } + +void CBtmRfcommSock::HandleActivateBasebandEventNotifierCompleteL( + TInt aErr, TBTBasebandEventNotification& aEventNotification) + { + TRACE_FUNC_ENTRY + if (!aErr) + { + switch(aEventNotification.EventType()) + { + case ENotifyActiveMode: + { + TRACE_INFO(_L( "BB Notif: Active mode" )) + iInSniff = EFalse; + break; + } + case ENotifySniffMode: + { + TRACE_INFO(_L( "BB Notif: Sniff mode" )) + break; + } + case ENotifyMaster: + { + TRACE_INFO(_L( "BB Notif: Master role")) + break; + } + case ENotifySlave: + { + TRACE_INFO(_L("BB Notif: Slave role")) + break; + } + case ENotifySCOLinkUp: + { + TRACE_INFO(_L("BB Notif: SCO up")) + break; + } + case ENotifySCOLinkDown: + { + TRACE_INFO(_L("BB Notif: SCO down")) + + TInt err = iDataSocket->Ioctl( KL2CAPEchoRequestIoctl, NULL, KSolBtL2CAP ); + + TRACE_INFO((_L("KL2CAPEchoRequestIoctl return code: %d"), err )) + break; + } + case ENotifySCOLinkError: + { + TRACE_INFO(_L("BB Notif: SCO error")) + break; + } + case ENotifyPhysicalLinkUp: + { + TRACE_INFO(_L("BB Notif: Physical link up")) + break; + } + case ENotifyPhysicalLinkDown: + { + TRACE_INFO(_L("BB Notif: Physical link down")) + break; + } + case ENotifyPhysicalLinkError: + { + TRACE_INFO(_L("BB Notif: Physical link error")) + break; + } + default: + { + TRACE_INFO((_L( "BB Notif: Uninteresting event (0x%08X)"), aEventNotification.EventType())) + } + }; + } + TRACE_FUNC_EXIT + } + +void CBtmRfcommSock::ConstructL() + { + } + +CBtmRfcommSock::CBtmRfcommSock(MBtmSockObserver& aObserver, RSocketServ& aServer) + : iObserver(&aObserver), iServer(aServer), iInSniff(EFalse) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtmAtPipe::HandleAccessoryDataEventL +// ----------------------------------------------------------------------------- +// +void CBtmRfcommSock::SendPacketL() + { + if (!iWriting && iOutDataQueue && iOutDataQueue->MdcaCount() > 0) + { + if (iOutData.MaxLength() < iOutDataQueue->MdcaPoint(0).Length()) + { + iOutData.ReAllocL(iOutDataQueue->MdcaPoint(0).Length()); + } + iOutData.Copy(iOutDataQueue->MdcaPoint(0)); + iDataSocket->Write(iOutData); + iOutDataQueue->Delete(0); + TRACE_INFO((_L8("[HFP] [O] %S"), &iOutData)) + iWriting = ETrue; + } + } + +void CBtmRfcommSock::ReceiveL() + { + TRACE_FUNC + TRACE_ASSERT(iDataSocket != NULL, EBTPanicObjectUninitialized) + iInData.Zero(); + LEAVE_IF_ERROR(iDataSocket->RecvOneOrMore(iInData, 0, iXfrLength)); + } + +void CBtmRfcommSock::CancelReceive() + { + if (iDataSocket) + { + TRACE_FUNC_ENTRY + iDataSocket->CancelRecv(); + TRACE_FUNC_EXIT + } + } + +void CBtmRfcommSock::SetService(TUint aService) + { + iService = aService; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsaudio.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsaudio.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2005-2006 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: The audio opened state definition +* Version : %version: 4.2.3 % +* +*/ + + +#include "btmsaudio.h" +#include "btmrfcommsock.h" +#include "btmsyncsock.h" +#include "btmslisten.h" +#include "btmsctrl.h" +#include "btmssniffm.h" +#include "btmsdisconnect.h" +#include "btmscloseaudio.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsAudio* CBtmsAudio::NewL(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco) + { + CBtmsAudio* self = new( ELeave ) CBtmsAudio(aParent, aRfcomm, aSco); + return self; + } + +CBtmsAudio::~CBtmsAudio() + { + delete iSco; + } + +void CBtmsAudio::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Audio")) + if (NotifyItem() == ENotifyAudioOpenedByRemote) + { + if (iRfcomm->Service() == EBTProfileHFP) + { + Parent().RemoteAudioOpened(iRfcomm->Remote(), EHFP); + } + else + { + Parent().RemoteAudioOpened(iRfcomm->Remote(), EHSP); + } + } + } + +void CBtmsAudio::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + iSco->DisconnectL(); + delete iSco; + iSco = NULL; + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsDisconnect::NewL(Parent(),&aStatus, SwapStateRfcommSock())); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsAudio::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + aStatus = KRequestPending; + if (aAddr == iRfcomm->Remote()) + { + CompleteRequest(&aStatus, KErrInUse); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsAudio::CloseAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsCloseAudio::NewL(Parent(),&aStatus, SwapStateRfcommSock(), SwapSyncSock(iSco))); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsAudio::RfcommErrorL(TInt /*aErr*/) + { + iSco->DisconnectL(); + delete iSco; + iSco = NULL; + } + +void CBtmsAudio::SyncLinkDisconnectCompleteL(TInt /*aErr*/) + { + CBtmsInuse* next; + if (iRfcomm->IsInSniff()) + next = CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), NULL); + else + next = CBtmsCtrl::NewL(Parent(), SwapStateRfcommSock(), NULL); + next->SetNotifyItemAtEntry(ENotifyAudioClosedByRemote); + Parent().ChangeStateL(next); + } + +TInt CBtmsAudio::AudioLinkLatency() + { + TRACE_FUNC + return iSco->Latency(); + } +CBtmsAudio::CBtmsAudio(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco) + : CBtmsInuse(aParent, NULL, aRfcomm), iSco(aSco) + { + iRfcomm->SetObserver(*this); + iSco->SetObserver(*this); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmscloseaudio.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmscloseaudio.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2005-2006 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: The close audio state definition +* +*/ + + +#include "btmscloseaudio.h" +#include "btmsdisconnect.h" +#include "btmrfcommsock.h" +#include "btmsyncsock.h" +#include "btmslisten.h" +#include "btmsctrl.h" +#include "btmssniffm.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsCloseAudio* CBtmsCloseAudio::NewL(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco) + { + CBtmsCloseAudio* self = new( ELeave ) CBtmsCloseAudio(aParent, aRequest, aRfcomm, aSco); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsCloseAudio::~CBtmsCloseAudio() + { + delete iSco; + } + +void CBtmsCloseAudio::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Close Audio")) + iSco->DisconnectL(); + } + +void CBtmsCloseAudio::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + delete iSco; + iSco = NULL; + CompleteStateRequest(KErrNone); + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsDisconnect::NewL(Parent(),&aStatus, SwapStateRfcommSock())); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsCloseAudio::CancelCloseAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + delete iSco; + iSco = NULL; + CompleteStateRequest(KErrCancel); + if (iRfcomm->IsInSniff()) + { + Parent().ChangeStateL(CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), NULL)); + } + else + { + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapStateRfcommSock(), NULL)); + } + } + } + + +void CBtmsCloseAudio::RfcommErrorL(TInt aErr) + { + delete iSco; + + iSco = NULL; + CompleteStateRequest(aErr); + } + +void CBtmsCloseAudio::SyncLinkDisconnectCompleteL(TInt aErr) + { + CompleteStateRequest(aErr); + if (iRfcomm->IsInSniff()) + { + Parent().ChangeStateL(CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), NULL)); + } + else + { + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapStateRfcommSock(), NULL)); + } + } + +CBtmsCloseAudio::CBtmsCloseAudio(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco) + : CBtmsInuse(aParent, aRequest, aRfcomm), iSco(aSco) + { + iRfcomm->SetObserver(*this); + iSco->SetObserver(*this); + } + +void CBtmsCloseAudio::ConstructL() + { + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsconnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsconnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,208 @@ +/* +* Copyright (c) 2005-2006 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: The connect state definition +* +*/ + + +// INCLUDE FILES +#include "btengdiscovery.h" +#include "btengconstants.h" +#include "btmsconnect.h" +#include "btmslisten.h" +#include "btmsrfcomm.h" +#include "btmsctrl.h" +#include "btmsopenaudio.h" +#include "btmrfcommsock.h" +#include "btmactive.h" +#include "debug.h" + +const TInt KSearchHandsfreeChannel = 1; +const TInt KSearchHeadsetChannel = 2; +const TInt KSearchCompleted = 3; + +// ======== MEMBER FUNCTIONS ======== + +CBtmsConnect* CBtmsConnect::NewL(CBtmMan& aParent, TRequestStatus* aRequest, + const TBTDevAddr& aAddr, TRequestCategory aRequestCat) + { + CBtmsConnect* self = new( ELeave ) CBtmsConnect(aParent, aRequest, aAddr, aRequestCat); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsConnect::~CBtmsConnect() + { + TRACE_FUNC_ENTRY + delete iBteng; + delete iRfcomm; + delete iDevice; + TRACE_FUNC_EXIT + } + +void CBtmsConnect::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Connect")) + *StateRequest() = KRequestPending; + iSearchState = KSearchHandsfreeChannel; + TInt err = iBteng->RemoteProtocolChannelQuery(iSockAddr.BTAddr(), EBTProfileHFP); + if(err) + { + CompleteStateRequest(err); + } + } + +void CBtmsConnect::CancelConnectL() + { + TRACE_FUNC + if (iRequestCat == ERequestConnect) + { + if (iRfcomm) + { + iRfcomm->CancelConnect(); + } + if (iBteng) + { + iBteng->CancelRemoteSdpQuery(); + } + CompleteStateRequest(KErrCancel); + Parent().ChangeStateL(CBtmsListen::NewL(Parent())); + } + } + +void CBtmsConnect::CancelOpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (aAddr == iSockAddr.BTAddr() && iRequestCat == ERequestOpenAudio) + { + CompleteStateRequest(KErrCancel); + iRequestCat = ERequestNone; + } + } + +CBtmRfcommSock* SwapRfcommSock(CBtmRfcommSock*& aSock) + { + CBtmRfcommSock* sock = aSock; + aSock = NULL; + return sock; + } + +void CBtmsConnect::RfcommConnectCompletedL(TInt aErr) + { + TRACE_FUNC + if (aErr) + { + CompleteStateRequest(aErr); + Parent().ChangeStateL(CBtmsListen::NewL(Parent())); + } + else + { + if (iRfcomm->Service() == EBTProfileHFP) + { + Parent().ChangeStateL(CBtmsRfcomm::NewL(Parent(),SwapStateRequest(), SwapRfcommSock(iRfcomm), iRequestCat)); + } + else + { + if (iRequestCat == ERequestConnect) + { + CompleteStateRequest(aErr); + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapRfcommSock(iRfcomm), NULL)); + } + else if (iRequestCat == ERequestConnect) + { + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(),SwapStateRequest(), SwapRfcommSock(iRfcomm), NULL)); + } + } + } + } + +void CBtmsConnect::AttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, const RSdpResultArray &aAttr, TInt aErr ) + { + TRACE_FUNC + if (iSearchState == KSearchHandsfreeChannel) + { + if (aErr == KErrNone || (aErr == KErrEof && aAttr.Count()>0)) + { + RSdpResultArray attr(aAttr); + CBTEngDiscovery::ParseRfcommChannel(attr, iRemoteChannel); + TRACE_INFO((_L("HFP channel %d"), iRemoteChannel)) + TRAP_IGNORE(DoSockConnectL(EBTProfileHFP)); + iSearchState = KSearchCompleted; + } + else if (aErr == KErrEof && aAttr.Count()== 0) + { + iSearchState = KSearchHeadsetChannel; + iBteng->RemoteProtocolChannelQuery(iSockAddr.BTAddr(), EBTProfileHSP); + } + else + { + CompleteStateRequest(aErr); + TRAP_IGNORE(Parent().ChangeStateL(CBtmsListen::NewL(Parent()))); + } + } + else if (iSearchState == KSearchHeadsetChannel) + { + if (aErr == KErrNone || (aErr == KErrEof && aAttr.Count()>0)) + { + RSdpResultArray attr(aAttr); + CBTEngDiscovery::ParseRfcommChannel(attr, iRemoteChannel); + TRACE_INFO((_L("HSP channel %d"), iRemoteChannel)) + TRAP_IGNORE(DoSockConnectL(EBTProfileHSP)); + iSearchState = KSearchCompleted; + } + else + { + CompleteStateRequest(aErr); + TRAP_IGNORE(Parent().ChangeStateL(CBtmsListen::NewL(Parent()))); + } + } + } + + +CBtmsConnect::CBtmsConnect(CBtmMan& aParent, TRequestStatus* aRequest, + const TBTDevAddr& aAddr, TRequestCategory aRequestCat) + : CBtmState(aParent, aRequest), iRequestCat(aRequestCat) + { + iSockAddr.SetBTAddr(aAddr); + } + +void CBtmsConnect::ConstructL() + { + TRACE_FUNC + iBteng = CBTEngDiscovery::NewL(this); + iRfcomm = CBtmRfcommSock::NewL(*this, Parent().SockServ()); + } + +void CBtmsConnect::DoSockConnectL(TUint aService) + { + TRACE_FUNC + iSockAddr.SetBTAddr(iSockAddr.BTAddr()); + TBTServiceSecurity sec; + sec.SetAuthentication(ETrue); + sec.SetEncryption(ETrue); + iSockAddr.SetSecurity(sec); + iSockAddr.SetPort(iRemoteChannel); + iRfcomm->ConnectL(iSockAddr, aService); + } +void CBtmsConnect::ServiceSearchComplete( const RSdpRecHandleArray& /*aResult*/, TUint /*aTotalRecordsCount*/, TInt /*aErr*/) {} + +void CBtmsConnect::DeviceSearchComplete( CBTDevice* /*aDevice*/, TInt /*aErr*/ ) {} + +void CBtmsConnect::ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, const RSdpResultArray& aAttr, TInt aErr ) + { + AttributeSearchComplete(aHandle, aAttr, aErr); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsctrl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsctrl.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2005-2006 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: The Control state definition +* +*/ + + +// INCLUDE FILES +//#include +#include + +#include "btmrfcommsock.h" +#include "btmsyncsock.h" +#include "btmsctrl.h" +#include "btmssniffm.h" +#include "btmsopenaudio.h" +#include "btmsdisconnect.h" +#include "btmsaudio.h" +#include "btmactive.h" +#include "btmstempd.h" +#include "debug.h" +#include "btmchandlerapi.h" +#include "btmcprofileid.h" +#include "atcodec.h" +#include + + + +// ======== MEMBER FUNCTIONS ======== + +CBtmsCtrl* CBtmsCtrl::NewL(CBtmMan& aParent, CBtmRfcommSock* aSock, CBtmSyncSock* aSco) + { + CBtmsCtrl* self = new( ELeave ) CBtmsCtrl(aParent, aSock, aSco); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsCtrl::~CBtmsCtrl() + { + TRACE_FUNC_ENTRY + delete iSco; + TRACE_FUNC_EXIT + } + +void CBtmsCtrl::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Ctrl")) + if (NotifyItem() == ENotifyAudioClosedByRemote) + { + if (iRfcomm->Service() == EBTProfileHFP) + { + Parent().RemoteAudioClosed(iRfcomm->Remote(), EHFP); + } + else + { + Parent().RemoteAudioClosed(iRfcomm->Remote(), EHSP); + } + } + if (!iSco && Parent().IsAccInuse()) + { + iSco = CBtmSyncSock::NewL(*this, Parent().SockServ()); + iSco->AcceptL(Parent().IsEdrSupported()); + } + if (iRfcomm->Service() == EBTProfileHSP) + { + Parent().LoadCmdHandlerL(EBtmcHSP, iRfcomm->Remote(), iRfcomm->AccessoryInitiatedConnection()); + } + } + +void CBtmsCtrl::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + if (iSco) + iSco->CancelAccept(); + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsDisconnect::NewL(Parent(), &aStatus, SwapStateRfcommSock())); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsCtrl::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + CBtmRfcommSock* rfcomm = iRfcomm; + iRfcomm = NULL; + CBtmSyncSock* sco = iSco; + iSco = NULL; + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), &aStatus, rfcomm, sco)); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsCtrl::AccInUse() + { + TRACE_FUNC + TInt err; + TRAP( err, + if (!iSco) + { + iSco = CBtmSyncSock::NewL(*this, Parent().SockServ()); + iSco->AcceptL(Parent().IsEdrSupported()); + } + ) + } + +void CBtmsCtrl::RfcommErrorL(TInt /*aErr*/) + { + if (iSco) + iSco->CancelAccept(); + } + +TBool CBtmsCtrl::CanDisableNrec() + { + return ETrue; + } + +void CBtmsCtrl::SyncLinkAcceptCompleteL(TInt aErr) + { + TRACE_FUNC + if (!aErr) + { + CBtmsAudio* next = CBtmsAudio::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iSco)); + next->SetNotifyItemAtEntry(ENotifyAudioOpenedByRemote); + Parent().ChangeStateL(next); + } + } + +void CBtmsCtrl::RfcommLinkInSniffModeL() + { + if (iRfcomm->Service() == EBTProfileHFP) + { + Parent().ChangeStateL(CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iSco))); + } + } + +void CBtmsCtrl::RequestCompletedL(CBtmActive& /*aActive*/) + { + if (iRfcomm->Service() == EBTProfileHSP) + { + TBTDevAddr addr = iRfcomm->Remote(); + iRfcomm->Disconnect(); + Parent().ChangeStateL(CBtmsHsTempd::NewL(Parent(), addr)); + } + else + { + iRfcomm->ActivateSniffRequester(); + } + } + +void CBtmsCtrl::CancelRequest(CBtmActive& /*aActive*/) + { + } + +CBtmsCtrl::CBtmsCtrl(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco) + : CBtmsInuse(aParent, NULL, aRfcomm), iSco(aSco) + { + iRfcomm->SetObserver(*this); + if (iSco) + { + iSco->SetObserver(*this); + } + } + +void CBtmsCtrl::ConstructL() + { + } + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsdisconnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsdisconnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2005-2006 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: The disconnect state definition +* +*/ + + +#include "btmsdisconnect.h" +#include "btmsyncsock.h" +#include "btmrfcommsock.h" +#include "btmslisten.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsDisconnect* CBtmsDisconnect::NewL(CBtmMan& aParent, TRequestStatus* aRequest, CBtmRfcommSock* aRfcomm) + { + CBtmsDisconnect* self = new( ELeave ) CBtmsDisconnect(aParent, aRequest, aRfcomm); + return self; + } + +CBtmsDisconnect::~CBtmsDisconnect() + { + TRACE_FUNC + } + +void CBtmsDisconnect::SetConnectFailReason(TInt aReason) + { + iConnectFailReason = aReason; + } + +void CBtmsDisconnect::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Disconnect")) + Parent().DeleteCmdHandler(); + iRfcomm->SetObserver(*this); + iRfcomm->Disconnect(); + } + +void CBtmsDisconnect::RfcommErrorL(TInt aErr) + { + TRACE_FUNC + delete iRfcomm; + iRfcomm = NULL; + CompleteStateRequest(aErr); + } + +void CBtmsDisconnect::RfcommShutdownCompletedL(TInt aErr) + { + TRACE_FUNC + if (iConnectFailReason) + { + CompleteStateRequest(iConnectFailReason); + } + else + { + CompleteStateRequest(aErr); + } + Parent().ChangeStateL(CBtmsListen::NewL(Parent())); + } + +CBtmsDisconnect::CBtmsDisconnect(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm) : CBtmsInuse(aParent, aRequest, aRfcomm) + { + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsidle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsidle.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2005-2006 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: The state idle definition +* +*/ + + +// INCLUDE FILES +#include "btmsidle.h" +#include "btmsconnect.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsIdle* CBtmsIdle::NewL(CBtmMan& aParent) + { + CBtmsIdle* self = new( ELeave ) CBtmsIdle(aParent); + return self; + } + +CBtmsIdle::~CBtmsIdle() + { + TRACE_FUNC + } + +void CBtmsIdle::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Idle")) + } + +// --------------------------------------------------------------------------- +// Move to Connect state +// --------------------------------------------------------------------------- +// +void CBtmsIdle::ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + Parent().ChangeStateL(CBtmsConnect::NewL(Parent(), &aStatus, aAddr, ERequestConnect)); + } + +CBtmsIdle::CBtmsIdle(CBtmMan& aParent) : CBtmState(aParent, NULL) + { + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsinuse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsinuse.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2005-2006 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: The in use state definition +* +*/ + + +// INCLUDE FILES +//#include +#include +#include "atcodec.h" +#include "btmsinuse.h" +#include "btmslisten.h" +#include "btmrfcommsock.h" +#include "btmsyncsock.h" +#include "btmsctrl.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsInuse::~CBtmsInuse() + { + delete iRfcomm; + } + + +void CBtmsInuse::ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + aStatus = KRequestPending; + if (iRfcomm->Remote() == aAddr) + { + CompleteRequest(&aStatus, KErrAlreadyExists); + } + else + { + CompleteRequest(&aStatus, KErrInUse); + } + } + +void CBtmsInuse::SendProtocolDataL(const TDesC8& aData) + { + TRACE_FUNC + iRfcomm->WriteL(aData); + } + +TBTDevAddr CBtmsInuse::Remote() + { + return (iRfcomm) ? iRfcomm->Remote() : TBTDevAddr(); + } + + +void CBtmsInuse::RfcommConnectCompletedL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void CBtmsInuse::RfcommAcceptCompletedL(TInt /*aErr*/, TUint /*aService*/) + { + TRACE_FUNC + } + +void CBtmsInuse::RfcommShutdownCompletedL(TInt /*aErr*/) + { + TRACE_FUNC + } + + +void CBtmsInuse::RfcommSendCompletedL(TInt aErr) + { + TRACE_FUNC + if (aErr) + { + if (iRfcomm->Service() == EBTProfileHFP) + { + Parent().AccessoryDisconnected(iRfcomm->Remote(), EHFP); + } + else + { + Parent().AccessoryDisconnected(iRfcomm->Remote(), EHSP); + } + RfcommErrorL(aErr); + Parent().ChangeStateL(CBtmsListen::NewL(Parent())); + } + } + +void CBtmsInuse::RfcommReceiveCompletedL(TInt aErr, const TDesC8& aData) + { + TRACE_FUNC + if (!aErr) + { + TRAP(aErr, Parent().NewProtocolDataL(aData)); + } + + if (aErr) + { + RfcommSendCompletedL(aErr); + } + } + +CBtmsInuse::CBtmsInuse(CBtmMan& aParent, TRequestStatus* aRequest, CBtmRfcommSock* aRfcomm) + : CBtmState(aParent, aRequest), iRfcomm(aRfcomm) + { + } + +CBtmRfcommSock* CBtmsInuse::SwapStateRfcommSock() + { + CBtmRfcommSock* sock = iRfcomm; + iRfcomm = NULL; + return sock; + } + +CBtmSyncSock* CBtmsInuse::SwapSyncSock(CBtmSyncSock*& aSyncSock) + { + CBtmSyncSock* sock = aSyncSock; + aSyncSock = NULL; + return sock; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmslisten.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmslisten.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2005-2006 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: The listen state definition +* +*/ + + +//#include +#include +#include "btmslisten.h" +#include "btmsidle.h" +#include "btmsconnect.h" +#include "btmsrfcomm.h" +#include "btmsctrl.h" +#include "btmrfcommsock.h" +#include "debug.h" +#include + + +// ======== MEMBER FUNCTIONS ======== + +CBtmsListen* CBtmsListen::NewL(CBtmMan& aParent) + { + CBtmsListen* self = new( ELeave ) CBtmsListen(aParent); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsListen::~CBtmsListen() + { + delete iHfpSock; + delete iHspSock; + } + +void CBtmsListen::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Listen")) + iHfpSock = CBtmRfcommSock::NewL(*this, Parent().SockServ()); + iHspSock = CBtmRfcommSock::NewL(*this, Parent().SockServ()); + if ( Parent().IsTrashBinEmpty() ) + { + StartListenerL(); + } + } +CBtmState* CBtmsListen::ErrorOnEntryL(TInt /*aReason*/) + { + TRACE_FUNC + return CBtmsIdle::NewL(Parent()); + } + +void CBtmsListen::StartListenerL() + { + TRACE_STATE(_L("[BTMAC State] Start Listener ")) + Parent().DeleteCmdHandler(); + TBTServiceSecurity sec; + sec.SetAuthorisation(ETrue); + sec.SetAuthentication(ETrue); + sec.SetEncryption(ETrue); + TUint ag = KBTSdpHandsfreeAudioGateway; + TInt lastUsedPort = Parent().GetLastUsedChannel(ag); + TRACE_STATE((_L("[BTMAC State] Start EBTProfileHFP, last used port %d"), lastUsedPort)) + iHfpSock->SetObserver(*this); + sec.SetUid(TUid::Uid(KBTSdpHandsfreeAudioGateway)); + Parent().RegisterServiceL(ag, iHfpSock->ListenL(ag, sec,lastUsedPort)); + iHfpSock->SetService(EBTProfileHFP); + iHspSock->SetObserver(*this); + sec.SetUid(TUid::Uid(KBTSdpHandsfreeAudioGateway)); + ag = KBTSdpHeadsetAudioGateway; + lastUsedPort = Parent().GetLastUsedChannel(ag); + TRACE_STATE((_L("[BTMAC State] Start EBTProfileHSP, last used port %d"), lastUsedPort)) + Parent().RegisterServiceL(ag, iHspSock->ListenL(ag, sec,lastUsedPort)); + iHspSock->SetService(EBTProfileHSP); + } + +void CBtmsListen::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if ( iHfpSock && iHspSock ) + { + iHfpSock->CancelListen(); + iHspSock->CancelListen(); + Parent().ChangeStateL(CBtmsConnect::NewL(Parent(), &aStatus, aAddr, ERequestOpenAudio)); + } + } + +void CBtmsListen::ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + if ( iHfpSock && iHspSock ) + { + iHfpSock->CancelListen(); + iHspSock->CancelListen(); + Parent().ChangeStateL(CBtmsConnect::NewL(Parent(), &aStatus, aAddr, ERequestConnect)); + } + } + +void CBtmsListen::RfcommAcceptCompletedL(TInt aErr, TUint aService) + { + TRACE_FUNC_ENTRY + if (!aErr) + { + CBtmRfcommSock* sock; + if (aService == EBTProfileHFP) + { + iHspSock->CancelListen(); + sock = iHfpSock; + iHfpSock = NULL; + Parent().ChangeStateL(CBtmsRfcomm::NewL(Parent(), NULL, sock, ERequestNone)); + } + else + { + iHfpSock->CancelListen(); + sock = iHspSock; + iHspSock = NULL; + Parent().NewAccessory(sock->Remote(), EHSP); + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), sock, NULL)); + } + + } + TRACE_FUNC_EXIT + } + +CBtmsListen::CBtmsListen(CBtmMan& aParent) : CBtmState(aParent, NULL) + { + } + +void CBtmsListen::ConstructL() + { + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsockobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsockobserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2005-2006 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: socket event observer default implementation +* +*/ + + +// INCLUDE FILES +#include "btmsockobserver.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +void MBtmSockObserver::RfcommConnectCompletedL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommAcceptCompletedL(TInt /*aErr*/, TUint /*aService*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommShutdownCompletedL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommSendCompletedL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommReceiveCompletedL(TInt /*aErr*/, const TDesC8& /*aData*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommIoctlCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommLinkInActiveModeL() + { + TRACE_FUNC + } + +void MBtmSockObserver::RfcommLinkInSniffModeL() + { + TRACE_FUNC + } + +void MBtmSockObserver::SyncLinkSetupCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::SyncLinkDisconnectCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::SyncLinkAcceptCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::SyncLinkSendCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void MBtmSockObserver::SyncLinkReceiveCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsopenaudio.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsopenaudio.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,200 @@ +/* +* Copyright (c) 2005-2006 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: The open audio state definition +* +*/ + +#include "btmsopenaudio.h" +#include "btmsdisconnect.h" +#include "btmrfcommsock.h" +#include "btmsyncsock.h" +#include "btmslisten.h" +#include "btmsctrl.h" +#include "btmssniffm.h" +#include "btmsaudio.h" +#include "debug.h" +#include + +// ======== MEMBER FUNCTIONS ======== + +CBtmsOpenAudio* CBtmsOpenAudio::NewL(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco, TBool aUseEsco, EESCOParam aESCOParameter) + { + CBtmsOpenAudio* self = new( ELeave ) CBtmsOpenAudio(aParent, aRequest, aRfcomm, aSco, aUseEsco, aESCOParameter); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsOpenAudio::~CBtmsOpenAudio() + { + delete iAcceptSco; + delete iSetupSco; + } + +void CBtmsOpenAudio::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Open Audio")) + if (!iAcceptSco) + { + iAcceptSco = CBtmSyncSock::NewL(*this, Parent().SockServ()); + iAcceptSco->AcceptL(Parent().IsEdrSupported()); + } + iSetupSco = CBtmSyncSock::NewL(*this, Parent().SockServ()); + if(Parent().IsEdrSupported() && iUseEsco) + { + iSetupSco->SetMaxLatency(KMaxLatencySpec); + iSetupSco->SetRetransmissionEffort(EeSCORetransmitDontCare); + iSetupSco->SetupL(iRfcomm->Remote(), TBTSyncPackets(iESCOParameter)); + } + else + { + iSetupSco->SetupL(iRfcomm->Remote(), TBTSyncPackets(KScoPacketTypeSpec)); + } + + if (iRfcomm->Service() == EBTProfileHSP) + { + Parent().LoadCmdHandlerL(EBtmcHSP, iRfcomm->Remote(), iRfcomm->AccessoryInitiatedConnection()); + } + } + +void CBtmsOpenAudio::Disconnect(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + CompleteRequest(&aStatus, KErrInUse); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsOpenAudio::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + aStatus = KRequestPending; + if (aAddr == iRfcomm->Remote()) + { + CompleteRequest(&aStatus, KErrAlreadyExists); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsOpenAudio::CancelOpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + iSetupSco->CancelSetup(); + CompleteStateRequest(KErrCancel); + if (iRfcomm->IsInSniff()) + { + Parent().ChangeStateL(CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco))); + } + else + { + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco))); + } + } + } + +void CBtmsOpenAudio::RfcommErrorL(TInt aErr) + { + TRACE_FUNC + if (iAcceptSco) + { + iAcceptSco->CancelAccept(); + } + if (iSetupSco) + { + iSetupSco->CancelSetup(); + } + CompleteStateRequest(aErr); + } + +void CBtmsOpenAudio::SyncLinkSetupCompleteL(TInt aErr) + { + TRACE_FUNC + if (aErr) + { + if(Parent().IsEdrSupported() && iESCOParameter != 0) + { + switch(iESCOParameter) + { + case EEV5: + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco), ETrue, EEV4)); + break; + case EEV4: + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco), ETrue, EEV3)); + break; + case EEV3: + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco), EFalse, ENoeSCO)); + break; + } + return; + } + else + { + TInt err4openaudio = (aErr == KErrInUse) ? KErrCouldNotConnect : aErr; + CompleteStateRequest(err4openaudio); + if (iRfcomm->IsInSniff()) + { + Parent().ChangeStateL(CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco))); + } + else + { + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco))); + } + } + } + else + { + iAcceptSco->CancelAccept(); + CompleteStateRequest(aErr); + Parent().ChangeStateL(CBtmsAudio::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iSetupSco))); + } + } + +void CBtmsOpenAudio::SyncLinkAcceptCompleteL(TInt aErr) + { + TRACE_FUNC + if (!aErr) + { + CompleteStateRequest(aErr); + iSetupSco->CancelSetup(); + Parent().ChangeStateL(CBtmsAudio::NewL(Parent(), SwapStateRfcommSock(), SwapSyncSock(iAcceptSco))); + } + } + +CBtmsOpenAudio::CBtmsOpenAudio(CBtmMan& aParent, TRequestStatus* aRequest, + CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco, TBool aUseEsco, EESCOParam aESCOParameter) + : CBtmsInuse(aParent, aRequest, aRfcomm), iAcceptSco(aSco), iUseEsco(aUseEsco), iESCOParameter(aESCOParameter) + { + if (iAcceptSco) + { + iAcceptSco->SetObserver(*this); + } + iRfcomm->SetObserver(*this); + } + +void CBtmsOpenAudio::ConstructL() + { + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsreconnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsreconnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2005-2006 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: The connect state definition +* +*/ + + +// INCLUDE FILES +//#include +#include "btengdiscovery.h" +#include "btengconstants.h" + +#include "btmsreconnect.h" +#include "btmslisten.h" +#include "btmstempd.h" +#include "btmsopenaudio.h" +#include "btmsctrl.h" +#include "btmrfcommsock.h" +#include "btmactive.h" +#include "btmsyncsock.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsReconnect* CBtmsReconnect::NewL(CBtmMan& aParent, TRequestStatus* aRequest, const TBTDevAddr& aAddr) + { + CBtmsReconnect* self = new( ELeave ) CBtmsReconnect(aParent, aRequest, aAddr); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsReconnect::~CBtmsReconnect() + { + delete iBteng; + } + +void CBtmsReconnect::EnterL() + { + TRACE_STATE(_L("[BTMAC State] HSP reconnect")) + TInt err = iBteng->RemoteProtocolChannelQuery(iSockAddr.BTAddr(), EBTProfileHSP); + if(err) + { + CompleteStateRequest(err); + } + } + +void CBtmsReconnect::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + aStatus = KRequestPending; + if (aAddr == iSockAddr.BTAddr()) + { + if (iRfcomm) + { + iRfcomm->CancelConnect(); + } + if (iBteng) + { + iBteng->CancelRemoteSdpQuery(); + } + CompleteRequest(&aStatus, KErrNone); + Parent().ChangeStateL(CBtmsListen::NewL(Parent())); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsReconnect::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + aStatus = KRequestPending; + if (aAddr == iSockAddr.BTAddr()) + { + CompleteRequest(&aStatus, KErrAlreadyExists); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsReconnect::CancelOpenAudioLinkL(const TBTDevAddr& aAddr) + { + if (aAddr == iSockAddr.BTAddr()) + { + if (iRfcomm) + { + iRfcomm->CancelConnect(); + } + CompleteStateRequest(KErrCancel); + Parent().ChangeStateL(CBtmsHsTempd::NewL(Parent(), iSockAddr.BTAddr())); + } + } + +void CBtmsReconnect::RfcommErrorL(TInt /*aErr*/) + { + // Not possible to happen + } + + +void CBtmsReconnect::AttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, const RSdpResultArray &aAttr, TInt aErr ) + { + if (aErr == KErrNone) + { + RSdpResultArray attr(aAttr); + CBTEngDiscovery::ParseRfcommChannel(attr, iRemoteChannel); + TRACE_INFO((_L("HSP channel %d"), iRemoteChannel)) + TRAP_IGNORE(DoSockConnectL(iRemoteChannel)); + } + else + { + CompleteStateRequest(aErr); + TRAP_IGNORE(Parent().ChangeStateL(CBtmsHsTempd::NewL(Parent(), iSockAddr.BTAddr()))); + } + } + + +CBtmsReconnect::CBtmsReconnect(CBtmMan& aParent, TRequestStatus* aRequest, const TBTDevAddr& aAddr) + : CBtmsInuse(aParent, aRequest, NULL) + { + iSockAddr.SetBTAddr(aAddr); + } + +void CBtmsReconnect::ConstructL() + { + iBteng = CBTEngDiscovery::NewL(this); + } + +void CBtmsReconnect::DoSockConnectL(TUint aService) + { + iRfcomm = CBtmRfcommSock::NewL(*this, Parent().SockServ()); + iSockAddr.SetBTAddr(iSockAddr.BTAddr()); + TBTServiceSecurity sec; + sec.SetAuthentication(ETrue); + sec.SetEncryption(ETrue); + iSockAddr.SetSecurity(sec); + iSockAddr.SetPort(iRemoteChannel); + iRfcomm->ConnectL(iSockAddr, aService); + } + +void CBtmsReconnect::RfcommConnectCompletedL(TInt aErr) + { + TRACE_FUNC + if (aErr) + { + CompleteStateRequest(aErr); + Parent().ChangeStateL(CBtmsHsTempd::NewL(Parent(), iSockAddr.BTAddr())); + } + else + { + Parent().LoadCmdHandlerL(EBtmcHSP, iRfcomm->Remote(), iRfcomm->AccessoryInitiatedConnection()); + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), SwapStateRfcommSock(), NULL)); + } + } + +void CBtmsReconnect::ServiceSearchComplete( const RSdpRecHandleArray& /*aResult*/, TUint /*aTotalRecordsCount*/, TInt /*aErr*/ ) {} + +void CBtmsReconnect::DeviceSearchComplete( CBTDevice* /*aDevice*/, TInt /*aErr*/ ) {} + +void CBtmsReconnect::ServiceAttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, const RSdpResultArray& aAttr, TInt aErr ) + { + if (aErr == KErrNone || (aErr == KErrEof && aAttr.Count()>0)) + { + RSdpResultArray attr(aAttr); + CBTEngDiscovery::ParseRfcommChannel(attr, iRemoteChannel); + TRACE_INFO((_L("HSP channel %d"), iRemoteChannel)) + TRAP_IGNORE(DoSockConnectL(EBTProfileHSP)); + } + else + { + CompleteStateRequest(aErr); + TRAP_IGNORE(Parent().ChangeStateL(CBtmsListen::NewL(Parent()))); + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsrfcomm.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsrfcomm.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 2005-2006 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: The RFCOMM connected state definition +* +*/ + + +// INCLUDE FILES +//#include +#include + +#include "btmrfcommsock.h" +#include "btmsrfcomm.h" +#include "btmsctrl.h" +#include "btmssniffm.h" +#include "btmsdisconnect.h" +#include "btmsopenaudio.h" +#include "debug.h" +#include "btmchandlerapi.h" +#include "btmcprofileid.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmsRfcomm* CBtmsRfcomm::NewL(CBtmMan& aParent, TRequestStatus* aStatus, + CBtmRfcommSock* aSock, TRequestCategory aRequestCat) + { + CBtmsRfcomm* self = new( ELeave ) CBtmsRfcomm(aParent, aStatus, aSock, aRequestCat); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsRfcomm::~CBtmsRfcomm() + { + } + +void CBtmsRfcomm::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Rfcomm")) + Parent().LoadCmdHandlerL(EBtmcHFP0105, iRfcomm->Remote(), iRfcomm->AccessoryInitiatedConnection()); + } + +void CBtmsRfcomm::CancelConnectL() + { + TRACE_FUNC + if (StateRequest() && iRequestCat == ERequestConnect) + { + CompleteStateRequest(KErrCancel); + CBtmsDisconnect* next = CBtmsDisconnect::NewL(Parent(), NULL, SwapStateRfcommSock()); + CleanupStack::PushL(next); + Parent().ChangeStateL(next); + CleanupStack::Pop(next); + } + } + +void CBtmsRfcomm::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsDisconnect::NewL(Parent(), &aStatus, SwapStateRfcommSock())); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsRfcomm::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + SetStateRequest(aStatus); + aStatus = KRequestPending; + iRequestCat = ERequestOpenAudio; + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsRfcomm::CancelOpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote() && iRequestCat == ERequestOpenAudio) + { + CompleteStateRequest(KErrCancel); + iRequestCat = ERequestNone; + } + } + +void CBtmsRfcomm::RfcommErrorL(TInt aErr) + { + CompleteStateRequest(aErr); + } + +void CBtmsRfcomm::SlcIndicateL(TBool aSlc) + { + TRACE_FUNC + if (!aSlc) + { + CBtmsDisconnect* next = CBtmsDisconnect::NewL(Parent(), SwapStateRequest(), SwapStateRfcommSock()); + next->SetConnectFailReason(KErrCouldNotConnect); + Parent().ChangeStateL(next); + } + else + { + if (StateRequest() && iRequestCat == ERequestConnect) + CompleteStateRequest(KErrNone); + else + Parent().NewAccessory(iRfcomm->Remote(), EHFP); + if (StateRequest() && iRequestCat == ERequestOpenAudio) + { + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), SwapStateRfcommSock(), NULL)); + } + else + { + if (iRfcomm->IsInSniff()) + { + Parent().ChangeStateL(CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), NULL)); + } + else + { + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), SwapStateRfcommSock(), NULL)); + } + } + } + } + +TBool CBtmsRfcomm::CanDisableNrec() + { + return ETrue; + } + +CBtmsRfcomm::CBtmsRfcomm(CBtmMan& aParent, TRequestStatus* aStatus, + CBtmRfcommSock* aRfcomm, TRequestCategory aRequestCat) + : CBtmsInuse(aParent, aStatus, aRfcomm), iRequestCat(aRequestCat) + { + iRfcomm->SetObserver(*this); + } + +void CBtmsRfcomm::ConstructL() + { + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmssniffm.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmssniffm.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,229 @@ +/* +* Copyright (c) 2005-2006 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: The sniff mode state definition +* +*/ + + +// INCLUDE FILES +#include "btmrfcommsock.h" +#include "btmsyncsock.h" +#include "btmsctrl.h" +#include "btmssniffm.h" +#include "btmslisten.h" +#include "btmsopenaudio.h" +#include "btmsdisconnect.h" +#include "btmsaudio.h" +#include "btmactive.h" +#include "debug.h" + +const TInt KTimerRequest = 20; + +const TInt KLinkActivatePeriodic = 550 * 1000; +const TInt KLinkActivateRetries = 4; + +// ======== MEMBER FUNCTIONS ======== + +CBtmsSniffm* CBtmsSniffm::NewL(CBtmMan& aParent, CBtmRfcommSock* aSock, CBtmSyncSock* aSco) + { + CBtmsSniffm* self = new( ELeave ) CBtmsSniffm(aParent, aSock, aSco); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmsSniffm::~CBtmsSniffm() + { + TRACE_FUNC_ENTRY + delete iActive; + iTimer.Close(); + delete iSco; + TRACE_FUNC_EXIT + } + +void CBtmsSniffm::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Sniffm")) + if (NotifyItem() == ENotifyAudioClosedByRemote) + { + Parent().RemoteAudioClosed(iRfcomm->Remote(), EHFP); + } + if (!iSco && Parent().IsAccInuse()) + { + iSco = CBtmSyncSock::NewL(*this, Parent().SockServ()); + iSco->AcceptL(Parent().IsEdrSupported()); + } + } + +void CBtmsSniffm::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + delete iActive; + iActive = NULL; + if (iSco) + iSco->CancelAccept(); + iRfcomm->RequestLinkToActiveMode(); + CBtmRfcommSock* rfcomm = iRfcomm; + iRfcomm = NULL; + aStatus = KRequestPending; + Parent().ChangeStateL(CBtmsDisconnect::NewL(Parent(), &aStatus, rfcomm)); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsSniffm::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + SetStateRequest(aStatus); + aStatus = KRequestPending; + iRfcomm->RequestLinkToActiveMode(); + iActive = CBtmActive::NewL(*this, CActive::EPriorityStandard, KTimerRequest); + iTimer.After(iActive->iStatus, KLinkActivatePeriodic); + iActive->GoActive(); + iLinkActivateRetries = 1; + } + else + { + CompleteRequest(&aStatus, KErrGeneral); + } + } + +void CBtmsSniffm::CancelOpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if (aAddr == iRfcomm->Remote()) + { + delete iActive; + iActive = NULL; + iSco->CancelAccept(); + CompleteStateRequest(KErrCancel); + } + } + +void CBtmsSniffm::RfcommErrorL(TInt /*aErr*/) + { + delete iActive; + iActive = NULL; + if (iSco) + iSco->CancelAccept(); + } + +void CBtmsSniffm::AccInUse() + { + TRACE_FUNC + TInt err; + TRAP(err, + if (!iSco) + { + iSco = CBtmSyncSock::NewL(*this, Parent().SockServ()); + iSco->AcceptL(Parent().IsEdrSupported()); + } + ) + } + +TBool CBtmsSniffm::CanDisableNrec() + { + return ETrue; + } + +void CBtmsSniffm::SyncLinkAcceptCompleteL(TInt aErr) + { + TRACE_FUNC + if (!aErr) + { + delete iActive; + iActive = NULL; + CBtmRfcommSock* rfcomm = iRfcomm; + iRfcomm = NULL; + CBtmSyncSock* sco = iSco; + iSco = NULL; + CBtmsAudio* next = CBtmsAudio::NewL(Parent(), rfcomm, sco); + if (StateRequest()) + { + CompleteStateRequest(KErrNone); + } + else + { + next->SetNotifyItemAtEntry(ENotifyAudioOpenedByRemote); + } + Parent().ChangeStateL(next); + } + } + +void CBtmsSniffm::RfcommLinkInActiveModeL() + { + TRACE_FUNC + delete iActive; + iActive = NULL; + CBtmRfcommSock* rfcomm = iRfcomm; + iRfcomm = NULL; + CBtmSyncSock* sco = iSco; + iSco = NULL; + if (StateRequest()) + { + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), rfcomm, sco)); + } + else + { + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), rfcomm, sco)); + } + } + +void CBtmsSniffm::RequestCompletedL(CBtmActive& /*aActive*/) + { + if (iLinkActivateRetries < KLinkActivateRetries) + { + iRfcomm->RequestLinkToActiveMode(); + iTimer.After(iActive->iStatus, KLinkActivatePeriodic); + iActive->GoActive(); + iLinkActivateRetries++; + } + else if (StateRequest()) + { + CBtmRfcommSock* rfcomm = iRfcomm; + iRfcomm = NULL; + CBtmSyncSock* sco = iSco; + iSco = NULL; + Parent().ChangeStateL(CBtmsOpenAudio::NewL(Parent(), SwapStateRequest(), rfcomm, sco)); + } + } + +void CBtmsSniffm::CancelRequest(CBtmActive& /*aActive*/) + { + iTimer.Cancel(); + } + +CBtmsSniffm::CBtmsSniffm(CBtmMan& aParent, CBtmRfcommSock* aRfcomm, CBtmSyncSock* aSco) + : CBtmsInuse(aParent, NULL, aRfcomm), iSco(aSco) + { + iRfcomm->SetObserver(*this); + if (iSco) + { + iSco->SetObserver(*this); + } + } + +void CBtmsSniffm::ConstructL() + { + iTimer.CreateLocal(); + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmstate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmstate.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2005-2006 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: The base state definition +* Version : %version: 2.1.5 % +* +* Copyright © 2005-2006 Nokia. All rights reserved. +*/ + + +// INCLUDE FILES +#include "btmstate.h" +#include "btmsidle.h" +#include "btmslisten.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmState::~CBtmState() + { + CompleteStateRequest(KErrAbort); + } + +void CBtmState::SetNotifyItemAtEntry(TNotifyItem aNotify) + { + iNotify = aNotify; + } + +TNotifyItem CBtmState::NotifyItem() + { + return iNotify; + } + +// --------------------------------------------------------------------------- +// returns CBtmsListen +// --------------------------------------------------------------------------- +// +CBtmState* CBtmState::ErrorOnEntryL(TInt /*aReason*/) + { + TRACE_FUNC + return CBtmsListen::NewL(iParent); + } + +// --------------------------------------------------------------------------- +// Completes with KErrInUse by default +// --------------------------------------------------------------------------- +// +void CBtmState::ConnectL(const TBTDevAddr& /*aAddr*/, TRequestStatus& aStatus) + { + TRACE_FUNC + CompleteRequest(&aStatus, KErrInUse); + } + +void CBtmState::CancelConnectL() + { + TRACE_FUNC + } + +// --------------------------------------------------------------------------- +// Completes with KErrNotFound by default +// --------------------------------------------------------------------------- +// +void CBtmState::DisconnectL(const TBTDevAddr& /*aAddr*/, TRequestStatus& aStatus) + { + TRACE_FUNC + CompleteRequest(&aStatus, KErrNotFound); + } + +// --------------------------------------------------------------------------- +// Completes with KErrNotReady by default +// --------------------------------------------------------------------------- +// +void CBtmState::OpenAudioLinkL(const TBTDevAddr& /*aAddr*/, TRequestStatus& aStatus) + { + TRACE_FUNC + CompleteRequest(&aStatus, KErrNotFound); + } + +void CBtmState::CancelOpenAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + } + +// --------------------------------------------------------------------------- +// Completes with KErrNotFound by default +// --------------------------------------------------------------------------- +// +void CBtmState::CloseAudioLinkL(const TBTDevAddr& /*aAddr*/, TRequestStatus& aStatus) + { + TRACE_FUNC + CompleteRequest(&aStatus, KErrNotFound); + } + +void CBtmState::CancelCloseAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + } + +void CBtmState::AccInUse() + { + TRACE_FUNC + } + +void CBtmState::SlcIndicateL(TBool /*aSlc*/) + { + TRACE_FUNC + } + +void CBtmState::SendProtocolDataL(const TDesC8& /*aData*/) + { + TRACE_FUNC + } + +TBool CBtmState::CanDisableNrec() + { + return EFalse; + } + +TBTDevAddr CBtmState::Remote() + { + return TBTDevAddr(); + } + +CBtmState::CBtmState(CBtmMan& aParent, TRequestStatus* aRequest) + : iParent(aParent), iRequest(aRequest) + { + } + +CBtmMan& CBtmState::Parent() + { + return iParent; + } + +void CBtmState::CompleteStateRequest(TInt aErr) + { + if (iRequest) + { + TRACE_INFO((_L("State request 0x%08X completed with %d"), iRequest, aErr)) + User::RequestComplete(iRequest, aErr); + } + } + +void CBtmState::CompleteRequest(TRequestStatus* aStatus, TInt aErr) + { + if (aStatus) + { + TRACE_INFO((_L("Request 0x%08X completed with %d"), aStatus, aErr)) + User::RequestComplete(aStatus, aErr); + } + } + +TRequestStatus* CBtmState::StateRequest() + { + return iRequest; + } + +void CBtmState::SetStateRequest(TRequestStatus& aStatus) + { + iRequest = &aStatus; + } + +TRequestStatus* CBtmState::SwapStateRequest() + { + TRequestStatus* swap = iRequest; + iRequest = NULL; + return swap; + } + +void CBtmState::StartListenerL() + { + TRACE_FUNC + } + +TInt CBtmState::AudioLinkLatency() + { + TRACE_FUNC + return KErrNotFound; + } + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmstempd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmstempd.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2005-2006 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: The temporarily disconnect state definition +* +*/ + +//#include +#include "btmstempd.h" +#include "btmsctrl.h" +#include "btmsyncsock.h" +#include "btmrfcommsock.h" +#include "btmslisten.h" +#include "btmsreconnect.h" +#include "btmsdisconnect.h" +#include "debug.h" +#include + +// ======== MEMBER FUNCTIONS ======== + +CBtmsHsTempd* CBtmsHsTempd::NewL(CBtmMan& aParent, const TBTDevAddr& aConnectedAddr) + { + CBtmsHsTempd* self = new( ELeave ) CBtmsHsTempd(aParent, aConnectedAddr); + return self; + } + +CBtmsHsTempd::~CBtmsHsTempd() + { + } + +void CBtmsHsTempd::EnterL() + { + TRACE_STATE(_L("[BTMAC State] Tempd")) + Parent().DeleteCmdHandler(); + + TBTServiceSecurity sec; + sec.SetAuthorisation(ETrue); + sec.SetAuthentication(ETrue); + sec.SetEncryption(ETrue); + TUint ag = KBTSdpHeadsetAudioGateway; + iRfcomm = CBtmRfcommSock::NewL(*this, Parent().SockServ()); + sec.SetUid(TUid::Uid(KBTSdpHeadsetAudioGateway)); + iRfcomm->SetService(EBTProfileHSP); + TInt lastUsedPort = Parent().GetLastUsedChannel(KBTSdpHeadsetAudioGateway); + Parent().RegisterServiceL(ag, iRfcomm->ListenL(ag, sec,lastUsedPort)); + } + +void CBtmsHsTempd::DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + aStatus = KRequestPending; + if (aAddr == iConnectedAddr) + { + CompleteRequest(&aStatus, KErrNone); + Parent().ChangeStateL(CBtmsListen::NewL(Parent())); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsHsTempd::OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + aStatus = KRequestPending; + if (aAddr == iConnectedAddr) + { + iRfcomm->CancelListen(); + Parent().ChangeStateL(CBtmsReconnect::NewL(Parent(), &aStatus, aAddr)); + } + else + { + CompleteRequest(&aStatus, KErrNotFound); + } + } + +void CBtmsHsTempd::RfcommErrorL(TInt /*aErr*/) + { + // Not possible to happen + } + +void CBtmsHsTempd::RfcommAcceptCompletedL(TInt /*aErr*/, TUint /*aService*/) + { + TRACE_FUNC_ENTRY + if (iConnectedAddr == iRfcomm->Remote()) + { + CBtmRfcommSock* rfcomm = iRfcomm; + iRfcomm = NULL; + Parent().ChangeStateL(CBtmsCtrl::NewL(Parent(), rfcomm, NULL)); + } + else + { + iRfcomm->Disconnect(); + Parent().ChangeStateL(CBtmsHsTempd::NewL(Parent(), iConnectedAddr)); + } + TRACE_FUNC_EXIT + } + + +CBtmsHsTempd::CBtmsHsTempd(CBtmMan& aParent, const TBTDevAddr& aConnectedAddr) + : CBtmsInuse(aParent, NULL, NULL), iConnectedAddr(aConnectedAddr) + { + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmac/btmsyncsock.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmac/btmsyncsock.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,223 @@ +/* +* Copyright (c) 2005-2006 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: BT sync socket +* Version : %version: 4.2.4 % +* +*/ + + +#include +#include "btmsyncsock.h" +#include "btmsockobserver.h" +#include "btmdefs.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtmSyncSock* CBtmSyncSock::NewL(MBtmSockObserver& aNotifier, RSocketServ& aSockServ) + { + CBtmSyncSock* self = new (ELeave) CBtmSyncSock(aNotifier, aSockServ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBtmSyncSock::~CBtmSyncSock() + { + TRACE_FUNC_ENTRY + delete iSco; + delete iEScoLink; + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::SetupL(const TBTDevAddr& aAddr, const TBTSyncPackets& aPackets) + { + TRACE_FUNC_ENTRY + iSco->SetupConnection(aAddr, aPackets); + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::CancelSetup() + { + TRACE_FUNC_ENTRY + iSco->CancelSetup(); + iSco->Disconnect(); + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::DisconnectL() + { + TRACE_FUNC_ENTRY + if (iConnectedLink) + iConnectedLink->Disconnect(); + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::AcceptL(TBool aAllowEsco) + { + TRACE_FUNC_ENTRY + iScoAcceptor = TScoAcceptor(this); + iSco->SetNotifier(iScoAcceptor); + iSco->AcceptConnection(TBTSyncPackets(KScoPacketTypeSpec)); + if (aAllowEsco) + { + iESco_Acceptor = TScoAcceptor(this); + iEScoLink = CBluetoothSynchronousLink::NewL(iESco_Acceptor, iServer); + iEScoLink->AcceptConnection(TBTSyncPackets(KEscoPacketTypeSpec)); + } + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::CancelAccept() + { + TRACE_FUNC_ENTRY + if (iSco) + { + iSco->CancelAccept(); + } + if (iEScoLink) + { + iEScoLink->CancelAccept(); + } + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::SetMaxLatency(TUint16 aLatency) + { + iSco->SetMaxLatency(aLatency); + if (iEScoLink) + iEScoLink->SetMaxLatency(aLatency); + } + +void CBtmSyncSock::SetRetransmissionEffort(TBTeSCORetransmissionTypes aRetransmissionEffort) + { + iSco->SetRetransmissionEffort(aRetransmissionEffort); + if (iEScoLink) + iEScoLink->SetRetransmissionEffort(aRetransmissionEffort); + } + +void CBtmSyncSock::Reset() + { + TRACE_FUNC_ENTRY + + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::SetObserver(MBtmSockObserver& aObserver) + { + iObserver = &aObserver; + } + +TInt CBtmSyncSock::Latency() + { + TRACE_FUNC + return TInt(iSco->Latency()); + } + +void CBtmSyncSock::HandleSetupConnectionCompleteL(TInt aErr) + { + TRACE_FUNC + iConnectedLink = iSco; + iObserver->SyncLinkSetupCompleteL(aErr); + } + +void CBtmSyncSock::HandleDisconnectionCompleteL(TInt aErr) + { + TRACE_FUNC_ENTRY + iConnectedLink = NULL; + iObserver->SyncLinkDisconnectCompleteL(aErr); + TRACE_FUNC_EXIT + } + +void CBtmSyncSock::HandleAcceptConnectionCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void CBtmSyncSock::HandleSendCompleteL(TInt aErr) + { + iObserver->SyncLinkSendCompleteL(aErr); + } + +void CBtmSyncSock::HandleReceiveCompleteL(TInt aErr) + { + TRACE_ERROR(_L("CBtmSyncSock::HandleReceiveCompleteL")) + iObserver->SyncLinkReceiveCompleteL(aErr); + } + +CBtmSyncSock::CBtmSyncSock(MBtmSockObserver& aObserver, RSocketServ& aSockServ) + : iObserver(&aObserver), iServer(aSockServ) + { + } + +void CBtmSyncSock::ConstructL() + { + TRACE_FUNC + iSco = CBluetoothSynchronousLink::NewL(*this, iServer); + } + +void CBtmSyncSock::AcceptRedirectL(TInt aErr, TScoAcceptor& aAcceptor) + { + TRACE_FUNC + if (&aAcceptor == &iScoAcceptor) + { + TRACE_INFO((_L("Sync link type SCO"))) + iConnectedLink = iSco; + if (iEScoLink) + iEScoLink->CancelAccept(); + } + else + { + TRACE_INFO((_L("Sync link type ESCO"))) + iConnectedLink = iEScoLink; + iSco->CancelAccept(); + } + iConnectedLink->SetNotifier(*this); + iObserver->SyncLinkAcceptCompleteL(aErr); + } + +CBtmSyncSock::TScoAcceptor::TScoAcceptor() + { + TScoAcceptor(NULL); + } + +CBtmSyncSock::TScoAcceptor::TScoAcceptor(CBtmSyncSock* aParent) + : iParent(aParent) + { + } + +void CBtmSyncSock::TScoAcceptor::HandleSetupConnectionCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } + +void CBtmSyncSock::TScoAcceptor::HandleDisconnectionCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } +void CBtmSyncSock::TScoAcceptor::HandleAcceptConnectionCompleteL(TInt aErr) + { + TRACE_FUNC + iParent->AcceptRedirectL(aErr, *this); + } + +void CBtmSyncSock::TScoAcceptor::HandleSendCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } +void CBtmSyncSock::TScoAcceptor::HandleReceiveCompleteL(TInt /*aErr*/) + { + TRACE_FUNC + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmonobearer/bmbcmdlistener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmonobearer/bmbcmdlistener.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2005-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: +* This class implements RemCon bearer pulgin interface. +* +*/ + +#include "bmbcmdlistener.h" +#include +#include "debug.h" +#include "bmbpanic.h" + +CBmbCmdListener* CBmbCmdListener::NewL(CBmbPlugin& aParent) + { + CBmbCmdListener* self = new(ELeave) CBmbCmdListener(aParent); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBmbCmdListener::~CBmbCmdListener() + { + Cancel(); + iProperty.Close(); + } + +// --------------------------------------------------------------------------- +// Send the response via PS, and starts listening the next command +// to be handled by this bearer. +// --------------------------------------------------------------------------- +// +void CBmbCmdListener::HandlingDataCompleted( const TDesC8& aResp ) + { + // No better error handling than ignoring it. + (void) iProperty.Set( aResp ); + // Handling previous received command has completed, this object + // is ready for picking up the next one, regardless of + // response sent successfully or not. + Subscribe(); + TRACE_FUNC + } + +CBmbCmdListener::CBmbCmdListener(CBmbPlugin& aParent) + : CActive(CActive::EPriorityStandard), iParent(aParent) + { + CActiveScheduler::Add(this); + } + +void CBmbCmdListener::ConstructL() + { + TRACE_FUNC + LEAVE_IF_ERROR(iProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTATCodec)); + Subscribe(); + } + +void CBmbCmdListener::RunL() + { + TRACE_FUNC + TInt err = iStatus.Int(); + // Error could be received from Subscribe when the PS + // key is deleted due to powering BT off. In + // this case, we just re-subscribe. + if(err == KErrNone) + { + iAtCmdBuf.Zero(); + err = iProperty.Get(iAtCmdBuf); + if ( !err && iAtCmdBuf.Length() > 0 ) + { + // An AT command to be processed by iParent. + // At command handling completion, iParent will call this object + // to send out response via HandlingDataCompleted() + // which will subscribe to PS key update after the response has been + // sent. + iParent.DataFromRemote(iAtCmdBuf); + } + else + { + // No valid command in the PS key, re-subscribe. + err = KErrArgument; + } + } + TRACE_ERROR((_L8("listener Status %d"), err)) + // If err is 0, this object shall not immediately listen to new commands via + // Subscribe() function while a command is under processing by iParent. + // Btmonocmdhandler ensures not to deliver + // the next command to this bearer while a command is being processed. + if(err != KErrNone) + { + Subscribe(); + } + } + +void CBmbCmdListener::DoCancel() + { + iProperty.Cancel(); + } + +void CBmbCmdListener::Subscribe() + { + __ASSERT_ALWAYS( !IsActive(), Panic(EBmbPanicCmdListenerBadState) ); + iProperty.Subscribe(iStatus); + SetActive(); + TRACE_FUNC + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmonobearer/bmbmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmonobearer/bmbmain.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2005 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: ECom implementation table +* +*/ + + +#ifndef BTASBAUDIOSERVICEPLUGINMAIN_H +#define BTASBAUDIOSERVICEPLUGINMAIN_H + +// INCLUDE FILES +#include +#include "bmbplugin.h" + +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x101FBAE9, CBmbPlugin::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmonobearer/bmbplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmonobearer/bmbplugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,308 @@ +/* +* Copyright (c) 2005-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: +* This class implements RemCon bearer pulgin interface. +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include "atcodec.h" +#include "bmbserviceuid.h" +#include "bmbplugin.h" +#include "debug.h" +#include "bmbcmdlistener.h" +#include + +class SRemConExtCallHandlingOpToCmd + { + public: + TRemConExtCallHandlingApiOperationId ifId; + TATId brId; + TATType brType; + }; + +const SRemConExtCallHandlingOpToCmd KRemConExtCallHandlingOpToCmd[] = + { + {ERemConExtAnswerCall, EATA, EATActionCmd}, + {ERemConExtEndCall, EATCHUP, EATActionCmd}, + {ERemConExtDialCall, EATD1, EATActionCmd}, + {ERemConExtSpeedDial, EATD2, EATActionCmd}, + {ERemConExtVoiceDial, EATBVRA, EATWriteCmd}, + {ERemConExtLastNumberRedial, EATBLDN, EATActionCmd}, + {ERemConExt3WaysCalling, EATCHLD, EATWriteCmd}, + {ERemConExtGenerateDTMF, EATVTS, EATWriteCmd}, + {ERemConExtAnswerEnd, EATCKPD, EATWriteCmd} + }; + +const TInt KRemConExtCallHandlingOpNum = (sizeof(KRemConExtCallHandlingOpToCmd) / sizeof(SRemConExtCallHandlingOpToCmd)); + + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CBTAspAccConnection::NewL() +// --------------------------------------------------------- +// +CBmbPlugin* CBmbPlugin::NewL(TBearerParams& aParams) + { + CBmbPlugin* self = new (ELeave) CBmbPlugin(aParams); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// Destructor +CBmbPlugin::~CBmbPlugin() + { + TRACE_FUNC_ENTRY + delete iListener; + delete iPlayerControlListener; + if( iConnIndicated ) + { + Observer().DisconnectIndicate(iRemConAddress); + } + TRACE_FUNC_EXIT + } + +TAny* CBmbPlugin::GetInterface(TUid aUid) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("aUid = [0x%08X]"), this, aUid)) + TAny* ret = NULL; + if (aUid == TUid::Uid(KRemConBearerInterface1)) + { + ret = reinterpret_cast( + static_cast(this) + ); + } + TRACE_INFO((_L("ret = [0x%08X]"), ret)) + TRACE_FUNC_EXIT + return ret; + } + +TInt CBmbPlugin::GetResponse( + TUid& /*aInterfaceUid*/, + TUint& /*aTransactionId*/, + TUint& /*aOperationId*/, + RBuf8& /*aData*/, + TRemConAddress& /*aAddr*/) + { + TRACE_FUNC + return KErrNotSupported; + } + +TInt CBmbPlugin::SendCommand( + TUid /*aInterfaceUid*/, + TUint /*aOperationId*/, + TUint /*aTransactionId*/, + RBuf8& /*aData*/, + const TRemConAddress& /*aAddr*/) + { + TRACE_FUNC + return KErrNotSupported; + } + +void CBmbPlugin::DataFromRemote(const TDesC8& aATCmd) + { + TRACE_FUNC_ENTRY + if (!iConnIndicated) + { + iConnIndicated = ETrue; + Observer().ConnectIndicate(iRemConAddress); + } + + CATCommand *tmpCmd = NULL; + TRAPD(err, tmpCmd = CATCommand::NewL(aATCmd)); + if(!err) + { + TRACE_INFO((_L8("DataFromRemote: %S, Id: %d, type %d"), &aATCmd, tmpCmd->Id(), tmpCmd->Type())); + for (TInt i = 0; i < KRemConExtCallHandlingOpNum; i++) + { + if (KRemConExtCallHandlingOpToCmd[i].brId == tmpCmd->Id() && + tmpCmd->Type() == KRemConExtCallHandlingOpToCmd[i].brType) + { + iOperationId = (TUint)KRemConExtCallHandlingOpToCmd[i].ifId; + break; + } + } + + iInterfaceUid = TUid::Uid(KRemConExtCallHandlingApiUid); + iTransactionId = Observer().NewTransactionId(); + + if (tmpCmd->ParamNum()) + { + TATParam param; + tmpCmd->Parameter(0, param); + iInData.Copy(param.Des()); + } + else + { + iInData = KNullDesC8; + } + + TRACE_INFO((_L8(" iInterfaceUid 0x%08X, iOperationId %d, iInData '%S'"), + iInterfaceUid, iOperationId, &iInData)) + + err = Observer().NewCommand(iRemConAddress); + TRACE_INFO((_L("NewCommand return %d"), err)) + delete tmpCmd; + } + if (err) + { + TPckgBuf pckg(err); + iListener->HandlingDataCompleted( pckg ); + } + TRACE_FUNC_EXIT + } + +TInt CBmbPlugin::GetCommand( + TUid& aInterfaceUid, + TUint& aTransactionId, + TUint& aOperationId, + RBuf8& aData, + TRemConAddress& aAddr) + { + TRACE_FUNC + aInterfaceUid = iInterfaceUid; + aTransactionId = iTransactionId; + aOperationId = iOperationId; + TInt err = aData.Create(iInData); + if (err) + { + TRACE_ERROR((_L("RBuf8::Create err %d"), err)) + } + aAddr = iRemConAddress; + return err; + } + +TInt CBmbPlugin::SendResponse( + TUid aInterfaceUid, + TUint aOperationId, + TUint /*aTransactionId*/, + RBuf8& aData, + const TRemConAddress& aAddr) + { + TRACE_FUNC + TRACE_INFO((_L8("interface [0x%08X], op %d"), + aInterfaceUid, aOperationId)) + if (aInterfaceUid.iUid == KRemConCoreApiUid) + { + aData.Close(); + return KErrNone; + } + if (aInterfaceUid.iUid == KRemConExtCallHandlingApiUid && + iRemConAddress == aAddr && + iOperationId == aOperationId) + { + iListener->HandlingDataCompleted( aData ); + aData.Close(); + return KErrNone; + } + return KErrNotFound; + } + +void CBmbPlugin::ConnectRequest(const TRemConAddress& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L8("Request to connect to %S"), &(aAddr.Addr()))) + Observer().ConnectConfirm(aAddr, KErrNotSupported); + TRACE_FUNC_EXIT + } + +void CBmbPlugin::DisconnectRequest(const TRemConAddress& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L8("Request to disconnect %S"), &(aAddr.Addr()))) + Observer().DisconnectConfirm(aAddr, KErrNotSupported); + TRACE_FUNC_EXIT + } + +void CBmbPlugin::ClientStatus(TBool /*aControllerPresent*/, TBool /*aTargetPresent*/) + { + TRACE_FUNC + } + +TSecurityPolicy CBmbPlugin::SecurityPolicy() const + { + return TSecurityPolicy(ECapabilityLocalServices); + } +void CBmbPlugin::Pause() + { + TRACE_FUNC_ENTRY + if (!iConnIndicated) + { + iConnIndicated = ETrue; + Observer().ConnectIndicate(iRemConAddress); + } + + iOperationId = (TUint) ERemConCoreApiPause; + iInterfaceUid = TUid::Uid(KRemConCoreApiUid); + iTransactionId = Observer().NewTransactionId(); + + iInData = _L8("a"); + iInData[0] = ERemConCoreApiButtonClick; + + TRACE_INFO((_L8(" iInterfaceUid 0x%08X, iOperationId %d"), + iInterfaceUid, iOperationId)) + iRemConAddress.Addr() = KBTAudioServiceName; + TInt err = Observer().NewCommand(iRemConAddress); + TRACE_INFO((_L("NewCommand return %d"), err)) + TRACE_FUNC_EXIT + } + +void CBmbPlugin::Play() + { + TRACE_FUNC_ENTRY + if (!iConnIndicated) + { + iConnIndicated = ETrue; + Observer().ConnectIndicate(iRemConAddress); + } + + iOperationId = (TUint) ERemConCoreApiPlay; + iInterfaceUid = TUid::Uid(KRemConCoreApiUid); + iTransactionId = Observer().NewTransactionId(); + + iInData = _L8("a"); + iInData[0] = ERemConCoreApiButtonClick; + + TRACE_INFO((_L8(" iInterfaceUid 0x%08X, iOperationId %d"), + iInterfaceUid, iOperationId)) + iRemConAddress.Addr() = KBTAudioServiceName; + TInt err = Observer().NewCommand(iRemConAddress); + TRACE_INFO((_L("NewCommand return %d"), err)) + TRACE_FUNC_EXIT + } + +CBmbPlugin::CBmbPlugin(TBearerParams& aParams) +: CRemConBearerPlugin(aParams) + { + } + +void CBmbPlugin::ConstructL() + { + TRACE_FUNC_ENTRY + iRemConAddress.BearerUid() = Uid(); + iListener = CBmbCmdListener::NewL(*this); + iPlayerControlListener = CBTAudioPlayerControlListener::NewL(*this); + iRemConAddress.Addr() = KBTAudioServiceName; + TRACE_FUNC_EXIT + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btmac/src/btmonobearer/playercontrolistener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btmac/src/btmonobearer/playercontrolistener.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2005 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: +* This class implements RemCon bearer pulgin interface. +* +*/ + +#include "playercontrolistener.h" +#include +#include "debug.h" + +CBTAudioPlayerControlListener* CBTAudioPlayerControlListener::NewL(MBmbPlayerControl& aControl) + { + CBTAudioPlayerControlListener* self = new(ELeave) CBTAudioPlayerControlListener(aControl); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CBTAudioPlayerControlListener::~CBTAudioPlayerControlListener() + { + Cancel(); + iProperty.Close(); + } + +CBTAudioPlayerControlListener::CBTAudioPlayerControlListener(MBmbPlayerControl& aControl) + : CActive(CActive::EPriorityStandard), iControl(aControl) + { + CActiveScheduler::Add(this); + } + +void CBTAudioPlayerControlListener::ConstructL() + { + TRACE_FUNC + LEAVE_IF_ERROR(iProperty.Attach(KBTAudioRemCon, KBTAudioPlayerControl)); + Start(); + } + +void CBTAudioPlayerControlListener::RunL() + { + TRACE_FUNC + TRACE_INFO((_L8("listener Status %d"), iStatus.Int())) + TInt err = iStatus.Int(); + if (iStatus == KErrNone || iStatus == KErrNotFound ) + Start(); + if(!err) + { + TInt value = 0; + err = iProperty.Get(value); + if (!err) + { + if (value == EBTAudioPausePlayer) + iControl.Pause(); + else if (value == EBTAudioResumePlayer) + iControl.Play(); + } + } + } + +void CBTAudioPlayerControlListener::DoCancel() + { + iProperty.Cancel(); + } + +void CBTAudioPlayerControlListener::Start() + { + iProperty.Subscribe(iStatus); + SetActive(); + TRACE_FUNC + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/bmarm/Btnotifu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/bmarm/Btnotifu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + NotifierArray__Fv @ 1 NONAME R3UNUSED ; NotifierArray(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/bwins/Btnotifu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/bwins/Btnotifu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?NotifierArray@@YAPAV?$CArrayPtr@VMEikSrvNotifierBase2@@@@XZ @ 1 NONAME ; class CArrayPtr * __cdecl NotifierArray(void) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/data/BTNotif.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/data/BTNotif.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,763 @@ +/* +* Copyright (c) 2002 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: This file contains all the resources for the module BTNotif. +* +*/ + + +NAME BNOT + +#include + +#include + +#include +#include +#include +#include +#include +#include "btnotif.hrh" + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf=""; } + +// === ICONS ================================================================= + +//---------------------------------------------------- +// Icon array for BTNOTIF +//---------------------------------------------------- +// +RESOURCE AKN_ICON_ARRAY r_btnotif_icons + { + //This resource is removed because of skinable icon change. The title is still staying here + //to prevent intruducing BC break. + } + +// === TITLES AND PROMPTS ==================================================== + +//---------------------------------------------------- +// Titles for popup windows +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_search_devs_popup_title { buf = qtn_bt_searching_found; } + +RESOURCE TBUF r_bt_found_devs_popup_title { buf = qtn_bt_devices_found; } + +RESOURCE TBUF r_bt_last_seen_devs_popup_title { buf = qtn_bt_last_seen_devices; } + +RESOURCE TBUF r_bt_last_used_devs_popup_title { buf = qtn_bt_last_used_devices; } + +//---------------------------------------------------- +// Fixed list items +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_more_devices_item { buf = qtn_bt_more_devices; } + +//---------------------------------------------------- +// Prompts for queries +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_passkey_prompt { buf = qtn_bt_enter_pk_for_conn; } + +RESOURCE TBUF r_bt_dialog_def_name { buf = qtn_bt_dialog_def_name; } + +RESOURCE TBUF r_bt_authorisation_name { buf = qtn_bt_accept_conn_request; } + +RESOURCE TBUF r_bt_receive_message { buf = qtn_bt_receive_message; } + +RESOURCE TBUF r_bt_receive_message_paired { buf = qtn_bt_receive_message_paired; } + +RESOURCE TBUF r_bt_no_devices_found { buf =qtn_bt_no_devices_found; } +//same text than in r_bt_try_again_query + +RESOURCE TBUF r_bt_power_is_off { buf = qtn_bt_is_off; } +//same text than in R_BT_POWER_IS_OFF_QUERY + +RESOURCE TBUF r_bt_activate_in_offline { buf= qtn_bt_activate_in_offline; } +//same text than in R_BT_ACTIVATE_IN_OFFLINE_QUERY + +RESOURCE TBUF r_bt_is_hidden_java { buf=qtn_bt_is_hidden_java; } + +RESOURCE TBUF r_bt_is_off_java { buf=qtn_bt_is_off_java; } + +RESOURCE TBUF r_bt_is_hidden_java_appname { buf=qtn_bt_is_hidden_java_appname; } + +RESOURCE TBUF r_bt_is_off_java_appname { buf=qtn_bt_is_off_java_appname; } + +RESOURCE TBUF r_bt_turn_bt_off { buf = qtn_bt_dos_query; } + +RESOURCE TBUF r_bt_switch_off_anyway { buf= qtn_bt_switch_off_anyway; } + +//---------------------------------------------------- +// Headers of the r_bt_is_hidden_java and r_bt_is_off_java queries +//---------------------------------------------------- +RESOURCE TBUF r_bt_is_off_java_header { buf=qtn_bt_is_off_java_header ; } + +RESOURCE TBUF r_bt_is_hidden_java_header { buf=qtn_bt_is_hidden_java_header ; } + +//---------------------------------------------------- +// Prompts for global notes +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_audio_accessory_prompt { buf = qtn_bt_audio_accessory; } + +RESOURCE TBUF r_bt_audio_handset_prompt { buf = qtn_bt_audio_handset; } + +RESOURCE TBUF r_bt_conf_connected_prompt { buf = qtn_bt_conf_connected; } + +RESOURCE TBUF r_bt_conf_disconnected_prompt { buf = qtn_bt_conf_disconnected; } + +RESOURCE TBUF r_bt_conn_closed_prompt { buf = qtn_bt_conn_closed; } + +RESOURCE TBUF r_bt_device_not_avail { buf = qtn_bt_device_not_avail; } + +RESOURCE TBUF r_bt_offline_disabled { buf = qtn_bt_offline_disabled; } +//text of R_BT_BUSY +RESOURCE TBUF r_bt_busy_text { buf =qtn_bt_busy; } + +RESOURCE TBUF r_ir_not_supported { buf =qtn_ir_not_supported; } + + +//---------------------------------------------------- +// Default name array for BTNotif +// These names are used if no name is received in inquiry. +// Note! The order must match enum TBTDefaultDevNameArrayIndexes +// defined in BTNInqUi.cpp. +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_default_device_names + { + items = { + LBUF { txt=qtn_bt_computer; }, + LBUF { txt=qtn_bt_phone; }, + LBUF { txt=qtn_bt_audio; }, + LBUF { txt=qtn_bt_keyboard; }, + LBUF { txt=qtn_bt_mouse; }, + LBUF { txt=qtn_bt_printer; }, + LBUF { txt=qtn_bt_carkit; }, + LBUF { txt=qtn_bt_dialog_def_name; } + }; + } + + +// === SOFTKEYS ============================================================== + +//---------------------------------------------------- +// Softkeys for "Searching devices" wait note +//---------------------------------------------------- +// +RESOURCE CBA r_bt_softkeys_empty_cancel + { + buttons = + { + CBA_BUTTON {txt="";}, + CBA_BUTTON {id=EAknSoftkeyCancel; txt = text_softkey_cancel; } + }; + } + + +//---------------------------------------------------- +// Softkeys for found devices popup list +//---------------------------------------------------- +// +RESOURCE CBA r_bt_softkeys_select_stop + { + buttons = + { + CBA_BUTTON {id=EAknSoftkeySelect; txt = text_softkey_select;}, + CBA_BUTTON {id=EAknSoftkeyCancel; txt = qtn_bt_softkey_stop; }, + CBA_BUTTON {id=EAknSoftkeySelect; txt = text_softkey_select;} + }; + } + +// === QUERIES =============================================================== + +//---------------------------------------------------- +// PIN request query +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_enter_passkey_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + items = + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + label = qtn_bt_passkey_heading; + }; + }, + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + control = EDWIN + { + maxlength = KBTPassKeyMaxLength; + default_input_mode = EAknEditorNumericInputMode; + flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable; + avkon_flags = EAknEditorFlagLatinInputModesOnly; + }; + }; + } + }; + } + +//---------------------------------------------------- +// OBEX PIN request query +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_obex_passkey_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + label = qtn_bt_enter_obex_pcode; + control = EDWIN + { + maxlength = KBTPassKeyMaxLength; + default_input_mode = EAknEditorNumericInputMode; + flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable; + }; + }; + } + }; + } + +//---------------------------------------------------- +// Query for accepting incoming connections +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_authorisation_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// If device search has been unsuccessful, the new +// search is asked with this query from user. +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_try_again_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_bt_no_devices_found; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Ask BT power mode setting from user +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_power_is_off_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_bt_is_off; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Ask BT power mode setting from user in offline mode +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_activate_in_offline_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_bt_activate_in_offline; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Inform user that data receiving failed because of low memory. +//---------------------------------------------------- +// +RESOURCE DIALOG r_memlo_memory_low_data_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_memlo_memory_low_data; + animation = R_QGN_NOTE_ERROR_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Inform user that data receiving to MMC failed because of low memory. +//---------------------------------------------------- +// +RESOURCE DIALOG r_memlo_mmc_memory_low_data_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_memlo_mmc_memory_low_data; + animation = R_QGN_NOTE_ERROR_ANIM; + }; + } + }; + } + +RESOURCE DIALOG r_bt_passkey_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +// === NOTES ================================================================= + +//---------------------------------------------------- +// Wait note right after bluetooth device search +// has been launched. +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_searching_devices_note + { + flags = EAknWaitNoteFlags | EEikDialogFlagWait; + buttons = r_bt_softkeys_empty_cancel; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTNotifSearchingDevicesNote; + control = AVKON_NOTE + { + layout = EWaitLayout; + singular_label = qtn_bt_searching; + animation = R_QGN_GRAF_WAIT_BAR_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Information note when maximum number of connections +// is reached and new one could not be created. +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_busy_note + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTNotifBtBusyNote; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_busy; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } + + +// === ANIMATIONS ============================================================ + +//---------------------------------------------------- +// Animation for r_bt_searching_devices_popuplist +//---------------------------------------------------- +// +RESOURCE BMPANIM_DATA r_bt_animation_for_popuplist + { + frameinterval = 200; + playmode = EAknBitmapAnimationPlayModeCycle; + bmpfile = btnotif_bitmap_file_data_caging; + frames = r_bt_animation_for_popuplist_images; + } + +//---------------------------------------------------- +// Image frames for r_bt_animation_for_popuplist_images +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_animation_for_popuplist_images + { + items= + { + BMPANIM_FRAME {bmpid=EMbmBtnotifQgn_note_bt_popup_2; maskid=EMbmBtnotifQgn_note_bt_popup_2_mask; }, + BMPANIM_FRAME {bmpid=EMbmBtnotifQgn_note_bt_popup; maskid=EMbmBtnotifQgn_note_bt_popup_mask; }, + BMPANIM_FRAME {bmpid=EMbmBtnotifQgn_note_bt_popup_3; maskid=EMbmBtnotifQgn_note_bt_popup_3_mask; }, + BMPANIM_FRAME {bmpid=EMbmBtnotifQgn_note_bt_popup; maskid=EMbmBtnotifQgn_note_bt_popup_mask; } + }; + } + +//--------------------------------------------------------------- +// Prompts for Remote SIM Access Profile notes +//---------------------------------------------------------------- +RESOURCE TBUF r_bt_enter_sap_note { buf = qtn_bt_wait_sap_entering; } + +RESOURCE TBUF r_bt_enter_sap_succeed_note { buf = qtn_bt_sap_entering_succeeded; } + +RESOURCE TBUF r_bt_enter_sap_failed_note { buf = qtn_bt_sap_entering_failed; } + +RESOURCE TBUF r_bt_min_passkey_prompt { buf = qtn_bt_enter_pk_sap; } + +//---------------------------------------------------- +// Data query "Enter Bluetooth name for your phone" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_enter_local_name_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + label = qtn_enter_bt_name; + control = EDWIN + { + flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable; + maxlength = KBTUIMaxNameLength; + }; + }; + } + }; + } +// --------------------------------------------------- +// +// r_bt_generic_message_query +// +// This is the query blanket used by Generic Message queries. +// They are java power and java visibility at the time +// of this writing, but probably in the future there will be +// others. +// --------------------------------------------------- +// +RESOURCE DIALOG r_bt_generic_message_query + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + }; + } + }; + } + +//---------------------------------------------------- +// r_bt_generic_query +// +// This is the blanket for all the generic yes/no queries, which +// do NOT use message query. This is not only used by CBTNGenericQueryNotifier +// but other notifiers such as PinNotifier use also this. +// +// NOTE: There is no blanket for empty genric message. +// It is just based on empty CAknInformationNote. +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_generic_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Information note that will be shown when temp +// visibility expire. +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_hidden_from_others_note + { + buf = qtn_bt_hidden_from_others; + } +//---------------------------------------------------- +// Block devices related items +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_block_device_header + { + buf = qtn_bt_block_device_header; + } + +//---------------------------------------------------- +// Blocking question asked, when the +// user is asked about blocking a non-paired device. +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_block_device_nohelp + { + buf= qtn_bt_block_all_conn_attempts; + } + +//---------------------------------------------------- +// Blocking question asked, when the +// user is asked about blocking a paired device. +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_block_paired_device_nohelp + { + buf= qtn_bt_block_paired_device; + } + +//---------------------------------------------------- +// Query for incoming pairing request +//---------------------------------------------------- +RESOURCE TBUF r_bt_accept_pairing_request + { + buf=qtn_bt_accept_pairing_request; + } + +//---------------------------------------------------- +// Information note that will be shown when temp +// visibility expire. +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_no_device_discovery_voip { buf = qtn_bt_no_device_discovery_voip; } + +//---------------------------------------------------- +// Information note that will be shown if SIM card +// is not available while trying SAP connection. +//---------------------------------------------------- +// + +RESOURCE TBUF r_bt_sap_no_sim_note { buf = qtn_bt_sap_no_sim; } + +//---------------------------------------------------- +// Information note when maximum number of connections +// is reached and new one could not be created. +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_turn_bt_off_note + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + label = qtn_bt_dos_query; + }; + } + }; + } + + +//--------------------------------------------------- +// Title for search filter +//--------------------------------------------------- +RESOURCE TBUF r_bt_search_filter_popup_title { buf = qtn_bt_search_for; } + +//---------------------------------------------------- +//List item text in search filter +//---------------------------------------------------- +RESOURCE TBUF r_bt_search_for_all { buf = qtn_bt_search_for_all; } +RESOURCE TBUF r_bt_search_for_phone { buf = qtn_bt_search_for_phone; } +RESOURCE TBUF r_bt_search_for_computer { buf = qtn_bt_search_for_computer; } +RESOURCE TBUF r_bt_search_for_audio { buf = qtn_bt_search_for_audio; } +RESOURCE TBUF r_bt_search_for_input { buf = qtn_bt_search_for_input; } + +//------------------------------------------------------------ +// query for unblocking selected blocked device +//------------------------------------------------------------ +RESOURCE DIALOG r_bt_unblock_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_unblock_device { buf = qtn_bt_unblock_device; } + +//---------------------------------------------------- +// Information note for AVRCP 1.3 Battery low info +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_accessory_low { buf = qtn_bt_accessory_low; } +RESOURCE TBUF r_bt_accessory_critical { buf = qtn_bt_accessory_critical; } +RESOURCE TBUF r_bt_permanently_on { buf = qtn_bt_permanently_on; } +RESOURCE TBUF r_bt_switched_on { buf = qtn_bt_switched_on; } +RESOURCE TBUF r_bt_switched_off { buf = qtn_bt_switched_off; } + +//---------------------------------------------------- +// SSP NumericComparison and PasskeyEntry +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_ssp_passkey_comparison_prompt { buf = qtn_bt_simple_passkey_comparison; } +RESOURCE TBUF r_bt_ssp_passkey_entry { buf = qtn_bt_simple_passkey_entry; } + +//---------------------------------------------------- +// Confirmation note "Pairing successfully done with %U" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_succesfully_paired_prompt { buf = qtn_bt_succesfully_paired; } + +//---------------------------------------------------- +// Error notes of SSP +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_pairing_failed_prompt { buf = qtn_bt_pairing_failed; } +RESOURCE TBUF r_bt_ssp_busy { buf = qtn_bt_simple_busy; } + +//----------------------------------------------------------------------------- +// Confirmation note "Authorise this device to make connections automatically?" +//----------------------------------------------------------------------------- +// +RESOURCE TBUF r_bt_authorization_prompt { buf = qtn_bt_authorisation_query; } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/eabi/BTNotifu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/eabi/BTNotifu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z13NotifierArrayv @ 1 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/ecom/101FD68F.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/ecom/101FD68F.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2002 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: This file specifies the interface and implementation information +* for BTnotif Ecom Plugins. +* +*/ + + +#include +#include + +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#endif + +RESOURCE REGISTRY_INFO theInfo +{ + dll_uid = 0x101FD68F; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KUikonUidPluginInterfaceNotifiers; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x101FD690; + version_no = 1; + display_name = "TTNOTIFY2V2 Plugin 1"; + default_data = "TTNOTIFY2V2"; + opaque_data = "0"; + } + }; + } + }; +} diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2004 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: Methods for BT notifier Ecom Plugins entry point +* +*/ + + +#include +#include // link against aknnotifierwrapper.lib +#include +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include // define btninqnotifer uid +#else +#include // define btninqnotifer uid +#include // define btninqnotifer uid +#endif +#include // notifier id for power mode setting + +const TInt KMaxSynchReplyBufLength = 256; //what should be? + +const TUid KBTInquiryChannel = {0x00000601}; // Channel for inquiry notifier +const TUid KBTAuthorisationChannel = {0x00000602}; // Channel for authorisation notifier +const TUid KBTAuthenticationChannel = {0x00000603}; // Channel for PIN query notifier +const TUid KBTObexPINChannel = {0x00000605}; // Channel for OBEX PIN notifier +const TUid KBTPowerModeChannel = {0x00000606}; // Channel for power mode notifier +const TUid KBTPairedDeviceSettingChannel = {0x00000610}; // Channel for Visibility timeout notifier + +const TInt KBTInquiryPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; +const TInt KBTAuthorisationPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; +const TInt KBTAuthenticationPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; +const TInt KBTObexPinPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; +const TInt KBTPowerModePriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; +const TInt KBTGenericInfoNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; +const TInt KBTGenericQueryNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; +const TInt KBTNumericComparisonPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP +const TInt KBTPasskeyEntryNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP +const TInt KBTPairedDeviceSettingPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; +const TInt KBTEnterpriseItSecurityInfoNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; + +const TInt KBTNotifierArrayIncrement = 8; + +void CleanupArray(TAny* aArray) + { + CArrayPtrFlat* + subjects=static_cast*>(aArray); + TInt lastInd = subjects->Count()-1; + for (TInt i=lastInd; i >= 0; i--) + subjects->At(i)->Release(); + delete subjects; + } + +CArrayPtr* DoCreateNotifierArrayL() + { + + CArrayPtrFlat* subjects= + new (ELeave)CArrayPtrFlat(KBTNotifierArrayIncrement); + + CleanupStack::PushL(TCleanupItem(CleanupArray, subjects)); + + // Create Wrappers + + // Session owning notifier(if default implementation is enough) + + CAknCommonNotifierWrapper* master = + CAknCommonNotifierWrapper::NewL( KDeviceSelectionNotifierUid, + KBTInquiryChannel, + KBTInquiryPriority, + _L("BTNotif.dll"), + KMaxSynchReplyBufLength); + + subjects->AppendL( master ); + + // Notifiers using masters session + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTManAuthNotifierUid, + KBTAuthorisationChannel, + KBTAuthorisationPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTPinCodeEntryNotifierUid, + KBTAuthenticationChannel, + KBTAuthenticationPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTObexPasskeyQueryNotifierUid, + KBTObexPINChannel, + KBTObexPinPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KPowerModeSettingNotifierUid, + KBTPowerModeChannel, + KBTPowerModePriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTGenericInfoNotifierUid, + KBTGenericInfoNotifierUid, + KBTGenericInfoNotifierPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTGenericQueryNotifierUid, + KBTGenericQueryNotifierUid, + KBTGenericQueryNotifierPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KPbapAuthNotifierUid, + KBTObexPINChannel, + KBTObexPinPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTPairedDeviceSettingNotifierUid, + KBTPairedDeviceSettingChannel, + KBTPairedDeviceSettingPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTNumericComparisonNotifierUid, + KBTNumericComparisonNotifierUid, + KBTNumericComparisonPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTPasskeyDisplayNotifierUid, + KBTPasskeyDisplayNotifierUid, + KBTPasskeyEntryNotifierPriority)); + + subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, + KBTEnterpriseItSecurityInfoNotifierUid, + KBTEnterpriseItSecurityInfoNotifierUid, + KBTEnterpriseItSecurityInfoNotifierPriority)); + + CleanupStack::Pop(); // array cleanup + return(subjects); + } + + +CArrayPtr* NotifierArray() + // old Lib main entry point + { + + CArrayPtr* array = 0; + TRAPD(ignore, array = DoCreateNotifierArrayL()); + if (ignore != KErrNone) + { + ignore = KErrNone; + } + return array; + } + +const TImplementationProxy ImplementationTable[] = + { +#ifdef __EABI__ + {{0x101FD690},(TFuncPtr)NotifierArray} +#else + {{0x101FD690},NotifierArray} +#endif + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy) ; + return ImplementationTable; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/ecom/BtnotifWrapper.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/ecom/BtnotifWrapper.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2004 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: This is project specification file for the BTNotif Ecom Plugins. +* +*/ + + +#include + +TARGET btnotifwrapper.DLL +CAPABILITY CAP_ECOM_PLUGIN +TARGETTYPE PLUGIN + +VENDORID VID_DEFAULT + +UID 0x10009D8D 0x101FD68F + +SOURCEPATH . +USERINCLUDE ../inc + + +SYSTEMINCLUDE /epoc32/include/ecom +MW_LAYER_SYSTEMINCLUDE + + + +LANG SC +SOURCE BtnotifWrapper.cpp +START RESOURCE 101FD68F.rss +TARGET btnotifwrapper.rsc +END + +LIBRARY ECOM.LIB +LIBRARY AKNNOTIFIERWRAPPER.LIB +LIBRARY EUSER.LIB diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/group/BTNotif.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/group/BTNotif.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2002 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: This is project specification file for the BTNotif. +* +*/ + +#include +#include + +TARGET BTNotif.dll +TARGETTYPE DLL +UID 0x101fdfae 0x10005953 +TARGETPATH SHARED_LIB_DIR + +VENDORID VID_DEFAULT +SOURCEPATH ../src +SOURCE BTNMain.cpp +SOURCE BTNotifier.cpp +SOURCE BTNAuthNotifier.cpp +SOURCE BTNPinNotifier.cpp +SOURCE BTNInqNotifier.cpp +SOURCE BTNInqUI.cpp +SOURCE BTNInquiAO.cpp +SOURCE BTNObexPinNotifier.cpp +SOURCE BTNPwrNotifier.cpp +SOURCE BTNGenericInfoNotifier.cpp +SOURCE BTNGenericQueryNotifier.cpp +SOURCE BTNPBAPPinNotifier.cpp +SOURCE btnpaireddevsettnotifier.cpp +SOURCE btnssppasskeyentrynotifier.cpp +SOURCE btnumcmpnotifier.cpp +SOURCE btnotifuiutil.cpp +SOURCE btnotifactive.cpp +SOURCE btnpairnotifier.cpp +SOURCE btnotifnameutils.cpp +SOURCE btnenterpriseitsecurityinfonotifier.cpp + +START RESOURCE ../data/BTNotif.rss +HEADER +TARGETPATH RESOURCE_FILES_DIR +LANGUAGE_IDS +END + +USERINCLUDE ../inc +SYSTEMINCLUDE ../../inc //for private API headers (BluetoothEngine subsystem) +SYSTEMINCLUDE ../../../inc //for internal API headers (localconnectivity) +APP_LAYER_SYSTEMINCLUDE // Standard system include paths + +LIBRARY euser.lib cone.lib // Symbian OS framework libraries +LIBRARY avkon.lib // UI library +LIBRARY bafl.lib // Basic Application Framework Library +LIBRARY bluetooth.lib // Bluetooth libraries +LIBRARY btdevice.lib // Bluetooth library +LIBRARY btextnotifiers.lib // Bluetooth library + +//Bteng New APIs +LIBRARY btengdevman.lib //btengdevman.dll +LIBRARY btengsettings.lib //btengsettings.dll +LIBRARY btengconnman.lib //btengconnman.dll + +LIBRARY commonengine.lib // Series 60 common components library +LIBRARY charconv.lib // Character conversion library +LIBRARY eikcoctl.lib eiksrv.lib // Eikon libraries +LIBRARY eikcore.lib // Library for eikonEnv static functions (BringForwards) +LIBRARY eiksrvui.lib // Eikon server ui (for suppressing app -key) +LIBRARY esock.lib // Sockects library for host resolver +LIBRARY AknSkins.lib // Skinned icons +LIBRARY aknicon.lib +LIBRARY aknNotifierWrapper.lib +LIBRARY centralrepository.lib // Central Repository +LIBRARY egul.lib +LIBRARY CdlEngine.lib AknLayout2.lib +LIBRARY btmanclient.lib // reguired by TBTRegistrySearch +LIBRARY hlplch.lib // required by help callback + +// For cover display support: +LIBRARY eikdlg.lib +LIBRARY estor.lib +LIBRARY FeatMgr.lib +LIBRARY efsrv.lib +LIBRARY etul.lib + +DEBUGLIBRARY flogger.lib // File logging services + +//Optional for codewarrior ide +//DOCUMENT data/BTNotif.rss +//DOCUMENT BTNotif.loc + +CAPABILITY CAP_GENERAL_DLL +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2002 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: This file provides building information for BTNotif. +* +*/ + + +#include + +PRJ_PLATFORMS +//DEFAULT + +PRJ_EXPORTS +../loc/btnotif.loc MW_LAYER_LOC_EXPORT_PATH(btnotif.loc) +../rom/Btnotif.iby CORE_MW_LAYER_IBY_EXPORT_PATH(Btnotif.iby) +../rom/BtnotifResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(BtnotifResources.iby) +../inc/devui_const.h |../../inc/devui_const.h + +PRJ_EXTENSIONS + +START EXTENSION s60/mifconv +OPTION TARGETFILE btnotif.mif +OPTION HEADERFILE btnotif.mbg +OPTION SOURCES -c8,8 qgn_note_bt_popup -c8,8 qgn_note_bt_popup_2 \ + -c8,8 qgn_note_bt_popup_3 -c8,8 qgn_indi_bt_blocked +END + +PRJ_MMPFILES + +// gnumakefile btnotif_icons_dc.mk + +../group/BTNotif.mmp +../ecom/BtnotifWrapper.mmp + +PRJ_TESTMMPFILES + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/group/btnotif_icons_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/group/btnotif_icons_dc.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +# TODO: Configure these +# ---------------------------------------------------------------------------- + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\btnotif.mif + +HEADERDIR=\epoc32\include +HEADERFILENAME=$(HEADERDIR)\btnotif.mbg + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# TODO: Configure these. +# +# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by +# MifConv if the mask detph is defined. +# +# NOTE 2: Usually, source paths should not be included in the bitmap +# definitions. MifConv searches for the icons in all icon directories in a +# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps. +# The directory \s60\icons is included in the search only if the feature flag +# __SCALABLE_ICONS is defined. +# ---------------------------------------------------------------------------- + +RESOURCE : + mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ + /c8,8 qgn_note_bt_popup.bmp \ + /c8,8 qgn_note_bt_popup_2.bmp \ + /c8,8 qgn_note_bt_popup_3.bmp \ + /c8,8 qgn_indi_bt_blocked.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(HEADERFILENAME)&& \ + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2002 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: Declares generic information notifier class. +* +*/ + + +#ifndef BTNGENERICINFONNOTIFIER_H +#define BTNGENERICINFONNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class + +// FORWARD DECLARATIONS +class CAknInformationNote; + +// CLASS DECLARATION +NONSHARABLE_CLASS(CBTGenericInfoNotifier) : public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTGenericInfoNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTGenericInfoNotifier(); + + private: // Functions from base classes + + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** From CBTNotifierBase Synchronic notifier launch. + * @param aBuffer Received parameter data. + * @return A pointer to return value. + */ + TPtrC8 StartL(const TDesC8& aBuffer ); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From CBTNotifierBase + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + private: + + /** + * Parse the data out of the message that is sent by the client of the notifier. + * @param aBuffer A package buffer containing received parameters. + * @return None. + */ + void ProcessParamBufferL(const TDesC8& aBuffer); + + /** + * C++ default constructor. + */ + CBTGenericInfoNotifier(); + + /** + * Show Information note and complete message. + */ + void ShowNoteAndCompleteL(); + + private: + HBufC* iQueryMessage; + TInt iMessageResourceId; + TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand; + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2002 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: Declares Generic Query Notifier Class. +* +*/ + + +#ifndef BTNGENERICQUERYNOTIFIER_H +#define BTNGENERICQUERYNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +NONSHARABLE_CLASS(CBTGenericQueryNotifier) : public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTGenericQueryNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTGenericQueryNotifier(); + + private: // Functions from base classes + + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** From CBTNotifierBase Synchronic notifier launch. + * @param aBuffer Received parameter data. + * @return A pointer to return value. + */ + TPtrC8 StartL(const TDesC8& aBuffer ); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From CBTNotifierBase Updates a currently active notifier. + * @param aBuffer The updated data. + * @return A pointer to return value. + */ + TPtrC8 UpdateL(const TDesC8& aBuffer); + + private: + + /** + * Parse the data out of the message that is sent by the client of the notifier. + * @param aBuffer A package buffer containing received parameters. + * @return None. + */ + void ProcessParamBufferL(const TDesC8& aBuffer); + + /** + * C++ default constructor. + */ + CBTGenericQueryNotifier(); + + /** + * Show query and complete message. + */ + void ShowQueryAndCompleteL(); + + private: + + HBufC* iQueryMessage; + HBufC* iQueryHeader; + HBufC* iName; + + TInt iMessageResourceId; + TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand; + TBool iIsMessageQuery; + TBool iIsNameQuery; + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btNotifDebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btNotifDebug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2002 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: This file defines logging macros for BT Notifiers +* +*/ + + +#ifndef BTNOTIF_DEBUG_H +#define BTNOTIF_DEBUG_H + + +#ifdef _DEBUG + +#include +#include + +// =========================================================================== +#ifdef __WINS__ // File logging for WINS +// =========================================================================== +#define FLOG(a) { FPrint(a); } +#define FTRACE(a) { a; } + +#include +#include + +_LIT(KLogFile,"btnotiflog.txt"); +_LIT(KLogDirFullName,"c:\\logs\\bt\\"); +_LIT(KLogDir,"BT"); + +// Declare the FPrint function +inline void FPrint(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); + } + +inline void FPrint(TRefByValue aFmt, ...) + { + + VA_LIST list; + VA_START(list, aFmt); + TBuf8<256> buf8; + buf8.AppendFormatList(aFmt, list); + + TBuf16<256> buf16(buf8.Length()); + buf16.Copy(buf8); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, buf16); + } + +// =========================================================================== +#else // RDebug logging for target HW +// =========================================================================== +#define FLOG(a) { RDebug::Print(a); } +#define FTRACE(a) { a; } + +inline void FPrint(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + TInt tmpInt = VA_ARG(list, TInt); + TInt tmpInt2 = VA_ARG(list, TInt); + TInt tmpInt3 = VA_ARG(list, TInt); + VA_END(list); + RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3); + } + +inline void FPrint(TRefByValue aFmt, ...) + { + + VA_LIST list; + VA_START(list, aFmt); + TBuf8<256> buf8; + buf8.AppendFormatList(aFmt, list); + + TBuf16<256> buf16(buf8.Length()); + buf16.Copy(buf8); + + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + } + +#endif //__WINS__ + +// =========================================================================== +#else // // No loggings --> Reduced binary size +// =========================================================================== +#define FLOG(a) +#define FTRACE(a) + +#endif // _DEBUG + + +#endif // BTNOTIF_DEBUG_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnauthnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnauthnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2002 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: Declares authorisation notifier class. +* +*/ + + +#ifndef BTNAUTHNOTIFIER_H +#define BTNAUTHNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class +#include "btnotiflock.h" +#include "btnotifactive.h" +#include +#include + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +NONSHARABLE_CLASS(CBTAuthNotifier): public CBTNotifierBase, public MBTNotifActiveObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTAuthNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTAuthNotifier(); + + private: // Functions from base classes + + /** + * From CBTNotifierBase Called when a notifier is first loaded. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Updates a currently active notifier. + * @param aBuffer The updated data. + * @return A pointer to return value. + */ + TPtrC8 UpdateL(const TDesC8& aBuffer); + + /** + * From CBTNotifierBase The notifier has been deactivated + * so resources can be freed and outstanding messages completed. + * @param None. + * @return None. + */ + void Cancel(); + + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From CBTNotifierBase + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + /** + * From MBTNotifActiveObserver + * Gets called when P&S key notifies change. + */ + void RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTNotifActiveObserver + */ + void HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ); + + /** + * From MBTNotifActiveObserver + */ + void DoCancelRequest( CBTNotifActive* aActive, TInt aId ); + + private: + + /** Checks if the notifier should be replied automatically and not shown to user. + * + *@the device + *@ return TRUE if the notifier should be replied immediately yes or no, without showing query. + */ + TBool GetByPassAudioNotifier(const TBTDevAddr& aDevice,TBool& aAccept); + + /** + *@param aAccepted. ETrue if user accepted the incoming audio connection. EFalse if not. + *@param aDeviceAddress. The address of the device that attempted audio connection. + */ + void MemorizeCurrentAudioAttempt(const TBool aAccept,const TBTDevAddr& aDeviceAddress); + + /** + * C++ default constructor. + */ + CBTAuthNotifier(); + + /** + * Ask user's response for authorization query + */ + void ShowAuthoQueryL(); + + /** + * After user rejects authorization, provide user the chance to turn BT off + * if it is a within a threshold. Query block the device according to logic of + * "second time for the same paired device". + */ + void DoRejectAuthorizationL(); + + /** + * Subscribe to P&S Key and check its value + */ + void CheckAndSubscribeNotifLocks(); + + private: // Data definitions + + enum TBTAuthState + { + EBTNormalAuthorisation, // Normal authorisation + EBTAutoAuthorisation, // Automated Authorisation + EBTAutoAuthorisationNotAuthorisedOnPhone, + EBTObexAuthorisation, // Obex authorisation for non paired devices + EBTObexAuthForPairedDevice // Obex authorisation for paired devices + + }; + + private: // Data + + TBTAuthState iAuthState; // Authorisation state + TInt iStrResourceId; + TSecondaryDisplayBTnotifDialogs iCoverUiDlgId; + TUint iServiceUid; + TBool iSuspended; + RProperty iNotifLockProp; + CBTNotifActive* iLockActive; + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnenterpriseitsecurityinfonotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnenterpriseitsecurityinfonotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 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: Declares generic information notifier class. +* +*/ + +#ifndef BTNENTERPRISEITSECURITYINFONNOTIFIER_H +#define BTNENTERPRISEITSECURITYINFONNOTIFIER_H + +// INCLUDES +#include "btnotifier.h" // Base class + +// CLASS DECLARATION +NONSHARABLE_CLASS(CBTEnterpriseItSecurityInfoNotifier) : public CBTNotifierBase + { +public: // Constructors and destructor + /** + * Two-phased constructor. + */ + static CBTEnterpriseItSecurityInfoNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTEnterpriseItSecurityInfoNotifier(); + +private: // Functions from base classes + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** From CBTNotifierBase Synchronic notifier launch. + * @param aBuffer Received parameter data. + * @return A pointer to return value. + */ + TPtrC8 StartL(const TDesC8& aBuffer); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From CBTNotifierBase + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + +private: + /** + * C++ default constructor. + */ + CBTEnterpriseItSecurityInfoNotifier(); + + /** + * Show Information note and complete message. + */ + void ShowNoteAndCompleteL(); + }; + +#endif //BTNENTERPRISEITSECURITYINFONNOTIFIER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btninqnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btninqnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth device inquiry notifier class. +* +*/ + + +#ifndef BTNINQNOTIFIER_H +#define BTNINQNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class +#include "btninqui.h" +#include // Bluetooth notifiers API + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +/** +* This class is used in Bluetooth device search. +*/ +NONSHARABLE_CLASS(CBTInqNotifier): public CBTNotifierBase, public MBTNDeviceSearchObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTInqNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTInqNotifier(); + + + private: // Functions from base classes + /** + * From CBTNotifierBase Called when a notifier is first loaded. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase The notifier has been deactivated + * so resources can be freed and outstanding messages completed. + * @param None. + * @return None. + */ + void Cancel(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From MBTNDeviceSearchObserver Called when device search and selection completes. + * @param aErr Error code + * @param aDevice Response parameters to caller + * defined in epoc32\include\btextnotifiers.h + */ + void NotifyDeviceSearchCompleted(TInt aErr, const TBTDeviceResponseParams& aDevice = TBTDeviceResponseParams()); + + private: + + /** + * C++ default constructor. + */ + CBTInqNotifier(); + + void LaunchInquiryL(const TBTDeviceClass& aDesiredDevice); + + private: // Data + + CBTInqUI* iUi; // User interface module + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btninqui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btninqui.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,355 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth device inquiry user interface class. +* +*/ + + +#ifndef BTNINQUI_H +#define BTNINQUI_H + +// INCLUDES + +#include // Bluetooth notifiers API +#include // For array handling +#include +#include "btnotifactive.h" // Active Object Helper class for inquiry +#include +#include +#include "btnotifier.h" + +const TInt KPeriodicTimerInterval4Sec(4000000); + + +// FORWARD DECLARATIONS + +class CAknStaticNoteDialog; +class CAknSingleGraphicPopupMenuStyleListBox; +class CAknPopupList; +class CAknQueryDialog; +class CBTInqNotifier; + +// CONSTANTS +enum TSearchFlowState + { + ESearchCompleted, // search completed for any reason, end of UI flow. + ESearchAgain, // no device found, user wants to search again. + ESearchFirstDeviceFound, // the first device is found, show found device list. + }; + +// CLASS DECLARATION +/** + * Class MBTNDeviceSearchObserver + * + * Callback class to notify device searching completed. + */ +class MBTNDeviceSearchObserver + { +public: + + /** + * Callback to notify that the device search request has completed. + * + * @since S60 5.1 + * @param aErr Error code + * @param aDevice Pckgbuf to retrieve the response from the device selection. + */ + virtual void NotifyDeviceSearchCompleted(TInt aErr, + const TBTDeviceResponseParams& aDevice = TBTDeviceResponseParams()) = 0; + }; + +/** +* A helper class used in Bluetooth device search. +* This class is responsible of the UI activity. +*/ +NONSHARABLE_CLASS(CBTInqUI) : public CBase, public MBTEngDevManObserver, public MBTNotifActiveObserver + { + public: // Constructor and destructor + /** + * C++ default constructor. + */ + CBTInqUI( MBTNDeviceSearchObserver* aObserver, + CBTNotifUIUtil* aUtil, const TBTDeviceClass& aDesiredDevClass); + + /** + * The 2nd phase constructor is required to do Asyncronous operations, + * So the readiness of the CBTInqUI is notified Asynchronously to the caller + */ + void ConstructL(); + + /** + * Destructor. + */ + virtual ~CBTInqUI(); + + public: // New functions + + /** + * Cancels all inquiry activity. + */ + void Cancel(); + + /** + * Issues a device inquiry request. + * @param None. + * @return None. + */ + void IssueRequestL(); + + /** + * Check if Eir device name available. + * @param TNameEntry Decode it to get device name + * @param TBTDeviceName Device name returned + * @return ETrue if Eir data contains name. + */ + static TBool CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName ); + + private: // Functions from base classes + + /** + * From MBTNotifActiveObserver + */ + void RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTNotifActiveObserver + */ + void HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ); + + /** + * From MBTNotifActiveObserver + */ + void DoCancelRequest( CBTNotifActive* aActive, TInt aId ); + + /** + * From MBTEngDevManObserver + */ + void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray); + + /** + * From MBTEngDevManObserver + */ + void HandleDevManComplete(TInt aErr); + + + private: + + /** + * Create the device search active object and prepare for search. + */ + void CreateScannerL(); + + /** + * Removes the device search active object if it still exists. + * @param None. + * @return None. + */ + void RemoveScanner(); + + /** + * Retrieves paired devices from BT Registry + * Calls HandleGetDevicesComplete, when done + */ + void RetrievePairedDevices(); + + /** + * Retrieves used devices from BT Registry + * Calls HandleGetDevicesComplete, when done + * @return None. + */ + void RetrieveUsedDevices(); + + /** + * Searches given BT Device from device array. + * @param aDeviceArray The device array to search in + * @param aDevice The device to be searched. + * @return Index of the device if found. + */ + TInt LookupFromDevicesArray( const CBTDeviceArray* aDeviceArray, const CBTDevice* aDevice ) const; + + /** + * Constructs a device popup list from resources. + * @param aSoftkeysResourceId Resource id for softkeys of the list. + * @param aTitleResourceId Resource id for the title of the list. + * @return None. + */ + void CreatePopupListL(TInt aSoftkeysResourceId, TInt aTitleResourceId ); + + /** + * Generates a format string and adds it to iDeviceItems array. + * Updates friendly name of given device if one is found from registry. + * @param aDevice The device to be added to list. + * @param aSignalStrength The signal bar for RSSI + * @return None. + */ + void UpdateDeviceListL(CBTDevice* aDevice, const TInt aSignalStrength = 0 ); + + /** + * Creates and adds local bitmap to icon array. + * @param aID Item ID of the masked bitmap to be created. + * @param aFilename Filename to be used to construct the item. + * @param aBitmapId The ID if bitmap + * @param aMaskId The ID of bitmap's mask + * @param aIconList The icon list for BT devices listbox. + */ + void CreateAndAppendIconL( const TAknsItemID& aID, + const TDesC& aFileName, + const TInt aBitmapId, + const TInt aMaskId, + CAknIconArray* aIconList); + + /** + * Adjust array, leave 5 lastet used devices in the array and remove the rest, + * and then insert the paired device array to this array by used time order. + * In the adjusted array, the first item will be the most lately used device. + * @param aDevArray The bluetooth device arrary to be adjusted. + * @return None. + */ + void AdjustDeviceArrayL( CBTDeviceArray* aDevArray); + + /** + * Filter for searching device + * @param The desired device class user selects from the filter + * @return User's input select/cancel + */ + void SelectSearchCategoryL(); + + /** + * Add filtering items to search device filter + * @param aResourceId + * @return None + */ + void AddItemToSearchFilterL ( TInt aResourceId ); + + /** + * Show query to ask if unblock device + * @param aDevice Selected device + * @return Keypress value + */ + TInt QueryUnblockDeviceL(CBTDevice* aDevice); + + /** + * The callback function for CPeriodic + * to reset the inactivity time + */ + static TInt PeriodicTimerCallBack(TAny* /*aAny*/); + + void GetColorIconL( TFileName& aFilename, TAknsItemID aItemID, TInt aPic, TInt aPicmask, CAknIconArray* aIconList ); + + /** + * Check if VoIP call is ongoing via WLAN connection. + * @return true if it is; false otherwise. + */ + TBool IsActiveVoIPOverWLAN(); + + void DoDeviceFrontListSelection(); + + /** + * Displays previous inquiry results. + */ + void DisplayDevicesFrontListL(); + + /** + * Unblock device after unblock query. + * @param aIndex Parameter containing information about selected device. + * @return Symbian OS error code. + */ + TInt UnblockDevice(TInt aIndex); + + void DeviceSearchUiL(); + + /** + * the initiator of inquiry until the first device found, or no device found, or + * other reasons causing inquiry stopped. + * @param aReason the reason of the search completion + */ + TSearchFlowState InitInquiryL(TInt& aReason); + + void HandleDeviceSelectionL(CBTDevice* aDev); + + /** + * Adds found Bluetooth device into popup list. + * @param aInquiryResultRecord TNameEntry and flag, which indicates if Eir device. + */ + void DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName); + + /** + * The inquiry has been completed. + * @param aError Status code of the operation. + * @return None. + */ + void InquiryComplete( TInt aError ); + + /** + * Inform the caller of the properties of found BTdevice, + * which passes the search filter. Its name will be retrived later + */ + void HandleInquiryDeviceL(); + + void HandleFoundNameL(); + + /** + * Allow/Disallow dialer and app key presses. + * @param aAllow ETrue to allow key press; EFalse to disallow. + */ + void AllowDialerAndAppKeyPress( TBool aAllow ); + + private: // Data + CBTNotifUIUtil* iUiUtil; + CBTDeviceArray* iLastSeenDevicesArray; // Last seen devices array from BTInqNotifier + CBTDeviceArray* iLastUsedDevicesArray; // Used devices from BT registry + CBTDeviceArray* iPairedDevicesArray; // Paired devices from Bluetooth registry + CBTDeviceArray* iAdjustedUsedDeviceArray; // 5 Lately used devices + All the Paired devices + CBTEngDevMan* iDevMan; //Async deviceHandler + + CDesCArray* iDefaultDeviceNamesArray; // Default device names array + CEikonEnv& iEikonEnvRef; // Reference to eikonenv + + CAknPopupList* iDevicePopupList; // Popup list for devices + CDesCArrayFlat* iDeviceListRows; // Array for device list format string rows + CAknSingleGraphicPopupMenuStyleListBox* iDeviceListBox; // ListBox for bluetooth devices + CAknPopupList* iSearchFilterPopupList; + + CBTNotifActive* iScanner; + + TBool iDevicesFound; // Flag if any devices has been found + TBool iInquiryComplete; + TBool iBroughtForwards; // Flag for BringForwards + TInt iInquiryStatus; // Error code from inquiry result + + TBTRegistryQueryState iBTRegistryQueryState; // which registry query (if any) is in progress. + TBTDeviceClass iDesiredDeviceClass; // Device Class user selects from search filter + CPeriodic* iPeriodicTimer; // the timer for reseting the user inactivity time + TBool iSystemCancel; // Used for a trick to avoid final device list is still on show + // while taking out mmc during BT device discovery + TBTDeviceResponseParams iDevParams; + TInt iHighLightedItemIndex; + + RSocketServ iSocketServer; // Socket server object + RHostResolver iHostResolver; // Host resolver object + TInquirySockAddr iInquirySockAddr; // Socket address record + TNameEntry iEntry; // Inquiry results record + TBool iPageForName; // Flag for inquiry name + RArray iDevsWithoutName; // Devices without dev name + TInt iIndex; // Current btdevice to inquiry its name + MBTNDeviceSearchObserver* iDevSearchObserver; + + TBool iExcludePairedDevices; + + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnobexpinnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnobexpinnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2002 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: Declares OBEX PIN query notifier class. +* +*/ + + +#ifndef BTNOBEXPINNOTIFIER_H +#define BTNOBEXPINNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class + +// CLASS DECLARATION + +/** +* This class is used to ask OBEX passkey from user. +*/ +NONSHARABLE_CLASS(CBTObexPinNotifier): public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTObexPinNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTObexPinNotifier(); + + private: // Functions from base classes + /** + * From CBTNotifierBase Called when a notifier is first loaded. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + private: + + /** + * C++ default constructor. + */ + CBTObexPinNotifier(); + + /** + * Show notes to ask user's response and return to caller. + * @param None. + * @return None. + */ + void ShowNoteCompleteMessageL(); + + private: // Data + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotif.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotif.hrh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2002 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: This file contains declarations for resources of btnotif. +* +*/ + + +#ifndef BTNOTIF_HRH +#define BTNOTIF_HRH + +#include + +#define KBTPassKeyMaxLength 16 // Same as KHCIPINCodeSize. Not available here direct from BT +#define KBTUIMaxNameLength 30 // Series 60 local BT name + +#define btnotif_bitmap_file "Z:\\system\\data\\BTNotif.mbm" +#define btnotif_bitmap_file_data_caging "Z:\\resource\\apps\\BTNotif.mbm" + + +enum BTNotifNotes + { + EBTNotifSearchingDevicesNote = 1, + EBTNotifBtBusyNote, + EBTNotifEnterSapNote, + EBTNotifEnterSapSucceedNote, + EBTNotifEnterSapFailNote + }; + +#endif +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotifactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotifactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 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: Declares active object helper class. +* +*/ + +#ifndef BTNOTIFACTIVE_H +#define BTNOTIFACTIVE_H + + +#include + +class CBTNotifActive; + +/** + * Class MBTNotifActiveObserver + * + * Callback class for receiving a completed active object event. + * Users of CBTEngActive need to derive from this class. + */ +class MBTNotifActiveObserver + { + +public: + + /** + * Callback to notify that an outstanding request has completed. + * + * @since S60 5.1 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTNotifActive* aActive, TInt aId, + TInt aStatus ) = 0; + + /** + * Callback to notify that an error has occurred in RunL. + * + * @param aActive Pointer to the active object that had error. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTNotifActive* aActive, TInt aId, + TInt aError ) = 0; + + /** + * Callback to notify that request is canceled. + * Active object may add specified steps here. + * + * @param aActive Pointer to the active object that is canceled. + * @param aId The ID that identifies the outstanding request. + */ + virtual void DoCancelRequest( CBTNotifActive* aActive, TInt aId ) = 0; + }; +/** + * Class CBTNotifActive + */ +NONSHARABLE_CLASS( CBTNotifActive ) : public CActive + { + +public: + /** + * Two-phased constructor. + * @param aObserver Pointer to callback interface that receives notification + * that the request has been completed. + * @param aId Request ID to identify which request is completed. + * @return Pointer to the constructed CBTNotifActive object. + */ + static CBTNotifActive* NewL( MBTNotifActiveObserver* aObserver, TInt aId, TInt aPriority ); + + /** + * Destructor. + */ + virtual ~CBTNotifActive(); + + /** + * Get the request ID of this active object. + * + * @since S60 v5.1 + * @return The request ID of this active object. + */ + inline TInt RequestId(); + + /** + * Set a new request ID for this active object. + * + * @since S60 v5.1 + * @param The new request ID of this active object. + */ + inline void SetRequestId( TInt aId ); + + /** + * Activate the active object. + * + * @since S60 v5.1 + */ + inline void GoActive(); + + /** + * Cancel an outstanding request. + * + * @since S60 v5.1 + */ + inline void CancelRequest(); + + /** + * Get a reference to the active object request status. + * + * @since S60 v5.1 + * @return Reference to the active object request status. + */ + TRequestStatus& RequestStatus(); + +// from base class CActive + + /** + * From CActive. + * Called by the active scheduler when the request has been cancelled. + * + * @since S60 v5.1 + */ + void DoCancel(); + + /** + * From CActive. + * Called by the active scheduler when the request has been completed. + * + * @since S60 v5.1 + */ + void RunL(); + + /** + * From CActive. + * Called by the active scheduler when an error in RunL has occurred. + * + * @since S60 v5.1 + */ + TInt RunError( TInt aError ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.1 + * @param aObserver Pointer to callback interface that receives notification + * that the request has been completed. + * @param aId ID of the request (for the client to keep track of multiple + * active objects). + * @param aPriority Priority of + */ + CBTNotifActive( MBTNotifActiveObserver* aObserver, TInt aId, TInt aPriority ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v5.1 + */ + void ConstructL(); + +private: // data + + /** + * ID of the request (used only by our client). + */ + TInt iRequestId; + + /** + * Our observer. + * Not own. + */ + MBTNotifActiveObserver* iObserver; + + }; + +#include "btnotifactive.inl" + + +#endif // BTNOTIFACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotifactive.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotifactive.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 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: Active object helper class inline function definitions. +* +*/ + +// ----------------------------------------------------------------------------- +// Get the identifier of this instance. +// ----------------------------------------------------------------------------- +// +inline TInt CBTNotifActive::RequestId() + { + return iRequestId; + } + + +// ----------------------------------------------------------------------------- +// Set the identifier of this instance. +// ----------------------------------------------------------------------------- +// +inline void CBTNotifActive::SetRequestId( TInt aId ) + { + iRequestId = aId; + } + + +// ----------------------------------------------------------------------------- +// Activate the active object. +// ----------------------------------------------------------------------------- +// +inline void CBTNotifActive::GoActive() + { + SetActive(); + } + + +// ----------------------------------------------------------------------------- +// Cancel an outstanding request. +// ----------------------------------------------------------------------------- +// +inline void CBTNotifActive::CancelRequest() + { + Cancel(); + } + + +// ----------------------------------------------------------------------------- +// Get a reference to the active object request status. +// ----------------------------------------------------------------------------- +// +inline TRequestStatus& CBTNotifActive::RequestStatus() + { + return iStatus; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,303 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth notifiers base class. +* +*/ + + +#ifndef BTNOTIFIERBASE_H +#define BTNOTIFIERBASE_H + +// INCLUDES + +#include "btnotif.h" +#include "btnotifuiutil.h" +#include +#include +#include + +// CONSTANTS + +// Literals for resource and bitmap files ( drive, directory, filename(s) ) + +const TUid KBTInquiryChannel = {0x00000601}; // Channel for inquiry notifier +const TUid KBTAuthorisationChannel = {0x00000602}; // Channel for PIN query notifier +const TUid KBTAuthenticationChannel = {0x00000603}; // Channel for authorisation notifier +const TUid KBTBBEventChannel = {0x00000604}; // Channel for baseband event notifier +const TUid KBTObexPINChannel = {0x00000605}; // Channel for OBEX PIN notifier +const TUid KBTPowerModeChannel = {0x00000606}; // Channel for power mode notifier +const TUid KBTAudioAccessoryChannel = {0x00000607}; // Channel for audio accessory notifier +const TUid KBTLowMemoryChannel = {0x00000608}; // Channel for low memory notifier +const TUid KBTPairedDeviceSettingChannel = {0x00000610}; + +// FORWARD DECLARATIONS +class CBTEngSettings; + +enum TBTRegistryQueryState +{ + ENoQuery=0, + EQueryPaired=1, + EQueryUsed=2, + ESetDeviceAuthorizeState, + ESetDeviceBlocked, + ESetDeviceUnblocked, +}; + +// CLASS DECLARATION +/** +* This class is the base class for all notifiers. +*/ +NONSHARABLE_CLASS(CBTNotifierBase): public CBase, public MEikSrvNotifierBase2, MBTEngDevManObserver + { + public: // Constructors and destructor + + /** + * Destructor. + */ + virtual ~CBTNotifierBase(); + + protected: // Constructors and destructor + + /** + * C++ default constructor. + */ + CBTNotifierBase(); + + /** + * Symbian 2nd phase constructor. + */ + virtual void ConstructL(); + + protected: // New functions + + /** + * Used in asynchronous notifier launch to store received parameters + * into members variables and make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + virtual void GetParamsL(const TDesC8& aBuffer, + TInt aReplySlot, + const RMessagePtr2& aMessage)=0; + + /** + * A utility function for checking whether autolock is on. + * @param None. + * @return A boolean according to autolock state. + */ + TBool AutoLockOnL(); + + /** + * A utility function for setting the power status of Bluetooth. + * If the power is not on the user will be presented a query. + * @return ETrue if BT is turned on successfully; EFalse otherwise + */ + TBool CheckAndSetPowerOnL(); + + /** + * A function for setting BT name + * @return ETrue if BT name is set successfully; EFalse otherwise + */ + TBool AskLocalBTNameQueryL(); + + /** + * Check if there is any existing connection to audio profiles from + * the same device + * @return ETrue if the device is connected. + */ + TBool IsExistingConnectionToAudioL(const TBTDevAddr& aDevAddr); + + /** + * Complete Client/Server message and Nulled the reply slot. + * @param aErr Error code for client notification. + * @return None + */ + void CompleteMessage(TInt aErr); + + /** + * Complete Client/Server message and Nulled the reply slot. + * @param aErr Error code for client notification. + * @return None + */ + void CompleteMessage(TInt aValueToReplySlot, TInt aErr); + + /** + * Complete Client/Server message and Nulled the reply slot. + * @param aErr Error code for client notification. + * @return None + */ + void CompleteMessage(const TDesC8& aDesToReplySlot, TInt aErr); + + /** + * Checks from central repository whether the Bluetooth friendly name + * has been modified . + * @return ETure if the name has been modified. + */ + TBool IsLocalNameModifiedL(); + + /** + * Get the device information from BT Registry by the given address. + */ + void GetDeviceFromRegL(const TBTDevAddr& aAddr); + + /** + * virtual function to be ovewritten by sub-classes. + * Will be called when Getting Device by BTEng DevMan is completed. + * @param aDev the device from registry if it is not null. indicates either a failure + * or the device is not available in registry. + */ + virtual void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + /** + * Asks the user if s/he want's to block the device in question + * Does not block the device. That is left to the caller. + * NOTE: Cannot be called while iAuthQueryDlg is active. + */ + void QueryBlockDeviceL(); + + /** + * Set BTDevice's security setting to blocked and modify device + * @param None + * @return None + */ + void DoBlockDevice(); + + /** + * Set BTDevice's security setting to un/authorized and modify device + * @param aTrust Set authorized if ETrue; otherwise, unauthorized. + * @return None + */ + void ChangeAuthorizeState( TBool aTrust); + + /** + * Checks if the user is queried too often, and handle the result. + * @return None + */ + void CheckAndHandleQueryIntervalL(); + + private: + + void DoHandleGetDevicesCompleteL(TInt aErr, CBTDeviceArray* aDeviceArray ); + + protected: // Functions from base classes + + /** + * From MEikSrvNotifierBase2 Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + virtual TNotifierInfo RegisterL()=0; + + /** + * From MEikSrvNotifierBase2 The notifier has been deactivated + * so resources can be freed and outstanding messages completed. + * @param None. + * @return None. + */ + virtual void Cancel(); + +#ifdef __SERIES60_HELP + /** This is used to create TCallBack to help. + * @param TCoeHelpContext. Must be instance TCoeHelpContext, or NULL. + * If null this will open help about blocked devices., + * @return KErrNone + */ + static TInt LaunchHelp(TAny *TCoeHelpContext=NULL); +#endif + + private: // Functions from base classes + + /** + * From MEikSrvNotifierBase2 Called when all resources allocated + * by notifiers should be freed. + * @param None. + * @return None. + */ + virtual void Release(); + + /** + * From MEikSrvNotifierBase2 Return the priority a notifier takes + * and the channels it acts on. + * @param None. + * @return A structure containing priority and channel info. + */ + virtual TNotifierInfo Info() const; + + /** + * From MEikSrvNotifierBase2 Synchronic notifier launch. + * @param aBuffer Received parameter data. + * @return A pointer to return value. + */ + virtual TPtrC8 StartL(const TDesC8& aBuffer); + + /** + * From MEikSrvNotifierBase2 Asynchronic notifier launch. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return A pointer to return value. + */ + virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From MEikSrvNotifierBase2 Updates a currently active notifier. + * @param aBuffer The updated data. + * @return A pointer to return value. + */ + virtual TPtrC8 UpdateL(const TDesC8& aBuffer); + + /** + * From MBTEngDevManObserver + * Indicates to the caller that adding, deleting or modifying a device + * has completed. + */ + virtual void HandleDevManComplete(TInt aErr); + + /** + * From MBTEngDevManObserver + * Call back function when GetDevices() request is completed. + * @param aErr Status information, if there is an error. + * @param aDeviceArray Array of devices that match the given criteria + * (the array provided by the calller). + */ + void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray ); + + /** + * Checks the timestamp since last query. + * @return true if too often + */ + TBool CheckQueryInterval(); + + protected: // Data + + RMessagePtr2 iMessage; // Received message + TInt iReplySlot; // Reply slot + TNotifierInfo iInfo; // Notifier parameters structure + TBTRegistryQueryState iBTRegistryQueryState; + CBTDeviceArray* iDeviceArray; // for getting device from registry + CBTDevice* iDevice; // Current Bluetooth device + TBTDevAddr iBTAddr; // Gotten from PckBuffer, constant no matter how iDevice changes. + CBTNotifUIUtil* iNotifUiUtil; // Utility to show UI notes & queries + CBTEngSettings* iBTEngSettings; + private: + CBTEngDevMan* iDevMan; // for BT registry manipulation + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotiflock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotiflock.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2006 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: Implements getting/setting notifier locks on BT devices +* from/to P&S KBTNotifierLocks from btengprivatepskeys.h. +* +*/ + +#ifndef BTNOTIFIERLOCK_H +#define BTNOTIFIERLOCK_H + +#include +#include + +/** + * BT Notifier lock identifiers + * @since S60 v5.1 + */ + +enum TBTNotifLockId + { + /** + * None + */ + EBTNotifierLockNone = 0x00, + + /** + * notifier is asking or going to ask if user wants to set device trusted. + */ + EBTNotiferLockPairedDeviceSetting = 0x01, + + /** + * notifer is asking or going to ask user if he wants to accept connection request + * from the device. + */ + EBTNotifierLockAuthorizeConnectRequest = 0x02, + }; + +/** + * the notifier lock status on a BT device. + * This lock mechanism uses by btui, bteng and btnotif to ensure the order of + * user interaction when a device is been paired. + */ +NONSHARABLE_CLASS( TBTNotifLock) + { +public: + + /** + * default constructor. iAddr is initialized to zero BT address and iLocks is set to 0 + */ + inline TBTNotifLock(); + + /** + * constructor to the specified value. + * @param aAddr the address of the BT device this object is for. + * @param aLocks one or more lock identifiers + */ + inline TBTNotifLock(const TBTDevAddr& aAddr, TInt aLocks); + + /** + * gets the target device address. + * @return the target device address + */ + inline const TBTDevAddr& Addr() const; + + /** + * Gets the locks on the device. + */ + inline TInt Locks() const; + + /** + * Gets the modifiable locks on the device + */ + inline TInt& Locks(); + +private: + + /** + * the BT device this object is for + */ + TBTDevAddr iAddr; + + /** + * the lock status, logical OR of one or more TBTNotifLockId values + */ + TInt iLocks; + }; + +NONSHARABLE_CLASS( TBTNotifLockPublish ) + { +public: + + /** + * gets from P&S KBTNotifierLocks the locks for a device. + * + * @param aLocks contains the locks for the device at return + * @param aAddr the address of the device which the locks are for + */ + inline static void GetNotifLocks( TInt& aLocks, const TBTDevAddr& aAddr ); + + /** + * gets from P&S KBTNotifierLocks the locks for a device. + * + * @aProperty the property instance which has been attached to key KBTNotifierLocks. + * @param aLocks contains the locks for the device at return + * @param aAddr the address of the device which the locks are for + */ + inline static void GetNotifLocks(RProperty& aProperty, TInt& aLocks, + const TBTDevAddr& aAddr ); + + /** + * Publishes locks to P&S KBTNotifierLocks. + * + * @param aLocks the locks to be published + * @param aAddr the address of the device which the locks are for + */ + inline static void AddNotifLocks( TInt aLocks, const TBTDevAddr& aAddr ); + + /** + * Publishes locks to P&S KBTNotifierLocks. + * @aProperty the property instance which has been attached to key KBTNotifierLocks. + * @param aLocks the locks to be published + * @param aAddr the address of the device which the locks are for + */ + inline static void AddNotifLocks(RProperty& aProperty, TInt aLocks, + const TBTDevAddr& aAddr ); + + /** + * Deletes locks from P&S KBTNotifierLocks. + * @param aLocks the locks to be deleted + * @param aAddr the address of the device which the locks are for + */ + inline static void DeleteNotifLocks( TInt aLocks, + const TBTDevAddr& aAddr ); + + /** + * Deletes locks from P&S KBTNotifierLocks. + * @aProperty the property instance which has been attached to key KBTNotifierLocks. + * @param aLocks the locks to be deleted + * @param aAddr the address of the device which the locks are for + */ + inline static void DeleteNotifLocks(RProperty& aProperty, TInt aLocks, + const TBTDevAddr& aAddr ); + }; + +#include "btnotiflock.inl" + +#endif // BTNOTIFIERLOCK_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotiflock.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotiflock.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,234 @@ +/* +* Copyright (c) 2006 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: Implements getting/setting notifier locks on BT devices +* from/to P&S KBTNotifierLocks from btengprivatepskeys.h. +* +*/ + +#include "btengprivatepskeys.h" +#include + +// ---------------------------------------------------------- +// Initialize members to zero +// ---------------------------------------------------------- +// +inline TBTNotifLock::TBTNotifLock() + : iAddr(TBTDevAddr()), iLocks(EBTNotifierLockNone) + { + } + +// ---------------------------------------------------------- +// initialize members to the specified values +// ---------------------------------------------------------- +// +inline TBTNotifLock::TBTNotifLock(const TBTDevAddr& aAddr, TInt aLocks) + : iAddr( aAddr ), iLocks( aLocks ) + { + } + +// ---------------------------------------------------------- +// returns the address +// ---------------------------------------------------------- +// +inline const TBTDevAddr& TBTNotifLock::Addr() const + { + return iAddr; + } + +// ---------------------------------------------------------- +// returns the lock as value +// ---------------------------------------------------------- +// +inline TInt TBTNotifLock::Locks() const + { + return iLocks; + } + +// ---------------------------------------------------------- +// returns the lock as modifiable reference +// ---------------------------------------------------------- +// +inline TInt& TBTNotifLock::Locks() + { + return iLocks; + } + +// ---------------------------------------------------------- +// Locally instantiate a RProperty and invoke GetNotifLocks +// ---------------------------------------------------------- +// +inline void TBTNotifLockPublish::GetNotifLocks( TInt& aLocks, const TBTDevAddr& aAddr ) + { + RProperty property; + TInt err = property.Attach( + KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks ); + if ( !err ) + { + GetNotifLocks( property, aLocks, aAddr ); + } + property.Close(); + } + +// ---------------------------------------------------------- +// Extracts from PS key and returns the lock value for +// the specified device +// ---------------------------------------------------------- +// +inline void TBTNotifLockPublish::GetNotifLocks(RProperty& aProperty, + TInt& aLocks, const TBTDevAddr& aAddr ) + { + aLocks = EBTNotifierLockNone; + TInt infoSize( sizeof( TBTNotifLock ) ); + TBuf8 infoDes; + TInt err = aProperty.Get( infoDes ); + if ( err || infoDes.Length() < infoSize ) + { + // zero length of the PS content indicates no lock set at all. + return; + } + TInt infoCount = infoDes.Length() / infoSize; + + TPckgBuf tmpPckg; + for ( TInt i = 0; i < infoCount; i++ ) + { + tmpPckg.Copy(infoDes.Mid( i * infoSize, infoSize )); + if ( tmpPckg().Addr() == aAddr ) + { + // found the locks for the device, writes to client. + aLocks = tmpPckg().Locks(); + return; + } + } + } + +// ---------------------------------------------------------- +// Locally instantiate a RProperty and invoke AddNotifLocks +// ---------------------------------------------------------- +// +inline void TBTNotifLockPublish::AddNotifLocks( TInt aLocks, const TBTDevAddr& aAddr ) + { + RProperty property; + TInt err = property.Attach( + KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks ); + if ( !err ) + { + AddNotifLocks( property, aLocks, aAddr ); + } + property.Close(); + } + +// ---------------------------------------------------------- +// Find the lock for the device from PS key and updates its value if +// needed. +// ---------------------------------------------------------- +// +inline void TBTNotifLockPublish::AddNotifLocks( RProperty& aProperty, + TInt aLocks, const TBTDevAddr& aAddr ) + { + TBuf8 infoDes; + TInt infoSize( sizeof( TBTNotifLock ) ); + TInt err = aProperty.Get( infoDes ); + if ( err ) + { + return; + } + TInt infoCount = infoDes.Length() / infoSize; + TPckgBuf tmpPckg; + + for ( TInt i = 0; i < infoCount; i++ ) + { + tmpPckg.Copy(infoDes.Mid( i * infoSize, infoSize )); + if ( tmpPckg().Addr() == aAddr ) + { + TInt newOps = tmpPckg().Locks() | aLocks; + // update the value only if it is really changed: + if ( tmpPckg().Locks() != newOps ) + { + tmpPckg().Locks() = newOps; + infoDes.Replace( i * infoSize, infoSize, tmpPckg ); + (void) aProperty.Set( infoDes ); + } + return; + } + } + // no lock for the device so far, append it to the end: + tmpPckg() = TBTNotifLock( aAddr, aLocks ); + if ( infoCount ) + { + infoDes.Append( tmpPckg ); + (void) aProperty.Set( infoDes ); + } + (void) aProperty.Set( tmpPckg ); + } + +// ---------------------------------------------------------- +// Locally instantiate a RProperty and invoke DeleteNotifLocks +// ---------------------------------------------------------- +// +inline void TBTNotifLockPublish::DeleteNotifLocks( TInt aLocks, const TBTDevAddr& aAddr ) + { + RProperty property; + TInt err = property.Attach( + KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks ); + if ( !err ) + { + DeleteNotifLocks( property, aLocks, aAddr ); + } + property.Close(); + } + +// ---------------------------------------------------------- +// Find the lock for the device from PS key and updates its value if +// needed. +// ---------------------------------------------------------- +// +inline void TBTNotifLockPublish::DeleteNotifLocks( RProperty& aProperty, + TInt aLocks, const TBTDevAddr& aAddr ) + { + TBuf8 infoDes; + TInt infoSize( sizeof( TBTNotifLock ) ); + TInt err = aProperty.Get( infoDes ); + if ( err || infoDes.Length() < infoSize ) + { + return; + } + TInt infoCount = infoDes.Length() / infoSize; + TPckgBuf tmpPckg; + for ( TInt i = 0; i < infoCount; i++ ) + { + tmpPckg.Copy( infoDes.Mid( i * infoSize, infoSize ) ); + if ( tmpPckg().Addr() == aAddr ) + { + TInt newOps = tmpPckg().Locks() & ~aLocks; + // update PS only if the value is changed: + if ( tmpPckg().Locks() != newOps ) + { + tmpPckg().Locks() = newOps; + if ( tmpPckg().Locks() == 0) + { + // no lock for this device anymore, remove from PS: + infoDes.Delete( i * infoSize, infoSize ); + } + else + { + // Update the lock value: + infoDes.Replace( i * infoSize, infoSize, tmpPckg ); + } + (void) aProperty.Set( infoDes ); + } + return; + } + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotifnameutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotifnameutils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 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: Declares Bluetooth notifiers base class. + * + */ + +#ifndef BTNOTIFNAMEUTILS_H +#define BTNOTIFNAMEUTILS_H + +#include + +class BtNotifNameUtils + { +public: + static void StripDeviceName(TBTDeviceName& aDeviceName); + static void GetDeviceDisplayName(TBTDeviceName& aName, const CBTDevice* aDev); + static void GetDeviceName(TBTDeviceName& aName, const CBTDevice* aDev); + static void SetDeviceNameL(const TBTDeviceName& aName, CBTDevice& aDev); + }; + +#endif // BTNOTIFNAMEUTILS_H + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotifpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotifpanic.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 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: Declares authorisation notifier class. +* +*/ + +#ifndef BTNOTIFPANIC_H +#define BTNOTIFPANIC_H + +_LIT(KBtNotifPanicName, "BtNotif Panic"); + +enum TBtNotifPanic + { + EiDeviceNullWhenCallingGetDeviceFromRegL = 0, + }; + +template +struct TBtNotifPanicCodeTypeChecker + { + inline static void Check(XAny) { } + }; + +#define BTNOTIF_PANIC(CODE) \ + TBtNotifPanicCodeTypeChecker::Check(CODE), \ + User::Panic(KBtNotifPanicName, CODE) + + +#endif // BTNOTIFPANIC_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnotifuiutil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnotifuiutil.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,177 @@ +/* +* Copyright (c) 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: Declares Bluetooth notifiers UI utility class. +* +*/ + +#ifndef BTNOTIFUIUTIL_H +#define BTNOTIFUIUTIL_H +#include // Eikon environment +#include +#include +#include +#include + +// CONSTANTS +// Literals for resource and bitmap files ( drive, directory, filename(s) ) +_LIT(KFileDrive,"z:"); +_LIT(KResourceFileName, "btnotif.rsc"); + +// FORWARD DECLARATIONS +class CEikonEnv; + +NONSHARABLE_CLASS( CBTNotifUIUtil ) : public CBase + { + public: // Constructors and destructor + + static CBTNotifUIUtil* NewL( TBool aCoverDisplayEnabled ); + + /** + * Destructor. + */ + virtual ~CBTNotifUIUtil(); + + private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CBTNotifUIUtil( TBool aCoverDisplayEnabled ); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + public: + /** + * A utility function for requesting the activation of lights. + * @param None. + * @return None. + */ + void TurnLightsOn(); + + /** + * Get the local eikon environment. + * @return the reference of the local Eikon Environment + */ + CEikonEnv& LocalEikonEnv(); + + /** + * Common utility for user confirmation dialog. + * @return the keypress value + */ + TInt ShowQueryL(TInt aPromptResource, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, + CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone ); + + /** + * Common utility for user confirmation dialog. + * @return the keypress value + */ + TInt ShowQueryL(const TDesC& aPrompt, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, + const TBTDeviceName& aDevNameInCoverUI, + CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone ); + + /** + * Common utility for user confirmation dialog. + * @return the keypress value + */ + TInt ShowMessageQueryL(TDesC& aMessage, const TDesC& aHeader, + TInt aResourceId, + CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone ); + /** + * Common utility for user confirmation dialog. + * @return the keypress value + */ + TInt ShowTextInputQueryL(TDes& aText, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, + CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone ); + + /** + * Common utility for user confirmation dialog. + * @return the keypress value + */ + TInt ShowTextInputQueryL(TDes& aText, const TDesC& aPrompt, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, + CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone ); + + /** + * Common utility for UI inforamtion note. + */ + void ShowInfoNoteL( TInt aResourceId, TSecondaryDisplayBTnotifDialogs aDialogId ); + + /** + * Common utility for UI inforamtion note. + */ + void ShowInfoNoteL( const TDesC& aResource, TSecondaryDisplayBTnotifDialogs aDialogId ); + + /** + * Common utility for Confirmation note. + */ + void ShowConfirmationNoteL( TBool aWaitingDlg, const TDesC& aResource, + TSecondaryDisplayBTnotifDialogs aDialogId, const TBTDeviceName& aDevNameInCoverUi ); + + /** + * Common utility for Error note. + */ + void ShowErrorNoteL( TBool aWaitingDlg, const TDesC& aResource, + TSecondaryDisplayBTnotifDialogs aDialogId, TBTDeviceName aDevNameInCoverUi ); + + /** + * Check if iYesNoDlg is NULL + */ + TBool IsQueryReleased(); + + /** + * Update the dialog when UpdateL() is called by client. + */ + void UpdateQueryDlgL( TDesC& aMessage ); + + /** + * Update the message dialog when UpdateL() is called by client. + */ + void UpdateMessageQueryDlgL( TDesC& aMessage ); + + /** + * It is used for Secondary display to update. + */ + void UpdateCoverUiL( const TDesC8& aMessage ); + + /** + * Delete the dialog, mostly used by UpdateL() + */ + void DismissDialog(); + + TInt ShowWaitDlgL( TInt aResourceId ); + + void CompleteWaitDlgL(); + + private: + + void CoverUIDisplayL( const MObjectProvider* aMop, const TBTDeviceName& aDevNameInCoverUi ); + + private: //DATA + CEikonEnv* iEikEnv; // Local eikonenv + TInt iResourceFileFlag; // Flag for eikon env. + CAknQueryDialog* iQueryDlg; // All kinds of query dialog + CAknWaitDialog* iWaitDlg; // WaitDialog + TBool iCoverDisplayEnabled; // Flag that indicate cover UI featur + TBool iSystemCancel; // Used to check if iEikEnv is valid. + TBool iAppKeyBlocked; // Apps key is deactivated. + }; +#endif //BTNOTIFUIUTIL_H + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,125 @@ +/* +* Copyright (c) 2002 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: Declares power mode setting notifier class. +* +*/ + + +#ifndef BTNPAIREDDEVSETTNOTIFIER_H +#define BTNPAIREDDEVSETTNOTIFIER_H + +// INCLUDES +#include "btnotifier.h" // Base class + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +NONSHARABLE_CLASS(CBTPairedDevSettNotifier) : public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTPairedDevSettNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTPairedDevSettNotifier(); + + private: // Functions from base classes + + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase The notifier has been deactivated + * so resources can be freed and outstanding messages completed. + * @param None. + * @return None. + */ + void Cancel(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From CBTNotifierBase Updates a currently active notifier. + * @param aBuffer The updated data. + * @return A pointer to return value. + */ + TPtrC8 UpdateL(const TDesC8& aBuffer); + + /** + * From CBTNotifierBase + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + private: + + /** + * Leave function called by non-leave btengdevman callback function HandleGetDevicesComplete(). + *@param aErr. Passed by caller. + */ + + /** + * Parse the data out of the message that is sent by the client of the notifier. + * @param aBuffer A package buffer containing received parameters. + * @return None. + */ + void ProcessParamBufferL(const TDesC8& aBuffer); + + /** + * Query to assign the friendly name when adding it into paired device list + * if the current device name is not unique in the paired devices view. + */ + void QueryRenameDeviceL(const CBTDevice& aDevice); + + /** + * C++ default constructor. + */ + CBTPairedDevSettNotifier(); + + /** + * Process pairing error code to show corresponding notes. + * @param aErr The pairing error code from HCI error. + * @return The resouce ID of notes + */ + TInt ProcessPairingErrorCode( const TInt aErr ); + + private: + + TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand; + TBool iIsMessageQuery; + TInt iPairingStatus; + + }; + +#endif //BTNPAIREDDEVSETTNOTIFIER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnpairnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnpairnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 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: Declares pair base notifier. +* +*/ + +#ifndef BTNPAIRNOTIFIER_H_ +#define BTNPAIRNOTIFIER_H_ + +#include "btnotifier.h" // base class + +// CLASS DECLARATION +/** +* This class is used as base class for all pairing purpose notifiers +*/ +NONSHARABLE_CLASS(CBTNPairNotifierBase) : public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTNPairNotifierBase* NewL(); // Constructor (public) + + /** + * Destructor. + */ + virtual ~CBTNPairNotifierBase(); // Destructor + + protected: // From base class + + /** + * From CBTNotifierBase + */ + virtual TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + virtual void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + virtual void UpdateL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + /** + * From CBTNotifierBase Updates a currently active notifier. + * @param aBuffer The updated data. + * @return A pointer to return value. + */ + virtual TPtrC8 UpdateL(const TDesC8& aBuffer); + + protected: // New functions + + void ProcessParamsGetDeviceL( const TBTDevAddr& aAddr, const TBTDeviceName& aName ); + + /** + * Check not to allow pairing attempt from banned devices, + */ + TBool CheckBlockedDeviceL(); + + /** + * Query user to accept/reject when the pairing request is initiated + * from remote device. + * @param None. + * @return ETrue if User accepted. + */ + TBool AuthoriseIncomingPairingL(); + + /** + * Generate prompt based on subclass's own needs. + */ + virtual HBufC* GenerateQueryPromoptLC(); + + private: + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + //TNotifierInfo RegisterL(); + + protected: + /** + * C++ default constructor. + */ + CBTNPairNotifierBase(); + + protected: // Data + TBool iLocallyInitiated; + }; + +#endif /* BTNPAIRNOTIFIER_H */ + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnpbappinnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnpbappinnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2002 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: Declares PBAP PIN query notifier class. +* +*/ + + +#ifndef BTNPBAPNOTIFIER_H +#define BTNPBAPNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class + +// CLASS DECLARATION + +/** +* This class is used to ask PBAP passkey from user. +*/ +NONSHARABLE_CLASS(CBTPBAPPinNotifier): public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTPBAPPinNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTPBAPPinNotifier(); + + private: // Functions from base classes + /** + * From CBTNotifierBase Called when a notifier is first loaded. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + private: + + /** + * C++ default constructor. + */ + CBTPBAPPinNotifier(); + + /** + * Show UI note and complete message. + * Ask user response and return it to caller. + * @param None. + * @return None. + */ + void ShowNoteCompleteMessageL(); + + private: // Data + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnpinnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnpinnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2002 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: Declares authentication (PIN query) notifier class. +* +*/ + + +#ifndef BTNPINNOTIFIER_H +#define BTNPINNOTIFIER_H + +// INCLUDES + +#include "btnpairnotifier.h" // Base class + +class MBTEngDevManObserver; + +// CLASS DECLARATION +/** +* This class is used to ask PIN code from user. +*/ +NONSHARABLE_CLASS(CBTPinNotifier): public CBTNPairNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTPinNotifier* NewL(); // Constructor (public) + + /** + * Destructor. + */ + virtual ~CBTPinNotifier(); // Destructor + + private: + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); // Get input parameters + + /** + * From CBTNotifierBase + * Show queries to ask user response and return it to caller by completing message. + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + /** + * From CBTNPairNotifierBase + * Generate prompt in Pin query dialog. + */ + HBufC* GenerateQueryPromoptLC(); + + private: + + /** + * C++ default constructor. + */ + CBTPinNotifier(); // Default constructor + + /** + * Checks and sets iPinCode to '0000', used with automated pairing for headsets. + */ + TBool CheckAndSetAutomatedPairing(); + + private: // Data + TUint iPasskeyLength; + TBTPinCode iPinCode; + TBTRegistryQueryState iBTRegistryQueryState; + TBool iLocallyInitiated; + TBool iStrongPinRequired; + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnpwrnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnpwrnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2002 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: Declares power mode setting notifier class. +* +*/ + + +#ifndef BTNPWRNOTIFIER_H +#define BTNPWRNOTIFIER_H + +// INCLUDES + +#include "btnotifier.h" // Base class + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** +* This class is used to confirm Bluetooth power status change from user. +*/ +NONSHARABLE_CLASS(CBTPwrNotifier): public CBTNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTPwrNotifier* NewL(); + + /** + * Destructor. + */ + virtual ~CBTPwrNotifier(); + + private: // Functions from base classes + + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + + private: + + /** + * C++ default constructor. + */ + CBTPwrNotifier(); + + /** + * Show Information Note and complete message. + * @param None. + * @return None. + */ + void ShowNoteAndCompleteMessageL(); + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2002 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: Declares authentication (PIN query) notifier class. +* +*/ + + +#ifndef BTNSSPPASSKEYENTRYNOTIFIER_H_ +#define BTNSSPPASSKEYENTRYNOTIFIER_H_ + + +// INCLUDES + +#include "btnpairnotifier.h" // Base class + +const TInt KPassKeylength = 6; +// CLASS DECLARATION +/** +* This class is used to confirm PIN code from remote input devices. such as bluetooth keyboard. +*/ +NONSHARABLE_CLASS(CBTSSPPasskeyEntryNotifier): public CBTNPairNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTSSPPasskeyEntryNotifier* NewL(); // Constructor (public) + + /** + * Destructor. + */ + virtual ~CBTSSPPasskeyEntryNotifier(); // Destructor + + private: + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + /** + * From CBTNotifierBase Updates a currently active notifier. + * @param aBuffer The updated data. + * @return A pointer to return value. + */ + TPtrC8 UpdateL(const TDesC8& aBuffer); + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); // Get input parameters + + /** + * From CBTNotifierBase + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + /** + * Generate prompt for passkey entry query. + * @param None. + * @return None. + */ + HBufC* GenerateQueryPromoptLC(); + + private: + + /** + * C++ default constructor. + */ + CBTSSPPasskeyEntryNotifier(); // Default constructor + + private: // Data + TInt iAnswer; + TBuf<100> iBuf; + TBuf<10> iPasskey; + }; +#endif +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/btnumcmpnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btnumcmpnotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 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: Declares Numeric Comparison notifier for Secure Simle Pairing +* +*/ + + +#ifndef BTNUMCMPNOTIFIER_H +#define BTNUMCMPNOTIFIER_H + +// INCLUDES + +#include "btnpairnotifier.h" // Base class + +// CLASS DECLARATION +/** +* This class is used to ask user to compare passcode in two devices. +*/ +const TInt Klength = 6; +const TInt KMaxPassKeyLength = 20; +const TInt KBTDeviceShortNameLength = 7; + + +NONSHARABLE_CLASS(CBTNumCmpNotifier): public CBTNPairNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTNumCmpNotifier* NewL(); // Constructor (public) + + /** + * Destructor. + */ + virtual ~CBTNumCmpNotifier(); // Destructor + + private: + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); // Get input parameters + + /** + * From CBTNotifierBase + * Show notes to ask user response and return to Notifier caller by completing message. + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + /** + * From CBTNPairNotifierBase + * @param None. + * @return None. + */ + HBufC* GenerateQueryPromoptLC(); + + private: + + /** + * C++ default constructor. + */ + CBTNumCmpNotifier(); // Default constructor + + private: // Data + TBuf<20> iPasskeyToShow; + + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/inc/devui_const.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/devui_const.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef DEVUI_CONST_H_ +#define DEVUI_CONST_H_ + +#include +// Order must match the one in resources (R_BT_DEFAULT_DEVICE_NAMES) +// +enum TBTDefaultDevNameIndex + { + EBTDeviceNameIndexComputer = 0, + EBTDeviceNameIndexPhone, + EBTDeviceNameIndexAudio, + EBTDeviceNameIndexKeyboard, + EBTDeviceNameIndexMouse, + EBTDeviceNameIndexPrinter, + EBTDeviceNameIndexCarKit, + EBTDeviceNameIndexDefault + }; + +// Enum for items in search filter +enum TBTSearchFilterItem + { + EBTSearchForAll = 0, + EBTSearchForAudio, + EBTSearchForPhone, + EBTSearchForComputer, + EBTSearchForInput + }; + +// Order must match the one in resources (R_BTNOTIF_ICONS) +// +enum TDeviceIconIndex + { + EDeviceIconComputer = 0, + EDeviceIconPhone, + EDeviceIconAudio, + EDeviceIconDefault, + EDeviceIconBlank, + EDeviceIconKeyboard, + EDeviceIconMouse, + EDeviceIconPrinter, + EDeviceIconCarkit, + EDeviceIconPaired, + EDeviceIconBlocked, + EDeviceIconRssiLow, + EDeviceIconRssiMed, + EDeviceIconRssiGood, + }; + +struct TDeviceIconFormat + { + TDeviceIconIndex iIdx; + const TText* iFormat; + }; + +// Order must match the one in TDeviceIconIndex +// +const TDeviceIconFormat KDeviceIconFormatTable[] = + { + {EDeviceIconComputer, _S("0\t")}, //computer + {EDeviceIconPhone, _S("1\t")}, // phone + {EDeviceIconAudio, _S("2\t")}, // audio + {EDeviceIconDefault, _S("3\t")}, // default + {EDeviceIconBlank, _S("4\t")}, // blank + {EDeviceIconKeyboard, _S("5\t")}, // keyboard + {EDeviceIconMouse, _S("6\t")}, // mouse + {EDeviceIconPrinter, _S("7\t")}, // printer + {EDeviceIconCarkit, _S("8\t")}, // carkit + {EDeviceIconPaired, _S("\t9")}, // paired + {EDeviceIconBlocked, _S("\t10")}, // blocked + {EDeviceIconRssiLow, _S("\t11")}, // RssiLow + {EDeviceIconRssiMed, _S("\t12")}, // RssiMed + {EDeviceIconRssiGood, _S("\t13")} // RssiGood + }; + +// Total number of different device icons +const TInt KDeviceIconCount = + sizeof(KDeviceIconFormatTable) / sizeof(TDeviceIconFormat); + +/* + * The classification of a device's icon and default name + * corresponding to its major and minor device classes. + */ +struct TDeviceRowLayout + { + TInt iMajorDevClass; + TInt iMinorDevClass; + TDeviceIconIndex iIconIndex; + TBTDefaultDevNameIndex iDefaultNameIndex; + }; + +/* + * Device classification mapping table. + * + * Notice 1: Considering runtime searching efficiency, if certain major or minor + * device classes shall use the default icon and name, it is not recommended + * to present in this table. + * + * Notice 2: Regulated by searching algorithm, when devices carrying the same + * major device class may have different icons and names for different minor + * device classes, the unclassified minor device class must present at last + * among these belonging to the same major device class. + */ +const TDeviceRowLayout KDeviceRowLayoutTable[] = + { + {EMajorDeviceComputer, 0, EDeviceIconComputer, EBTDeviceNameIndexComputer }, + {EMajorDevicePhone, 0, EDeviceIconPhone, EBTDeviceNameIndexPhone }, + {EMajorDeviceAudioDevice, EMinorDeviceAVCarAudio, EDeviceIconCarkit, EBTDeviceNameIndexCarKit }, + {EMajorDeviceAudioDevice, 0, EDeviceIconAudio, EBTDeviceNameIndexAudio }, + {EMajorDeviceImaging, EMinorDeviceImagingPrinter, EDeviceIconPrinter, EBTDeviceNameIndexPrinter }, + {EMajorDevicePeripheral, EMinorDevicePeripheralKeyboard, EDeviceIconKeyboard, EBTDeviceNameIndexKeyboard }, + {EMajorDevicePeripheral, EMinorDevicePeripheralPointer, EDeviceIconMouse, EBTDeviceNameIndexMouse }, + }; + +const TInt KDeviceRowLayoutTableSize = (sizeof(KDeviceRowLayoutTable) / sizeof(TDeviceRowLayout)); + +#endif /*DEVUI_CONST_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/loc/btnotif.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/loc/btnotif.loc Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,432 @@ +/* +* Copyright (c) 2002 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: This is a localisation file for btnotif. +* +*/ + + +// LOCALISATION STRINGS + +// *** TITLES (FOR POPUP WINDOWS) *** + +// d: Header text of the popup window for already found Bluetooth devices +// d: while searching is still in progress. (List query) +// d: Note! There is also an icon at right edge of the title. +// l: heading_pane_t1/opt2 +// +#define qtn_bt_searching_found "Searching" + +// d: Header text of the popup window for already found Bluetooth devices. +// d: while searching has been completed. (List query) +// l: heading_pane_t1 +// +#define qtn_bt_devices_found "Devices found:" + +// d: Header text of the popup window for "last seen bluetooth devices". (List query) +// l: heading_pane_t1 +// +#define qtn_bt_last_seen_devices "Last seen devices" + +// d: Header text of the popup window for last used bluetooth devices. (List query) +// l: heading_pane_t1 +// +#define qtn_bt_last_used_devices "Bluetooth devices:" + +// d: List item text (with icon at left) of the popup window +// d: for "last seen bluetooth devices". (List query) +// l: list_single_graphic_pane_t1_cp2 +// +#define qtn_bt_more_devices "More devices" + +// Generic_BTUI +// d: Header text of the search device filer +// l: heading_pane_t1 +// r: 5.1 +#define qtn_bt_search_for "Search for:" + +// d: list item text for different class of devices in search filter +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_search_for_all "All devices" + +// d: list item text for different class of devices in search filter +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_search_for_audio "Audio devices" + +// d: list item text for different class of devices in search filter +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_search_for_phone "Phones" + +// d: list item text for different class of devices in search filter +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_search_for_computer "Computers" + +// d: list item text for different class of devices in search filter +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_search_for_input "Input devices" +//End Generic_BTUI + +// *** SOFTKEYS *** + +// d: Right softkey for device search popup menu list while searching is still in progress. +// l: control_pane_t1/opt7 +// +#define qtn_bt_softkey_stop "Stop" + + +// *** QUERIES *** + +// d: Confirmation query when Bluetooth needs to be activated. +// l: popup_note_window +// +#define qtn_bt_is_off "Bluetooth is currently switched off. Switch on?" + +// d: Confirmation query when Bluetooth needs to be activated in off-line mode. +// l: popup_note_window +// +#define qtn_bt_activate_in_offline "Do you want to activate bluetooth in off-line mode?" + +// d: Confirmation query when Bluetooth device search has met timeout and no devices has been found. +// l: popup_note_window +// +#define qtn_bt_no_devices_found "No Bluetooth devices found. Try again?" + +// d: Data query when pairing procedure is needed. Bluetooth passkey is entered. +// l: popup_query_data_window +// +#define qtn_bt_enter_pk_for_conn "Enter passkey for: %U" + +// d: Heading text for qtn_bt_enter_pk_for_conn -query +// l: popup_info_list_pane_t2/opt1 +// +#define qtn_bt_passkey_heading "Bluetooth" + +// d: Confirmation query when remote Bluetooth device want's connect to us. +// l: popup_note_window +// +#define qtn_bt_accept_conn_request "Accept connection request from:\n%U" + +// d: Confirmation query when remote Bluetooth (unpaired) device want's to send obex message to us. +// l: popup_note_window +// +#define qtn_bt_receive_message "Receive Bluetooth message from: %U" + +// d: Confirmation query when remote Bluetooth (paired) device want's to send obex message to us. +// l: popup_note_window +// +#define qtn_bt_receive_message_paired "Receive message via Bluetooth from paired device %U?" + +// d: Data query when obex file transfer needs it. OBEX passkey is entered. +// l: popup_query_data_window +// +#define qtn_bt_enter_obex_pcode "Passcode for data transfer:" + +// d: This is default prompt extension for queries, notes and lists that contain Bluetooth device name. +// d: The %U in queries are replaced with this text if no other Bluetooth device name is available. +// l: list_single_graphic_pane_t1_cp2 +// +#define qtn_bt_dialog_def_name "Bluetooth Device" + +// *** NOTES *** + +// d: Wait note while phone is performing Bluetooth device search/inquiry. +// l: popup_note_wait_window +// +#define qtn_bt_searching "Searching for devices" + +// d: Information note if there is maximum number of connections and new one could not be created. +// l: popup_note_window +// +#define qtn_bt_busy "Maximum amount of Bluetooth connections in use. Can't establish a new one." + +// d: Confirmation query when Bluetooth needs to be turned off when there os active BT connection. +// l: popup_note_window +// +#define qtn_bt_switch_off_anyway "Active Bluetooth connection.\nSwitch off anyway?" + + +// *** GLOBAL NOTES *** + +// d: Global Information note telling audio is routed to BT handsfree. +// l: popup_note_window +// +#define qtn_bt_audio_accessory "Audio routed to BT handsfree" + +// d: Global Information note telling audio is routed to handset. +// l: popup_note_window +// +#define qtn_bt_audio_handset "Audio routed to handset" + +// d: Global Information note for successful connection establishment. +// l: popup_note_window +// +#define qtn_bt_conf_connected "Connected to %U" + +// d: Global Information note for successful connection close. +// l: popup_note_window +// +#define qtn_bt_conf_disconnected "Disconnected from %U" + +// d: Global Information note telling BT connection was closed outside the phones menu. +// l: popup_note_window +// +#define qtn_bt_conn_closed "Bluetooth connection to %U closed" + +// d: An information note when Bluetooth needs to be activated and it's disallowed in off-line mode. +// l: popup_note_window +// +#define qtn_bt_offline_disabled "Bluetooth can't activated in off-line mode" + +// d: Global information note telling phone is entering SIM access profile mode +// l: popup_note_window +// +#define qtn_bt_wait_sap_entering "Phone entering SIM access profile mode" + +// d: Global information note telling phone entering SIM access profile mode is succeeded +// l: popup_note_window +// +#define qtn_bt_sap_entering_succeeded "Phone in SIM access profile mode" + +// d: Global information note telling phone entering SIM access profile mode is failed +// l: popup_note_window +// +#define qtn_bt_sap_entering_failed "Unable to enter SIM access profile mode" + +// d: Global information note telling phone has no sim card +// l: popup_note_window +// +#define qtn_bt_sap_no_sim "No SIM card in phone" + +// d: Global information note telling phone bt stays switched on +// l: popup_note_window +// +#define qtn_bt_permanently_on "Bluetooth switched permanently on" +// d: Global information note telling phone bt is switched on +// l: popup_note_window +// +#define qtn_bt_switched_on "Bluetooth switched on" + +// d: Global information note telling phone bt is switched off +// l: popup_note_window +// +#define qtn_bt_switched_off "Bluetooth switched off" + +// *** DEFAULT BLUETOOTH DEVICE CLASS NAMES *** + +// The icon of each Bluetooth device shown in the UI is based on +// Class of Device (CoD). These are defined in the "Bluetooth" UI specification. +// Device classes and their default names are: + +// d: Class of Device = Computer +// l: list_single_graphic_pane_t1_cp2 +// +#define qtn_bt_computer "Computer" + +// d: Class of Device = Phone +// l: list_single_graphic_pane_t1_cp2 +// +#define qtn_bt_phone "Phone" + +// d: Class of Device = Audio/Video +// l: list_single_graphic_pane_t1_cp2 +// +#define qtn_bt_audio "Audio/Video" + +// d: Class of Device = Audio +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_gen_audio "Audio" + +// d: Class of Device = Keyboard +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_keyboard "Keyboard" + +// d: Class of Device = Mouse +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_mouse "Mouse" + +// d: Class of Device = Printer +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_printer "Printer" + +// d: Class of Device = Car kit +// l: list_single_graphic_pane_t1_cp2 +// r: 5.1 +#define qtn_bt_carkit "Car kit" +// d: Data query when pairing procedure is needed. Bluetooth passkey is entered. +// l: popup_query_data_window +// w: +// r: 3.0 +#define qtn_bt_enter_pk_sap "Enter %0N digit passkey for %1U" + +// d: Data query when user has try to turn BT on for the first time and +// d: there is no local Bluetooth name defined yet (empty name). +// l: popup_query_data_window +// +#define qtn_enter_bt_name "My Bluetooth name:" + +// d: Information note shows the phone's visibility has changed to hidden. +// l: popup_note_window +// w: +// r: 3.1 +// +#define qtn_bt_hidden_from_others "Phone is not detectable in searches made by other devices" + +// d: Confirmation query when use refuse the incoming connection request and want to block connection +// l: popup_note_window +// w: +// r: 3.1 +#define qtn_bt_block_conn_request "Block connection request from %U?" + +// d: query if the bluetooth is off, when java needs it. +// l: popup_info_list_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_is_off_java "The application you are using will not be fully functional while Bluetooth is off. \n\nDo you want to turn Bluetooth on?" + +// d: query if the bluetooth is off, when java needs it. +// l: heading_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_is_off_java_header "Turn Bluetooth on?" + +// d: query if the bluetooth is hidden, when discoverabiliti is needed. +// l: popup_info_list_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_is_hidden_java "Do you want to change your Bluetooth visibility setting value to 'Shown to all'? \n\nThe application you are using will not be fully functional while your Bluetooth visibility is set as 'Hidden'." + +// d: query header if the bluetooth is hidden, when discoverabiliti is needed. +// l: heading_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_is_hidden_java_header "Change discoverability?" + +// d: When the Infrared feature is disabled in runtime, a global information note is shown to the user when Infrared reception is tried to be activated.. +// l: popup_note_window +// w: +// r: 3.2 +#define qtn_ir_not_supported "Infrared not supported" + +// d: Confirmation query when use refuse the incoming connection request and want to block connection >>> Isn't this a heading? +// l: heading_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_block_device_header "Block device?" + +// d: Confirmation query when use refuse the incoming connection request and want to block connection +// l: popup_info_list_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_block_all_conn_attempts "Do you want to block all future connection attempts from device %U?" + +// d: the link key to help in confirmation query when use refuse the incoming connection request and want to block connection from paired device +// l: popup_info_list_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_block_paired_device "Do you want to block all future connection attempts from paired device %U? \nThis will delete your pairing with the device." + +// d: Confirmation query when pairing is requested by the remote device +// l: popup_note_window +// w: +// r: 3.2 +#define qtn_bt_accept_pairing_request "Device '%U' is trying to pair with you. Allow pairing?" + +// d: When VoIP call is on going over WLAN, BT device search is not allowed, a global information note is shown to the user. +// l: popup_note_window +// w: +// r: 3.1 +#define qtn_bt_no_device_discovery_voip "While a VOIP call over WLAN is on-going, Bluetooth device discovery is not possible." + +// d: Query if the bluetooth is off, when java needs it. In this query %U will be substituted with requiring Java application's name. +// l: popup_info_list_pane_t1 +// w: +// r: 5.0 +#define qtn_bt_is_off_java_appname "The %U application you are using will not be fully functional while Bluetooth is off.\n\nDo you want to turn Bluetooth on?" + +// d: Query if the bluetooth is hidden, when discoverabiliti is needed. In this query %U will be substituted with requiring Java application's name. +// l: popup_info_list_pane_t1 +// w: +// r: 5.0 +#define qtn_bt_is_hidden_java_appname "The %U application you are using will not be fully functional when your visibility is set as ’Hidden? Do you want to change your Bluetooth visibility to ’Shown to all?" + +// d: If DOS attacked is detected, user is asked if bluetooth should be swtiched off. +// l: popup_note_window +// r: 5.0 +#define qtn_bt_dos_query "Switch Bluetooth off?" + +// d: If a blocked device is selected after searching devices starts, user is asked whether to unblock it. +// l: popup_note_window +// r: 5.0 +#define qtn_bt_unblock_device "%U is blocked. Do you want to unblock it?" + +// *** Information Notes for AVRCP1.3 *** + +// d: the battery level of AVRCP1.3-supported accessory drops below "low" treshold +// l: popup_note_window +// r: 5.1 +#define qtn_bt_accessory_low "%U battery level low" + +// d: the battery level of AVRCP1.3-supported accessory drops below "critical" treshold +// l: popup_note_window +// r: 5.1 +#define qtn_bt_accessory_critical "%U battery level critical" + +// *** Query for Simple Pairing *** + +// d: Confirmation query when simple pairing procedure is needed. Check if Bluetooth passkeys shown in two devices match. +// l: popup_note_window +// d: %U contains device name, %U1 contains passkey. +// r: 5.1 +#define qtn_bt_simple_passkey_comparison "Does this code match the one on %0U?\n\n%1U" + +// d: Query askes user to type the passkey code from remote input device. +// d: %U contains device name %U1 contains passkey. +// l: popup_note_window +// r: 5.1 +#define qtn_bt_simple_passkey_entry "Enter on %0U:\n\n%1U" + +// *** Error notes for SSP *** + +// d: Error note if a timeout is exceeded before the user accepts or denies the query. +// d: %U contains device name. +// l: popup_note_window +// r: 5.1 +#define qtn_bt_pairing_failed "Unable to pair with %U" + +// d: Warning note If the remote device is already in the process of pairing with another device. +// l: popup_note_window +// r: 5.1 +#define qtn_bt_simple_busy "Pairing failed. Remote device is pairing with another device." + +// *** Notes and query for incoming authorization *** +// d: Confirmation note shows pairing succeeded. +// d: %U contains device name. +// l: popup_note_window +// r: 5.1 +#define qtn_bt_succesfully_paired "Pairing with %U complete" + +// d: Confirmation query to set a Bluetooth device authorised after user has succesfully paired with the device. +// l: popup_note_window +// +#define qtn_bt_authorisation_query "Authorise this device to make connections automatically?" + +//End diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/rom/Btnotif.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/rom/Btnotif.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef __BTNOTIF_IBY__ +#define __BTNOTIF_IBY__ + +REM Bluetooth notifiers library + +file=ABI_DIR\BUILD_DIR\btnotif.dll SHARED_LIB_DIR\btnotif.dll +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,btnotif) + +ECOM_PLUGIN(btnotifwrapper.dll,101FD68F.rsc) + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/rom/BtnotifResources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/rom/BtnotifResources.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef __BTNOTIFRESOURCES_IBY__ +#define __BTNOTIFRESOURCES_IBY__ + +data=DATAZ_\RESOURCE_FILES_DIR\btnotif.rsc RESOURCE_FILES_DIR\btnotif.rsc + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNAuthNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,618 @@ +/* +* Copyright (c) 2002 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: Implements authorisation notifier class. +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Own resources +#include "btnauthnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include +#include // Cover UI +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Unicode character conversion utilities +#include +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif +#include "btnotifnameutils.h" + + +// +// SDP UUID Constants - Short form +// Taken from Bluetooth Profile specification v1.1 +// These are used when registering the service to +// local SDP database and when searching the service +// information from remote device. +const TUint KBTSdpDun = 0x1103; +const TUint KBTSdpGenericTelephony = 0x1204; +const TUint KBTSdpFax = 0x1111; +const TUint KBTSdpObjectPush = 0x1105; +const TUint KBTSdpFileTransfer = 0x1106; +const TUint KBTSdpHeadSet = 0x1108; +const TUint KBTSdpGenericNetworking = 0x1201; +const TUint KBTSdpBasicImaging = 0x111b; + +/** Identification for active object */ +const TInt KBTNotifAuthNotifierLockReq = 10; + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTAuthNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTAuthNotifier* CBTAuthNotifier::NewL() + { + CBTAuthNotifier* self = new (ELeave) CBTAuthNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::CBTAuthNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTAuthNotifier::CBTAuthNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTAuthNotifier::~CBTAuthNotifier() + { + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::RegisterL +// ---------------------------------------------------------- +// +CBTAuthNotifier::TNotifierInfo CBTAuthNotifier::RegisterL() + { + iInfo.iUid=KBTManAuthNotifierUid; + iInfo.iChannel=KBTAuthorisationChannel; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::GetParamsL +// Initialize parameters and check if device is already +// in registry. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTAuthNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::GetParamsL()")); + + if( !iMessage.IsNull()) + { + User::Leave(KErrInUse); + } + else if ( AutoLockOnL() ) + { + // The phone is locked, access denied. + // Write results back to caller and complete message. + CompleteMessage(EFalse, KErrNone); + return; + } + + TBTAuthorisationParams param; + TPckgC pckg(param); + pckg.Set(aBuffer); + + iServiceUid = pckg().iUid.iUid; // Pick up service uid from message + iBTAddr = pckg().iBDAddr; + if ( OtherOutgoPairing( iBTAddr ) ) + { + // We won't allow connection request from another device during outgoing pairing: + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier: outgoing pair in progress, reject request from other device")); + CompleteMessage(KErrCancel); + return; + } + + iMessage = aMessage; + iReplySlot = aReplySlot; + + // create iDevice so that the name won't be lost if the device does + // not exist in registry. + iDevice = CBTDevice::NewL( iBTAddr ); + BtNotifNameUtils::SetDeviceNameL(pckg().iName, *iDevice); + + if ( !iNotifLockProp.Handle() ) + { + User::LeaveIfError( iNotifLockProp.Attach( + KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks ) ); + } + iLockActive = CBTNotifActive::NewL( this, KBTNotifAuthNotifierLockReq, CActive::EPriorityStandard ); + + CheckAndSubscribeNotifLocks(); + + if ( !iSuspended ) + { + // Check if device is in the registry, function of notifier base + GetDeviceFromRegL( iBTAddr ); + } + +#ifdef _DEBUG + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::GetParamsL() Executing authorisation...")); + TBuf<12> deviceAddressString; + pckg().iBDAddr.GetReadable(deviceAddressString); + FTRACE(FPrint(_L("[BTNOTIF]\t BT Address: %S"), &deviceAddressString)); + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::GetParamsL Service Uid: %d = 0x%X"), iServiceUid, iServiceUid )); +#endif + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::UpdateL +// Notifier update. Stores the received bluetooth +// device name into registry and show it on screen. +// ---------------------------------------------------------- +// +TPtrC8 CBTAuthNotifier::UpdateL(const TDesC8& aBuffer) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL()")); + + TBTNotifierUpdateParams params; // Contains iName and iResult (name request) + TPckgC pckg(params); + pckg.Set(aBuffer); + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL - Name: '%S' length: %d"), &pckg().iName, pckg().iName.Length() )); + + + // If the device name request was successful and if new name is valid, show the new name. + if (pckg().iResult == KErrNone) + { + BtNotifNameUtils::SetDeviceNameL(pckg().iName, *iDevice); // Override possible previous device name + + // Show new prompt for dialog if it is still on the screen + if ( !iDevice->IsValidFriendlyName() && iDevice->IsValidDeviceName()) + { + // Create new prompt string with new device name + HBufC* stringholder = StringLoader::LoadL( iStrResourceId, BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())); + CleanupStack::PushL( stringholder ); + iNotifUiUtil->UpdateQueryDlgL( *stringholder ); + iNotifUiUtil->UpdateCoverUiL( iDevice->DeviceName() ); + CleanupStack::PopAndDestroy(); // stringholder + } + } + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL() completed")); + TPtrC8 ret(KNullDesC8); + return (ret); + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::RequestCompletedL +// Gets called when P&S key notifies change +// ---------------------------------------------------------- +void CBTAuthNotifier::RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::RequestCompletedL()")); + ASSERT( aId == KBTNotifAuthNotifierLockReq ); + (void) aActive; + (void) aId; + + if ( aStatus == KErrNone ) + { + TBool prevSuspend = iSuspended; + // check the latest lock status and subscribe to further lock event: + CheckAndSubscribeNotifLocks(); + if ( prevSuspend && !iSuspended ) + { + // Check if device is in the registry, function of notifier base + GetDeviceFromRegL( iBTAddr ); + } + else if ( iSuspended && !(iNotifUiUtil->IsQueryReleased()) ) + { + iNotifUiUtil->DismissDialog(); + } + } + else + { + HandleError( aActive, KBTNotifAuthNotifierLockReq, iLockActive->RequestStatus().Int() ); + } + + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::RequestCompletedL() completed")); + + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::HandleError +// ---------------------------------------------------------- +void CBTAuthNotifier::HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::HandleError() error = %d"), aError )); + (void) aActive; + (void) aId; + (void) aError; + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::DoCancelRequest +// Root caller is CBTNotifActive::CancelRequest(), which calls +// CActive::Cancel that calls DoCancel() if request is active. +// ---------------------------------------------------------- +void CBTAuthNotifier::DoCancelRequest( CBTNotifActive* aActive, TInt aId ) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoCancel() >>")); + ASSERT( aId == KBTNotifAuthNotifierLockReq ); + (void) aActive; + (void) aId; + + iNotifLockProp.Cancel(); + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoCancel() <<")); + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::Cancel +// Not Active Object's cancel, but notifier deactivation +// Release all own resources (member variables) +// ---------------------------------------------------------- +// +void CBTAuthNotifier::Cancel() + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::Cancel()")); + + iLockActive->CancelRequest(); + delete iLockActive; + iLockActive = NULL; + iNotifLockProp.Close(); + + CBTNotifierBase::Cancel(); + + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::Cancel() completed")); + } + +void CBTAuthNotifier::HandleGetDeviceCompletedL(const CBTDevice* aDev) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::HandleGetDeviceCompleted()")); + (void) aDev; + if ( iSuspended) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::HandleGetDeviceCompleted, still suspended, wait")); + return; + } + + TBool reqAllowed = IsJustWorksPaired( iDevice->AsNamelessDevice() ) ? + IsUserAwarePaired( iDevice->AsNamelessDevice() ) : ETrue ; + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier, reqAllowed %d" ), reqAllowed ) ); + if ( !reqAllowed ) + { + // Do not grant access to device that is not paired in Just Works mode without + // user awareness, e.g. pairing due to an incoming connection request from a + // headset. + CompleteMessage(KErrAccessDenied); + return; + } + + iStrResourceId = R_BT_AUTHORISATION_NAME; + + // Select authorisation state for further use (dialogue selection) + switch( iServiceUid ) + { + case KBTSdpObjectPush: + case KBTSdpBasicImaging: + iAuthState = EBTObexAuthorisation; + iStrResourceId = R_BT_RECEIVE_MESSAGE; + iCoverUiDlgId = ECmdShowReceiveMessageFromDeviceDlg; + + if( IsUserAwarePaired( iDevice->AsNamelessDevice() ) ) + { + iAuthState = EBTObexAuthForPairedDevice; + iStrResourceId = R_BT_RECEIVE_MESSAGE_PAIRED; + iCoverUiDlgId = ECmdShowReceiveMessageFromPairedDeviceDlg; + } + break; + case KBTSdpFax: + case KBTSdpDun: + case KBTSdpFileTransfer: + case KBTSdpHeadSet: + case KBTSdpGenericTelephony: + case KBTSdpGenericNetworking: + if ( iDevice->GlobalSecurity().NoAuthorise() ) + { + iAuthState = EBTAutoAuthorisation; + } + else + { + iAuthState = EBTNormalAuthorisation; + } + iCoverUiDlgId = ECmdShowAcceptConnRequestDlg; + break; + default: + { // check if device is authorized + if ( iDevice->GlobalSecurity().NoAuthorise() ) + { + iAuthState = EBTAutoAuthorisation; + } + else + { + iAuthState = EBTAutoAuthorisationNotAuthorisedOnPhone; + } + break; + } + } + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::HandleGetDeviceComplete() Complete. iAuthState = %d"), iAuthState )); + ShowAuthoQueryL(); + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::GetByPassAudioNotifier +// is bypassing this audio connection query needed and if it is, will the +// query be automatically accepted or rejected. +// +// This is used for bypassing the notifiers of the 2nd audio connection, so +// the the user needs to reply to the incoming audio link only once. +// ---------------------------------------------------------- +// +TBool CBTAuthNotifier::GetByPassAudioNotifier(const TBTDevAddr& aDeviceAddress,TBool& aAccept) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::GetByPassAudioNotifier()")); + TBuf8<48> buf; + + RProperty::Define(KPSUidBluetoothEnginePrivateCategory,KBTAuthorInfoPerDevice, RProperty::EByteArray ); + RProperty::Get(KPSUidBluetoothEnginePrivateCategory,KBTAuthorInfoPerDevice,buf); + + if(buf.Length()>2) + { + // accept status of last attempt + aAccept= (buf[0]=='1'); + + // last address + TBuf<12> oldAddrString; + oldAddrString.Copy(buf.Mid(2,12)); + TBTDevAddr lastAddress; + lastAddress.SetReadable(oldAddrString); + + // last time + TInt64 num(0); + TLex8 lex; + lex=buf.Mid(15); + TBuf<32> tmp_debug; + tmp_debug.Copy(buf.Mid(15)); + + lex.Val( num ); + TTime lastConnectionTime( num ); + TTime now; + now.UniversalTime(); + + TBuf16<48> buf2; + buf2.Copy(buf); + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::GetByPassAudioNotifier() Complete same_address=%d Time_ok=%d last_reply=%d"),lastAddress==aDeviceAddress,now>=lastConnectionTime && now =lastConnectionTime && now buf; + buf.Zero(); + buf.AppendNum(aAccept!=EFalse);//now 0/1 only. + buf.Append(';'); + + TBuf<12> a; + aDeviceAddress.GetReadable(a); + for(TInt t=0;t<12;t++) + buf.Append(a[t]); + buf.Append(';'); + + TTime writeTime; + writeTime.UniversalTime(); + buf.AppendNum( writeTime.Int64() ); + + RProperty::Set(KPSUidBluetoothEnginePrivateCategory,KBTAuthorInfoPerDevice,buf); + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::MemorizeCurrentAudioAttempt() complete")); + } + + +// ---------------------------------------------------------- +// CBTAuthNotifier::ShowAuthoQueryL +// Ask user's response on authorization query +// ---------------------------------------------------------- +// +void CBTAuthNotifier::ShowAuthoQueryL() + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ShowAuthoQueryL")); + + if ( iAuthState == EBTAutoAuthorisation ) + { + // device alreay set trusted now. allow connection automatically + CompleteMessage(ETrue, KErrNone); + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier, device authorized already, allow connection automatically" )); + return; + } + + TBool reply; + if ( GetByPassAudioNotifier(iDevice->BDAddr(),reply) ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier::ShowAuthoQueryL bypassing notifier with reply: %d"),reply)); + CompleteMessage(reply, KErrNone); + return; + } + + // Not asking user's response if auth request is for: profile HFP/HSP/A2DP/AVRCP, and + // there is already existing connection to one of those profiles from the same device. + // + TBool connectStatus = IsExistingConnectionToAudioL( iDevice->BDAddr() ); + // if iAuthState==EBTAutoAuthorisationNotAuthorised and device is connected it means it tries several connections + // so we just approve this. Also if connected & EBTAutoAuthorisation. + // + if(connectStatus && ( iAuthState==EBTAutoAuthorisationNotAuthorisedOnPhone)) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::Automatic authorisation ()")); + //Antomatic authorisation without asking user + CompleteMessage(ETrue, KErrNone); + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::ShowAuthoQueryL() completed-" )); + return; + } + + // check if we're showing bt off query + TInt queryValue=EBTQueryOff; + RProperty::Get(KPSUidBluetoothEnginePrivateCategory,KBTTurnBTOffQueryOn,queryValue); + if( queryValue == EBTQueryOn ) + { + CompleteMessage(KErrCancel); + return; + } + + TBTDeviceName tempDeviceName; + BtNotifNameUtils::GetDeviceDisplayName(tempDeviceName, iDevice); + HBufC* stringholder = StringLoader::LoadLC( iStrResourceId, tempDeviceName); + TInt keypress = iNotifUiUtil->ShowQueryL( *stringholder, R_BT_AUTHORISATION_QUERY, + iCoverUiDlgId, tempDeviceName, CAknQueryDialog::EConfirmationTone ); + CleanupStack::PopAndDestroy(); // stringholder + // If this notifier is cancelled by the caller, no need to perform the rest operation: + if ( iSuspended || iMessage.IsNull() ) + { + return; + } + + if( keypress ) // User has accepted the dialog + { + if( iDevice && !iDevice->IsValidLinkKey() ) + { + TTime now; + now.UniversalTime(); + TBuf8<32> buf; + buf.AppendNum( now.Int64() ); + RProperty::Set(KPSUidBluetoothEnginePrivateCategory,KBTConnectionTimeStamp,buf); + } + + MemorizeCurrentAudioAttempt(ETrue,iDevice->BDAddr() ); + CompleteMessage( ETrue, KErrNone ); + } + else // User has rejected the dialog. + { + iLockActive->CancelRequest(); + DoRejectAuthorizationL(); + } + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::DoRejectAuthorizationL +// Handle query threshold and block after user rejects authorization +// ---------------------------------------------------------- +// +void CBTAuthNotifier::DoRejectAuthorizationL() + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL()")); + + CheckAndHandleQueryIntervalL(); + if( iMessage.IsNull() ) + { + return; // No need to continue. + } + + MemorizeCurrentAudioAttempt(EFalse,iDevice->BDAddr()); + + //Logic: query block only at the second time for the same paired device + // query block everytime after rejection for non-paired device. + if( IsPaired( iDevice->AsNamelessDevice() ) ) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() rejected a paired device.")); + + TBuf<2*KBTDevAddrSize> tmp; //2 hex digits per byte + RProperty::Get(KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr, tmp); + TBTDevAddr priorDeviceaddress; + priorDeviceaddress.Reset(); + priorDeviceaddress.SetReadable(tmp); + + if(priorDeviceaddress != iDevice->BDAddr() ) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() NOT the prior rejected device, no block query.")); + + // The last device was not current device, + // so the last device is updated to be current device. + iDevice->BDAddr().GetReadable(tmp); + RProperty::Set(KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr, tmp ); + + // Complete message and free resources + CompleteMessage(EFalse, KErrNone); + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() completed")); + return; + } + else + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::DoRejectAuthorizationL() IS SAME as the prior rejected device.")); + + // this was 2nd time in row. Clear the key, so the question will not be made next time. + TBuf<2*KBTDevAddrSize> tmp; + TBTDevAddr emptyAddr; + emptyAddr.Reset(); + emptyAddr.GetReadable(tmp); + RProperty::Set(KPSUidBluetoothEnginePrivateCategory, KBTBlockDevAddr, tmp ); + } + } + + // Ask user to Block this device or not. + if( !iMessage.IsNull() ) + { + QueryBlockDeviceL(); + } + } + +// ---------------------------------------------------------- +// CBTAuthNotifier::CheckAndSubscribeNotifLocks +// Subscribe to PS key and check key value. +// ---------------------------------------------------------- +// +void CBTAuthNotifier::CheckAndSubscribeNotifLocks() + { + if ( !iLockActive->IsActive() ) + { + FLOG(_L("[BTNOTIF]\t CBTAuthNotifier, Subscribe Device Operation Info")); + iNotifLockProp.Subscribe( iLockActive->RequestStatus() ); + iLockActive->GoActive(); + } + TInt ops; + TBTNotifLockPublish::GetNotifLocks( iNotifLockProp, + ops, iBTAddr ); + iSuspended = ops & EBTNotiferLockPairedDeviceSetting; + FTRACE(FPrint(_L("[BTNOTIF]\t CBTAuthNotifier suspended ? %d"), iSuspended )); + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,249 @@ +/* +* Copyright (c) 2002 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: Bluetooth visibility timeout notifier class. +* +*/ + + +// INCLUDE FILES + +#include // Localisation stringloader +#include // Own resources +#include "BTNGenericInfoNotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include +#include +#include "btnotifnameutils.h" + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTGenericInfoNotifier* CBTGenericInfoNotifier::NewL() + { + CBTGenericInfoNotifier* self=new (ELeave) CBTGenericInfoNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::CBTGenericInfoNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTGenericInfoNotifier::CBTGenericInfoNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTGenericInfoNotifier::~CBTGenericInfoNotifier() + { + Cancel(); // Free own resources + delete iQueryMessage; + } + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTGenericInfoNotifier::TNotifierInfo CBTGenericInfoNotifier::RegisterL() + { + iInfo.iUid=KBTGenericInfoNotifierUid; + iInfo.iChannel=KBTGenericInfoNotifierUid; + iInfo.iPriority=ENotifierPriorityHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::StartL +// Synchronic notifier launch. Contructs and shows a global +// note when temp visibility expire, no parameters need here. +// ---------------------------------------------------------- +// +TPtrC8 CBTGenericInfoNotifier::StartL( const TDesC8& aBuffer ) + { + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL()")); + ProcessParamBufferL(aBuffer); + + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL() completed")); + + TPtrC8 ret(KNullDesC8); + return (ret); + } + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::GetParamsL +// Mandatory for BT Notifiers when using asynchronous launch. +// ---------------------------------------------------------- +// +void CBTGenericInfoNotifier::GetParamsL(const TDesC8& aBuffer, + TInt /*aReplySlot*/, + const RMessagePtr2& aMessage ) + { + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::GetParamsL")); + if (!iMessage.IsNull()) + { + aMessage.Complete(KErrInUse); + return; + } + iMessage = aMessage; + ProcessParamBufferL(aBuffer); + } + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::ProcessParamBufferL +// Parse the data out of the message that is sent by the +// client of the notifier. +// ---------------------------------------------------------- +void CBTGenericInfoNotifier::ProcessParamBufferL(const TDesC8& aBuffer) + { + TBTGenericInfoNotifierParams bParams; + TPckgC bPckg(bParams); + + bPckg.Set( aBuffer ); + iSecondaryDisplayCommand = ECmdBTnotifUnavailable; + switch (bPckg().iMessageType) + { + case EBTConnected: + iMessageResourceId= R_BT_CONF_CONNECTED_PROMPT; + iSecondaryDisplayCommand=ECmdShowBtConnectedNote; + break; + case EBTDisconnected: + iMessageResourceId= R_BT_CONF_DISCONNECTED_PROMPT; + iSecondaryDisplayCommand=ECmdShowBtDisconnectedNote; + break; + case EBTAudioAccessory: + iMessageResourceId= R_BT_AUDIO_ACCESSORY_PROMPT; + iSecondaryDisplayCommand=ECmdShowBtAudioAccessoryNote; + break; + case EBTAudioHandset: + iMessageResourceId= R_BT_AUDIO_HANDSET_PROMPT; + iSecondaryDisplayCommand=ECmdShowBtAudioHandsetNote; + break; + case EBTClosed: + iMessageResourceId= R_BT_CONN_CLOSED_PROMPT; + iSecondaryDisplayCommand=ECmdShowBtDisconnectedNote; + break; + case EBTDeviceNotAvailable: + iMessageResourceId= R_BT_DEVICE_NOT_AVAIL; + iSecondaryDisplayCommand=ECmdShowBtDeviceNotAvailableNote; + break; + case EBTOfflineDisabled: + iMessageResourceId= R_BT_OFFLINE_DISABLED; + iSecondaryDisplayCommand=ECmdShowBtOfflineDisableNote; + break; + case EBTVisibilityTimeout: + iMessageResourceId= R_BT_HIDDEN_FROM_OTHERS_NOTE; + iSecondaryDisplayCommand=ECmdShowBtHiddenFromOthersNote; + break; + case EBTEnterSap: + iMessageResourceId= R_BT_ENTER_SAP_NOTE; + iSecondaryDisplayCommand=ECmdShowBtSapEnteringNote; + break; + case EBTSapOk: + iMessageResourceId= R_BT_ENTER_SAP_SUCCEED_NOTE; + iSecondaryDisplayCommand=ECmdShowBtSapEnteringSucceededNote; + break; + case EBTSapFailed: + iMessageResourceId= R_BT_ENTER_SAP_FAILED_NOTE; + iSecondaryDisplayCommand=ECmdShowBtSapEnteringFailedNote; + break; + case EBTSapNoSim: + iMessageResourceId= R_BT_SAP_NO_SIM_NOTE; + iSecondaryDisplayCommand=ECmdShowBtSapNoSimNote; + break; + case EBTDeviceBusy: + iMessageResourceId=R_BT_BUSY_TEXT; + iSecondaryDisplayCommand=ECmdShowBtBusyNote; + break; + case EIRNotSupported: + iMessageResourceId=R_IR_NOT_SUPPORTED; + iSecondaryDisplayCommand=ECmdShowIrNotSupportedNote; + break; + case ECmdShowBtBatteryLow: + iMessageResourceId= R_BT_ACCESSORY_LOW; + iSecondaryDisplayCommand= ECmdShowBtBatteryLowNote; + break; + case ECmdShowBtBatteryCritical: + iMessageResourceId= R_BT_ACCESSORY_CRITICAL; + iSecondaryDisplayCommand= ECmdShowBtBatteryCriticalNote; + break; + case EBTStayPowerOn: + iMessageResourceId= R_BT_PERMANENTLY_ON; + break; + case EBTSwitchedOn: + iMessageResourceId= R_BT_SWITCHED_ON; + break; + case EBTSwitchedOff: + iMessageResourceId= R_BT_SWITCHED_OFF; + break; + default: + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier:: Unkown messageType! ")); + User::Leave(KErrNotFound); + } + + // if the logic string contains substitute indicator "%U", replace it with device name: + iQueryMessage = StringLoader::LoadL( iMessageResourceId); + _LIT(PU,"%U"); + if( iQueryMessage->Find(PU) != KErrNotFound) + { + iBTAddr = TBTDevAddr( bPckg().iRemoteAddr ); + iDevice = CBTDevice::NewL(iBTAddr); + GetDeviceFromRegL( iBTAddr ); + } + else + { + ShowNoteAndCompleteL(); + } + } + +// ---------------------------------------------------------- +// CBTGenericInfoNotifier::ShowNoteAndCompleteL +// Shows the notifier in backround +// ---------------------------------------------------------- +// +void CBTGenericInfoNotifier::ShowNoteAndCompleteL() + { + iNotifUiUtil->ShowInfoNoteL( *iQueryMessage, iSecondaryDisplayCommand ); + CompleteMessage(KErrNone); + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete")); + } + +void CBTGenericInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()")); + + delete iQueryMessage; + iQueryMessage=NULL; + + TBTDeviceName name; + BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); + iQueryMessage = StringLoader::LoadL( iMessageResourceId, name); + + ShowNoteAndCompleteL(); + + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete")); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,342 @@ +/* +* Copyright (c) 2002 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: Bluetooth visibility timeout notifier class. +* +*/ + + +// INCLUDE FILES + +#include // Localisation stringloader +#include +#include +#include // Own resources +#include +#include "BTNGenericQueryNotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTGenericQueryNotifier* CBTGenericQueryNotifier::NewL() + { + CBTGenericQueryNotifier* self=new (ELeave) CBTGenericQueryNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::CBTGenericQueryNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTGenericQueryNotifier::CBTGenericQueryNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTGenericQueryNotifier::~CBTGenericQueryNotifier() + { + Cancel(); // Free own resources + delete iName; + delete iQueryMessage; + delete iQueryHeader; + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTGenericQueryNotifier::TNotifierInfo CBTGenericQueryNotifier::RegisterL() + { + iInfo.iUid=KBTGenericQueryNotifierUid; + iInfo.iChannel=KBTGenericQueryNotifierUid; + iInfo.iPriority=ENotifierPriorityHigh; + return iInfo; + } + + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::StartL +// Synchronic notifier launch. Contructs and shows a global +// note, no parameters need here. +// ---------------------------------------------------------- +// +TPtrC8 CBTGenericQueryNotifier::StartL( const TDesC8& /*aBuffer*/ ) + { + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::StartL()")); + + TPtrC8 ret(KNullDesC8); + return (ret); + + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::GetParamsL +// Mandatory for BT Notifiers when using asynchronous launch. +// This notifier is synchronous so no implementation is needed. +// ---------------------------------------------------------- +// +void CBTGenericQueryNotifier::GetParamsL(const TDesC8& aBuffer, + TInt aReplySlot, + const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL")); + + if (iMessage.Handle()) + { + aMessage.Complete(KErrInUse); + return; + } + + ProcessParamBufferL(aBuffer); + + iMessage = aMessage; + iReplySlot = aReplySlot; + + ShowQueryAndCompleteL(); + + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL Complete")); + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::ProcessParamBufferL +// Parse the data out of the message that is sent by the +// client of the notifier. +// ---------------------------------------------------------- +void CBTGenericQueryNotifier::ProcessParamBufferL(const TDesC8& aBuffer) + { + + TBTGenericQueryNotifierParams bParams; + TPckgC bPckg(bParams); + bPckg.Set( aBuffer ); + + if( bPckg().iMessageType == EBTNameQuery ) + { + iIsNameQuery = ETrue; + return; + } + iSecondaryDisplayCommand = ECmdBTnotifUnavailable; + switch (bPckg().iMessageType) + { + case EBTReceiveMessageQuery: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_RECEIVE_MESSAGE ; + iSecondaryDisplayCommand=ECmdShowReceiveMessageFromDeviceDlg; + break; + case EBTReceiveMessagePairedQuery: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_RECEIVE_MESSAGE_PAIRED; + iSecondaryDisplayCommand= ECmdShowReceiveMessageFromPairedDeviceDlg; + break; + case EBTIsOffQuery: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_POWER_IS_OFF ; + iSecondaryDisplayCommand=ECmdShowBtIsOffDlg; + break; + case EBTActivateOffLineQuery: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_ACTIVATE_IN_OFFLINE; + iSecondaryDisplayCommand=ECmdShowBtActivateInOfflineDlg; + break; + case EBTNoDevicesFoundQuery: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_NO_DEVICES_FOUND; + break; + case EBTAcceptRequestQuery: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_AUTHORISATION_NAME ; + iSecondaryDisplayCommand=ECmdShowAcceptConnRequestDlg; + break; + + case EBTIsOffJavaQuery: + iIsMessageQuery=ETrue; + if( bPckg().iNameExists ) + { + iMessageResourceId=R_BT_IS_OFF_JAVA_APPNAME; // when caller provide Java application name. + } + else + { + iMessageResourceId=R_BT_IS_OFF_JAVA; //r_bt_is_hidden_java + } + iSecondaryDisplayCommand=ECmdShowBtBtIsOffJavaDlg; + iQueryHeader=StringLoader::LoadL( R_BT_IS_OFF_JAVA_HEADER); + break; + + case EBTIsNotShownQuery: + iIsMessageQuery=ETrue; + if( bPckg().iNameExists ) + { + iMessageResourceId=R_BT_IS_HIDDEN_JAVA_APPNAME; // when caller provide Java application name. + } + else + { + iMessageResourceId=R_BT_IS_HIDDEN_JAVA; //r_bt_is_hidden_java + } + iSecondaryDisplayCommand=ECmdShowBtIsNotVisibleDlg; + iQueryHeader=StringLoader::LoadL( R_BT_IS_HIDDEN_JAVA_HEADER); + break; + + case EBTBlockConnectionQuery: + case EBTBlockPairedConnectionQuery: + iIsMessageQuery=ETrue; + if( bPckg().iMessageType == EBTBlockConnectionQuery ) + iMessageResourceId = R_BT_BLOCK_DEVICE_NOHELP; + else + iMessageResourceId = R_BT_BLOCK_PAIRED_DEVICE_NOHELP ; + + iQueryHeader= StringLoader::LoadL( R_BT_BLOCK_DEVICE_HEADER ); + break; + + case EBTSwitchOffAnyway: + iIsMessageQuery=EFalse; + iMessageResourceId=R_BT_SWITCH_OFF_ANYWAY; + break; + + default: + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier:: Unkown messageType! ")); + User::Leave(KErrNotFound); + } + + // if the logic string contains substitute indicator "%U", replace it with device name: + // + iQueryMessage = StringLoader::LoadL( iMessageResourceId); + _LIT(PU,"%U"); + if( iQueryMessage->Find(PU) != KErrNotFound) + { + delete iQueryMessage; + iQueryMessage=NULL; + + //if no device name provided, default name will be used: + if( !bPckg().iNameExists ) + iName=StringLoader::LoadL(R_BT_DIALOG_DEF_NAME); + else + { + iName=HBufC::NewL(bPckg().iName.Length() ); + iName->Des().Copy(bPckg().iName); + } + iQueryMessage = StringLoader::LoadL( iMessageResourceId,*iName); + } + else + { + iName=NULL; + } + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::UpdateL +// Update notifier according to new data +// ---------------------------------------------------------- +// +TPtrC8 CBTGenericQueryNotifier::UpdateL(const TDesC8& aBuffer) + { + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL")); + delete iQueryMessage; + iQueryMessage = NULL; + ProcessParamBufferL(aBuffer); + if( !iNotifUiUtil->IsQueryReleased() ) + { + if(iIsMessageQuery ) + { + iNotifUiUtil->UpdateMessageQueryDlgL(*iQueryMessage); + } + else + { + iNotifUiUtil->UpdateQueryDlgL(*iQueryMessage); + } + } + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete")); + + TPtrC8 ret(KNullDesC8); + return (ret); + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::ShowQueryAndCompleteL +// Shows the notifier in backround and complete message +// ---------------------------------------------------------- +// +void CBTGenericQueryNotifier::ShowQueryAndCompleteL() + { + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL")); + + // Turn lights on and deactivate apps -key + // + iNotifUiUtil->TurnLightsOn(); + if( iIsNameQuery ) + { + TBool nameStatus = IsLocalNameModifiedL(); + if( !nameStatus ) + { + (void) AskLocalBTNameQueryL(); + } + // Check if Local name is set again before turn BT on. + // Turn BT on only when there is local name, since user still has chance + // to ignore the asking name query - like pressing End-key + // + TBTDeviceName localName; + localName.Zero(); + TInt err = iBTEngSettings->GetLocalName(localName); + + if (localName.Length() <= 0) + { + err = KErrCancel; + } + + CompleteMessage( (!err) ? ETrue : EFalse, KErrNone ); + + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL iIsNameQuery complete")); + return; + } + + TInt keypress; + TBTDeviceName name(KNullDesC); + if( iName ) + { + name.Copy( *iName ); + } + if( iIsMessageQuery ) + { + + keypress = iNotifUiUtil->ShowMessageQueryL(*iQueryMessage, *iQueryHeader, + R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); + } + else + { + keypress = iNotifUiUtil->ShowQueryL( *iQueryMessage, R_BT_GENERIC_QUERY, + iSecondaryDisplayCommand, name, CAknQueryDialog::EConfirmationTone ); + } + + CompleteMessage( (keypress) ? ETrue: EFalse, KErrNone ); + + FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL complete")); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNInqNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNInqNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth device inquiry notifier class. +* +*/ + + +// INCLUDE FILES +#include // Eikon environment + +#include "btninqnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include // Localisation stringloader +#include // Own resources + + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTInqNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTInqNotifier* CBTInqNotifier::NewL() + { + CBTInqNotifier* self=new (ELeave) CBTInqNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTInqNotifier::CBTInqNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTInqNotifier::CBTInqNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTInqNotifier::~CBTInqNotifier() + { + FLOG(_L("[BTNOTIF]\t CBTInqNotifier::~CBTInqNotifier()")); + delete iUi; + FLOG(_L("[BTNOTIF]\t CBTInqNotifier::~CBTInqNotifier() completed")); + } + +// ---------------------------------------------------------- +// CBTInqNotifier::RegisterL +// ---------------------------------------------------------- +// +CBTInqNotifier::TNotifierInfo CBTInqNotifier::RegisterL() + { + + iInfo.iUid=KDeviceSelectionNotifierUid; + iInfo.iChannel=KBTInquiryChannel; + iInfo.iPriority=ENotifierPriorityVHigh; // User input level + return iInfo; + } + +// ---------------------------------------------------------- +// CBTInqNotifier::GetParamsL +// Initialize parameters and launch device search. +// ---------------------------------------------------------- +// +void CBTInqNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL()")); + + if( iUi || iReplySlot!=NULL || !iMessage.IsNull() ) + { + aMessage.Complete(KErrInUse); + return; + } + + iMessage = aMessage; + iReplySlot = aReplySlot; + + TBTDeviceClass cod; + TBTDeviceSelectionParamsPckg pckg; + pckg.Copy(aBuffer); + + LaunchInquiryL(pckg().DeviceClass()); + + FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL() completed ")); + } + +// ---------------------------------------------------------- +// CBTInqNotifier::NotifyDeviceSearchCompleted +// Notified by InquiryUI, return to caller by completing message +// ---------------------------------------------------------- +// +void CBTInqNotifier::NotifyDeviceSearchCompleted(TInt aErr, const TBTDeviceResponseParams& aDevice) + { + FTRACE(FPrint( _L("[BTNOTIF]\t CBTInqNotifier::NotifyDeviceSearchCompleted aErr %d"), aErr )); + CompleteMessage(TBTDeviceResponseParamsPckg( aDevice ), aErr); + } + +// ---------------------------------------------------------- +// CBTInqNotifier::Cancel +// Release all own resources (member variables) +// ---------------------------------------------------------- +// +void CBTInqNotifier::Cancel() + { + FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel()")); + if( iUi ) + { + iUi->Cancel(); + } + CBTNotifierBase::Cancel(); + FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel() completed")); + } + +// ---------------------------------------------------------- +// Ensure BT is ON; there are not too many connections; InqUi +// is launched successfully. +// ---------------------------------------------------------- +// +void CBTInqNotifier::LaunchInquiryL(const TBTDeviceClass& aDesiredDevice) + { + // Turn BT on if it is not yet. + if ( !CheckAndSetPowerOnL() ) + { + CompleteMessage(KErrGeneral); + return; + } + + TInt linkCount; + User::LeaveIfError(RProperty::Get(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount, linkCount)); + if ( linkCount > 6 ) //support only piconet + { + iNotifUiUtil->ShowInfoNoteL( R_BT_BUSY_NOTE, ECmdBTnotifUnavailable ); + User::Leave(KErrInUse); + } + + // launch Inquiry UI + + iUi = new (ELeave) CBTInqUI( this, iNotifUiUtil, aDesiredDevice); + + + iUi->ConstructL(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNInqUI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNInqUI.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1348 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth device inquiry user interface class. +* +*/ + + +// INCLUDE FILES +#include // AVKON components +#include +#include +#include +#include +#include // Localisation stringloader +#include // For WLAN state checking +#include +#include +#include // Resource reader +#include // Own resources +#include +#include +#include // Borrow WLan signal strenth bar to show RSSI +#include +#include +#include "btninqui.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include "btnotifnameutils.h" + + +const TInt KBTAllPurposeBufferLength = 266; +const TInt KBTNotifNonPairedUsedDevicesMaxNumber= 5; +// RSSI value range: -127dB ~ +20dB +const TInt KRssiRangeOffset = 127 + 1; // Offset for getting a non-zero positive value +const TInt KMediumStrength = 53; +const TInt KHighStrength = 82; +const TUint32 ExcludePairedDeviceMask = 0x800000; +const TUint32 ResetExcludePairedDeviceMask = 0xFF7FFFFF; +_LIT(KBtnotifBmpFileName,"btnotif.mbm"); +_LIT(KWLanBmpFileName,"wlanplugin.mif"); + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTInqUI::CBTInqUI +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTInqUI::CBTInqUI( MBTNDeviceSearchObserver* aObserver, + CBTNotifUIUtil* aUtil, + const TBTDeviceClass& aDesiredDevClass): + iUiUtil (aUtil), + iEikonEnvRef( iUiUtil->LocalEikonEnv() ), + iDevicesFound (EFalse), + iBroughtForwards (EFalse), + iDesiredDeviceClass (aDesiredDevClass), + iSystemCancel (EFalse), + iPageForName ( EFalse ), + iIndex (0), + iDevSearchObserver (aObserver) + { + iBTRegistryQueryState=ENoQuery; + } + +// ---------------------------------------------------------- +// CBTInqUI::ConstructL +// Symbian 2nd phase constructor can leave. +// Creates first device list (not shown yet) and initializes +// couple of member variables with default values. +// ---------------------------------------------------------- +// +void CBTInqUI::ConstructL() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::ConstructL()")); + + // Read default device names to an array + iDefaultDeviceNamesArray = iEikonEnvRef.ReadDesCArrayResourceL( R_BT_DEFAULT_DEVICE_NAMES ); + + // create the timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle); + + // Create device array + // + iDeviceListRows = new(ELeave) CDesCArrayFlat(1); + + iPairedDevicesArray = new (ELeave) CBTDeviceArray(1); + iLastUsedDevicesArray = new(ELeave) CBTDeviceArray(1); + iLastSeenDevicesArray = new(ELeave) CBTDeviceArray(1); + iAdjustedUsedDeviceArray = new(ELeave) CBTDeviceArray(1); + + iDevMan=CBTEngDevMan::NewL(this); + + iExcludePairedDevices = iDesiredDeviceClass.DeviceClass() & ExcludePairedDeviceMask ? + ETrue : EFalse; + if ( iExcludePairedDevices ) + { + FLOG (_L("[BTNOTIF]\t CBTInqUI::ConstrucL Excluding paired devices")); + iDesiredDeviceClass = iDesiredDeviceClass.DeviceClass() & ResetExcludePairedDeviceMask; + } + // Retrieve paired devices to a local array + RetrievePairedDevices(); + + FLOG(_L("[BTNOTIF]\t CBTInqUI::ConstructL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::RetrieveUsedDevices- Substitute +// ---------------------------------------------------------- +// +void CBTInqUI::RetrieveUsedDevices() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrieveUsedDevicesL()")); + + TBTRegistrySearch searchPattern; + searchPattern.FindAll(); + + //Ignore this error. Continue device search. + TInt err=iDevMan->GetDevices( searchPattern, iLastUsedDevicesArray ); + if(err) + { + TRAP_IGNORE(AdjustDeviceArrayL(iAdjustedUsedDeviceArray)); + DoDeviceFrontListSelection(); + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI: get useddevice err %d"), err)); + } + else + { + iBTRegistryQueryState=EQueryUsed; + } + FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrieveUsedDevicesL() returned")); + } + +//--------------------------------------------------------------- +// CBTInqUI::RetrievePairedDevices +//--------------------------------------------------------------- +void CBTInqUI::RetrievePairedDevices() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrievePairedDevicesL()")); + + TBTRegistrySearch searchPattern; + searchPattern.FindBonded(); + + TInt err= iDevMan->GetDevices( searchPattern, iPairedDevicesArray ); + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI: get paireddevice err %d"), err)); + if(err) + { + //Next: try to get used devices + RetrieveUsedDevices(); + } + else + { + iBTRegistryQueryState=EQueryPaired; + } + FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrievePairedDevicesL() returned")); + } + +// ---------------------------------------------------------- +// CBTInqUI::HandleGetDevicesComplete +// ---------------------------------------------------------- +// +void CBTInqUI::HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* /*aDeviceArray*/) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleGetDevicesComplete() err: %d"), aErr)); + (void) aErr; + switch(iBTRegistryQueryState) + { + case EQueryPaired: + // If a device is paired in Just Works model but without user awareness, + // This device won't be shown in UI paired view, so we have to + // remove it from this array so that it will be shown to user + // in the last used device list. + for (int i = iPairedDevicesArray->Count() - 1; i >= 0; --i ) + { + if ( !IsUserAwarePaired( iPairedDevicesArray->At( i )->AsNamelessDevice() ) ) + { + delete iPairedDevicesArray->At( i ); + iPairedDevicesArray->Delete( i ); + } + } + RetrieveUsedDevices(); + break; + case EQueryUsed: + // fill in the list of last seen devices, so it can be shown + TRAP_IGNORE(AdjustDeviceArrayL(iAdjustedUsedDeviceArray)); + DoDeviceFrontListSelection(); + break; + default: + break; + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleGetDevicesComplete() Complete")); + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTInqUI::~CBTInqUI() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::~CBTInqUI()")); + + if( iBroughtForwards ) + { + iEikonEnvRef.BringForwards(EFalse); + iBroughtForwards = EFalse; + } + + if( iPairedDevicesArray ) + { + iPairedDevicesArray->ResetAndDestroy(); + delete iPairedDevicesArray; + } + if( iLastUsedDevicesArray ) + { + iLastUsedDevicesArray->ResetAndDestroy(); + delete iLastUsedDevicesArray; + } + if( iLastSeenDevicesArray ) + { + iLastSeenDevicesArray->ResetAndDestroy(); + delete iLastSeenDevicesArray; + } + if( iAdjustedUsedDeviceArray ) + { + iAdjustedUsedDeviceArray->ResetAndDestroy(); + delete iAdjustedUsedDeviceArray; + } + if( iDefaultDeviceNamesArray ) + { + iDefaultDeviceNamesArray->Reset(); + delete iDefaultDeviceNamesArray; + } + + delete iDevMan; + delete iDeviceListBox; + delete iDeviceListRows; + delete iPeriodicTimer; + + FLOG(_L("[BTNOTIF]\t CBTInqUI::~CBTInqUI() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::Cancel +// ---------------------------------------------------------- +// +void CBTInqUI::Cancel() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::Cancel()")); + + iSystemCancel = ETrue; + if(iDevMan) + { + iDevMan->Cancel(); + } + + if( iSearchFilterPopupList ) + { + iSearchFilterPopupList->CancelPopup(); + } + + if(iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + } + + RemoveScanner(); + InquiryComplete(KErrCancel); + + FLOG(_L("[BTNOTIF]\t CBTInqUI::Cancel() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::DisplayDevicesFrontListL +// Display last seen devices popuplist +// ---------------------------------------------------------- +// +void CBTInqUI::DisplayDevicesFrontListL() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::DisplayDevicesFrontListL()")); + + + if ( iAdjustedUsedDeviceArray->Count() <= 0 ) + { + SelectSearchCategoryL(); + return; + } + + if( !iBroughtForwards ) + { + iEikonEnvRef.BringForwards(ETrue); // Destructor will release this later on + iBroughtForwards = ETrue; + } + + // Create the devices popuplist + CreatePopupListL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT , R_BT_LAST_USED_DEVS_POPUP_TITLE ); + + // Add devices into device list. + for( TInt index = 0; index < iAdjustedUsedDeviceArray->Count(); index++ ) + { + UpdateDeviceListL ( iAdjustedUsedDeviceArray->At(index) ); + } + + // Add "more devices" command as first item of list + HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength ); + formatString->Des().Copy( TPtrC(KDeviceIconFormatTable[EDeviceIconBlank].iFormat ) ); + HBufC* moreDevicesString = iEikonEnvRef.AllocReadResourceLC( R_BT_MORE_DEVICES_ITEM ); + formatString->Des().Append( *moreDevicesString ); + CleanupStack::PopAndDestroy(); // moreDevicesString + iDeviceListRows->InsertL( 0, *formatString ); + CleanupStack::Pop(); // formatString + + // Launch popup list and wait for user input + AllowDialerAndAppKeyPress( EFalse ); + TInt popupRetVal = iDevicePopupList->ExecuteLD(); + iDevicePopupList = NULL; + AllowDialerAndAppKeyPress( ETrue ); + + if( !popupRetVal ) + { + // query cancelled by user or system, complete device search: + iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel); + return; + } + TInt currentDeviceIndex = iDeviceListBox->CurrentItemIndex(); + + // Delete device list box and reset device items array + delete iDeviceListBox; + iDeviceListBox = NULL; + iDeviceListRows->Reset(); + + if( currentDeviceIndex > 0 ) // User selected "a used device" + { + HandleDeviceSelectionL( iAdjustedUsedDeviceArray->At( currentDeviceIndex - 1 ) ); + return; + } + + // user selected more devices. + SelectSearchCategoryL(); + FLOG(_L("[BTNOTIF]\t CBTInqUI::DisplayDevicesFrontListL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::DeviceSearchUiL +// Execute bluetooth device search/inquiry. +// Parameters: +// OUT: aDevice - selected device after inquiry +// IN: aObexOnly - flag if OBEX capable devices is requested +// ---------------------------------------------------------- +// +void CBTInqUI::DeviceSearchUiL() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL()")); + + TSearchFlowState searchFlow; + TInt err; + AllowDialerAndAppKeyPress( EFalse ); + do + { + searchFlow = InitInquiryL(err); + } while (searchFlow == ESearchAgain); + + if (searchFlow == ESearchCompleted) + { + // search completed caused by either user cancel or failure + iDevSearchObserver->NotifyDeviceSearchCompleted(err); + AllowDialerAndAppKeyPress( ETrue ); + return; + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI, Displaying devices already found")); + + TInt keypress(0); + // Show devices popup list for received devices while + // inquiry is still active and list may be updated. + if( !iInquiryComplete ) + { + CreatePopupListL( R_BT_SOFTKEYS_SELECT_STOP, R_BT_SEARCH_DEVS_POPUP_TITLE ); + + // Set animation + iDevicePopupList->Heading()->SetHeaderAnimationL( R_BT_ANIMATION_FOR_POPUPLIST ); + + // Launch popup list and wait for user input + keypress = iDevicePopupList->ExecuteLD(); + iDevicePopupList = NULL; + } + + // If Cancel() is called while DoInquery() is still running, + // such as taking out MMC while bt devices discovery or user pressed redkey. + // In such cases, We need to dismiss anything and function returns immediately. + // + if (iSystemCancel ) + { + FLOG(_L("[BTNOTIF]\t inquiry was canncelled by the system!")); + iSystemCancel = EFalse; + AllowDialerAndAppKeyPress( ETrue ); + iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel); + return; + } + + // Cancel inquiry + RemoveScanner(); + + // Store the highlighted device index and destroy list box + iHighLightedItemIndex = 0; + if( iDeviceListBox ) + { + iHighLightedItemIndex = iDeviceListBox->CurrentItemIndex(); + delete iDeviceListBox; + iDeviceListBox = NULL; + } + + // user selected a device during active inquiry + if (keypress) + { + AllowDialerAndAppKeyPress( ETrue ); + HandleDeviceSelectionL( iLastSeenDevicesArray->At( iHighLightedItemIndex ) ); + return; + } + + // Error encountered in inquiry + if (iInquiryStatus) + { + AllowDialerAndAppKeyPress( ETrue ); + iDevSearchObserver->NotifyDeviceSearchCompleted(iInquiryStatus); + return; + } + + // Inquiry completed, show final device list + FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL Displaying final devicelist")); + CreatePopupListL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, R_BT_FOUND_DEVS_POPUP_TITLE ); + + //cancel iPeriodicTimer after the final list is shown + iPeriodicTimer->Cancel(); + User::ResetInactivityTime(); + // Set highlight on top of same device as it was in previous popuplist + if( iHighLightedItemIndex >= 0 ) + { + iDeviceListBox->HandleItemAdditionL(); + iDeviceListBox->SetCurrentItemIndex(iHighLightedItemIndex); + } + + // Launch popup list and wait for user input + keypress = iDevicePopupList->ExecuteLD(); + iDevicePopupList = NULL; + AllowDialerAndAppKeyPress( ETrue ); + // If dialog is cancelled by system: + if( !keypress) + { + iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel); + return; + } + + // Get user selection + TInt index = iDeviceListBox->CurrentItemIndex(); + delete iDeviceListBox; + iDeviceListBox = NULL; + + HandleDeviceSelectionL( iLastSeenDevicesArray->At( index ) ); + + FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL() complete")); + } + +TSearchFlowState CBTInqUI::InitInquiryL(TInt& aReason) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::InitInquiryL")); + if (IsActiveVoIPOverWLAN()) + { + iUiUtil->ShowInfoNoteL( R_BT_NO_DEVICE_DISCOVERY_VOIP, ECmdBTnotifUnavailable ); + aReason = KErrInUse; + return ESearchCompleted; + } + + // starting the timer + iPeriodicTimer->Cancel(); + iPeriodicTimer->Start(KPeriodicTimerInterval4Sec, KPeriodicTimerInterval4Sec, + TCallBack(PeriodicTimerCallBack, this)); + + // Prepare for using hostresolver to search devices + CreateScannerL(); + + iInquiryStatus = KErrCancel; // Give a initial value (for end key handling) + iDevicesFound = EFalse; + iInquiryComplete = EFalse; + iSystemCancel = EFalse; + + // Show wait note until dialog is dismissed by inquirey result callbacks or user cancel + TInt ret = iUiUtil->ShowWaitDlgL( R_BT_SEARCHING_DEVICES_NOTE ); + + // If user cancels searching, ret will be KerrNone. + // According to Description of Eikdialog, ShowWaitDlgL() returns zero + // if it was the cancel button (@c EEikBidCancel). + if( ret == KErrNone || iSystemCancel ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI, User cancelled waiting note")); + RemoveScanner(); + aReason = KErrCancel; + return ESearchCompleted; + } + + if( !iDevicesFound ) // No devices found at all + { + FLOG(_L("[BTNOTIF]\t CBTInqUI no devices found at all")); + RemoveScanner(); // Cancel inquiry + + if( iInquiryStatus != KErrNone ) + { + aReason = iInquiryStatus; + return ESearchCompleted; + } + + // Show try again query + TBool keypress(0); + keypress = iUiUtil->ShowQueryL( KErrNone, R_BT_TRY_AGAIN_QUERY, ECmdBTnotifUnavailable ); + if( !keypress ) // User has not requested new inquiry + { + aReason = KErrCancel; + return ESearchCompleted; + } + else + { + FLOG(_L("[BTNOTIF]\t CBTInqUI user wanted to try again")); + return ESearchAgain; + } + } + return ESearchFirstDeviceFound; + } + +// ---------------------------------------------------------- +// CBTInqUI::DeviceAvailableL +// Bluetooth device has been received. +// ---------------------------------------------------------- +// +void CBTInqUI::DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL()")); + + if( !iDevicesFound ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() first found, clear last seen devices array")); + iLastSeenDevicesArray->ResetAndDestroy(); // Remove previous inquiry results + iDevicesFound = ETrue; + iInquiryStatus = KErrNone; + } + + iUiUtil->CompleteWaitDlgL(); + + TInquirySockAddr& sa = TInquirySockAddr::Cast( aNameRecord.iAddr ); + + // Create device object with received CoD information + CBTDevice* newDevice = CBTDevice::NewLC( sa.BTAddr() ); + TBTDeviceClass cod( sa.MajorServiceClass(), sa.MajorClassOfDevice(), sa.MinorClassOfDevice() ); + newDevice->SetDeviceClass( cod ); + FTRACE(FPrint(_L("[BTNOTIF]\t CoD %b"), cod.DeviceClass() )); + TInt rssi = 0; + if( sa.ResultFlags() & TInquirySockAddr::ERssiValid ) + { + rssi = sa.Rssi() + KRssiRangeOffset; + } + + BtNotifNameUtils::SetDeviceNameL(aDevName, *newDevice); + + // Update device popup list with newDevice + UpdateDeviceListL( newDevice, rssi ); + + // Append newDevice in the bottom of the "last seen" device array. + iLastSeenDevicesArray->AppendL(newDevice); + CleanupStack::Pop(); // new device is under iLastSeenDevicesArray control now + + FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::InquiryComplete +// Inquiry has been completed. +// ---------------------------------------------------------- +// +void CBTInqUI::InquiryComplete( TInt aError ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::InquiryComplete() status = %d: %d devices found"), aError, iLastSeenDevicesArray->Count() )); + iInquiryComplete = ETrue; + // Remove popup list if any devices exists + if( iDevicePopupList ) + { + iDevicePopupList->CancelPopup(); + iDevicePopupList = NULL; + } + + TRAP_IGNORE( iUiUtil->CompleteWaitDlgL() ); + + if ( aError == KErrNone || aError == KErrCancel || aError == KErrEof ) + { + iInquiryStatus = (aError == KErrEof ) ? KErrNone : aError; + } + else + { + iLastSeenDevicesArray->ResetAndDestroy(); // Remove previous inquiry results + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI::InquiryComplete() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::PeriodicTimerCallBack(TAny* aAny) +// The call back function +// ---------------------------------------------------------- +// +TInt CBTInqUI::PeriodicTimerCallBack(TAny* /*aAny*/) + { + User::ResetInactivityTime(); + return KErrNone; // Return value ignored by CPeriodic + } + +// ---------------------------------------------------------- +// CBTInqUI::RemoveScanner +// Remove scanner active object if still exists. +// ---------------------------------------------------------- +// +void CBTInqUI::RemoveScanner() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::RemoveScanner()")); + if( iScanner ) + { + iScanner->CancelRequest(); + iHostResolver.Close(); + iSocketServer.Close(); + delete iScanner; + iScanner = NULL; + } + iDevsWithoutName.Close(); + FLOG(_L("[BTNOTIF]\t CBTInqUI::RemoveScanner() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::CreatePopupListL +// ---------------------------------------------------------- +// +void CBTInqUI::CreatePopupListL(TInt aSoftkeysResourceId, TInt aTitleResourceId ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::CreatePopupListL()")); + + __ASSERT_DEBUG( !iDeviceListBox, User::Panic(_L("BTNotifInqUI - iDeviceListBox not released!" ), KErrAlreadyExists)); + __ASSERT_DEBUG( !iDevicePopupList, User::Panic(_L("BTNotifInqUI - iDevicePopupList not released!"),KErrAlreadyExists)); + + // Create listbox for devices + iDeviceListBox = new(ELeave) CAknSingleGraphicPopupMenuStyleListBox; + + // Create popup list + iDevicePopupList = CAknPopupList::NewL( iDeviceListBox, aSoftkeysResourceId, AknPopupLayouts::EDynMenuWindow ); + + iDeviceListBox->ConstructL(iDevicePopupList, EAknListBoxMenuList ); + iDeviceListBox->CreateScrollBarFrameL(ETrue); + iDeviceListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + + // Read title from resources + HBufC* popupListTitle = iEikonEnvRef.AllocReadResourceLC( aTitleResourceId ); + iDevicePopupList->SetTitleL(*popupListTitle); + CleanupStack::PopAndDestroy(); // popupListTitle + + // Create list box model for devices + CTextListBoxModel* model = iDeviceListBox->Model(); + model->SetItemTextArray(iDeviceListRows); + model->SetOwnershipType(ELbmDoesNotOwnItemArray); // Do not destroy items + + // Set up filename for Avkon bitmap + TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName(); + + // Setup graphic items list for BT devices listbox + CAknIconArray* iconList = new(ELeave) CAknIconArray(KDeviceIconCount); + CleanupStack::PushL( iconList ); + + CreateAndAppendIconL( KAknsIIDQgnPropBtComputer, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_computer, + EMbmAvkonQgn_prop_bt_computer_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtPhone, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_phone, + EMbmAvkonQgn_prop_bt_phone_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtAudio, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_audio, + EMbmAvkonQgn_prop_bt_audio_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtMisc, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_misc, + EMbmAvkonQgn_prop_bt_misc_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnStatBtBlank, avkonbmpFilename, + EMbmAvkonQgn_stat_bt_blank, + EMbmAvkonQgn_stat_bt_blank, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtKeyboard, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_keyboard, + EMbmAvkonQgn_prop_bt_keyboard_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtMouse, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_mouse, + EMbmAvkonQgn_prop_bt_mouse_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtPrinter, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_printer, + EMbmAvkonQgn_prop_bt_printer_mask, iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtCarKit, avkonbmpFilename, + EMbmAvkonQgn_prop_bt_carkit, + EMbmAvkonQgn_prop_bt_carkit_mask, iconList); + + GetColorIconL( avkonbmpFilename, KAknsIIDQgnIndiBtPairedAdd, + EMbmAvkonQgn_indi_bt_paired_add, + EMbmAvkonQgn_indi_bt_paired_add_mask, iconList ); + + + TFileName bmpFilename; + bmpFilename += KFileDrive; + bmpFilename += KDC_BITMAP_DIR; + bmpFilename += KBtnotifBmpFileName; + + GetColorIconL( bmpFilename, KAknsIIDQgnIndiBtBlocked, + EMbmBtnotifQgn_indi_bt_blocked, + EMbmBtnotifQgn_indi_bt_blocked_mask, iconList ); + + bmpFilename.Zero(); + bmpFilename.Append( KFileDrive ); + bmpFilename.Append( KDC_APP_BITMAP_DIR ); + bmpFilename.Append( KWLanBmpFileName ); + + GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalLowAdd, + EMbmWlanpluginQgn_indi_wlan_signal_low_add, + EMbmWlanpluginQgn_indi_wlan_signal_low_add_mask, iconList); + + GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalMedAdd, + EMbmWlanpluginQgn_indi_wlan_signal_med_add, + EMbmWlanpluginQgn_indi_wlan_signal_med_add_mask, iconList ); + + GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalGoodAdd, + EMbmWlanpluginQgn_indi_wlan_signal_good_add, + EMbmWlanpluginQgn_indi_wlan_signal_good_add_mask, iconList ); + + // Transfer iconlist ownership to the listbox + // + iDeviceListBox->ItemDrawer()->ColumnData()->SetIconArray(iconList); + CleanupStack::Pop(); // iconList + + FLOG(_L("[BTNOTIF]\t CBTInqUI::CreatePopupListL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::UpdateDeviceListL +// ---------------------------------------------------------- +// +void CBTInqUI::UpdateDeviceListL( CBTDevice* aDevice, const TInt aSignalStrength ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::UpdateDeviceListL()")); + + TInt iconIndex (EDeviceIconDefault); + TInt defNameIndex (EBTDeviceNameIndexDefault); + + HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength ); + + // Check whether the device is already in registry. + TInt index = LookupFromDevicesArray(iPairedDevicesArray, aDevice ); + + if( index >= 0 ) + { + // Update device's link key and friendly name + // with those found from registry. + aDevice->UpdateL( *( iPairedDevicesArray->At( index ) ) ); + } + + for (TInt i = 0; i < KDeviceRowLayoutTableSize; i++) + { + if ( ( aDevice->DeviceClass().MajorDeviceClass() == KDeviceRowLayoutTable[i].iMajorDevClass ) && + ( (aDevice->DeviceClass().MinorDeviceClass() == KDeviceRowLayoutTable[i].iMinorDevClass ) || + KDeviceRowLayoutTable[i].iMinorDevClass == 0 ) ) + { + iconIndex = KDeviceRowLayoutTable[i].iIconIndex; + defNameIndex = KDeviceRowLayoutTable[i].iDefaultNameIndex; + break; + } + } + + if ( !aDevice->IsValidFriendlyName() && !aDevice->IsValidDeviceName() ) + { + BtNotifNameUtils::SetDeviceNameL(iDefaultDeviceNamesArray->MdcaPoint(defNameIndex), *aDevice); + } + + //Convert device name to Unocode for display + if ( aDevice->IsValidFriendlyName() ) + { + formatString->Des().Copy( aDevice->FriendlyName() ); + } + else + { + formatString->Des().Copy( BTDeviceNameConverter::ToUnicodeL(aDevice->DeviceName())); + } + + TPtrC iconFormat (KDeviceIconFormatTable[iconIndex].iFormat); + + formatString->Des().Insert( 0, iconFormat ); + + if( aSignalStrength > 0) + { + if( aSignalStrength <= KMediumStrength ) + { + formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiLow].iFormat ) ); + } + else if( aSignalStrength <= KHighStrength ) + { + formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiMed].iFormat ) ); + } + else + { + formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiGood].iFormat ) ); + } + } + + // If the device is paired, add paired icon to format list + // Paired device using JustWork file transfering mode is not shown as paired here. + if( index >= 0 && IsUserAwarePaired ( aDevice->AsNamelessDevice() ) ) + { + formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconPaired].iFormat ) ); + } + else + { + // if device is blocked, add blocked icon to format list + + TInt indexB = LookupFromDevicesArray(iLastUsedDevicesArray, aDevice ); + + if ( indexB>=0 && iLastUsedDevicesArray->At( indexB )->GlobalSecurity().Banned()) + { + formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconBlocked].iFormat ) ); + } + } + + // Add device format string into device items + // + TInt deviceCount = iDeviceListRows->Count(); + iDeviceListRows->InsertL( deviceCount, *formatString ); + CleanupStack::PopAndDestroy(); // formatString + + TInt currentItemIndex = 0; + if(deviceCount != 0 && iDeviceListBox) + { + // Store temporarily the highlighted device and destroy list box + // + currentItemIndex = iDeviceListBox->CurrentItemIndex(); + } + + if( iDeviceListBox ) + { + iDeviceListBox->HandleItemAdditionL(); + + if(deviceCount != 0 ) + { + //set highligh back to user selected one. + iDeviceListBox->SetCurrentItemIndex(currentItemIndex); + } + + // Adjust top item index in order to "scroll up" the list. + // If current highlight device is not the top one and the listbox's visible slots are full(at least 5 devices are listed), + // to make the newly discovered device visible, the list needs to be scrolled up. + // + TInt topIndex = iDeviceListBox->TopItemIndex(); + deviceCount = iDeviceListRows->Count(); + + if( (currentItemIndex != topIndex && deviceCount > 5 ) && (currentItemIndex+1 < deviceCount ) ) + { + iDeviceListBox->SetTopItemIndex( topIndex+1 ); //scroll up + } + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI::UpdateDeviceListL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::LookupFromDevicesArrayL +// Check if the BT device is paired devices array +// ---------------------------------------------------------- +// +TInt CBTInqUI::LookupFromDevicesArray(const CBTDeviceArray* aDeviceArray, const CBTDevice* aDevice ) const + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::LookupFromDevicesArray()")); + + __ASSERT_DEBUG( aDeviceArray, User::Panic(_L("BTNotifInqUI - aDeviceArray not created"), KErrNotFound )); + + for( TInt index = 0; index < aDeviceArray->Count(); index++ ) + { + // Try to find device by its address. + if ( aDeviceArray->At( index )->BDAddr() == aDevice->BDAddr() ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::LookupFromDevicesArrayL()idx %d"), index)); + return index; // Return index to the device at array + } + } + return KErrNotFound; + } + +// ---------------------------------------------------- +// CBTInqUI::CreateAndAppendIconL +// ---------------------------------------------------- +void CBTInqUI::CreateAndAppendIconL( const TAknsItemID& aID, + const TDesC& aFileName, + const TInt aBitmapId, + const TInt aMaskId, + CAknIconArray* aIconList) + { + CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), aID, aFileName, aBitmapId, aMaskId); + + CleanupStack::PushL(icon); + aIconList->AppendL( icon ); + CleanupStack::Pop(); // icon + } + +// --------------------------------------------------------- +// CBTInqUI::AdjustDeviceArrayL +// Applend max 5 lately used non-paird devices plus all the +// paired devices to the input parameter by the order of +// the last used time stamp. +// --------------------------------------------------------- +// +void CBTInqUI::AdjustDeviceArrayL(CBTDeviceArray* aDeviceArray) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::AdjustDeviceArrayL()")); + + TInt lSize = iLastUsedDevicesArray->Count(); + + if (lSize <= 0) + { + return; + } + + TInt pSize = iPairedDevicesArray->Count(); + TInt nonPairedUsedDevicesNumber = lSize - pSize; + + // Pickup 5 latest used devices (paired devices are excluded) + // + TInt count(0); + + if (nonPairedUsedDevicesNumber <= KBTNotifNonPairedUsedDevicesMaxNumber) + count = nonPairedUsedDevicesNumber; + else + count = KBTNotifNonPairedUsedDevicesMaxNumber; + + for(TInt i=0; i < count; i++ ) + { + TInt targetDeviceIndex = 0; + + //go through iLastUsedDevicesArray, compare each device's time stamp and, find the latest used one. + for(TInt k=0; k < lSize; k++) + { + if(iLastUsedDevicesArray->At(targetDeviceIndex)->Used() < iLastUsedDevicesArray->At(k)->Used()) + { + targetDeviceIndex = k; + } + } + + //if result is not a paired device, add it to the adjuested device array. + if( LookupFromDevicesArray(iPairedDevicesArray, iLastUsedDevicesArray->At(targetDeviceIndex)) == KErrNotFound ) + { + aDeviceArray->AppendL(iLastUsedDevicesArray->At(targetDeviceIndex)->CopyL()); + } + //if result is a paired device, ignore this search round and step-back counter i to make sure this + //search round won't be count. + else + { + i--; + } + + //set the time stamp to -1, in order to ignore this device during next search round. + iLastUsedDevicesArray->At(targetDeviceIndex)->SetUsed(-1); + } + + // Add paired devices to the adjusted list(if paired device exist), + // by the order of last used time. + // + if(pSize > 0) + { + for( TInt i = 0; i < pSize; i++ ) + { + //count size in the beginning of each loop, since the size could grow, + //if new item has been appended in last loop round. + TInt sSize = aDeviceArray->Count(); + + TInt j = 0; + for (; j < sSize ; j++) + { + //check if this paired device alreay on the list jump out this loop + if (iPairedDevicesArray->At(i)->BDAddr() == aDeviceArray->At(j)->BDAddr()) + { + break; + } + + // We do not add device still valid paired into list if iExcludePairedDevices is set. + if ( IsUserAwarePaired( iPairedDevicesArray->At(i)->AsNamelessDevice() ) && + iExcludePairedDevices ) + { + break; + } + + //if this device is not on the list and it is used later then current comparing + //device, insert the paired device to aDeviceArray at suitable position. + TTime pTime = iPairedDevicesArray->At(i)->Used(); + TTime sTime = aDeviceArray->At(j)->Used(); + + if ( pTime > sTime) + { + aDeviceArray->InsertL(j, iPairedDevicesArray->At(i)->CopyL()); + break; + } + } + + //if this paired device is not on the sorted list(it is older then all the devices on the list), + //append it to the end of the list. + if (j == sSize) + { + if ( iExcludePairedDevices ) + { + // Add device to list if device is not paired and iExcludePairedDevices is not set. + if ( !IsUserAwarePaired( iPairedDevicesArray->At(i)->AsNamelessDevice() ) ) + { + aDeviceArray->AppendL(iPairedDevicesArray->At(i)->CopyL()); + } + } + else + { + aDeviceArray->AppendL(iPairedDevicesArray->At(i)->CopyL()); + } + } + } + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI::AdjustDeviceArrayL() Complete.")); + } + +//---------------------------------------------------------- +// CBTInqUI::QueryUnblockDeviceL +//---------------------------------------------------------- +TInt CBTInqUI::QueryUnblockDeviceL(CBTDevice* aDevice) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL()")); + + HBufC* stringholder = NULL; + + if (aDevice->IsValidFriendlyName()) + { + stringholder = StringLoader::LoadLC(R_BT_UNBLOCK_DEVICE, aDevice->FriendlyName()); + } + else + { + stringholder = StringLoader::LoadLC(R_BT_UNBLOCK_DEVICE, BTDeviceNameConverter::ToUnicodeL(aDevice->DeviceName())); + } + + TBTDeviceName name(KNullDesC); + TInt keypress(0); + keypress = iUiUtil->ShowQueryL( *stringholder, R_BT_UNBLOCK_QUERY, + ECmdBTnotifUnavailable, name, CAknQueryDialog::EConfirmationTone ); + CleanupStack::PopAndDestroy(); // stringholder + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL() keypress= %d"),keypress)); + + return keypress; + } + +// ---------------------------------------------------------- +// CBTInqUI::UnblockDevice +// Unblock device by modifying registry +//----------------------------------------------------------- +// +TInt CBTInqUI::UnblockDevice(TInt aIndex) + { + TInt returnValue = KErrNone; + TBTDeviceSecurity deviceSecuritySettings = iLastUsedDevicesArray->At(aIndex)->GlobalSecurity(); + deviceSecuritySettings.SetBanned(EFalse); + iLastUsedDevicesArray->At(aIndex)->DeleteLinkKey(); + //DeleteLinkKey() invalidates the LinkKey and IsPaired entries in Lisbon, so... + iLastUsedDevicesArray->At(aIndex)->SetGlobalSecurity(deviceSecuritySettings); + returnValue = iDevMan->ModifyDevice(*iLastUsedDevicesArray->At(aIndex)); + if (!returnValue) + { + iBTRegistryQueryState = ESetDeviceUnblocked; + } + return returnValue; + } + +// --------------------------------------------------------- +// CBTInqUI::HandleDevManComplete +// CBTEngDevMan callback +// --------------------------------------------------------- +// +void CBTInqUI::HandleDevManComplete(TInt aErr) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleDevManComplete() aErr= %d"),aErr)); + + switch(iBTRegistryQueryState) + { + case ESetDeviceUnblocked: + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleDevManComplete() EModifyDevice"))); + iDevSearchObserver->NotifyDeviceSearchCompleted(aErr, iDevParams); + break; + } + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleDevManComplete() complete"))); + } + +//---------------------------------------------------------------- +// CBTInqUI: DeviceSearchFilter +//---------------------------------------------------------------- +void CBTInqUI::SelectSearchCategoryL() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::SelectSearchCategoryL()")); + + if( !(iDesiredDeviceClass == TBTDeviceClass(0)) ) + { + // Notifier caller passed specified COD to search device, not need to show filter query. + DeviceSearchUiL(); + FLOG(_L("[BTNOTIF]\t CBTInqUI::SelectSearchCategoryL() complete: not show filter query")); + return; + } + // Create listbox for devices + // + CEikTextListBox* searchFilterListBox = new(ELeave) CAknSinglePopupMenuStyleListBox; + CleanupStack::PushL(searchFilterListBox); + + // Create popup list + // + iSearchFilterPopupList = CAknPopupList::NewL( + searchFilterListBox, + R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, + AknPopupLayouts::EDynMenuWindow ); + + searchFilterListBox->ConstructL(iSearchFilterPopupList, EAknListBoxMenuList ); + searchFilterListBox->CreateScrollBarFrameL(ETrue); + searchFilterListBox->ScrollBarFrame()->SetScrollBarVisibilityL( + CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + + // Read title from resources + // + HBufC* popupListTitle = iEikonEnvRef.AllocReadResourceLC( R_BT_SEARCH_FILTER_POPUP_TITLE ); + iSearchFilterPopupList->SetTitleL(*popupListTitle); + CleanupStack::PopAndDestroy(); // popupListTitle + + // reuse iDeviceListRows for serch filter items + iDeviceListRows->Reset(); + + // Create list box model for devices + // + + CTextListBoxModel* model = searchFilterListBox->Model(); + model->SetItemTextArray(iDeviceListRows); + model->SetOwnershipType(ELbmDoesNotOwnItemArray); // Do not destroy items + + + // Add itms of filter to popuplist + // Order must be same as in enum EBTSerchFilterItem + // + + AddItemToSearchFilterL(R_BT_SEARCH_FOR_ALL); + AddItemToSearchFilterL(R_BT_SEARCH_FOR_AUDIO); + AddItemToSearchFilterL(R_BT_SEARCH_FOR_PHONE); + AddItemToSearchFilterL(R_BT_SEARCH_FOR_COMPUTER); + AddItemToSearchFilterL(R_BT_SEARCH_FOR_INPUT); + + // Launch popup list and wait for user input, disable other Ui key presses first: + AllowDialerAndAppKeyPress( EFalse ); + // After input, destroy popup list + // + TInt popupRetVal = iSearchFilterPopupList->ExecuteLD(); + iSearchFilterPopupList = NULL; + AllowDialerAndAppKeyPress( ETrue ); + + if( popupRetVal ) + { + TInt currentDeviceIndex = searchFilterListBox->CurrentItemIndex(); + switch(currentDeviceIndex) + { + case EBTSearchForAll: + iDesiredDeviceClass = TBTDeviceClass(0,0,0); + break; + case EBTSearchForAudio: + iDesiredDeviceClass = TBTDeviceClass(0,EMajorDeviceAV,0); + break; + + case EBTSearchForPhone: + iDesiredDeviceClass = TBTDeviceClass(0,EMajorDevicePhone,0); + break; + + case EBTSearchForComputer: + iDesiredDeviceClass = TBTDeviceClass(0,EMajorDeviceComputer,0); + break; + + case EBTSearchForInput: + iDesiredDeviceClass = TBTDeviceClass(0,EMajorDevicePeripheral,0); + break; + + default: + break; + } + } + + CleanupStack::PopAndDestroy(); //searchFilterListBox + iDeviceListRows->Reset(); + + if( !popupRetVal ) + { + iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel); + } + else + { + DeviceSearchUiL(); + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI::SelectSearchCategoryL() complete")); + } + +//------------------------------------------------------------------------------ +// CBTInqUI: AddItemToSearchFilterL +//------------------------------------------------------------------------------ +void CBTInqUI::AddItemToSearchFilterL ( TInt aResourceId ) + { + HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength ); + HBufC* string = iEikonEnvRef.AllocReadResourceLC( aResourceId ); + formatString->Des().Append( *string ); + CleanupStack::PopAndDestroy(); // string + iDeviceListRows->AppendL( *formatString ); + CleanupStack::Pop(); // formatString + } + +void CBTInqUI::GetColorIconL( TFileName& aFilename, TAknsItemID aItemID, + TInt aPic, TInt aPicmask, CAknIconArray* aIconList ) + { + CFbsBitmap* bitmap = NULL; + CFbsBitmap* mask = NULL; + + AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), aItemID, + KAknsIIDQsnIconColors, + EAknsCIQsnIconColorsCG13, + bitmap, mask, aFilename, aPic, aPicmask, KRgbBlack); + + CGulIcon* icon = CGulIcon::NewL(bitmap, mask); + CleanupStack::Pop(2); // bitmap, mask; + CleanupStack::PushL(icon); + aIconList->AppendL( icon ); + CleanupStack::Pop(); // icon + } + +TBool CBTInqUI::IsActiveVoIPOverWLAN() + { + TInt error = KErrNone; + + // check VoIP over WLAN is on going or not: + // + TInt wlanStatus = 0; + error = RProperty::Get(KPSUidWlan, KPSWlanIndicator, wlanStatus); + FTRACE( FPrint( _L( "CBTInqNotifier::CheckActivationOfVoIPOverWLAN() WLAN state: %d (error %d)" ), wlanStatus, error ) ); + if (error) + { + return EFalse; + } + + TInt callState = 0; + error = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType, callState ); + FTRACE( FPrint( _L( "CBTInqNotifier::CheckActivationOfVoIPOverWLAN() call state: %d (error %d)" ), callState, error ) ); + if( error == KErrNone && + (wlanStatus == EPSWlanIndicatorActive || wlanStatus == EPSWlanIndicatorActiveSecure)&& + callState == EPSCTsyCallTypeVoIP ) + { + FTRACE( FPrint( _L( " VoIP call ongoing, do not allow inquiry!" ) ) ); + return ETrue; + } + return EFalse; + } + +void CBTInqUI::DoDeviceFrontListSelection() + { + TRAPD(err, DisplayDevicesFrontListL()); + if (err) + { + iDevSearchObserver->NotifyDeviceSearchCompleted(err); + } + } + +void CBTInqUI::HandleDeviceSelectionL(CBTDevice* aDev) + { + iDevParams = TBTDeviceResponseParams(); + iDevParams.SetDeviceAddress( aDev->BDAddr()); + iDevParams.SetDeviceClass( aDev->DeviceClass()); + if( aDev->IsValidFriendlyName()) + { + iDevParams.SetDeviceName( aDev->FriendlyName()); + } + else if( aDev->IsValidDeviceName()) + { + iDevParams.SetDeviceName( BTDeviceNameConverter::ToUnicodeL( aDev->DeviceName() ) ); + } + //check if this device is blocked + TInt index = LookupFromDevicesArray(iLastUsedDevicesArray, aDev); + TBool blocked = ( index >= 0 && iLastUsedDevicesArray->At( index )->GlobalSecurity().Banned() ); + if (!blocked) + { + iDevSearchObserver->NotifyDeviceSearchCompleted(KErrNone, iDevParams); + return; + } + + TInt toUnblk = QueryUnblockDeviceL(aDev); + if (!toUnblk) + { + iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel); + return; + } + TInt err = UnblockDevice( index ); + if (err) + { + iDevSearchObserver->NotifyDeviceSearchCompleted(err); + } + // otherwise NotifyDeviceSearchCompleted will be called after unblock is really done. + } + +void CBTInqUI::AllowDialerAndAppKeyPress( TBool aAllow ) + { + CEikAppUi* const eikAppUi = CEikonEnv::Static()->EikAppUi(); + if ( aAllow) + { + // Enable dialer + static_cast( eikAppUi )->SetKeyEventFlags( 0x00 ); + // Activate apps key. + // Ignore the return error code as we can do nothing if this operation fails + (void) static_cast(eikAppUi)->SuppressAppSwitching(EFalse); + } + else + { + // Disable dialer + static_cast( eikAppUi )->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | + CAknAppUiBase::EDisableSendKeyLong); + // Deactivate apps key + (void) static_cast(eikAppUi)->SuppressAppSwitching(ETrue); + } + FTRACE( FPrint( _L( "CBTInqUI::AllowDialerAndAppKeyPress : %d" ), aAllow ) ); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNInquiAO.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNInquiAO.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,239 @@ +/* +* Copyright (c) 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: Part of CBTInqUI class: use Active object to search BT devices. +* +*/ +#include "btninqui.h" +#include "btNotifDebug.h" + +/** Identification for active object request */ +const TInt KBTNotifInquiryNotifierReq = 20; + +// ---------------------------------------------------------- +// CBTInqUI::PrepareScannerL +// ---------------------------------------------------------- +// +void CBTInqUI::CreateScannerL() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::CreateScannerL()")); + + __ASSERT_DEBUG( iScanner == NULL, User::Panic(_L("BTNotifInqUI - iScanner not released!"),KErrAlreadyExists)); + + // Create scanner object which will do the actual search + iScanner = CBTNotifActive::NewL( this, KBTNotifInquiryNotifierReq, CActive::EPriorityStandard ); + User::LeaveIfError( iSocketServer.Connect() ); + TProtocolDesc pInfo; + User::LeaveIfError( iSocketServer.FindProtocol( _L("BTLinkManager"), pInfo)); + User::LeaveIfError( iHostResolver.Open(iSocketServer, pInfo.iAddrFamily, pInfo.iProtocol)); + IssueRequestL(); + + FLOG(_L("[BTNOTIF]\t CBTInqUI::CreateScannerL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::IssueRequestL +// Issue Bluetooth device inquiry/search itself. +// Reads also inquiry mode from shared data. +// ---------------------------------------------------------- +// +void CBTInqUI::IssueRequestL() + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::IssueRequestL()")); + + TUint action = 0; + if( !iPageForName ) + { + action = KHostResInquiry + KHostResEir + KHostResIgnoreCache; + } + else + { + if( iIndex < iDevsWithoutName.Count() ) + { + action = KHostResName + KHostResIgnoreCache; + TInquirySockAddr& sa = TInquirySockAddr::Cast( iDevsWithoutName[iIndex].iAddr ); + iInquirySockAddr.SetBTAddr( sa.BTAddr() ); + } + } + if (action) + { + iInquirySockAddr.SetAction( action ); + iInquirySockAddr.SetIAC(KGIAC); + iHostResolver.GetByAddress( iInquirySockAddr, iEntry, iScanner->RequestStatus() ); + iScanner->GoActive(); + } + else + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::RunL() All name inquiries complete .")); + iPageForName = EFalse; + iIndex = 0; + InquiryComplete( KErrNone ); + } + FLOG(_L("[BTNOTIF]\t CBTInqUI::IssueRequestL() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::RequestCompletedL +// BT-device or timeout has been received. Inform caller for +// received device and issue next EIR/Name request. +// ---------------------------------------------------------- +// +void CBTInqUI::RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() status: %d >>"), aStatus )); + ASSERT( aId == KBTNotifInquiryNotifierReq); + (void) aActive; + + if( aStatus == KErrNone ) + { + if( iPageForName ) + { + HandleFoundNameL(); + iIndex++; + IssueRequestL(); + } + else + { + HandleInquiryDeviceL(); + iHostResolver.Next( iEntry, iScanner->RequestStatus() ); + iScanner->GoActive(); + } + } + else if( aStatus == (KHCIErrorBase - EPageTimedOut) && iPageForName ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() HCI:EPageTimeOut, page next one.")); + iIndex++; + IssueRequestL(); + } + else + { + if( !iPageForName && iDevsWithoutName.Count()>0 ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() nameless devices %d, paging for name."), + iDevsWithoutName.Count() )); + iIndex = 0; + iPageForName = ETrue; + IssueRequestL(); + } + else + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() NameInquiryComplete with error or no device found.")); + HandleError( aActive, aId, aStatus ); + } + } + FLOG(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() <<")); + } + +// ---------------------------------------------------------- +// CBTInqUI::HandleError +// Inform UI from error occured. +// ---------------------------------------------------------- +// +void CBTInqUI::HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleError()")); + (void) aActive; + (void) aId; + iPageForName = EFalse; + InquiryComplete( aError ); + FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleError() completed")); + } + +// ---------------------------------------------------------- +// CBTInqUI::DoCancelRequest +// ---------------------------------------------------------- +// +void CBTInqUI::DoCancelRequest( CBTNotifActive* aActive, TInt aId ) + { + (void) aActive; + (void) aId; + iHostResolver.Cancel(); + } + +// ---------------------------------------------------------- +// CBTInqUI::HandleInquiryDeviceL +// Inform of properties of the found BTdevice, +// which passes the search filter. Its name would be retrived +// later if not contained by the first round of inquiry. +// ---------------------------------------------------------- +// +void CBTInqUI::HandleInquiryDeviceL() + { + TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr ); + + if ( iDesiredDeviceClass.DeviceClass() == 0 || sa.MajorClassOfDevice() == iDesiredDeviceClass.MajorDeviceClass() ) + { + FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleInquiryDeviceL() The found device passes the search filter.")); +#ifdef _DEBUG + TBuf<12> devAddrString; + sa.BTAddr().GetReadable(devAddrString); + FTRACE(FPrint(_L("[BTNOTIF]\t BT Address: %S"), &devAddrString)); +#endif + TBTDeviceName devName; + TBool nameGotten = CheckEirDeviceName( iEntry, devName ); + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleInquiryDeviceL() EIR device name? %d, %S"), nameGotten, &devName )); + if( nameGotten ) + { + DeviceAvailableL( iEntry(), devName ); + } + else + { + iDevsWithoutName.Append( iEntry() ); + } + } + } + +// ---------------------------------------------------------- +// CBTInqUI::HandleFoundNameL +// Inform of retrieved device name after 2nd inquiry. +// ---------------------------------------------------------- +// +void CBTInqUI::HandleFoundNameL() + { +#ifdef _DEBUG + TBuf<12> devAddrString; + TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr ); + sa.BTAddr().GetReadable(devAddrString); + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleFoundNameL() BT Address: %S"), &devAddrString)); +#endif + if( iEntry().iName != KNullDesC ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleFoundNameL() Name found: %S"), &(iEntry().iName) )); + + DeviceAvailableL( iDevsWithoutName[iIndex], iEntry().iName ); + } + + FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleFoundNameL() Complete")); + } + +// ---------------------------------------------------------- +// CBTInqUI::CheckEirDeviceName +// Check if the retrieved the device info contains device name. +// ---------------------------------------------------------- +// +TBool CBTInqUI::CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName ) + { + TBluetoothNameRecordWrapper eir( aEntry() ); + TInt length = eir.GetDeviceNameLength(); + + TBool isComplete( EFalse ); + TInt err( KErrNone ); + + if( length > 0 ) + { + err = eir.GetDeviceName( aName, isComplete); + return (!err); + } + return EFalse; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNMain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNMain.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2002 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: Methods for BT notifier +* +*/ + + +// INCLUDE FILES + +#include + +#include "btnauthnotifier.h" // All notifiers +#include "btnpinnotifier.h" +#include "btninqnotifier.h" +#include "btnobexpinnotifier.h" +#include "btnpwrnotifier.h" +#include "btNotifDebug.h" +#include "BTNGenericInfoNotifier.h" +#include "BTNGenericQueryNotifier.h" +#include "btnpbappinnotifier.h" +#include "btnpaireddevsettnotifier.h" +#include "btnssppasskeyentrynotifier.h" +#include "btnumcmpnotifier.h" +#include "btnenterpriseitsecurityinfonotifier.h" + +// CONSTANTS +const TInt KBTNotifierArrayIncrement = 8; + + +// ================= EXPORTED FUNCTIONS ==================== + +// --------------------------------------------------------- +// +// Instantiate notifiers +// +// --------------------------------------------------------- + +LOCAL_C void CreateBTNotifiersL( CArrayPtrFlat* aNotifiers ) + { + FLOG(_L("[BTNOTIF]\t CreateBTNotifiersL")); + + CBTInqNotifier* inquiryNotifier = CBTInqNotifier::NewL(); + CleanupStack::PushL( inquiryNotifier ); + aNotifiers->AppendL( inquiryNotifier ); + CleanupStack::Pop( inquiryNotifier ); + + CBTPinNotifier* pinNotifier = CBTPinNotifier::NewL(); + CleanupStack::PushL( pinNotifier ); + aNotifiers->AppendL( pinNotifier ); + CleanupStack::Pop( pinNotifier ); + + CBTAuthNotifier* authNotifier = CBTAuthNotifier::NewL(); + CleanupStack::PushL( authNotifier ); + aNotifiers->AppendL( authNotifier ); + CleanupStack::Pop( authNotifier ); + + CBTObexPinNotifier* obexNotifier = CBTObexPinNotifier::NewL(); + CleanupStack::PushL( obexNotifier ); + aNotifiers->AppendL( obexNotifier ); + CleanupStack::Pop( obexNotifier ); + + CBTPwrNotifier* pwrNotifier = CBTPwrNotifier::NewL(); + CleanupStack::PushL( pwrNotifier ); + aNotifiers->AppendL( pwrNotifier ); + CleanupStack::Pop( pwrNotifier ); + + CBTGenericInfoNotifier* infoNotifier = CBTGenericInfoNotifier::NewL(); + CleanupStack::PushL( infoNotifier ); + aNotifiers->AppendL( infoNotifier ); + CleanupStack::Pop( infoNotifier ); + + CBTGenericQueryNotifier* queryNotifier = CBTGenericQueryNotifier::NewL(); + CleanupStack::PushL( queryNotifier ); + aNotifiers->AppendL( queryNotifier ); + CleanupStack::Pop( queryNotifier ); + + CBTPBAPPinNotifier* pbapNotifier = CBTPBAPPinNotifier::NewL(); + CleanupStack::PushL( pbapNotifier ); + aNotifiers->AppendL( pbapNotifier ); + CleanupStack::Pop( pbapNotifier ); + + CBTPairedDevSettNotifier* pdsNotifier = CBTPairedDevSettNotifier::NewL(); + CleanupStack::PushL( pdsNotifier ); + aNotifiers->AppendL( pdsNotifier ); + CleanupStack::Pop( pdsNotifier ); + + CBTSSPPasskeyEntryNotifier* sspPinNotifier = CBTSSPPasskeyEntryNotifier::NewL(); + CleanupStack::PushL( sspPinNotifier ); + aNotifiers->AppendL( sspPinNotifier ); + CleanupStack::Pop( sspPinNotifier ); + + CBTNumCmpNotifier* numCmpNotifier = CBTNumCmpNotifier::NewL(); + CleanupStack::PushL(numCmpNotifier); + aNotifiers->AppendL( numCmpNotifier ); + CleanupStack::Pop( numCmpNotifier ); + + CBTEnterpriseItSecurityInfoNotifier* enterpriseItSecurityNotifier = CBTEnterpriseItSecurityInfoNotifier::NewL(); + CleanupStack::PushL(enterpriseItSecurityNotifier); + aNotifiers->AppendL(enterpriseItSecurityNotifier); + CleanupStack::Pop(enterpriseItSecurityNotifier); + + FLOG(_L("[BTNOTIF]\t CreateBTNotifiersL completed")); + } + +// --------------------------------------------------------- +// +// Lib main entry point: Creates a notifiers array. +// +// --------------------------------------------------------- + +EXPORT_C CArrayPtr* NotifierArray() + { + FLOG(_L("[BTNOTIF]\t NotifierArray")); + + CArrayPtrFlat* notifiers = NULL; + + notifiers = + new CArrayPtrFlat( KBTNotifierArrayIncrement ); + if( notifiers ) + { + TRAPD( err, CreateBTNotifiersL( notifiers )); + if( err ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t Notifier creation failure! Error code: %d"), err)); + TInt count = notifiers->Count(); + while(count--) + (*notifiers)[count]->Release(); + delete notifiers; + notifiers = NULL; + } + + FLOG(_L("[BTNOTIF]\t NotifierArray completed")); + } + return notifiers; + } + + +// End of File + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2002 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: Declares OBEX PIN query notifier class. +* +*/ + + +// INCLUDE FILES +#include // Unicode character conversion utilities + +#include // Own resources +#include "btnobexpinnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros + +#include + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTObexPinNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTObexPinNotifier* CBTObexPinNotifier::NewL() + { + CBTObexPinNotifier* self=new (ELeave) CBTObexPinNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTObexPinNotifier::CBTObexPinNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTObexPinNotifier::CBTObexPinNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTObexPinNotifier::~CBTObexPinNotifier() + { + } + +// ---------------------------------------------------------- +// CBTObexPinNotifier::RegisterL +// ---------------------------------------------------------- +// +CBTObexPinNotifier::TNotifierInfo CBTObexPinNotifier::RegisterL() + { + iInfo.iUid=KBTObexPasskeyQueryNotifierUid; + iInfo.iChannel=KBTObexPINChannel; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTObexPinNotifier::GetParamsL +// Initialize parameters. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTObexPinNotifier::GetParamsL(const TDesC8& /* aBuffer */, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::GetParamsL()")); + + if( !iMessage.IsNull()) + { + User::Leave(KErrInUse); + } + else if ( AutoLockOnL() ) + { + // The phone is locked, access denied. + // + CompleteMessage(KErrCancel); + return; + } + + iMessage = aMessage; + iReplySlot = aReplySlot; + + ShowNoteCompleteMessageL(); + + FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTObexPinNotifier::ShowNoteCompleteMessageL +// Ask user response and return it to caller. +// ---------------------------------------------------------- +// +void CBTObexPinNotifier::ShowNoteCompleteMessageL() + { + FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::ShowNoteCompleteMessageL()")); + + TBuf tempPasskeyBuffer; // Unicode buffer + + TInt keypress = iNotifUiUtil->ShowTextInputQueryL( tempPasskeyBuffer, + R_BT_OBEX_PASSKEY_QUERY, ECmdShowBtOpenCoverNote ); + + if( keypress ) // OK pressed + { + // Convert data from unicode to 8 bit and write it back to caller + // + TBTObexPasskey obexPasskey; + obexPasskey.Zero(); + CnvUtfConverter::ConvertFromUnicodeToUtf8(obexPasskey, tempPasskeyBuffer); + CompleteMessage(TPckgBuf(obexPasskey), KErrNone); + } + else // Cancel pressed + { + CompleteMessage(KErrCancel); + } + + FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::ShowNoteCompleteMessageL() completed")); + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2007 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: Declares PBAP PIN query notifier class. +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Unicode character conversion utilities + +#include // own resources +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include +#endif + +#include "btnpbappinnotifier.h" // own class definition +#include "btNotifDebug.h" // debugging macros + +#include + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTObexPinNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTPBAPPinNotifier* CBTPBAPPinNotifier::NewL() + { + CBTPBAPPinNotifier* self=new (ELeave) CBTPBAPPinNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTObexPinNotifier::CBTObexPinNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTPBAPPinNotifier::CBTPBAPPinNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTPBAPPinNotifier::~CBTPBAPPinNotifier() + { + } + +// ---------------------------------------------------------- +// CBTPBAPPinNotifier::RegisterL +// ---------------------------------------------------------- +// +CBTPBAPPinNotifier::TNotifierInfo CBTPBAPPinNotifier::RegisterL() + { + iInfo.iUid=KPbapAuthNotifierUid; + iInfo.iChannel=KBTObexPINChannel; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTPBAPPinNotifier::GetParamsL +// Initialize parameters. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTPBAPPinNotifier::GetParamsL(const TDesC8& /* aBuffer */, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTPBAPPinNotifier::GetParamsL()")); + + if( !iMessage.IsNull()) + { + User::Leave(KErrInUse); + } + else if ( AutoLockOnL() ) + { + // The phone is locked, access denied. + // + CompleteMessage(KErrCancel); + return; + } + + iMessage = aMessage; + iReplySlot = aReplySlot; + + ShowNoteCompleteMessageL(); + + FLOG(_L("[BTNOTIF]\t CBTPBAPPinNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTPBAPPinNotifier::ShowNoteCompleteMessageL +// Ask user response and return it to caller. +// ---------------------------------------------------------- +// +void CBTPBAPPinNotifier::ShowNoteCompleteMessageL() + { + FLOG(_L("[BTNOTIF]\t CBTPBAPPinNotifier::ShowNoteCompleteMessageL()")); + + TBuf pbapPasskey; // Unicode buffer + + TInt keypress = iNotifUiUtil->ShowTextInputQueryL( pbapPasskey, + R_BT_OBEX_PASSKEY_QUERY, ECmdShowBtOpenCoverNote ); + + if( keypress ) // OK pressed + { + TPbapAuthNotifierResponsePckg pbapPasskeyResponse; + pbapPasskeyResponse().SetPassword(pbapPasskey); + CompleteMessage(pbapPasskeyResponse, KErrNone); + } + else // Cancel pressed + { + CompleteMessage(KErrCancel); + } + + FLOG(_L("[BTNOTIF]\t CBTPBAPPinNotifier::ShowNoteCompleteMessageL() completed")); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNPinNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNPinNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,282 @@ +/* +* Copyright (c) 2002 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: Declares authentication (PIN query) notifier class. +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Unicode character conversion utilities +#include +#include +#include +#include +#include // Own resources +#include "btnotif.hrh" // Own resource header +#include "btnpinnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include "btnotifnameutils.h" + +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include +#endif + +#include + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif +const TInt KDefaultPinCodeLength=4; +const TUint8 KZeroPinValue = '0'; + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTPinNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTPinNotifier* CBTPinNotifier::NewL() + { + CBTPinNotifier* self=new (ELeave) CBTPinNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------- +// CBTPinNotifier::CBTPinNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTPinNotifier::CBTPinNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTPinNotifier::~CBTPinNotifier() + { + } + +// ---------------------------------------------------------- +// CBTPinNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTPinNotifier::TNotifierInfo CBTPinNotifier::RegisterL() + { + iInfo.iUid=KBTPinCodeEntryNotifierUid; + iInfo.iChannel=KBTAuthenticationChannel; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTPinNotifier::GetParamsL +// Initialize parameters and check if device is already +// in registry. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTPinNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GetParamsL() >>")); + + CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage ); + + TBTPinCodeEntryNotifierParams param; + TPckgC pckg(param); + pckg.Set(aBuffer); + + iBTAddr = pckg().DeviceAddress(); + if ( OtherOutgoPairing(iBTAddr) ) + { + // We won't allow incoming pairing during outgoing pairing: + FLOG(_L("[BTNOTIF]\t CBTPinNotifier: outgoing pair in progress, reject incoming pair")); + CompleteMessage(KErrCancel); + return; + } + + iLocallyInitiated = pckg().LocallyInitiated(); + iPasskeyLength = pckg().PinCodeMinLength(); + iStrongPinRequired = pckg().StrongPinCodeRequired(); + ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() ); + + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GetParamsL() <<")); + } + +// ---------------------------------------------------------- +// CBTPinNotifier::HandleGetDeviceCompletedL +// Ask user response and return it to caller. +// Store device into registry if user has accepted pairing. +// ---------------------------------------------------------- +// +void CBTPinNotifier::HandleGetDeviceCompletedL(const CBTDevice* aDev) + { + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::HandleGetDeviceCompletedL() >>")); + (void) aDev; + + // Check if blocked device + if( CheckBlockedDeviceL() ) + return; + + // Turn lights on and deactivate apps -key + iNotifUiUtil->TurnLightsOn(); + + if( CheckAndSetAutomatedPairing() ) + { + CompleteMessage(iPinCode, KErrNone); + return; + } + + // For incoming pairing request + if(!iLocallyInitiated) + { + TBool userAnswer = AuthoriseIncomingPairingL(); + if( !userAnswer ) + { + //User rejects the incoming pairing, complete message in QueryBlockDevice. + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::HandleGetDeviceCompletedL() <<")); + return; + } + } + + // Use a forever loop here to show query dialog again of ínput pin code does't fulfill the + // minimum length requirement + // + FOREVER + { + TBuf tempResultBuffer; + + HBufC* prompt = GenerateQueryPromoptLC(); // prompt still in stack. + TInt keypress = iNotifUiUtil->ShowTextInputQueryL(tempResultBuffer, *prompt, R_BT_ENTER_PASSKEY_QUERY, + ECmdShowBtOpenCoverNote, CAknQueryDialog::EConfirmationTone ); + CleanupStack::PopAndDestroy( prompt ); + + if( keypress ) // OK pressed + { + // Convert data from buf to pin + TBuf8 buf8; + buf8.Zero(); + CnvUtfConverter::ConvertFromUnicodeToUtf8(buf8, tempResultBuffer); + + //check if the length of pin less that minimum required pin code length + if ((iPasskeyLength == 0) || ( buf8.Length() >= iPasskeyLength)) + { + iPinCode().iLength = STATIC_CAST(TUint8, buf8.Length()); + for (TInt index=0; index do automated pairing with 0000. + if ( iDevice && + OutgoPairingMode( iBTAddr ) == EBTOutgoingHeadsetAutoPairing && + iPasskeyLength <= KDefaultPinCodeLength ) + { + FLOG( _L( "[BTNOTIF]\t CBTPinNotifier::CheckAndSetAutomatedPairing - automated pairing on" ) ); + FLOG(_L("[BTNOTIF]\t Setting default PIN code")); + iPinCode().iLength = KDefaultPinCodeLength; + for( TInt i=0; i < KDefaultPinCodeLength; ++i) + { + iPinCode().iPIN[i] = KZeroPinValue; + } + ret = ETrue; + } + return ret; + } + +// ---------------------------------------------------------- +// CBTPinNotifier::GenerateQueryPromoptLC +// ---------------------------------------------------------- +HBufC* CBTPinNotifier::GenerateQueryPromoptLC() + { + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromoptLC() >>")); + HBufC* prompt = NULL; + + TBTDeviceName devName; + BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); + if (iPasskeyLength > 0) //Minimum length passkey is defined + { + CDesCArray* stringArray = new ( ELeave ) CDesCArrayFlat( 1 ); + CleanupStack::PushL( stringArray ); + CArrayFix* indexArray = new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL( indexArray ); + + stringArray->AppendL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()) ); + indexArray->AppendL( iPasskeyLength); + prompt = StringLoader::LoadL( R_BT_MIN_PASSKEY_PROMPT, *stringArray, *indexArray ); + + CleanupStack::PopAndDestroy( indexArray ); + CleanupStack::PopAndDestroy( stringArray ); + CleanupStack::PushL( prompt ); + } + else + { + prompt = StringLoader::LoadLC( R_BT_PASSKEY_PROMPT, devName ); + } + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromoptLC() <<")); + return prompt; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNPwrNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNPwrNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2002 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: Declares power mode setting notifier class. +* +*/ + + +// INCLUDE FILES +#include // Own resources +#include "btnpwrnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include +#include + + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTPwrNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTPwrNotifier* CBTPwrNotifier::NewL() + { + CBTPwrNotifier* self=new (ELeave) CBTPwrNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTPwrNotifier::CBTPwrNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTPwrNotifier::CBTPwrNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTPwrNotifier::~CBTPwrNotifier() + { + } + +// ---------------------------------------------------------- +// CBTPwrNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTPwrNotifier::TNotifierInfo CBTPwrNotifier::RegisterL() + { + iInfo.iUid=KPowerModeSettingNotifierUid; + iInfo.iChannel=KBTPowerModeChannel; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTPwrNotifier::GetParamsL +// Initialize parameters. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTPwrNotifier::GetParamsL(const TDesC8& /*aBuffer*/, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTPwrNotifier::GetParamsL()")); + + if( iReplySlot!=NULL || !iMessage.IsNull() ) + User::Leave(KErrInUse); + + iMessage = aMessage; + iReplySlot = aReplySlot; + + ShowNoteAndCompleteMessageL(); + FLOG(_L("[BTNOTIF]\t CBTPwrNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTPwrNotifier::RunL +// Ask user response and return it to caller. +// ---------------------------------------------------------- +// +void CBTPwrNotifier::ShowNoteAndCompleteMessageL() + { + FLOG(_L("[BTNOTIF]\t CBTPwrNotifier::ShowNoteAndCompleteMessageL()")); + + if ( !CheckAndSetPowerOnL() ) + { + CompleteMessage(KErrGeneral); + return; + } + // TODO: Why do we show BT BUSY note from BT power notifier? + //get connection amount + TInt linkCount = 0; + RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetPHYCount, linkCount); + + if (linkCount > 6) //support only piconet + { + iNotifUiUtil->ShowInfoNoteL( R_BT_BUSY_NOTE, ECmdShowBtBusyNote ); + } + CompleteMessage(ETrue, KErrNone ); + FLOG(_L("[BTNOTIF]\t CBTPwrNotifier::ShowNoteAndCompleteMessageL() completed")); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/BTNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/BTNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,747 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth notifiers base class. +* +*/ + + +// INCLUDE FILES +#include +#include + +#include +#include + +#include +#include +#include +#include +#include // Localisation stringloader +#include // Own resources +#include // Feature Manager API +#include // CnvUtfConverter + +#include "btnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include "btnotiflock.h" +#include "btnotif.hrh" // define MaxNameLength +#include "btnotifpanic.h" +#include "btnotifnameutils.h" + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + +// CONSTANTS +const TInt KBTNAutolockEnabled = 1; + +// The following definitions are used to implement checking of connection/pairing +// request frequency + +// if a new connection is made quicker than CONNECT_ADD_TIME after the old one, +// then the saved time is added with CONNECT_ADD_TIME. +#define CONNECT_ADD_TIME TTimeIntervalSeconds(10) + +// if the saved time is later than now+DENY_THRESHOLD, start rejecting incoming connections +// from unpaired devices. +#define DENY_THRESHOLD TTimeIntervalSeconds(30) + +// if the user denies incoming connection the saved time goes this much in the future. +#define REJECT_ADD_TIME TTimeIntervalSeconds(31) + + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTNotifierBase::CBTNotifierBase +// C++ default constructor can NOT contain any code, that +// might leave. Sets the AOs priority and puts +// itself to the active scheduler stack. +// ---------------------------------------------------------- +// +CBTNotifierBase::CBTNotifierBase() + { + } + +// ---------------------------------------------------------- +// CBTNotifierBase::ConstructL +// Symbian 2nd phase constructor can leave. +// Create registry object and open resource file. +// ---------------------------------------------------------- +// +void CBTNotifierBase::ConstructL() + { + // Sets up TLS, must be done before FeatureManager is used. + FeatureManager::InitializeLibL(); + TBool isCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) + ? ETrue : EFalse; + // Frees the TLS. Must be done after FeatureManager is used. + FeatureManager::UnInitializeLib(); + + iBTEngSettings = CBTEngSettings::NewL(); + iDevMan = CBTEngDevMan::NewL( this ); + iNotifUiUtil = CBTNotifUIUtil::NewL( isCoverUI ); + } + +// ---------------------------------------------------------- +// Destructor. +// ---------------------------------------------------------- +// +CBTNotifierBase::~CBTNotifierBase() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::~CBTNotifierBase()")); + Cancel(); + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::~CBTNotifierBase() -- Done")); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::Release +// Release itself. Call to destructor. +// ---------------------------------------------------------- +// +void CBTNotifierBase::Release() + { + delete this; + } + + +// ---------------------------------------------------------- +// CBTNotifierBase::Info +// Return registered information. +// ---------------------------------------------------------- +// +CBTNotifierBase::TNotifierInfo CBTNotifierBase::Info() const + { + return iInfo; + } + +// ---------------------------------------------------------- +// CBTNotifierBase::StartL +// Synchronic notifier launch. Does nothing here. +// ---------------------------------------------------------- +// +TPtrC8 CBTNotifierBase::StartL(const TDesC8& /*aBuffer*/) + { + TPtrC8 ret(KNullDesC8); + return (ret); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::StartL +// Asynchronic notifier launch. +// ---------------------------------------------------------- +// +void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage)); + if (err) + { + CompleteMessage(err); + } + } + +// ---------------------------------------------------------- +// CBTNotifierBase::Cancel +// Cancelling method. +// ---------------------------------------------------------- +// +void CBTNotifierBase::Cancel() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::Cancel()")); + + delete iNotifUiUtil; + iNotifUiUtil = NULL; + + delete iBTEngSettings; + iBTEngSettings = NULL; + + delete iDevMan; + iDevMan = NULL; + + delete iDevice; + iDevice = NULL; + + if (iDeviceArray) + { + iDeviceArray->ResetAndDestroy(); + delete iDeviceArray; + iDeviceArray = NULL; + } + + CompleteMessage(KErrCancel); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::UpdateL +// Notifier update. Not supported. +// ---------------------------------------------------------- +// +TPtrC8 CBTNotifierBase::UpdateL(const TDesC8& /*aBuffer*/) + { + TPtrC8 ret(KNullDesC8); + return (ret); + } + + +// ---------------------------------------------------------- +// CBTNotifierBase::AutoLockOnL +// ---------------------------------------------------------- +// +TBool CBTNotifierBase::AutoLockOnL() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::AutoLockOnL()")); + + TBool result = EFalse; + TInt status = KBTNAutolockEnabled; + + // Connecting and initialization: + CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); + + repository->Get(KSettingsAutolockStatus, status); + + // Closing connection: + delete repository; + + if ( status == KBTNAutolockEnabled ) + { + result = ETrue; + } + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::AutoLockOnL() completed with %d"), result )); + + return result; + } + +// ---------------------------------------------------------- +// CBTNotifierBase::CheckAndSetPowerOnL +// The note or query to be shown depends on two SharedData flags +// ---------------------------------------------------------- +// +TBool CBTNotifierBase::CheckAndSetPowerOnL() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::CheckAndSetPowerOnL()")); + + TBTPowerStateValue powerState( EBTPowerOff ); + // Get current power status + // + User::LeaveIfError( iBTEngSettings->GetPowerState( powerState ) ); + + // If power is off, turn it on + // + if ( powerState == EBTPowerOff ) + { + TInt offlineModeOff( 1 ); // possible values are 0 and 1 + TInt activationEnabled( 0 ); // possible values are 0 and 1 + + // Offline mode on? + CRepository* repository = CRepository::NewL(KCRUidCoreApplicationUIs); + repository->Get(KCoreAppUIsNetworkConnectionAllowed, offlineModeOff); + delete repository; + + // BT Activation enabled? + repository = CRepository::NewL(KCRUidBluetoothEngine); + repository->Get(KBTEnabledInOffline, activationEnabled); + delete repository; + + // Choose user interaction + // + if ( !offlineModeOff && !activationEnabled ) + { + // Show user that feature is disabled: + iNotifUiUtil->ShowInfoNoteL( R_BT_OFFLINE_DISABLED, ECmdShowBtOfflineDisableNote ); + return EFalse; // Bluetooth can't be set on. + } + else + { + // Choose query + // + TInt keypress( 0 ); + if ( offlineModeOff ) + { + keypress = iNotifUiUtil->ShowQueryL( KErrNone, R_BT_POWER_IS_OFF_QUERY, ECmdShowBtIsOffDlg ); + } + else + { + keypress = iNotifUiUtil->ShowQueryL( KErrNone, R_BT_ACTIVATE_IN_OFFLINE_QUERY, + ECmdShowBtActivateInOfflineDlg ); + } + + if( keypress ) // User answered YES + { + //Check if the local name has been set. If not ask user to set name + + TBool ok = IsLocalNameModifiedL(); + if( !ok ) + { + ok = AskLocalBTNameQueryL(); + } + if ( ok ) + { + ok = ( iBTEngSettings->SetPowerState( EBTPowerOn ) ) ? EFalse : ETrue; + } + return ok; + } + else // User has cancelled the dialog + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::CheckAndSetPowerOnL(), dialog canceled")); + return EFalse; + } + } + } + return ETrue; + } + +// ---------------------------------------------------------- +// CBTNotifierBase::AskLocalBTNameQueryL() +// ---------------------------------------------------------- +// +TBool CBTNotifierBase::AskLocalBTNameQueryL() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::AskLocalBTNameQueryL() >>")); + + TBTDeviceName tempNameBuffer; + // Cut the excess part of the name away. The query can handle only + // KBTUIMaxNameLength characters. + // + if( tempNameBuffer.Length() > KBTUIMaxNameLength ) + { + tempNameBuffer.SetLength( KBTUIMaxNameLength ); + } + + //Get default name if given by e.g. phone product + (void) RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetDeviceName, tempNameBuffer ); + + if( !tempNameBuffer.Length() ) + { + (void) RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetDeviceName, tempNameBuffer ); + } + + if( !tempNameBuffer.Length() ) + { + RBTRegServ btRegServ; + RBTLocalDevice btReg; + TBTLocalDevice localDev; + + TInt err = btRegServ.Connect(); + if( !err ) + { + err = btReg.Open( btRegServ ); + } + if( !err ) + { + // Read the BT local name from BT Registry. + err = btReg.Get( localDev ); + } + if( !err ) + { + // The error can be > 0 if there are unconverted characters. + err = CnvUtfConverter::ConvertToUnicodeFromUtf8( tempNameBuffer, localDev.DeviceName() ); + } + btReg.Close(); + btRegServ.Close(); + } + + TInt keypress = iNotifUiUtil->ShowTextInputQueryL( tempNameBuffer, + R_BT_ENTER_LOCAL_NAME_QUERY, ECmdBTnotifUnavailable ); + + if( keypress ) // User has accepted the dialog + { + AknTextUtils::StripCharacters(tempNameBuffer, KAknStripListControlChars); + tempNameBuffer.TrimAll(); // Remove extra spaces + // If name was full of invalid chars, it becomes empty after above cleanup. + if( tempNameBuffer.Length() ) + { + TInt err = iBTEngSettings->SetLocalName( tempNameBuffer ); + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::AskLocalBTNameQueryL() <<")); + return (err) ? EFalse : ETrue; + } + else + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::AskLocalBTNameQueryL() << failed")); + return EFalse; + } + } + else + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::AskLocalBTNameQueryL() << cancelled")); + return EFalse; + } + } + +// --------------------------------------------------------------------------------- +// CBTNotifierBase::IsExistingConnectionToAudioL +// Check if there is any existing connection to audio profiles from the same device +// --------------------------------------------------------------------------------- +TBool CBTNotifierBase::IsExistingConnectionToAudioL( const TBTDevAddr& aDevAddr ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::IsExistingConnectionToAudioL()")); + CBTEngConnMan* connMan = CBTEngConnMan::NewL(); + TBTEngConnectionStatus conntatus( EBTEngNotConnected ); + (void) connMan->IsConnected(aDevAddr,conntatus); + delete connMan; + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::IsExistingConnectionToAudioL() complete")); + return ( conntatus==EBTEngConnected || conntatus==EBTEngConnecting ); + } + +// --------------------------------------------------------------------------- +// CBTNotifierBase::IsLocalNameModified +// Checks from central repository whether the Bluetooth friendly name +// has been modified . +// --------------------------------------------------------------------------- +// +TBool CBTNotifierBase::IsLocalNameModifiedL() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::IsLocalNameModified()")); + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + TInt val( EBTLocalNameDefault ); + (void) cenRep->Get( KBTLocalNameChanged, val ); + delete cenRep; + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::IsLocalNameModified() complete")); + return val == EBTLocalNameSet; + } + + +void CBTNotifierBase::GetDeviceFromRegL(const TBTDevAddr& aAddr) + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL")); + __ASSERT_DEBUG(iDevice, BTNOTIF_PANIC(EiDeviceNullWhenCallingGetDeviceFromRegL)); + + TBTRegistrySearch mySearch; + mySearch.FindAddress( aAddr ); + iDeviceArray = new (ELeave) CBTDeviceArray(1); + TInt err = iDevMan->GetDevices( mySearch, iDeviceArray ); + if(err) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL iDevMan->GetDevices error = %d"), err)); + DoHandleGetDevicesCompleteL(err, NULL); + } + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL done")); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::QueryBlockDeviceL +// Opens a query that returns wether or not user wants the device blocked +// ---------------------------------------------------------- +void CBTNotifierBase::QueryBlockDeviceL() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::QueryBlockDeviceL()")); + __ASSERT_DEBUG( iNotifUiUtil->IsQueryReleased(), User::Panic( _L("CBTNotifierBase - iYesNoDlg not released!"), KErrAlreadyExists ) ); + + TBTDeviceName bName; + BtNotifNameUtils::GetDeviceDisplayName(bName, iDevice); + + HBufC* header= StringLoader::LoadLC( R_BT_BLOCK_DEVICE_HEADER ); + + TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? + R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP; + + HBufC* stringHolder = StringLoader::LoadLC( resId, bName ); + + TInt keypress = iNotifUiUtil->ShowMessageQueryL( *stringHolder, *header, + R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); + + CleanupStack::PopAndDestroy(stringHolder); + CleanupStack::PopAndDestroy(header); + + if( keypress )// user replied "Yes" + { + DoBlockDevice(); + } + else // user replied "No" + { + CompleteMessage(KErrCancel); + } + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::QueryBlockDeviceL() complete")); + } + +void CBTNotifierBase::DoBlockDevice() + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::DoBlockDevice()")); + TBTDeviceSecurity deviceSecurity = iDevice->GlobalSecurity(); + deviceSecurity.SetBanned(ETrue); + deviceSecurity.SetNoAuthenticate(EFalse); + deviceSecurity.SetNoAuthorise(EFalse); + iDevice->SetGlobalSecurity(deviceSecurity); + iDevice->DeleteLinkKey(); + + iBTRegistryQueryState = ESetDeviceBlocked; + TInt devManErr = iDevMan->ModifyDevice( *iDevice ); + + // if error, complete message, otherwise waiting for devman callback + // + if(devManErr != KErrNone) + CompleteMessage(devManErr); + } + +void CBTNotifierBase::ChangeAuthorizeState( TBool aTrust ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::ChangeAuthorizeState()")); + TBTDeviceSecurity sec = iDevice->GlobalSecurity(); + sec.SetBanned(EFalse); + sec.SetNoAuthorise( ( aTrust ) ? ETrue : EFalse ) ; + iDevice->SetGlobalSecurity(sec); + + iBTRegistryQueryState = ESetDeviceAuthorizeState; + TInt devManErr = iDevMan->ModifyDevice( *iDevice ); + + // if error, complete message, otherwise waiting for devman callback + // + if(devManErr != KErrNone) + { + CompleteMessage(devManErr); + TBTNotifLockPublish::DeleteNotifLocks( + EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); + } + } + +// ---------------------------------------------------------- +// CBTNotifierBase::CheckAndHandleQueryIntervalL +// ---------------------------------------------------------- +// +void CBTNotifierBase::CheckAndHandleQueryIntervalL() + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval start." ) ); + TBool res = CheckQueryInterval(); + if( res ) + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval check on/off query status." ) ); + // Check if we're already showing Turn BT off query + TInt queryValue=EBTQueryOff; + RProperty::Get( KPSUidBluetoothEnginePrivateCategory, KBTTurnBTOffQueryOn, queryValue ); + if( queryValue==EBTQueryOff ) + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval asking to turn BT off." ) ); + RProperty::Set( KPSUidBluetoothEnginePrivateCategory, KBTTurnBTOffQueryOn, EBTQueryOn ); + TInt keypress = iNotifUiUtil->ShowQueryL( KErrNone, R_BT_TURN_BT_OFF_NOTE, ECmdBTnotifUnavailable ); + RProperty::Set( KPSUidBluetoothEnginePrivateCategory, KBTTurnBTOffQueryOn, EBTQueryOff ); + if( keypress ) // User has accepted the dialog + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval turning BT off." ) ); + (void) iBTEngSettings->SetPowerState( EBTPowerOff ); + CompleteMessage( KErrAccessDenied ); + } + } + } + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckAndHandleQueryIntervalL done." ) ); + } + +void CBTNotifierBase::DoHandleGetDevicesCompleteL( TInt aErr, CBTDeviceArray* aDeviceArray) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::DoHandleGetDevicesCompleteL(%d)"), aErr )); + TBTDeviceName devName; + if (!aErr && aDeviceArray && aDeviceArray->Count()) + { + // Reassign so that we won't lose the device name as it is + // needed if registry doesn't have the name for this device yet: + CBTDevice* temp = iDevice; + CleanupStack::PushL(temp); + // Taking the object returned by registry so that iDevice have + // all the up-to-date information except device name. + iDevice = aDeviceArray->At(0); + aDeviceArray->Delete( 0 ); + // we show user the device name from registry if it is available; + // Otherwise, the name passed in by the notifier request shall be + // used. + if( ( !iDevice->IsValidDeviceName() || + !iDevice->DeviceName().Length() ) && + temp->IsValidDeviceName() ) + { + // We are using a stored device name, which will + // already have been processed + iDevice->SetDeviceNameL( temp->DeviceName() ); + } + CleanupStack::PopAndDestroy(temp); + } + BtNotifNameUtils::GetDeviceName(devName, iDevice); + + // It is possible that iDevice hasn't got a name so far. Use the default BT name + // got from GetDeviceName(). + if ( !iDevice->IsValidDeviceName() || !iDevice->DeviceName().Length() ) + { + BtNotifNameUtils::SetDeviceNameL(devName, *iDevice); + } + HandleGetDeviceCompletedL( iDevice ); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::CompleteMessage +// ---------------------------------------------------------- +// +void CBTNotifierBase::CompleteMessage(TInt aErr) + { + if( !iMessage.IsNull() ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::CompleteMessage(%d)"), aErr )); + iMessage.Complete( aErr ); + } + } + +// ---------------------------------------------------------- +// CBTNotifierBase::CompleteMessage +// ---------------------------------------------------------- +// +void CBTNotifierBase::CompleteMessage(TInt aValueToReplySlot, TInt aErr) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::CompleteMessage(%d, %d)"), + aValueToReplySlot, aErr ) ); + CompleteMessage(TPckgBuf( aValueToReplySlot ), aErr); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::CompleteMessage +// ---------------------------------------------------------- +// +void CBTNotifierBase::CompleteMessage(const TDesC8& aDesToReplySlot, TInt aErr) + { + if( !iMessage.IsNull() ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::CompleteMessage(TDesC8&, %d)"), aErr ) ); + if ( !aErr ) + { + aErr = iMessage.Write( iReplySlot, aDesToReplySlot ); + } + iMessage.Complete( aErr ); + } + } + +#ifdef __SERIES60_HELP +//------------------------------------------------------------- +// CBTNotifierBase::LaunchHelp +//-------------------------------------------------------------- +TInt CBTNotifierBase::LaunchHelp(TAny * tCoeHelpContext ) + { + TCoeHelpContext hc; + + if( tCoeHelpContext==NULL) + hc = TCoeHelpContext(KUidBTUI,KBT_HLP_BLOCKED); + else + hc = *static_cast(tCoeHelpContext); + + CArrayFix< TCoeHelpContext >* array = new CArrayFixFlat< TCoeHelpContext >(1); + TRAPD(err, + { + CleanupStack::PushL(array); + array->AppendL(hc); + HlpLauncher::LaunchHelpApplicationL( CCoeEnv::Static()->WsSession() , array ); + CleanupStack::Pop(array); + }); + + // the array is not deleted, since deleting it will result + // to E32User-CBase 3. It is assumed that HlpLancher is taking care of it. + // however this has not been documented. + return err; + } +#endif + +void CBTNotifierBase::HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray) + { + TRAP_IGNORE(DoHandleGetDevicesCompleteL(aErr, aDeviceArray)); + } + +void CBTNotifierBase::HandleDevManComplete(TInt aErr) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::HandleDevManComplete() aErr = %d"), aErr )); + + switch (iBTRegistryQueryState) + { + case ESetDeviceBlocked: + { + // Blocking device was demanded by user after the user + // rejected incoming pairing or connect request. The message + // to be completed here is the original pair or authorization request + // which has been rejected by the user. + CompleteMessage(KErrCancel); + } + case ESetDeviceAuthorizeState: + { + TBTNotifLockPublish::DeleteNotifLocks( + EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); + CompleteMessage(aErr); + break; + } + } + FLOG(_L("[BTNOTIF]\t CBTNotifierBase::HandleDevManComplete() Complete")); + } + +void CBTNotifierBase::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + } + +// ---------------------------------------------------------- +// CBTNotifierBase::CheckQueryInterval +// ---------------------------------------------------------- +// +TBool CBTNotifierBase::CheckQueryInterval() + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval()" ) ); + TBool result = EFalse; + // Check if the user gets too many queries within a certain time interval from unpaired devices + if( iDevice && !iDevice->IsValidLinkKey() ) + { + TBuf8<32> buf; + TTime now; + now.UniversalTime(); // Get current time + TInt64 writeTime = ( now + REJECT_ADD_TIME ).Int64(); + + // get last connection time + TInt err = RProperty::Get( KPSUidBluetoothEnginePrivateCategory, KBTConnectionTimeStamp, buf ); + if( !err ) + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval Checking query interval." ) ); + // Parse recorded time stamp + TInt64 num(0); + TLex8 lex; + lex = buf; + lex.Val( num ); + TTime lastTime( num ); + + // detection of clock adjusment + TInt timetravel = 2 * REJECT_ADD_TIME.Int(); + if( lastTime > now + TTimeIntervalSeconds(timetravel) ) + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval time travel detection." ) ); + lastTime = now; + } + // new request too quickly, move booked time + if( lastTime + CONNECT_ADD_TIME > now ) + { + FLOG( _L( "[BTNOTIF]\t CBTAuthNotifier::IsDosAttack CONNECT_ADD_TIME added." ) ); + writeTime = ( lastTime + CONNECT_ADD_TIME ).Int64(); + } + + FTRACE( FPrint( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval() lastTime = %d" ), lastTime.Int64() ) ); + FTRACE( FPrint( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval now + treshold: %d" ), (now + DENY_THRESHOLD).Int64() ) ); + // If threshold is exceeded, ask user to turn Bluetooth OFF + if( lastTime > now + DENY_THRESHOLD ) + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval threshold exceeded!." ) ); + result = ETrue; + } + } + else + { + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval setting connection timestamp first time." ) ); + } + // Write back the timestamp + buf.Num( writeTime ); + FTRACE( FPrint( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval updating timestamp: %d." ), writeTime ) ); + RProperty::Set( KPSUidBluetoothEnginePrivateCategory,KBTConnectionTimeStamp, buf ); + } // end of query interval check + FLOG( _L( "[BTNOTIF]\t CBTNotifierBase::CheckQueryInterval() complete" ) ); + return result; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2002 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: Bluetooth visibility timeout notifier class. +* +*/ + +// INCLUDE FILES +#include // Own resources +#include "btnenterpriseitsecurityinfonotifier.h" // Own class definition +#include "BTNotifDebug.h" // Debugging macros +#include +#include +#include + +_LIT(KDcmoResourceFileName, "z:dcmo.rsc"); +_LIT(KNewLine, "\n"); + +//"Bluetooth" is 9 characters long +const TInt KDefaultBluetoothStringLength = 9; + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTEnterpriseItSecurityInfoNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTEnterpriseItSecurityInfoNotifier* CBTEnterpriseItSecurityInfoNotifier::NewL() + { + CBTEnterpriseItSecurityInfoNotifier* self=new (ELeave) CBTEnterpriseItSecurityInfoNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------- +// CBTEnterpriseItSecurityInfoNotifier::CBTEnterpriseItSecurityInfoNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTEnterpriseItSecurityInfoNotifier::CBTEnterpriseItSecurityInfoNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTEnterpriseItSecurityInfoNotifier::~CBTEnterpriseItSecurityInfoNotifier() + { + Cancel(); + } + +// ---------------------------------------------------------- +// CBTEnterpriseItSecurityInfoNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTEnterpriseItSecurityInfoNotifier::TNotifierInfo CBTEnterpriseItSecurityInfoNotifier::RegisterL() + { + iInfo.iUid = KBTEnterpriseItSecurityInfoNotifierUid; + iInfo.iChannel = KBTEnterpriseItSecurityInfoNotifierUid; + iInfo.iPriority = ENotifierPriorityHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTEnterpriseItSecurityInfoNotifier::StartL +// Synchronic notifier launch. Contructs and shows a global +// note when temp visibility expire, no parameters need here. +// ---------------------------------------------------------- +// +TPtrC8 CBTEnterpriseItSecurityInfoNotifier::StartL(const TDesC8& /*aBuffer*/) + { + FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::StartL()")); + + ShowNoteAndCompleteL(); + + FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::StartL() completed")); + return TPtrC8(KNullDesC8); + } + +// ---------------------------------------------------------- +// CBTEnterpriseItSecurityInfoNotifier::GetParamsL +// Mandatory for BT Notifiers when using asynchronous launch. +// ---------------------------------------------------------- +// +void CBTEnterpriseItSecurityInfoNotifier::GetParamsL(const TDesC8& /*aBuffer*/, + TInt /*aReplySlot*/, + const RMessagePtr2& /*aMessage*/) + { + //nothing to do here + } + +// ---------------------------------------------------------- +// CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL +// Shows the notifier in backround +// ---------------------------------------------------------- +// +void CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL() + { + FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete()")); + + //get full path to the DCMO resource file + TParse* parser = new (ELeave) TParse; + parser->Set(KDcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL); + CleanupStack::PushL(parser); + TFileName* fileName = new (ELeave) TFileName; + *fileName = parser->FullName(); + CleanupStack::PopAndDestroy(parser); + CleanupStack::PushL(fileName); + + //create the resource reader object that we need to use several times + CTulStringResourceReader* reader = CTulStringResourceReader::NewL(*fileName); + CleanupStack::PushL(reader); + + //get pointer to the message part of the notifier + TPtrC resourceString; + resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_DISABLE)); + + //create descriptor with a max length to fit the localised "disabled" text + new line + "Bluetooth" + RBuf content; + content.CreateL(resourceString.Length() + KNewLine().Length() + KDefaultBluetoothStringLength); + CleanupClosePushL(content); + + //add resource string and new line character to the content descriptor + content.Append(resourceString); + content.Append(KNewLine()); + + //get pointer to the Bluetooth name part of the notifier (can't assume this is actually "Bluetooth" in all languages) + resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH)); + + //check that the resource string will fit into the content descriptor + TInt requiredLength = content.Length() + resourceString.Length(); + if (requiredLength > content.MaxLength()) + { + //allocate more space in the content descriptor + content.ReAllocL(requiredLength); + } + + //add resource string to the content descriptor + content.Append(resourceString); + + //display the notifier and complete + iNotifUiUtil->ShowInfoNoteL(content, ECmdBTnotifUnavailable); + CompleteMessage(KErrNone); + + //pop and destroy the content descriptor, resource reader and file name + CleanupStack::PopAndDestroy(3, fileName); + + FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete() complete")); + } + +void CBTEnterpriseItSecurityInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + //nothing to do here + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnotifactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnotifactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 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: Active object helper class. +* +*/ + +#include "btnotifactive.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTNotifActive::CBTNotifActive( MBTNotifActiveObserver* aObserver, + TInt aId, TInt aPriority ) +: CActive( aPriority ), iRequestId( aId ), iObserver( aObserver ) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTNotifActive::ConstructL() + { + } + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTNotifActive* CBTNotifActive::NewL( MBTNotifActiveObserver* aObserver, + TInt aId, TInt aPriority ) + { + CBTNotifActive* self = new (ELeave) CBTNotifActive( aObserver, aId, aPriority ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTNotifActive::~CBTNotifActive() + { + Cancel(); + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been cancelled. +// --------------------------------------------------------------------------- +// +void CBTNotifActive::DoCancel() + { + iObserver->DoCancelRequest( this, iRequestId ); + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been completed. +// --------------------------------------------------------------------------- +// +void CBTNotifActive::RunL() + { + iObserver->RequestCompletedL( this, iRequestId, iStatus.Int() ); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when an error in RunL has occurred. +// --------------------------------------------------------------------------- +// +TInt CBTNotifActive::RunError( TInt aError ) + { + iObserver->HandleError( this, iRequestId, aError ); + return KErrNone; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnotifnameutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnotifnameutils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 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: Declares Bluetooth notifiers base class. + * + */ + +#include +#include +#include + +#include + +#include "btNotifDebug.h" +#include "btnotifnameutils.h" + +/** + * A function for strip dangerous chars out of BT name + * @param a device name. After return, it contains the stripped name. + * @return void + */ +void BtNotifNameUtils::StripDeviceName(TBTDeviceName& aDeviceNameForStrip) + { + aDeviceNameForStrip.Trim(); + // Filter out listbox non-friendly control chars. + // + AknTextUtils::StripCharacters(aDeviceNameForStrip, KAknStripListControlChars); + + // Filter out sub-string-separator to pretend unexpected text layout. + // + TChar subStringSeparator = TChar(0x0001); + TBuf<1> tempCharBuf; + tempCharBuf.Append(subStringSeparator); + AknTextUtils::StripCharacters(aDeviceNameForStrip, tempCharBuf); + } + +/** + * Gets the device name to be displayed in note or dialog. + * @param aName contains the name to be displayed + * @param aDev the device that may have a friendly or device name, or no name at all. + */ +void BtNotifNameUtils::GetDeviceDisplayName(TBTDeviceName& aName, const CBTDevice* aDev) + { + if(aDev && aDev->IsValidFriendlyName() ) + { + aName.Copy( aDev->FriendlyName() ); + } + else + { + GetDeviceName(aName, aDev); + } + } + +/** + * Gets the device name from aDev if its friendly name or device name is valid; otherwise + * the predefined default BT name. + * @param aName contains the device name as the result + * @param aDev the device that may have a device name, or no name at all. + */ +void BtNotifNameUtils::GetDeviceName(TBTDeviceName& aName, const CBTDevice* aDev) + { + aName.Zero(); + TInt err (CnvUtfConverter::EErrorIllFormedInput); + if(aDev && aDev->IsValidDeviceName()) + { + err = CnvUtfConverter::ConvertToUnicodeFromUtf8(aName, aDev->DeviceName()); + } + // if there are illformated chars in the device name, default name should be used for display. + if (err == CnvUtfConverter::EErrorIllFormedInput || aName.Length() == 0) + { + StringLoader::Load(aName, R_BT_DIALOG_DEF_NAME); + } + StripDeviceName(aName); + } + +/** + * Sets the device name. This handles the conversion from unicode + * to UTF8. + * @param aDev the device that the name should be set for + * @param aName the name to set + */ +void BtNotifNameUtils::SetDeviceNameL(const TBTDeviceName& aName, CBTDevice& aDev) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::SetDeviceNameL - Name: '%S' length: %d"), &aName, aName.Length() )); + + // Rationalise the name to remove whitespace and control characters + // then set the name if there's anything left + TBTDeviceName devName(aName); + StripDeviceName(devName); + if (aName.Length()) + { + aDev.SetDeviceNameL(BTDeviceNameConverter::ToUTF8L(devName)); + } + } + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnotifuiutil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnotifuiutil.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,412 @@ +/* +* Copyright (c) 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: Declares Utility to show UI notes and queries. +* +*/ + +#include // BAFL utils (for language file) +#include "btnotifuiutil.h" +#include "BTNotifDebug.h" // Debugging macros +#include // Localisation stringloader +#include // Information note +#include // for the blocking query +#include // CoverUI +#include // Backlight control +#include // Application Key enable/disable + +CBTNotifUIUtil* CBTNotifUIUtil::NewL( TBool aCoverDisplayEnabled ) + { + CBTNotifUIUtil* self = new (ELeave) CBTNotifUIUtil( aCoverDisplayEnabled ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +CBTNotifUIUtil::CBTNotifUIUtil( TBool aCoverDisplayEnabled ) : + iCoverDisplayEnabled( aCoverDisplayEnabled ), + iSystemCancel( EFalse ), + iAppKeyBlocked( EFalse ) + { + } + +void CBTNotifUIUtil::ConstructL() + { + iEikEnv = CEikonEnv::Static(); + + TFileName filename; + filename += KFileDrive; + filename += KDC_RESOURCE_FILES_DIR; + filename += KResourceFileName; + BaflUtils::NearestLanguageFile(iEikEnv->FsSession(),filename); + iResourceFileFlag=iEikEnv->AddResourceFileL(filename); + } + +CBTNotifUIUtil::~CBTNotifUIUtil() + { + iSystemCancel = ETrue; + delete iQueryDlg; + delete iWaitDlg; + // Activate apps key again before exit, in case any interruption happens before activation + if( iAppKeyBlocked ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil destructor Activate apps key before exiting. ")); + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(EFalse); + } + iEikEnv->DeleteResourceFile(iResourceFileFlag); + } +// ---------------------------------------------------------- +// CBTNotifierBase::TurnLightsOn +// ---------------------------------------------------------- +// +void CBTNotifUIUtil::TurnLightsOn() + { + // Change the bit on and off. SysAp will detect that + // the lights should be switched on for the specified time. + // + TInt err = KErrNone; + + err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn); + err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOff); + + if ( err != KErrNone ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifUIUtil::TurnLightsOn() RProperty::Set return error %d"), err )); + } + + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::TurnLightsOn() <<")); + } + +// ---------------------------------------------------------- +// CBTNotifierBase::LocalEikonEnv +// ---------------------------------------------------------- +// +CEikonEnv& CBTNotifUIUtil::LocalEikonEnv() + { + return *iEikEnv; + } + +// ---------------------------------------------------------- +// CBTNotifierBase::ShowQueryL +// ---------------------------------------------------------- +// +TInt CBTNotifUIUtil::ShowQueryL(TInt aPromptResource, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, CAknQueryDialog::TTone aTone ) + { + TInt ret; + TBTDeviceName name( KNullDesC ); + if ( aPromptResource ) + { + HBufC* prompt = StringLoader::LoadLC( aPromptResource ); + ret = ShowQueryL(*prompt, aExecuteResource, aDialogId, name, aTone ); + CleanupStack::PopAndDestroy( prompt ); + } + else + { + ret = ShowQueryL(KNullDesC, aExecuteResource, aDialogId, name, aTone ); + } + return ret; + } + +TInt CBTNotifUIUtil::ShowQueryL(const TDesC& aPrompt, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, const TBTDeviceName& aDevNameInCoverUi, CAknQueryDialog::TTone aTone ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowQueryL >>")); + __ASSERT_DEBUG( iQueryDlg == NULL, + User::Panic(_L("CBTNotifier iQueryDlg not released!"),KErrAlreadyExists)); + + iQueryDlg = CAknQueryDialog::NewL(aTone); + if( iCoverDisplayEnabled && aDialogId != ECmdBTnotifUnavailable) + { + // initializes cover support + iQueryDlg->PublishDialogL(aDialogId, KUidCoverUiCategoryBTnotif ); + CoverUIDisplayL( iQueryDlg, aDevNameInCoverUi ); + } + + // Deactivate apps key + // we can do nothing if this operation fails + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(ETrue); + iAppKeyBlocked = ETrue; + TurnLightsOn(); + iQueryDlg->SetFocus( ETrue ); + + TInt keypress; + if ( aPrompt.Length() ) + { + keypress = iQueryDlg->ExecuteLD(aExecuteResource, aPrompt ); + } + else + { + keypress = iQueryDlg->ExecuteLD( aExecuteResource ); + } + + iQueryDlg = NULL; + if( !iSystemCancel ) + { // Activate apps key when no external cancellation happens + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(EFalse); + iAppKeyBlocked = EFalse; + } + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowQueryL keypress %d <<"), keypress ) ); + return keypress; + } + +TInt CBTNotifUIUtil::ShowMessageQueryL(TDesC& aMessage, const TDesC& aHeader, + TInt aResourceId, CAknQueryDialog::TTone aTone ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowMessageQueryL >>")); + __ASSERT_DEBUG( iQueryDlg == NULL, + User::Panic(_L("CBTNotifier iQueryDlg not released!"),KErrAlreadyExists)); + + iQueryDlg = CAknMessageQueryDialog::NewL( aMessage, aTone ); + iQueryDlg->PrepareLC( aResourceId ); + if( aHeader.Length() ) + { + static_cast(iQueryDlg)->Heading()->SetTextL( aHeader ); + } + + // Deactivate apps key + // we can do nothing if this operation fails + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(ETrue); + iAppKeyBlocked = ETrue; + TurnLightsOn(); + iQueryDlg->SetFocus( ETrue ); + TInt keypress = iQueryDlg->RunLD(); + iQueryDlg = NULL; + + if( !iSystemCancel ) + { // Activate apps key when no external cancellation happens + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(EFalse); + iAppKeyBlocked = EFalse; + } + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowMessageQueryL keypress %d <<"), keypress ) ); + return keypress; + } + + +TInt CBTNotifUIUtil::ShowTextInputQueryL(TDes& aText, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, + CAknQueryDialog::TTone aTone ) + { + return ShowTextInputQueryL(aText, KNullDesC, aExecuteResource, aDialogId, aTone); + } + +TInt CBTNotifUIUtil::ShowTextInputQueryL(TDes& aText, const TDesC& aPrompt, TInt aExecuteResource, + TSecondaryDisplayBTnotifDialogs aDialogId, + CAknQueryDialog::TTone aTone ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowTextInputQueryL >>")); + + __ASSERT_DEBUG( iQueryDlg == NULL, + User::Panic(_L("CBTNotifier iQueryDlg not released!"),KErrAlreadyExists)); + + iQueryDlg = CAknTextQueryDialog::NewL( aText, aTone ); + if( iCoverDisplayEnabled && aDialogId != ECmdBTnotifUnavailable) + { + // initializes cover support + iQueryDlg->PublishDialogL(aDialogId, KUidCoverUiCategoryBTnotif ); + } + if ( aPrompt.Length() ) + { + iQueryDlg->SetPromptL( aPrompt ); + } + + // Deactivate apps key + // we can do nothing if this operation fails + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(ETrue); + iAppKeyBlocked = ETrue; + TurnLightsOn(); + iQueryDlg->SetFocus( ETrue ); + TInt keypress = iQueryDlg->ExecuteLD( aExecuteResource ); + iQueryDlg = NULL; + + if( !iSystemCancel ) + { // Activate apps key when no external cancellation happens + (void) ((CAknNotifierAppServerAppUi*)iEikEnv->EikAppUi())->SuppressAppSwitching(EFalse); + iAppKeyBlocked = EFalse; + } + + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowTextInputQueryL txt '%S' keypress %d <<"), + &aText, keypress ) ); + return keypress; + } + +void CBTNotifUIUtil::ShowInfoNoteL( + TInt aResourceId, TSecondaryDisplayBTnotifDialogs aDialogId ) + { + // Load a string, create and show a note + HBufC* stringHolder = StringLoader::LoadLC( aResourceId ); + ShowInfoNoteL( *stringHolder, aDialogId ); + CleanupStack::PopAndDestroy(); //stringHolder + } + + +void CBTNotifUIUtil::ShowInfoNoteL( + const TDesC& aResource, TSecondaryDisplayBTnotifDialogs aDialogId ) + { + FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowInfoNoteL '%S' >> "), + &aResource ) ); + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + if(iCoverDisplayEnabled && aDialogId != ECmdBTnotifUnavailable) + { + CleanupStack::PushL( note ); + // initializes cover support + note->PublishDialogL(aDialogId, KUidCoverUiCategoryBTnotif ); + CleanupStack::Pop(note); + } + note->ExecuteLD( aResource ); + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowInfoNoteL done <<")); + } + +void CBTNotifUIUtil::ShowConfirmationNoteL( TBool aWaitingDlg, const TDesC& aResource, + TSecondaryDisplayBTnotifDialogs aDialogId, const TBTDeviceName& aDevNameInCoverUi ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowConfirmationNoteL >>")); + CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( aWaitingDlg ); + + if(iCoverDisplayEnabled && aDialogId != ECmdBTnotifUnavailable) + { + CleanupStack::PushL( note ); + // initializes cover support + note->PublishDialogL(aDialogId, KUidCoverUiCategoryBTnotif ); + CoverUIDisplayL( note, aDevNameInCoverUi ); + CleanupStack::Pop(note); + } + TurnLightsOn(); + note->ExecuteLD( aResource ); + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowConfirmationNoteL done <<")); + } + +void CBTNotifUIUtil::ShowErrorNoteL( TBool aWaitingDlg, const TDesC& aResource, + TSecondaryDisplayBTnotifDialogs aDialogId, TBTDeviceName aDevNameInCoverUi ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowErrorNoteL >>")); + CAknErrorNote* note = new (ELeave) CAknErrorNote( aWaitingDlg ); + if(iCoverDisplayEnabled && aDialogId != ECmdBTnotifUnavailable) + { + CleanupStack::PushL( note ); + // initializes cover support + note->PublishDialogL(aDialogId, KUidCoverUiCategoryBTnotif ); + CoverUIDisplayL( note, aDevNameInCoverUi ); + CleanupStack::Pop(note); + } + TurnLightsOn(); + note->ExecuteLD( aResource ); + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowErrorNoteL done <<")); + } + +// ---------------------------------------------------------- +// CBTNotifUIUtil::IsQueryReleased +// Check if iQueryDlg is NULL +// ---------------------------------------------------------- +// +TBool CBTNotifUIUtil::IsQueryReleased() + { + return ( iQueryDlg ) ? EFalse : ETrue; + } + +// ---------------------------------------------------------- +// CBTNotifUIUtil::UpdateQueryDlgL +// Update Query with specified info, called by UpdateL() +// ---------------------------------------------------------- +// +void CBTNotifUIUtil::UpdateQueryDlgL( TDesC& aMessage ) + { + __ASSERT_DEBUG( iQueryDlg != NULL, + User::Panic(_L("CBTNotifier iQueryDlg not exist to update!"),KErrNotFound)); + iQueryDlg->SetPromptL( aMessage ); + iQueryDlg->DrawDeferred(); + } + +// ---------------------------------------------------------- +// CBTNotifUIUtil::UpdateMessageQueryDlgL +// Update message query when RNotifier::UpdateL() is called +// ---------------------------------------------------------- +// +void CBTNotifUIUtil::UpdateMessageQueryDlgL( TDesC& aMessage ) + { + __ASSERT_DEBUG( iQueryDlg != NULL, + User::Panic(_L("CBTNotifier CAknTextQueryDialog iQueryDlg not exist to update!"),KErrNotFound)); + static_cast(iQueryDlg)->SetMessageTextL( aMessage ); + iQueryDlg->DrawDeferred(); + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::UpdateMessageQueryDlg ")); + } + +// ---------------------------------------------------------- +// CBTNotifUIUtil::UpdateCoverUiL +// Update secondary display +// ---------------------------------------------------------- +// +void CBTNotifUIUtil::UpdateCoverUiL( const TDesC8& aMessage ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::UpdateCoverUiL >>")); + __ASSERT_DEBUG( iQueryDlg != NULL, + User::Panic(_L("CBTNotifier iQueryDlg not exist to update!"),KErrNotFound)); + if(iCoverDisplayEnabled ) + { + CAknMediatorFacade* coverData = AknMediatorFacade(iQueryDlg); + if(coverData) + { + coverData->ResetBuffer(); + coverData->BufStream() << aMessage; // insert your buffer here + coverData->BufStream().CommitL(); + coverData->PostUpdatedDataL(); + } + } + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::UpdateCoverUiL done <<")); + } + +void CBTNotifUIUtil::DismissDialog() + { + if( !IsQueryReleased() ) + { + delete iQueryDlg; + iQueryDlg = NULL; + } + } + +void CBTNotifUIUtil::CoverUIDisplayL( const MObjectProvider* aMop, + const TBTDeviceName& aDevNameInCoverUi ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::CoverUIDisplayL() >>")); + + CAknMediatorFacade* covercl = AknMediatorFacade( aMop ); + if( covercl && aDevNameInCoverUi.Length() ) + { + covercl->BufStream() << aDevNameInCoverUi; + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::CoverUIDisplayL() <<")); + } + +TInt CBTNotifUIUtil::ShowWaitDlgL( TInt aResourceId ) + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowWaitDlgL() >>")); + iWaitDlg = new(ELeave) CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDlg)), ETrue ); + TInt ret = iWaitDlg->ExecuteLD(aResourceId); + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::ShowWaitDlgL() <<")); + return ret; + } + +void CBTNotifUIUtil::CompleteWaitDlgL() + { + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::CompleteWaitDlgL() >>")); + if(iWaitDlg) + { + iWaitDlg->ProcessFinishedL(); + } + FLOG(_L("[BTNOTIF]\t CBTNotifUIUtil::CompleteWaitDlgL() <<")); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2002 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: Show pairing status and set authorized, unique devicename of paired device. +* +*/ + + +// INCLUDE FILES + +#include // Localisation stringloader +#include // Own resources +#include +#include "btnotiflock.h" +#include "btnpaireddevsettNotifier.h" // Own class definition +#include "BTNotifDebug.h" // Debugging macros +#include +#include "btnotifnameutils.h" + +#include + +#include +#include // CoverUI + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTPairedDevSettNotifier* CBTPairedDevSettNotifier::NewL() + { + CBTPairedDevSettNotifier* self=new (ELeave) CBTPairedDevSettNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::CBTPairedDevSettNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTPairedDevSettNotifier::CBTPairedDevSettNotifier() + { + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTPairedDevSettNotifier::~CBTPairedDevSettNotifier() + { + } + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTPairedDevSettNotifier::TNotifierInfo CBTPairedDevSettNotifier::RegisterL() + { + iInfo.iUid = KBTPairedDeviceSettingNotifierUid; + iInfo.iChannel = KBTPairedDeviceSettingChannel; + iInfo.iPriority = ENotifierPriorityVHigh; + return iInfo; + } + + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::GetParamsL +// Mandatory for BT Notifiers when using asynchronous launch. +// This notifier is synchronous so no implementation is needed. +// ---------------------------------------------------------- +// +void CBTPairedDevSettNotifier::GetParamsL(const TDesC8& aBuffer, + TInt aReplySlot, + const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::GetParamsL")); + + if( iReplySlot != NULL || !iMessage.IsNull()) + { + User::Leave(KErrInUse); + } + + iMessage = aMessage; + iReplySlot = aReplySlot; + ProcessParamBufferL(aBuffer); + + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::GetParamsL Complete")); + } + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::UpdateL +// Update notifier according to new data +// ---------------------------------------------------------- +// +TPtrC8 CBTPairedDevSettNotifier::UpdateL(const TDesC8& /*aBuffer*/) + { + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::UpdateL")); + TPtrC8 ret(KNullDesC8); + return (ret); + } + +void CBTPairedDevSettNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::HandleGetDeviceCompletedL >>")); + TBTDeviceName name; + BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); + + // 1. Show pairing status note + FTRACE(FPrint(_L("[BTNOTIF]\t CBTPairedDevSettNotifier iPairingStatus: %d"), iPairingStatus)); + TInt resourceId = ProcessPairingErrorCode( iPairingStatus ); + HBufC* stringholder = StringLoader::LoadLC( resourceId ); + _LIT(PU,"%U"); + if( stringholder->Find(PU) != KErrNotFound) + { + CleanupStack::PopAndDestroy( stringholder ); + stringholder = StringLoader::LoadLC( resourceId, name ); + } + + if (!iPairingStatus) + { + iNotifUiUtil->ShowConfirmationNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name ); + } + else + { + iNotifUiUtil->ShowErrorNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name ); + } + CleanupStack::PopAndDestroy( stringholder ); // stringholder + + if( iPairingStatus || (iDevice && iDevice->GlobalSecurity().Banned() ) ) + { + TBTNotifLockPublish::DeleteNotifLocks( + EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); + CompleteMessage(KErrNone); + return; + } + + // 2. Show Authorization query + // + TInt keypress = iNotifUiUtil->ShowQueryL( R_BT_AUTHORIZATION_PROMPT, R_BT_AUTHORISATION_QUERY, + iSecondaryDisplayCommand, CAknQueryDialog::EConfirmationTone); + + if (!iMessage.IsNull()) + { + // this notifier is not cancelled, continue the task: + ChangeAuthorizeState(keypress); + } + } + +// ---------------------------------------------------------- +// CBTGenericQueryNotifier::ProcessParamBufferL +// Parse the data out of the message that is sent by the +// client of the notifier. +// ---------------------------------------------------------- +void CBTPairedDevSettNotifier::ProcessParamBufferL(const TDesC8& aBuffer) + { + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::ProcessParamBufferL()")); + + TBTPairedDeviceSettingParamsPckg pckg; + pckg.Copy( aBuffer ); + + iPairingStatus = pckg().iPairingStatus; + if( iPairingStatus <= KHCIErrorBase ) + { + // Pairing status could be KErrNone, or the Symbian error code + // used for indicating HCI error codes. + iPairingStatus -= KHCIErrorBase; + } + if ( !iPairingStatus ) + { + TBTNotifLockPublish::AddNotifLocks( + EBTNotiferLockPairedDeviceSetting, pckg().iRemoteAddr ); + } + + iDevice = CBTDevice::NewL(pckg().iRemoteAddr); + GetDeviceFromRegL( pckg().iRemoteAddr ); + + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::ProcessParamBufferL() end")); + } + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::Cancel +// Release all own resources (member variables) +// ---------------------------------------------------------- +// +void CBTPairedDevSettNotifier::Cancel() + { + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::Cancel()")); + + TBTNotifLockPublish::DeleteNotifLocks( + EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); + CBTNotifierBase::Cancel(); + + FLOG(_L("[BTNOTIF]\t CBTPairedDevSettNotifier::Cancel() completed")); + } + +// ---------------------------------------------------------- +// CBTPairedDevSettNotifier::ProcessPairingErrorCode +// ---------------------------------------------------------- +// +TInt CBTPairedDevSettNotifier::ProcessPairingErrorCode( const TInt aErr ) + { + if( !aErr ) + { + return R_BT_SUCCESFULLY_PAIRED_PROMPT; + } + else if( aErr == -EHostBusyPairing ) + { + return R_BT_SSP_BUSY; + } + else + { + return R_BT_PAIRING_FAILED_PROMPT; + } + } + + +void CBTPairedDevSettNotifier::QueryRenameDeviceL(const CBTDevice& /*aDevice*/) + { + // No implementation for now. + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnpairnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnpairnotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,246 @@ +/* +* Copyright (c) 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: Base class for all notifiers for pairing purpose. +* +*/ + +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include // new file introduced by xSymbian +#endif + +#include // Localisation stringloader +#include // Unicode character conversion utilities +#include +#include // Own resources +#include "btnpairnotifier.h" +#include "btNotifDebug.h" +#include "btnotifnameutils.h" + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::NewL +// ---------------------------------------------------------- +// +CBTNPairNotifierBase* CBTNPairNotifierBase::NewL() + { + CBTNPairNotifierBase* self = new (ELeave) CBTNPairNotifierBase(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase Destructor +// ---------------------------------------------------------- +// +CBTNPairNotifierBase::~CBTNPairNotifierBase() + { + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase default construct +// ---------------------------------------------------------- +// +CBTNPairNotifierBase::CBTNPairNotifierBase() + :iLocallyInitiated(EFalse) + { + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::RegisterL +// ---------------------------------------------------------- +// +CBTNPairNotifierBase::TNotifierInfo CBTNPairNotifierBase::RegisterL() + { + return iInfo; + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::GetParamsL +// ---------------------------------------------------------- +// +void CBTNPairNotifierBase::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + (void)aBuffer; + if( !iMessage.IsNull() ) + { + User::Leave(KErrInUse); + } + else if ( AutoLockOnL() ) + { + // The phone is locked, access denied. + // + CompleteMessage(KErrCancel); + return; + } + + iMessage = (RMessage2)aMessage; + iReplySlot = aReplySlot; + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::UpdateL +// ---------------------------------------------------------- +// +void CBTNPairNotifierBase::UpdateL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + (void) aReplySlot; + UpdateL(aBuffer); + aMessage.Complete(KErrNone); + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::UpdateL +// ---------------------------------------------------------- +// +TPtrC8 CBTNPairNotifierBase::UpdateL( const TDesC8& aBuffer ) + { + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::UpdateL()")); + + TBTDeviceNameUpdateParamsPckg pckg; + pckg.Copy( aBuffer ); + if (pckg().Type() != TBTNotifierUpdateParams2::EDeviceName) + { + TPtrC8 ret(KNullDesC8); + return (ret); + } + + if (pckg().Result() == KErrNone) + { + BtNotifNameUtils::SetDeviceNameL(pckg().DeviceName(), *iDevice); + + // Finally show new prompt for dialog if it is still on the screen + // and user has not given a alias for device. + if( !iNotifUiUtil->IsQueryReleased() && !iDevice->IsValidFriendlyName() ) + { + HBufC* prompt = GenerateQueryPromoptLC(); + iNotifUiUtil->UpdateQueryDlgL( *prompt ); + CleanupStack::PopAndDestroy( prompt ); + } + } + + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::UpdateL() completed")); + TPtrC8 ret(KNullDesC8); + return (ret); + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::ProcessParamsGetDeviceL +// Get device from registry based on notifier's param +// ---------------------------------------------------------- +// +void CBTNPairNotifierBase::ProcessParamsGetDeviceL( const TBTDevAddr& aAddr, const TBTDeviceName& aName ) + { + iDevice = CBTDevice::NewL(aAddr); + BtNotifNameUtils::SetDeviceNameL(aName, *iDevice); + + // Get all properties of device from registry. + GetDeviceFromRegL( aAddr ); + +#ifdef _DEBUG + FTRACE(FPrint(_L("[BTNOTIF]\t Executing authentication... Parameters:"))); + TBuf<12> deviceAddressString; + aAddr.GetReadable(deviceAddressString); + FTRACE(FPrint(_L("[BTNOTIF]\t BT Address: %S"), &deviceAddressString)); +#endif + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::CheckBlockedDeviceL +// Forbid pairing from remote banned devices +// ---------------------------------------------------------- +// +TBool CBTNPairNotifierBase::CheckBlockedDeviceL() + { + if ( !iDevice ) + { + User::Leave( KErrGeneral ); + } + + // Do not allow pairing attempt from banned devices + if( iDevice->GlobalSecurity().Banned() && !iLocallyInitiated ) + { + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::CheckBlockedDeviceL() Pairing attempt from banned device is denied.")); + CompleteMessage(KErrCancel); + return ETrue; + } + return EFalse; + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::AuthoriseIncomingPairingL +// Query user to authorise imcoming pair request or not. +// If reject, query whether to block the remot device. +// ---------------------------------------------------------- +// +TBool CBTNPairNotifierBase::AuthoriseIncomingPairingL() + { + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::AuthoriseIncomingPairingL() >>")); + + // Start pairing observer so that user will be informed about the result: + TInt err = CBTEngConnMan::StartPairingObserver( iBTAddr ); + if ( err ) + { + // Failed to start observer because of other ongoing pairing, + // reject this request: + CompleteMessage( err ); + return EFalse; + } + + TBTDeviceName devName; + BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); + HBufC* prompt = StringLoader::LoadLC( R_BT_ACCEPT_PAIRING_REQUEST, devName ); + + TBTDeviceName nameCoverUi( KNullDesC ); + // Show query for use to accept/reject incoming pairing request + TInt keypress = iNotifUiUtil->ShowQueryL( *prompt, R_BT_GENERIC_QUERY, + ECmdBTnotifUnavailable, nameCoverUi, CAknQueryDialog::EConfirmationTone ); + CleanupStack::PopAndDestroy( prompt ); + + if( iMessage.IsNull() ) // cancelled by the stack + { + return EFalse; + } + else if( !keypress ) // User rejected pairing + { + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase: user rejected incoming pairing")); + // stop observer to omit pairing failure note. + CBTEngConnMan::StopPairingObserver( iDevice->BDAddr() ); + iDevice->SetPaired(EFalse); + CheckAndHandleQueryIntervalL(); + if( !iMessage.IsNull() ) + { + // Ask user does he/she wishes to block this device (if not canceled because the + // frequency is too high). + QueryBlockDeviceL(); + } + return EFalse; + } + + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::AuthoriseIncomingPairingL() << ")); + return ETrue; + } + +// ---------------------------------------------------------- +// CBTNPairNotifierBase::GenerateQueryPromoptLC +// To be implemented in derived classes. +// ---------------------------------------------------------- +// +HBufC* CBTNPairNotifierBase::GenerateQueryPromoptLC() + { + return NULL; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,282 @@ +/* +* Copyright (c) 2002 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: Declares authentication (PIN query) notifier class. +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Unicode character conversion utilities +#include +#include +#include +#include +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include +#endif +#include // Own resources +#include + +#include "btnotif.hrh" // Own resource header +#include "btnssppasskeyentrynotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include "btnotifnameutils.h" + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTSSPPasskeyEntryNotifier* CBTSSPPasskeyEntryNotifier::NewL() + { + CBTSSPPasskeyEntryNotifier* self=new (ELeave) CBTSSPPasskeyEntryNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::CBTSSPPasskeyEntryNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTSSPPasskeyEntryNotifier::CBTSSPPasskeyEntryNotifier() + { + iPasskey.Zero(); + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTSSPPasskeyEntryNotifier::~CBTSSPPasskeyEntryNotifier() + { + } + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTSSPPasskeyEntryNotifier::TNotifierInfo CBTSSPPasskeyEntryNotifier::RegisterL() + { + iInfo.iUid = KBTPasskeyDisplayNotifierUid; + iInfo.iChannel = KBTPasskeyDisplayNotifierUid; + iInfo.iPriority = ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::GetParamsL +// Initialize parameters and check if device is already +// in registry. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTSSPPasskeyEntryNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GetParamsL()")); + + CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage ); + + TBTPasskeyDisplayParamsPckg pckg; + pckg.Copy(aBuffer); + iBTAddr = pckg().DeviceAddress(); + if ( OtherOutgoPairing(iBTAddr) ) + { + // We won't allow incoming pairing during outgoing pairing: + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier: outgoing pair in progress, reject incoming pair")); + CompleteMessage(KErrCancel); + return; + } + + iLocallyInitiated = pckg().LocallyInitiated(); + iPasskey.AppendNumFixedWidth(pckg().NumericalValue(), EDecimal, KPassKeylength); + iPasskey.Insert(3,_L(" ")); + + ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() ); + + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::UpdateL +// Notifier update. Stores the received bluetooth +// device name into registry and show it on screen. +// ---------------------------------------------------------- +// +TPtrC8 CBTSSPPasskeyEntryNotifier::UpdateL(const TDesC8& aBuffer) + { + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::UpdateL()")); + + TBTPasskeyDisplayUpdateParamsPckg pckg; + pckg.Copy(aBuffer); + + if(pckg().Type() != TBTNotifierUpdateParams2::EPasskeyDisplay) + { + TPtrC8 ret(KNullDesC8); + return (ret); + } + + switch (pckg().KeypressNotification()) + { + case EPasskeyEntryStarted: + { + iBuf.Zero(); + iBuf.Append(iPasskey); + iBuf.Append(_L(" ")); + break; + } + case EPasskeyDigitEntered: + { + // show an '*' + iBuf.Append(_L("*")); + break; + } + case EPasskeyDigitDeleted: + { + // remove an '*' from the tail of iBuf + iBuf.Delete(iBuf.Length()-1, 1); + break; + } + case EPasskeyCleared: + { + // remove all '*' + iBuf.Zero(); + iBuf.Append(iPasskey); + iBuf.Append(_L(" ")); + break; + } + case EPasskeyEntryCompleted: + { + // complete passkey entry + // Set iAnswer to 1 , + // Continue pairing in Run() + iAnswer = 1; + //iPasskeyDlg->DismissQueryL(); + iNotifUiUtil->DismissDialog(); + break; + } + } + if ( !iNotifUiUtil->IsQueryReleased() ) + { + HBufC* update = GenerateQueryPromoptLC(); + iNotifUiUtil->UpdateQueryDlgL( *update ); + CleanupStack::PopAndDestroy( update ); + } + + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::UpdateL() completed")); + TPtrC8 ret(KNullDesC8); + return (ret); + } + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::HandleGetDeviceCompletedL +// Ask user response and return it to caller. +// Store device into registry if user rejects the incoming pairing. +// ---------------------------------------------------------- +// +void CBTSSPPasskeyEntryNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::HandleGetDeviceCompletedL()")); + iAnswer = 0; + + // Check if blocked device. + if( CheckBlockedDeviceL() ) + return; + + // For pairing request from remote device + if ( !iLocallyInitiated ) + { + TBool keypress = AuthoriseIncomingPairingL(); + if( !keypress ) + { + //User rejects the incoming pairing, complete message in QueryBlockDevice. + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::HandleGetDeviceCompletedL() <<")); + return; + } + } + + TBTDeviceName nameCoverUi( KNullDesC ); + + iBuf.Zero(); + iBuf.Append(iPasskey); + iBuf.Append(_L(" ")); + HBufC* prompt = GenerateQueryPromoptLC(); + + TInt answer = iNotifUiUtil->ShowQueryL( *prompt, R_BT_PASSKEY_QUERY, + ECmdBTnotifUnavailable, nameCoverUi ); + CleanupStack::PopAndDestroy( prompt ); + + if( iAnswer ) // user pressed entry key from remote keyboard. + { + CompleteMessage(KErrNone); + } + else + { + // If the outgoing pairing mode is set, then this is bonding initiated by the user. + TBool incomingConn = ( OutgoPairingMode( iBTAddr ) == EBTOutgoingPairNone ); + if( !iMessage.IsNull() ) + { + // No need to inform the user of the pairing result if the user cancelled it. + // If user doesn't answer anything but stack cancels, pairing result is needed + // to show for outgoing pairing. In this case, don't stop pairng observer. + (void) CBTEngConnMan::StopPairingObserver( iBTAddr ); + } + // We may be asking for pairing (locally initiated), because a remote device is requesting + // accesss to a service for which we require authentication. + if( iLocallyInitiated && incomingConn ) + { + CheckAndHandleQueryIntervalL(); + } + CompleteMessage(KErrCancel); + } + + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::HandleGetDeviceCompletedL() completed")); + } + +// ---------------------------------------------------------- +// CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC +// ---------------------------------------------------------- +// +HBufC* CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC() + { + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC()")); + TBTDeviceName devName; + BtNotifNameUtils::GetDeviceDisplayName(devName, iDevice); + + CPtrCArray* subsPrompt = new (ELeave) CPtrCArray(2); + CleanupStack::PushL( subsPrompt ); + subsPrompt->AppendL( devName ); + subsPrompt->AppendL( iBuf ); + HBufC* prompt = StringLoader::LoadL( R_BT_SSP_PASSKEY_ENTRY , *subsPrompt ); + CleanupStack::PopAndDestroy( subsPrompt ); + CleanupStack::PushL( prompt ); + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC() << ")); + return prompt; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/src/btnumcmpnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,232 @@ +/* +* Copyright (c) 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: Declares Numeric Comparison notifier for Secure Simle Pairing +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Unicode character conversion utilities +#include +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include +#endif +#include // Own resources +#include "btnotif.hrh" // Own resource header +#include "btnumcmpnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include +#include +#include +#include "btnotifnameutils.h" + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTNumCmpNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTNumCmpNotifier* CBTNumCmpNotifier::NewL() + { + CBTNumCmpNotifier* self=new (ELeave) CBTNumCmpNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------- +// CBTNumCmpNotifier::CBTNumCmpNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTNumCmpNotifier::CBTNumCmpNotifier() + { + iPasskeyToShow.Zero(); + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTNumCmpNotifier::~CBTNumCmpNotifier() + { + } + +// ---------------------------------------------------------- +// CBTNumCmpNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTNumCmpNotifier::TNotifierInfo CBTNumCmpNotifier::RegisterL() + { + iInfo.iUid = KBTNumericComparisonNotifierUid; + iInfo.iChannel = KBTNumericComparisonNotifierUid; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTNumCmpNotifier::GetParamsL +// Initialize parameters and check if device is already +// in registry. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTNumCmpNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GetParamsL()")); + + CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage ); + + TBTNumericComparisonParamsPckg pckg; + pckg.Copy(aBuffer); + iBTAddr = pckg().DeviceAddress(); + if ( OtherOutgoPairing( iBTAddr) ) + { + // We won't allow incoming pairing during outgoing pairing: + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier: outgoing pair in progress, reject incoming pair")); + CompleteMessage(KErrCancel); + return; + } + + TUint32 passkey = pckg().NumericalValue(); + iLocallyInitiated = pckg().LocallyInitiated(); + iPasskeyToShow.AppendNumFixedWidth(passkey, EDecimal, Klength); + iPasskeyToShow.Insert(3,_L(" ")); + + // base class + ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() ); + + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTNumCmpNotifier::HandleGetDeviceCompletedL +// Ask user response and return it to caller. +// Store device into registry if user has accepted pairing. +// ---------------------------------------------------------- +// +void CBTNumCmpNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::HandleGetDeviceCompletedL()")); + + // Check if blocked device. + if( CheckBlockedDeviceL() ) + return; + + // Turn lights on and deactivate apps -key + iNotifUiUtil->TurnLightsOn(); + + // For incoming pairing request + if(!iLocallyInitiated) + { + TBool keypress = AuthoriseIncomingPairingL(); + if( !keypress ) + { + //User rejects the incoming pairing, complete message in QueryBlockDevice. + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::HandleGetDeviceCompletedL() <<")); + return; + } + } + + // For outgoing pairing request or accepted incoming pairing request, + // ask user to compare the pincodes in two devices. + TBTDeviceName nameCoverUi( KNullDesC ); + HBufC* prompt = GenerateQueryPromoptLC(); + TInt answer = iNotifUiUtil->ShowQueryL( *prompt, R_BT_GENERIC_QUERY, ECmdShowBtOpenCoverNote, nameCoverUi ); + CleanupStack::PopAndDestroy( prompt ); + + if( answer ) + { + CompleteMessage(answer, KErrNone); + } + else + { + // If the outgoing pairing mode is set, then this is bonding initiated by the user. + TBool incomingConn = ( OutgoPairingMode( iBTAddr ) == EBTOutgoingPairNone ); + + if( !iMessage.IsNull() ) + { + // No need to inform the user of the pairing result if the user cancelled it. + // If user doesn't answer anything but stack cancels, pairing result is needed + // to show for outgoing pairing. In this case, don't stop pairng observer. + CBTEngConnMan::StopPairingObserver( iBTAddr ); + } + // We may be asking for pairing (locally initiated), because a remote device is requesting + // accesss to a service for which we require authentication. + if( iLocallyInitiated && incomingConn ) + { + CheckAndHandleQueryIntervalL(); + } + CompleteMessage(KErrCancel); + } + + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::HandleGetDeviceCompletedL() completed")); + } + +// ---------------------------------------------------------- +// CBTNumCmpNotifier::GenerateQueryPromoptLC +// Generate prompt for Numeric Comparison query and return. +// ---------------------------------------------------------- +// +HBufC* CBTNumCmpNotifier::GenerateQueryPromoptLC() + { + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromoptLC()")); + TBTDeviceName devName; + BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); + + CPtrCArray* subs = new (ELeave) CPtrCArray(2); + CleanupStack::PushL( subs ); + TBuf shortName; + + // Cut the name and put ellipsis in the middle if necessary + // By example "SampleSymbianDevice" after this operation will be shown in + // the dialog as "Sam...ice"(for 7 chars device name limit) + // This need to be done, because if name of the device is too long, the PIN + // codes aren't visible and user can't compare it with PIN code taken from + // other phone + if ( devName.Length() > KBTDeviceShortNameLength ) + { + shortName.Copy( devName.Left( KBTDeviceShortNameLength/2 ) ); + //adding ellipsis ("...") char in the middle of the string + shortName.Append( TChar( KEllipsis) ); + //adding only end of the name to the final string + shortName.Append( devName.Right( shortName.MaxLength() - + shortName.Length() ) ); + subs->AppendL( shortName ); + } + else + { + subs->AppendL( devName ); + } + subs->AppendL( iPasskeyToShow ); + HBufC* prompt = StringLoader::LoadL( R_BT_SSP_PASSKEY_COMPARISON_PROMPT, *subs ); + CleanupStack::PopAndDestroy( subs ); + CleanupStack::PushL( prompt ); + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromoptLC() <<")); + return prompt; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/Bmarm/BtNotifApiTestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/Bmarm/BtNotifApiTestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/Bwins/BtNotifApiTestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/Bwins/BtNotifApiTestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/EABI/BtNotifApiTestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/EABI/BtNotifApiTestU.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/conf/ui_BtNotifApiTest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/conf/ui_BtNotifApiTest.cfg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,834 @@ +// BT notif tests - 74 tc + + +// Paired device setting notifier tests + + + +// PBAP authorization query notifier tests (2) + +[Test] +title BT Correct Passkey Entered (PBAP Auth Query Notifier Test) +create BtNotifApiTest tester +tester PbapAuthNotifierTest +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +tester FinishPbapAuthQuery PASSKEY +delete tester +[Endtest] + +[Test] +title BT PBAP Auth Query Cancelled (PBAP Auth Query Notifier Test) +create BtNotifApiTest tester +tester PbapAuthNotifierTest +pause 1000 +presskey global EKeyDevice1 +tester FinishPbapAuthQuery CANCEL +delete tester +[Endtest] + +// Passkey display notifier tests (4) + +[Test] +title BT Remote Connection/Pairing Discarded/Device Blocked (Passkey Display Notifier Test) +create BtNotifApiTest tester +tester PasskeyDisplayNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice0 +tester FinishPasskeyDisplayQuery BLOCK +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Discarded/Device Not Blocked (Passkey Display Notifier Test) +create BtNotifApiTest tester +tester PasskeyDisplayNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice1 +tester FinishPasskeyDisplayQuery NONBLOCK +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed (Passkey Display Notifier Test) +create BtNotifApiTest tester +tester PasskeyDisplayNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice1 +tester FinishPasskeyDisplayQuery +delete tester +[Endtest] + +[Test] +title BT Local Connection/Pairing Allowed (Passkey Display Notifier Test) +create BtNotifApiTest tester +tester PasskeyDisplayNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice1 +tester FinishPasskeyDisplayQuery +delete tester +[Endtest] + +// Numeric comparison query notifier tests (6) + +[Test] +title BT Remote Connection/Pairing Discarded/Device Blocked (Numeric Comparison Query Notifier Test) +create BtNotifApiTest tester +tester NumericComparisonQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice0 +tester FinishNumericComparisonQuery CANCEL BLOCK +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Discarded/Device Not Blocked (Numeric Comparison Query Notifier Test) +create BtNotifApiTest tester +tester NumericComparisonQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice1 +tester FinishNumericComparisonQuery CANCEL NONBLOCK +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed/Code Mismatch (Numeric Comparison Query Notifier Test) +create BtNotifApiTest tester +tester NumericComparisonQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice1 +tester FinishNumericComparisonQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed/Code Match (Numeric Comparison Query Notifier Test) +create BtNotifApiTest tester +tester NumericComparisonQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice0 +tester FinishNumericComparisonQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Local Connection/Code Mismatch (Numeric Comparison Query Notifier Test) +create BtNotifApiTest tester +tester NumericComparisonQueryNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice1 +tester FinishNumericComparisonQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Local Connection/Code Match (Numeric Comparison Query Notifier Test) +create BtNotifApiTest tester +tester NumericComparisonQueryNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice0 +tester FinishNumericComparisonQuery ACCEPT +delete tester +[Endtest] + +// Authorization query notifier tests (3) + +[Test] +title BT Authorization Query Discarded - Accept Blocking (Authorization Query Notifier Test) +create BtNotifApiTest tester +tester AuthQueryNotifierTest +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice0 +tester FinishAuthQuery DISCARD BLOCK +delete tester +[Endtest] + +[Test] +title BT Authorization Query Discarded - Discard Blocking (Authorization Query Notifier Test) +create BtNotifApiTest tester +tester AuthQueryNotifierTest +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice1 +tester FinishAuthQuery DISCARD NONBLOCK +delete tester +[Endtest] + +[Test] +title BT Authorization Query Accepted (Authorization Query Notifier Test) +create BtNotifApiTest tester +tester AuthQueryNotifierTest +pause 1000 +presskey global EKeyDevice0 +tester FinishAuthQuery ACCEPT +delete tester +[Endtest] + +// PIN query notifier tests (10) + +[Test] +title BT Remote Connection/Pairing Discarded/Device Blocked (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice0 +tester FinishPinPasskeyQuery CANCEL DISCARDCONN BLOCK +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Discarded/Device Not Blocked (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice1 +pause 1000 +presskey global EKeyDevice1 +tester FinishPinPasskeyQuery CANCEL DISCARDCONN NONBLOCK +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed/Correct Pin Entered (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +tester FinishPinPasskeyQuery PASSKEY +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed/Too Short Pin Entered (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +tester FinishPinPasskeyQuery PASSKEY +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed/Pin Query Cancelled (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice1 +tester FinishPinPasskeyQuery CANCEL ACCEPTCONN +delete tester +[Endtest] + +[Test] +title BT Remote Connection/Pairing Allowed/Too Short Pin Entered/Pin Query Cancelled (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest REMOTE +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice1 +tester FinishPinPasskeyQuery CANCEL ACCEPTCONN +delete tester +[Endtest] + +[Test] +title BT Local Connection/Correct Pin Entered (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +tester FinishPinPasskeyQuery PASSKEY +delete tester +[Endtest] + +[Test] +title BT Local Connection/Too Short Pin Entered (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +tester FinishPinPasskeyQuery PASSKEY +delete tester +[Endtest] + +[Test] +title BT Local Connection/Pin Query Cancelled (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice1 +tester FinishPinPasskeyQuery CANCEL +delete tester +[Endtest] + +[Test] +title BT Local Connection/Too Short Pin Entered/Pin Query Cancelled (Pin Query Notifier Test) +create BtNotifApiTest tester +tester PinPasskeyQueryNotifierTest LOCAL +pause 1000 +presskey global EKeyDevice0 +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyDevice1 +tester FinishPinPasskeyQuery CANCEL +delete tester +[Endtest] + +// Inquiry notifier tests (8) + +[Test] +title BT Not Switched On (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest BTOFF +presskey global EKeyDevice1 +tester FinishInquiry CANCEL +delete tester +[Endtest] + +[Test] +title BT Launch Inquiry/Test Device Paired/Cancel Search (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest PAIRED +presskey global EKeyEnter +pause 1000 +presskey global EKeyUpArrow +pause 1000 +presskey global EKeyEnter +presskey global EKeyDevice1 +tester FinishInquiry CANCEL +delete tester +[Endtest] + +[Test] +title BT Launch Inquiry/Test Device Paired/Switch BT Off (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest PAIRED +presskey global EKeyEnter +pause 1000 +presskey global EKeyUpArrow +pause 1000 +presskey global EKeyEnter +tester FinishInquiry CANCEL BTOFF +delete tester +[Endtest] + +[Test] +title BT Select Paired Test Device (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest PAIRED +presskey global EKeyDownArrow +pause 1000 +presskey global EKeyEnter +tester FinishInquiry ACCEPT +delete tester +[Endtest] + +[Test] +title BT Launch Inquiry/Test Device Paired/Inquiry Timeout (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest PAIRED +presskey global EKeyEnter +pause 1000 +presskey global EKeyEnter +pause 60000 +tester TurnLightsOn +pause 10000 +presskey global EKeyDevice1 +tester FinishInquiry CANCEL +tester TurnLightsOn +delete tester +[Endtest] + +[Test] +title BT Launch Inquiry/Cancel Search (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest NONPAIRED +presskey global EKeyUpArrow +pause 1000 +presskey global EKeyEnter +presskey global EKeyDevice1 +tester FinishInquiry CANCEL +delete tester +[Endtest] + +[Test] +title BT Launch Inquiry/Switch BT Off (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest NONPAIRED +presskey global EKeyUpArrow +pause 1000 +presskey global EKeyEnter +tester FinishInquiry CANCEL BTOFF +delete tester +[Endtest] + +[Test] +title BT Launch Inquiry/Inquiry Timeout (Inquiry Notifier Test) +create BtNotifApiTest tester +tester InquiryNotifierTest NONPAIRED +presskey global EKeyEnter +pause 60000 +tester TurnLightsOn +pause 10000 +presskey global EKeyDevice1 +tester FinishInquiry CANCEL +tester TurnLightsOn +delete tester +[Endtest] + +// OBEX PIN query notifier tests (2) + +[Test] +title BT Correct Passkey (OBEX PIN Query Notifier Test) +create BtNotifApiTest tester +tester ObexPasskeyQueryNotifierTest +pause 1000 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global 0 +presskey global EKeyDevice0 +tester FinishObexPasskeyQuery PASSKEY +delete tester +[Endtest] + +[Test] +title BT Query Canceled (OBEX PIN Query Notifier Test) +create BtNotifApiTest tester +tester ObexPasskeyQueryNotifierTest +pause 1000 +presskey global EKeyDevice1 +tester FinishObexPasskeyQuery CANCEL +delete tester +[Endtest] + +// Power mode notifier tests (2) + +[Test] +title BT Power Mode Query Discarded (Power Mode Notifier Test) +create BtNotifApiTest tester +tester PowerModeQueryNotifierTest +pause 1000 +presskey global EKeyDevice1 +tester FinishPowerModeQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Power Mode Query Accepted (Power Mode Notifier Test) +create BtNotifApiTest tester +tester PowerModeQueryNotifierTest +pause 1000 +presskey global EKeyDevice0 +tester FinishPowerModeQuery ACCEPT +delete tester +[Endtest] + +// Generic info notifier tests (17) + +[Test] +title BT Connected (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTConnected +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Disconnected (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTDisconnected +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Audio Accessory (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTAudioAccessory +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Audio Handset (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTAudioHandset +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Closed (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTClosed +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Device Not Available (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTDeviceNotAvailable +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Offline Disabled (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTOfflineDisabled +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Visibility Timeout (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTVisibilityTimeout +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Enter SAP (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTEnterSap +delete tester +pause 6000 +[Endtest] + +[Test] +title BT SAP Ok (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTSapOk +delete tester +pause 6000 +[Endtest] + +[Test] +title BT SAP Failed (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTSapFailed +delete tester +pause 6000 +[Endtest] + +[Test] +title BT SAP No SIM (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTSapNoSim +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Device Busy (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTDeviceBusy +delete tester +pause 6000 +[Endtest] + +[Test] +title IR Not Supported (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EIRNotSupported +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Cmd Show BT Battery Low (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest ECmdShowBtBatteryLow +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Cmd Show BT Battery Critical (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest ECmdShowBtBatteryCritical +delete tester +pause 6000 +[Endtest] + +[Test] +title BT Stay Power On (Generic Info Notifier Test) +create BtNotifApiTest tester +tester GenericInfoNotifierTest EBTStayPowerOn +delete tester +pause 6000 +[Endtest] + +// Generic query notifier tests (20) + +[Test] +title BT Receive Message Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTReceiveMessageQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Receive Message Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTReceiveMessageQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Receive Message Paired Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTReceiveMessagePairedQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Receive Message Paired Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTReceiveMessagePairedQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Is Off Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTIsOffQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Is Off Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTIsOffQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Activate Offline Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTActivateOffLineQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Activate Offline Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTActivateOffLineQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT No Devices Found Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTNoDevicesFoundQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT No Devices Found Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTNoDevicesFoundQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Accept Request Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTAcceptRequestQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Accept Request Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTAcceptRequestQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Block Connection Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTBlockConnectionQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Block Connection Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTBlockConnectionQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Block Paired Connection Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTBlockPairedConnectionQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Block Paired Connection Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTBlockPairedConnectionQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Is Not Shown Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTIsNotShownQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Is Not Shown Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTIsNotShownQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] + +[Test] +title BT Is Off Java Discarded (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTIsOffJavaQuery +pause 1000 +presskey global EKeyDevice1 +tester FinishGenericQuery DISCARD +delete tester +[Endtest] + +[Test] +title BT Is Off Java Accepted (Generic Query Notifier Test) +create BtNotifApiTest tester +tester GenericQueryNotifierTest EBTIsOffJavaQuery +pause 1000 +presskey global EKeyDevice0 +tester FinishGenericQuery ACCEPT +delete tester +[Endtest] \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/BtNotifApiTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/BtNotifApiTest.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 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: +* +*/ + + +#if defined(__S60_) + // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET BtNotifApiTest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB + +DEFFILE BtNotifApiTest.def + +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +SOURCEPATH ../src +SOURCE BtNotifApiTest.cpp +SOURCE BtNotifApiTestBlocks.cpp BtSettingsObserver.cpp BtEngDevManObserver.cpp + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY btengsettings.lib +LIBRARY bluetooth.lib +LIBRARY btextnotifiers.lib +LIBRARY btmanclient.lib +LIBRARY btdevice.lib +LIBRARY BTEngDevMan.lib + + +LANG SC + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/BtNotifApiTest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/BtNotifApiTest.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +; +; Copyright (c) 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: +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x1028315F], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\udeb\BtNotifApiTest.dll"-"c:\Sys\Bin\BtNotifApiTest.dll" +"..\init\BtNotifApiTest.ini"-"e:\testing\init\BtNotifApiTest.ini" +"..\conf\ui_BtNotifApiTest.cfg"-"e:\testing\conf\ui_BtNotifApiTest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/BtNotifApiTest_phone.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/BtNotifApiTest_phone.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +; +; Copyright (c) 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: +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x1028315F], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"\epoc32\release\armv5\urel\BtNotifApiTest.dll"-"c:\Sys\Bin\BtNotifApiTest.dll" +"..\init\BtNotifApiTest_phone.ini"-"c:\testframework\testframework.ini" +"..\conf\ui_BtNotifApiTest.cfg"-"c:\testframework\ui_BtNotifApiTest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTEXPORTS + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +BtNotifApiTest.mmp + +PRJ_MMPFILES + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/build_sis.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/build_sis.bat Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +call abld test build armv5 +call makesis BtNotifApiTest.pkg +call signsis BtNotifApiTest.sis BtNotifApiTest.sisx rd.cer rd-key.pem diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/build_sis_phone.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/group/build_sis_phone.bat Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +call abld test build armv5 +call makesis BtNotifApiTest_phone.pkg +call signsis BtNotifApiTest_phone.sis BtNotifApiTest_phone.sisx rd.cer rd-key.pem diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/inc/BtEngDevManObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/inc/BtEngDevManObserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTENGDEVMANOBSERVER_H_ +#define BTENGDEVMANOBSERVER_H_ + +#include "BTEngDevMan.h" + +NONSHARABLE_CLASS( CBtEngDevManObserver ) : public MBTEngDevManObserver +{ +public: + static CBtEngDevManObserver* NewL(); + static CBtEngDevManObserver* NewLC(); + + TInt GetDevices( const TBTRegistrySearch& aCriteria, + CBTDeviceArray* aResultArray ); + TInt AddDevice( const CBTDevice& aDevice ); + TInt DeleteDevices( const TBTRegistrySearch& aCriteria ); + + virtual ~CBtEngDevManObserver(); + void HandleDevManComplete( TInt aErr ); + void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray ); + +private: + CBtEngDevManObserver(); + void ConstructL(); + +private: + CActiveSchedulerWait* iWait; + CBTEngDevMan* iDevMan; + +}; + +#endif /*BTENGDEVMANOBSERVER_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/inc/BtNotifApiTest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/inc/BtNotifApiTest.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,260 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + + +#ifndef BTNOTIFAPITEST_H +#define BTNOTIFAPITEST_H + +// INCLUDES +#include +#include +#include +#include +#include + +#include "btnotif.h" +#include "btmanclient.h" +#include "btnotifierapi.h" +#include "btextnotifiers.h" +#include "coreapplicationuisdomainpskeys.h" + +#include "BtEngDevManObserver.h" +#include "BtSettingsObserver.h" + + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +//_LIT( KBtNotifApiTestLogPath, "\\logs\\testframework\\bt\\" ); +_LIT( KBtNotifApiTestLogPath, "e:\\testing\\stiflogs\\" ); +// Log file +_LIT( KBtNotifApiTestLogFile, "BtNotifApiTest.txt" ); +_LIT( KBtNotifApiTestLogFileWithTitle, "BtNotifApiTest_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CBtNotifApiTest; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +enum TTestOption + { + EQueryDiscarded = 0, + EQueryAccepted, + ECheckPasskey, + EQueryCanceled + }; + +// CLASS DECLARATION + +/** +* CBtNotifApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CBtNotifApiTest) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBtNotifApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CBtNotifApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CBtNotifApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Example test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt PairedDeviceSettingNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishPairedDeviceSettingQuery( CStifItemParser& aItem ); + + virtual TInt PbapAuthNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishPbapAuthQuery( CStifItemParser& aItem ); + + virtual TInt PasskeyDisplayNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishPasskeyDisplayQuery( CStifItemParser& aItem ); + + virtual TInt NumericComparisonQueryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishNumericComparisonQuery( CStifItemParser& aItem ); + + virtual TInt AuthQueryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishAuthQuery( CStifItemParser& aItem ); + + virtual TInt PinPasskeyQueryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishPinPasskeyQuery( CStifItemParser& aItem ); + + virtual TInt InquiryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishInquiry( CStifItemParser& aItem ); + + virtual TInt ObexPasskeyQueryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishObexPasskeyQuery( CStifItemParser& aItem ); + + virtual TInt PowerModeQueryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishPowerModeQuery( CStifItemParser& aItem ); + + virtual TInt GenericInfoNotifierTest( CStifItemParser& aItem ); + + virtual TInt GenericQueryNotifierTest( CStifItemParser& aItem ); + virtual TInt FinishGenericQuery( CStifItemParser& aItem ); + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + TInt GetGenericInfoNoteType( TPtrC aTypeString, TBTGenericInfoNoteType& aGenericInfoNoteType ); + TInt GetGenericQueryNoteType( TPtrC aTypeString, TBTGenericQueryNoteType& aGenericQueryNoteType ); + + TInt GetTestOption( TPtrC optionString, TTestOption& aOption ); + TInt TurnLightsOn( CStifItemParser& aItem ); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + RNotifier* iNotifier; + + TPbapAuthNotifierResponsePckg iPbapAuthNotifierResponsePckg; + TBTDeviceResponseParamsPckg iBtDeviceResponseParamsPckg; + TPckgBuf iNumericComparisonQueryReply; + TBTPinCode iEnteredPinPasskey; + TBTPinCode iPinPasskey; + TObexPasskeyBuf iObexPasskeyBuf; + TObexPasskeyBuf iEnteredPasskeyBuf; + TPckgBuf iAuthQueryReply; + TPckgBuf iPowerModeQueryReply; + TPckgBuf iGenericQueryReply; + + + TRequestStatus iReqStatus; + TBuf iLocalDeviceName; + + CBtSettingsObserver* iBtSettings; + CBtEngDevManObserver* iBtEngDevManObserver; + CBTDeviceArray* iBtDeviceArray; + CBTDevice* iTestDevice; + + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#endif // BTNOTIFAPITEST_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/inc/BtSettingsObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/inc/BtSettingsObserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef BTSETTINGSOBSERVER_H_ +#define BTSETTINGSOBSERVER_H_ + +#include +#include +#include + +NONSHARABLE_CLASS( CBtSettingsObserver ) : public CBase, + public MBTEngSettingsObserver + { +public: + /** + * Destructor. + */ + ~CBtSettingsObserver(); + + /** + * Two-phased constructor. + */ + static CBtSettingsObserver* NewL(); + + /** + * Two-phased constructor. + */ + static CBtSettingsObserver* NewLC(); + + TInt GetPowerState( TBTPowerStateValue& aState ); + TInt SetPowerState( TBTPowerStateValue aState ); + TInt GetVisibilityMode( TBTVisibilityMode& aMode ); + TInt SetVisibilityMode( TBTVisibilityMode aMode, TInt aTime = 0 ); + TInt GetLocalName( TDes& aName ); + TInt SetLocalName( const TDes& aName ); + +private: + + // From MBTEngSettingsObserver + void PowerStateChanged( TBTPowerStateValue aState ); + void VisibilityModeChanged( TBTVisibilityMode aState ); + + + CBtSettingsObserver(); + void ConstructL(); + + +private: //Data + + CBTEngSettings* iSettings; // Own. + CActiveSchedulerWait* iWaiter; //Own. + TInt iError; + }; + +#endif /*BTSETTINGSOBSERVER_H_*/ diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/init/BtNotifApiTest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/init/BtNotifApiTest.ini Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,218 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= e:\testing\logs\ +TestReportFileName= BtNotifApiTest + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= e:\testing\conf\ui_BtNotifApiTest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/init/BtNotifApiTest_phone.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/init/BtNotifApiTest_phone.ini Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,218 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= c:\logs\testframework\ +TestReportFileName= BtNotifApiTest + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\ui_BtNotifApiTest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtEngDevManObserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtEngDevManObserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 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 "BtEngDevManObserver.h" + +CBtEngDevManObserver::CBtEngDevManObserver() + { + + } + +CBtEngDevManObserver::~CBtEngDevManObserver() + { + if( iWait->IsStarted() ) + { + iWait->AsyncStop(); + } + delete iWait; + iWait = NULL; + delete iDevMan; + iDevMan = NULL; + } + +CBtEngDevManObserver* CBtEngDevManObserver::NewLC() + { + CBtEngDevManObserver* self = new ( ELeave ) CBtEngDevManObserver(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CBtEngDevManObserver* CBtEngDevManObserver::NewL() + { + CBtEngDevManObserver* self = CBtEngDevManObserver::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +void CBtEngDevManObserver::ConstructL() + { + iWait = new ( ELeave ) CActiveSchedulerWait(); + iDevMan = CBTEngDevMan::NewL( this ); + } + +TInt CBtEngDevManObserver::GetDevices( const TBTRegistrySearch& aCriteria, + CBTDeviceArray* aResultArray ) + { + TInt res; + res = iDevMan -> GetDevices( aCriteria, aResultArray ); + if ( res != KErrNone ) + { + return res; + } + + iWait -> Start(); + + return KErrNone; + } + +TInt CBtEngDevManObserver::AddDevice( const CBTDevice& aDevice ) + { + TInt res; + res = iDevMan -> AddDevice( aDevice ); + if ( res != KErrNone ) + { + return res; + } + + iWait -> Start(); + + return KErrNone; + } + +TInt CBtEngDevManObserver::DeleteDevices( const TBTRegistrySearch& aCriteria ) + { + TInt res; + res = iDevMan -> DeleteDevices( aCriteria ); + if ( res != KErrNone ) + { + return res; + } + + iWait -> Start(); + + return KErrNone; + } + +void CBtEngDevManObserver::HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray ) + { + iWait -> AsyncStop(); + } + +void CBtEngDevManObserver::HandleDevManComplete( TInt aErr ) + { + iWait -> AsyncStop(); + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtNotifApiTest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtNotifApiTest.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,209 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + + +// INCLUDE FILES +#include +#include "BtNotifApiTest.h" +#include + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::CBtNotifApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBtNotifApiTest::CBtNotifApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CBtNotifApiTest::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KBtNotifApiTestLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KBtNotifApiTestLogFile); + } + + iLog = CStifLogger::NewL( KBtNotifApiTestLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + + iNotifier = new ( ELeave ) RNotifier(); + iBtSettings = CBtSettingsObserver::NewL(); + iBtEngDevManObserver = CBtEngDevManObserver::NewL(); + iBtDeviceArray = new ( ELeave ) CBTDeviceArray( 1 ); + + iTestDevice = CBTDevice::NewL(); + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBtNotifApiTest* CBtNotifApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CBtNotifApiTest* self = new (ELeave) CBtNotifApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CBtNotifApiTest::~CBtNotifApiTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +//----------------------------------------------------------------------------- +// CBtNotifApiTest::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CBtNotifApiTest::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("BtNotifApiTest.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CBtNotifApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtNotifApiTestBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtNotifApiTestBlocks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1632 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include "BtNotifApiTest.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CBtNotifApiTest::Delete() + { + delete iNotifier; + iNotifier = NULL; + delete iBtSettings; + iBtSettings = NULL; + delete iBtEngDevManObserver; + iBtEngDevManObserver = NULL; + delete iBtDeviceArray; + iBtDeviceArray = NULL; + delete iTestDevice; + iTestDevice = NULL; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CBtNotifApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + + ENTRY( "PairedDeviceSettingNotifierTest", CBtNotifApiTest::PairedDeviceSettingNotifierTest ), + ENTRY( "FinishPairedDeviceSettingQuery", CBtNotifApiTest::FinishPairedDeviceSettingQuery ), + + ENTRY( "PbapAuthNotifierTest", CBtNotifApiTest::PbapAuthNotifierTest ), + ENTRY( "FinishPbapAuthQuery", CBtNotifApiTest::FinishPbapAuthQuery ), + + ENTRY( "PasskeyDisplayNotifierTest", CBtNotifApiTest::PasskeyDisplayNotifierTest ), + ENTRY( "FinishPasskeyDisplayQuery", CBtNotifApiTest::FinishPasskeyDisplayQuery ), + + ENTRY( "NumericComparisonQueryNotifierTest", CBtNotifApiTest::NumericComparisonQueryNotifierTest ), + ENTRY( "FinishNumericComparisonQuery", CBtNotifApiTest::FinishNumericComparisonQuery ), + + ENTRY( "AuthQueryNotifierTest", CBtNotifApiTest::AuthQueryNotifierTest ), + ENTRY( "FinishAuthQuery", CBtNotifApiTest::FinishAuthQuery ), + + ENTRY( "PinPasskeyQueryNotifierTest", CBtNotifApiTest::PinPasskeyQueryNotifierTest ), + ENTRY( "FinishPinPasskeyQuery", CBtNotifApiTest::FinishPinPasskeyQuery ), + + ENTRY( "InquiryNotifierTest", CBtNotifApiTest::InquiryNotifierTest ), + ENTRY( "FinishInquiry", CBtNotifApiTest::FinishInquiry ), + + ENTRY( "ObexPasskeyQueryNotifierTest", CBtNotifApiTest::ObexPasskeyQueryNotifierTest ), + ENTRY( "FinishObexPasskeyQuery", CBtNotifApiTest::FinishObexPasskeyQuery ), + + ENTRY( "PowerModeQueryNotifierTest", CBtNotifApiTest::PowerModeQueryNotifierTest ), + ENTRY( "FinishPowerModeQuery", CBtNotifApiTest::FinishPowerModeQuery ), + + ENTRY( "GenericInfoNotifierTest", CBtNotifApiTest::GenericInfoNotifierTest ), + + ENTRY( "GenericQueryNotifierTest", CBtNotifApiTest::GenericQueryNotifierTest ), + ENTRY( "FinishGenericQuery", CBtNotifApiTest::FinishGenericQuery ), + + ENTRY( "TurnLightsOn", CBtNotifApiTest::TurnLightsOn ), + + //ADD NEW ENTRY HERE + // [test cases entries] - Do not remove + + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::PairedDeviceSettingNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::PairedDeviceSettingNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TBTRegistrySearch regSearch; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + regSearch.FindAll(); + res = iBtEngDevManObserver -> GetDevices( regSearch, iBtDeviceArray ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Getting devices from register failed with value: %d"), res ); + return res; + } + + if ( iBtDeviceArray -> Count() > 0 ) + { + iBtDeviceArray -> Reset(); + res = iBtEngDevManObserver -> DeleteDevices( regSearch ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Deleting devices from register failed with value: %d"), res ); + return res; + } + } + + TBTDevAddr addr( 0x12345678 ); + CBTDevice *testDevice = CBTDevice::NewL( addr ); + CleanupStack::PushL( testDevice ); + testDevice -> SetPaired( ELinkKeyAuthenticated ); + TTime time; + time.UniversalTime(); + testDevice -> SetUsed( time ); + testDevice -> SetDeviceNameL( _L8( "TestedDevice" ) ); + CleanupStack::Pop( testDevice ); + + res = iBtEngDevManObserver -> AddDevice( *testDevice ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Adding device to register failed with value: %d"), res ); + delete testDevice; + return res; + } + + TInt paramStatus = KErrNone; + TBTPairedDeviceSettingParams notifierParams; + notifierParams.iPairingStatus = paramStatus; + notifierParams.iRemoteAddr = testDevice -> BDAddr(); + TBTPairedDeviceSettingParamsPckg notifierParamsPckg( notifierParams ); + + TPckgBuf notifierResponsePckg; + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTPairedDeviceSettingNotifierUid, notifierParamsPckg, notifierResponsePckg ); + iLog -> Log( _L("Notifier started") ); + + User::WaitForRequest( iReqStatus ); + + iLog -> Log( _L("Request status value: %d"), iReqStatus.Int() ); + iLog -> Log( _L("Input status value: %d"), notifierParams.iPairingStatus ); + iLog -> Log( _L("Pairing status value: %d"), notifierResponsePckg() ); + + delete testDevice; + iNotifier -> Close(); + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishPairedDeviceSettingQuery( CStifItemParser& aItem ) + { + iLog -> Log( _L("Test case passed") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::PbapAuthNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::PbapAuthNotifierTest( CStifItemParser& aItem ) + { + TInt res; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + TPbapAuthNotifierParams notifierParams = TPbapAuthNotifierParams(); + TPbapAuthNotifierParamsPckg notifierParamsPckg( notifierParams ); + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KPbapAuthNotifierUid, notifierParamsPckg, iPbapAuthNotifierResponsePckg ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishPbapAuthQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TTestOption option; + TPbapAuthNotifierResponse expectedData; + + if ( !expectedData.SetPassword( _L( "0000" ) ) ) + { + iLog -> Log( _L("SetPassword failed") ); + iNotifier -> Close(); + return KErrGeneral; + } + + res = aItem.GetString( _L( "FinishPbapAuthQuery" ), optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel ) + { + iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() ); + iNotifier -> Close(); + return iReqStatus.Int(); + } + iLog -> Log( _L("Notifier responded") ); + + switch ( option ) + { + case ECheckPasskey: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Equal passkeys expected") ); + STIF_ASSERT_EQUALS( expectedData.Password(), iPbapAuthNotifierResponsePckg().Password() ); + break; + case EQueryCanceled: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::PasskeyDisplayNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::PasskeyDisplayNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TBTRegistrySearch regSearch; + TPtrC initOptionName( KNullDesC ); + TUint32 numericalValue = 999; + TBTPasskeyDisplayParams notifierParams; + TBTPasskeyDisplayParamsPckg emptyReplyPckg; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + regSearch.FindAll(); + res = iBtEngDevManObserver -> GetDevices( regSearch, iBtDeviceArray ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Getting devices from register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( iBtDeviceArray -> Count() > 0 ) + { + iBtDeviceArray -> Reset(); + res = iBtEngDevManObserver -> DeleteDevices( regSearch ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Deleting devices from register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + + iTestDevice -> SetDeviceAddress( 0x12345678 ); + iTestDevice -> SetDeviceNameL( _L8( "Tested_Device" ) ); + iTestDevice -> SetFriendlyNameL( _L( "TestedDevice" ) ); + + res = iBtEngDevManObserver -> AddDevice( *iTestDevice ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Adding device to register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = aItem.GetString( _L( "PasskeyDisplayNotifierTest" ), initOptionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( !initOptionName.Compare( _L( "LOCAL" ) ) ) + { + iLog -> Log( _L("Locally initiated connection") ); + notifierParams = TBTPasskeyDisplayParams( iTestDevice -> BDAddr(), iTestDevice -> FriendlyName(), numericalValue, ETrue ); + } + else if ( !initOptionName.Compare( _L( "REMOTE" ) ) ) + { + iLog -> Log( _L("Remote side initiated connection") ); + notifierParams = TBTPasskeyDisplayParams( iTestDevice -> BDAddr(), iTestDevice -> FriendlyName(), numericalValue, EFalse ); + } + else + { + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + TBTPasskeyDisplayParamsPckg notifierParamsPckg( notifierParams ); + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTPasskeyDisplayNotifierUid, notifierParamsPckg, emptyReplyPckg ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + +TInt CBtNotifApiTest::FinishPasskeyDisplayQuery( CStifItemParser& aItem ) + { + TInt res; + TBTRegistrySearch regSearch; + TPtrC deviceBlockOptionName( KNullDesC ); + + res = aItem.GetString( _L( "FinishPasskeyDisplayQuery" ), deviceBlockOptionName ); + + User::WaitForRequest( iReqStatus ); + + if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) ) + { + iLog -> Log( _L("Block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied ); + STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() ); + } + else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) ) + { + iLog -> Log( _L("Don't block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + } + else + { + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + } + + iBtDeviceArray -> Reset(); + res = iBtEngDevManObserver -> DeleteDevices( regSearch ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Deleting devices from register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::NumericComparisonQueryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::NumericComparisonQueryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TPtrC initOptionName( KNullDesC ); + TUint32 numericalValue = 999999; + TBTNumericComparisonParams notifierParams; + + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + res = aItem.GetString( _L( "NumericComparisonQueryNotifierTest" ), initOptionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( !initOptionName.Compare( _L( "LOCAL" ) ) ) + { + iLog -> Log( _L("Locally initiated connection") ); + notifierParams = TBTNumericComparisonParams( TBTDevAddr(), _L( "Test Device" ), numericalValue, TBTNumericComparisonParams::ERemoteCannotConfirm, ETrue ); + } + else if ( !initOptionName.Compare( _L( "REMOTE" ) ) ) + { + iLog -> Log( _L("Remote side initiated connection") ); + notifierParams = TBTNumericComparisonParams( TBTDevAddr(), _L( "Test Device" ), numericalValue, TBTNumericComparisonParams::ERemoteCannotConfirm, EFalse ); + } + else + { + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + TBTNumericComparisonParamsPckg notifierParamsPckg( notifierParams ); + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTNumericComparisonNotifierUid, notifierParamsPckg, iNumericComparisonQueryReply ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishNumericComparisonQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TPtrC deviceBlockOptionName( KNullDesC ); + TTestOption option; + + res = aItem.GetString( _L( "FinishNumericComparisonQuery" ), optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel && iReqStatus.Int()!= KErrAccessDenied ) + { + iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() ); + iNotifier -> Close(); + return iReqStatus.Int(); + } + iLog -> Log( _L("Notifier responded") ); + + switch ( option ) + { + case EQueryDiscarded: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %d, expected: %b"), iNumericComparisonQueryReply(), EFalse ); + STIF_ASSERT_FALSE( iNumericComparisonQueryReply() ); + break; + case EQueryAccepted: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %d, expected: %b"), iNumericComparisonQueryReply(), ETrue ); + STIF_ASSERT_TRUE( iNumericComparisonQueryReply() ); + break; + case EQueryCanceled: + res = aItem.GetNextString( deviceBlockOptionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) ) + { + iLog -> Log( _L("Block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied ); + STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() ); + } + else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) ) + { + iLog -> Log( _L("Don't block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + } + else + { + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::AuthQueryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::AuthQueryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + TBTAuthorisationParams notifierParams; + notifierParams.iName = _L( "Test Device" ); + TBTAuthorisationParamsPckg notifierParamsPckg( notifierParams ); + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTManAuthNotifierUid, notifierParamsPckg, iAuthQueryReply ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishAuthQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TPtrC deviceBlockOptionName( KNullDesC ); + TTestOption option; + + res = aItem.GetString( _L("FinishAuthQuery"), optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = aItem.GetNextString( deviceBlockOptionName ); + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel && iReqStatus.Int()!= KErrAccessDenied ) + { + iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() ); + iNotifier -> Close(); + return iReqStatus.Int(); + } + iLog -> Log( _L("Notifier responded") ); + + switch ( option ) + { + case EQueryDiscarded: + if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) ) + { + iLog -> Log( _L("Block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied ); + STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iAuthQueryReply(), EFalse ); + STIF_ASSERT_FALSE( iAuthQueryReply() ); + } + else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) ) + { + iLog -> Log( _L("Don't block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iAuthQueryReply(), EFalse ); + STIF_ASSERT_FALSE( iAuthQueryReply() ); + } + else + { + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + break; + case EQueryAccepted: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iAuthQueryReply(), ETrue ); + STIF_ASSERT_TRUE( iAuthQueryReply() ); + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::PinPasskeyQueryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::PinPasskeyQueryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TPtrC initOptionName( KNullDesC ); + TUint pinCodeMinLength = 4; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + res = aItem.GetString( _L( "PinPasskeyQueryNotifierTest" ), initOptionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + TBTPinCodeEntryNotifierParams notifierParams; + + if ( !initOptionName.Compare( _L( "LOCAL" ) ) ) + { + iLog -> Log( _L("Locally initiated connection") ); + notifierParams = TBTPinCodeEntryNotifierParams( TBTDevAddr(), _L( "Test Device" ), pinCodeMinLength, ETrue, EFalse, pinCodeMinLength ); + } + else if ( !initOptionName.Compare( _L( "REMOTE" ) ) ) + { + iLog -> Log( _L("Remote side initiated connection") ); + notifierParams = TBTPinCodeEntryNotifierParams( TBTDevAddr(), _L( "Test Device" ), pinCodeMinLength, EFalse, EFalse, pinCodeMinLength ); + } + else + { + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + TBTPinCodeEntryNotifierParamsPckg notifierParamsPckg( notifierParams ); + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTPinCodeEntryNotifierUid, notifierParamsPckg, iEnteredPinPasskey ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishPinPasskeyQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TPtrC connectionOptionName( KNullDesC ); + TPtrC deviceBlockOptionName( KNullDesC ); + TTestOption option; + TPINCodeV10 pinKey; + + pinKey.iLength = 4; + pinKey.iPIN[0] = '0'; + pinKey.iPIN[1] = '0'; + pinKey.iPIN[2] = '0'; + pinKey.iPIN[3] = '0'; + + for ( int i = pinKey.iLength; i< KHCIPINCodeSize; i++ ) + { + pinKey.iPIN[i] = NULL; + } + iPinPasskey = pinKey; + + res = aItem.GetString( _L( "FinishPinPasskeyQuery" ), optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + + switch( option ) + { + case ECheckPasskey: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Equal passkeys expected") ); + STIF_ASSERT_EQUALS( iPinPasskey, iEnteredPinPasskey ); + break; + case EQueryCanceled: + res = aItem.GetNextString( connectionOptionName ); + if ( res == KErrNone ) + { + if ( !connectionOptionName.Compare( _L( "DISCARDCONN" ) ) ) + { + res = aItem.GetNextString( deviceBlockOptionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) ) + { + iLog -> Log( _L("Block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied ); + STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() ); + } + else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) ) + { + iLog -> Log( _L("Don't block test device") ); + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + } + else + { + iLog -> Log( _L("Block connection option unavailable") ); + return KErrNotFound; + } + } + else if ( !connectionOptionName.Compare( _L( "ACCEPTCONN" ) ) ) + { + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + } + else + { + iLog -> Log( _L("Connection option unavailable") ); + return KErrNotFound; + } + } + else if ( res == KErrNotFound ) + { + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + } + else + return res; + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::InquiryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::InquiryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TPtrC initOptionName( KNullDesC ); + TBTRegistrySearch regSearch; + TBTPowerStateValue btPowerState; + TBTDeviceSelectionParamsPckg emptyNotifierParamsPckg; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + res = iBtSettings -> GetPowerState( btPowerState ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to get BT power state with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( btPowerState == EBTPowerOn ) + { + res = iBtSettings -> SetPowerState( EBTPowerOff ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to set BT off with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + + regSearch.FindAll(); + res = iBtEngDevManObserver -> GetDevices( regSearch, iBtDeviceArray ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Getting devices from register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( iBtDeviceArray -> Count() > 0 ) + { + iBtDeviceArray -> Reset(); + res = iBtEngDevManObserver -> DeleteDevices( regSearch ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Deleting devices from register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + + res = aItem.GetString( _L( "InquiryNotifierTest" ), initOptionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( !initOptionName.Compare( _L( "BTOFF" ) ) ) + { + iLog -> Log( _L("Init test option: bt off") ); + } + else if ( !initOptionName.Compare( _L( "PAIRED" ) ) ) + { + iLog -> Log( _L("Init test option: paired test device") ); + iTestDevice -> SetDeviceAddress( 0x12345678 ); + iTestDevice -> SetPaired( ELinkKeyAuthenticated ); + TBTDeviceClass testDeviceClass( EMajorServiceLimitedDiscoverableMode, EMajorDeviceComputer, EMinorDeviceComputerUnclassified ); + iTestDevice -> SetDeviceClass( testDeviceClass ); + iTestDevice -> SetDeviceNameL( _L8( "TestedDevice" ) ); + + res = iBtEngDevManObserver -> AddDevice( *iTestDevice ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Adding device to register failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + else if ( !initOptionName.Compare( _L( "NONPAIRED" ) ) ) + { + iLog -> Log( _L("Init test option: test device not paired") ); + } + else + { + iLog -> Log( _L("Option unavailable") ); + iNotifier -> Close(); + return KErrNotFound; + } + + if ( initOptionName.Compare( _L( "BTOFF" ) ) ) + { + res = iBtSettings -> SetPowerState( EBTPowerOn ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to set BT on with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KDeviceSelectionNotifierUid, emptyNotifierParamsPckg, iBtDeviceResponseParamsPckg ); + iLog -> Log( _L("Notifier started") ); + + User::After( 5000000 ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishInquiry( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TPtrC subOptionName( KNullDesC ); + TBTPowerStateValue btPowerState; + TTestOption option; + + res = aItem.GetString( _L( "FinishInquiry" ), optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = aItem.GetNextString( subOptionName ); + iLog -> Log( _L("GetString value: %d"), res ); + + if ( !subOptionName.Compare( _L( "BTOFF" ) ) ) + { + iLog -> Log( _L("Test suboption: set bt off") ); + iBtSettings -> SetPowerState( EBTPowerOff ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to set BT off with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + + switch( option ) + { + case EQueryAccepted: + { + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + + HBufC16* inputDeviceNameBuf = HBufC16::New( iTestDevice -> DeviceName().Length() ); + TPtr16 inputDeviceName = inputDeviceNameBuf -> Des(); + inputDeviceName.Copy( iTestDevice -> DeviceName() ); + + HBufC16* outputDeviceNameBuf = HBufC16::New( iBtDeviceResponseParamsPckg().DeviceName().Length() ); + TPtr16 outputDeviceName = outputDeviceNameBuf -> Des(); + outputDeviceName.Copy( iBtDeviceResponseParamsPckg().DeviceName() ); + + iLog -> Log( _L( "Equal device addresses expected" ) ); + STIF_ASSERT_EQUALS( iTestDevice -> BDAddr(), iBtDeviceResponseParamsPckg().BDAddr() ); + iLog -> Log( _L( "Equal device names expected" ) ); + STIF_ASSERT_EQUALS( inputDeviceName, outputDeviceName ); + iLog -> Log( _L( "Equal device classes expected" ) ); + STIF_ASSERT_EQUALS( iTestDevice -> DeviceClass(), iBtDeviceResponseParamsPckg().DeviceClass() ); + + delete inputDeviceNameBuf; + delete outputDeviceNameBuf; + } + break; + case EQueryCanceled: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + res = iBtSettings -> GetPowerState( btPowerState ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to get BT power state with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + if ( btPowerState == EBTPowerOn ) + { + res = iBtSettings -> SetPowerState( EBTPowerOff ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to set BT off with value: %d"), res ); + iNotifier -> Close(); + return res; + } + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::ObexPasskeyQueryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::ObexPasskeyQueryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TUint8 passCode[] = { "0000" }; + TBTObexPasskey passKey = passCode; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + iObexPasskeyBuf = passKey; + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTObexPasskeyQueryNotifierUid, iObexPasskeyBuf, iEnteredPasskeyBuf ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishObexPasskeyQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TTestOption option; + + res = aItem.GetNextString( optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + switch( option ) + { + case ECheckPasskey: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Equal passkeys expected") ); + STIF_ASSERT_EQUALS( iObexPasskeyBuf(), iEnteredPasskeyBuf() ); + break; + case EQueryCanceled: + iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::PowerModeQueryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::PowerModeQueryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TBTPowerStateValue state; + TBuf testDeviceName = _L( "Device Test Name" ); + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + + res = iBtSettings -> GetPowerState( state ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to get bt power state with value: %d"), res ); + return res; + } + + if ( state != EBTPowerOff ) + { + res = iBtSettings -> SetPowerState( EBTPowerOff ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to set bt power state with value: %d"), res ); + return res; + } + } + + res = iBtSettings -> GetLocalName( iLocalDeviceName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed backup device name: %d"), res ); + return res; + } + + res = iBtSettings -> SetLocalName( testDeviceName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed set device name: %d"), res ); + return res; + } + + TPckgBuf emptyInput; + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KPowerModeSettingNotifierUid, emptyInput, iPowerModeQueryReply ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishPowerModeQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TTestOption option; + + res = aItem.GetNextString( optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + + if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel ) + { + iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() ); + iNotifier -> Close(); + return iReqStatus.Int(); + } + iLog -> Log( _L("Notifier responded") ); + + iBtSettings -> SetLocalName( iLocalDeviceName ); + + switch ( option ) + { + case EQueryDiscarded: + iLog -> Log( _L("Returned request status: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iPowerModeQueryReply(), EFalse ); + STIF_ASSERT_FALSE( iPowerModeQueryReply() ); + break; + case EQueryAccepted: + res = iBtSettings -> SetPowerState( EBTPowerOff ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to set bt power state off with value: %d"), res ); + return res; + } + iLog -> Log( _L("Returned request status: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iPowerModeQueryReply(), ETrue ); + STIF_ASSERT_TRUE( iPowerModeQueryReply() ); + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::GenericInfoNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::GenericInfoNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TBTGenericInfoNotifierParams notifierParams; + TBTGenericInfoNoteType genericInfoNoteType; + TPtrC genericInfoNoteTypeString( KNullDesC ); + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + res = aItem.GetNextString( genericInfoNoteTypeString ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetGenericInfoNoteType( genericInfoNoteTypeString, genericInfoNoteType ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Generic info note type not found") ); + iNotifier -> Close(); + return res; + } + + notifierParams.iMessageType = genericInfoNoteType; + notifierParams.iRemoteAddr = _L8( "012345" ); + TBTGenericInfoNotiferParamsPckg messageInfo( notifierParams ); + TPckgBuf emptyReply; + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTGenericInfoNotifierUid, messageInfo, emptyReply ); + iLog -> Log( _L("Notifier started") ); + User::WaitForRequest( iReqStatus ); + iLog -> Log( _L("Returned request status: %d, expected: %d"), iReqStatus.Int(), KErrNone ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + + return KErrNone; + } + +TInt CBtNotifApiTest::GetGenericInfoNoteType( TPtrC aTypeString, TBTGenericInfoNoteType& aGenericInfoNoteType ) + { + if ( !aTypeString.Compare( _L( "EBTConnected" ) ) ) + { + aGenericInfoNoteType = EBTConnected; + iLog -> Log( _L("Generic info message type: EBTConnected") ); + } + else if ( !aTypeString.Compare( _L( "EBTDisconnected" ) ) ) + { + aGenericInfoNoteType = EBTDisconnected; + iLog -> Log( _L("Generic info message type: EBTDisconnected") ); + } + else if ( !aTypeString.Compare( _L( "EBTAudioAccessory" ) ) ) + { + aGenericInfoNoteType = EBTAudioAccessory; + iLog -> Log( _L("Generic info message type: EBTAudioAccessory") ); + } + else if ( !aTypeString.Compare( _L( "EBTAudioHandset" ) ) ) + { + aGenericInfoNoteType = EBTAudioHandset; + iLog -> Log( _L("Generic info message type: EBTAudioHandset") ); + } + else if ( !aTypeString.Compare( _L( "EBTClosed" ) ) ) + { + aGenericInfoNoteType = EBTClosed; + iLog -> Log( _L("Generic info message type: EBTClosed") ); + } + else if ( !aTypeString.Compare( _L( "EBTDeviceNotAvailable" ) ) ) + { + aGenericInfoNoteType = EBTDeviceNotAvailable; + iLog -> Log( _L("Generic info message type: EBTDeviceNotAvailable") ); + } + else if ( !aTypeString.Compare( _L( "EBTOfflineDisabled" ) ) ) + { + aGenericInfoNoteType = EBTOfflineDisabled; + iLog -> Log( _L("Generic info message type: EBTOfflineDisabled") ); + } + else if ( !aTypeString.Compare( _L( "EBTVisibilityTimeout" ) ) ) + { + aGenericInfoNoteType = EBTVisibilityTimeout; + iLog -> Log( _L("Generic info message type: EBTVisibilityTimeout") ); + } + else if ( !aTypeString.Compare( _L( "EBTEnterSap" ) ) ) + { + aGenericInfoNoteType = EBTEnterSap; + iLog -> Log( _L("Generic info message type: EBTEnterSap") ); + } + else if ( !aTypeString.Compare( _L( "EBTSapOk" ) ) ) + { + aGenericInfoNoteType = EBTSapOk; + iLog -> Log( _L("Generic info message type: EBTSapOk") ); + } + else if ( !aTypeString.Compare( _L( "EBTSapFailed" ) ) ) + { + aGenericInfoNoteType = EBTSapFailed; + iLog -> Log( _L("Generic info message type: EBTSapFailed") ); + } + else if ( !aTypeString.Compare( _L( "EBTSapNoSim" ) ) ) + { + aGenericInfoNoteType = EBTSapNoSim; + iLog -> Log( _L("Generic info message type: EBTSapNoSim") ); + } + else if ( !aTypeString.Compare( _L( "EBTDeviceBusy" ) ) ) + { + aGenericInfoNoteType = EBTDeviceBusy; + iLog -> Log( _L("Generic info message type: EBTDeviceBusy") ); + } + else if ( !aTypeString.Compare( _L( "EIRNotSupported" ) ) ) + { + aGenericInfoNoteType = EIRNotSupported; + iLog -> Log( _L("Generic info message type: EIRNotSupported") ); + } + else if ( !aTypeString.Compare( _L( "ECmdShowBtBatteryLow" ) ) ) + { + aGenericInfoNoteType = ECmdShowBtBatteryLow; + iLog -> Log( _L("Generic info message type: ECmdShowBtBatteryLow") ); + } + else if ( !aTypeString.Compare( _L( "ECmdShowBtBatteryCritical" ) ) ) + { + aGenericInfoNoteType = ECmdShowBtBatteryCritical; + iLog -> Log( _L("Generic info message type: ECmdShowBtBatteryCritical") ); + } + else if ( !aTypeString.Compare( _L( "EBTStayPowerOn" ) ) ) + { + aGenericInfoNoteType = EBTStayPowerOn; + iLog -> Log( _L("Generic info message type: EBTStayPowerOn") ); + } + else + { + iLog -> Log( _L("Generic info message type: No type matched") ); + return KErrNotFound; + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::GenericQueryNotifierTests +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::GenericQueryNotifierTest( CStifItemParser& aItem ) + { + TInt res; + TBTGenericQueryNotifierParams notifierParams; + TBTGenericQueryNoteType genericQueryNoteType; + TPtrC genericQueryNoteTypeString( KNullDesC ); + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); + return res; + } + iLog -> Log( _L("RNotifier connected") ); + + res = aItem.GetNextString( genericQueryNoteTypeString ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetGenericQueryNoteType( genericQueryNoteTypeString, genericQueryNoteType ); + if ( res != KErrNone ) + { + iLog -> Log( _L("Generic query note type not found") ); + iNotifier -> Close(); + return res; + } + + notifierParams.iMessageType = genericQueryNoteType; + notifierParams.iNameExists = EFalse; + TBTGenericQueryNotiferParamsPckg messageInfo( notifierParams ); + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTGenericQueryNotifierUid, messageInfo, iGenericQueryReply ); + iLog -> Log( _L("Notifier started") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::FinishGenericQuery( CStifItemParser& aItem ) + { + TInt res; + TPtrC optionName( KNullDesC ); + TTestOption option; + + res = aItem.GetNextString( optionName ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetNextString failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + res = GetTestOption( optionName, option ); + if ( res != KErrNone ) + { + iLog -> Log( _L("GetTestOption failed with value: %d"), res ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + if ( iReqStatus.Int()!= KErrNone ) + { + iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() ); + iNotifier -> Close(); + return iReqStatus.Int(); + } + iLog -> Log( _L("Notifier responded") ); + + switch ( option ) + { + case EQueryDiscarded: + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iGenericQueryReply(), EFalse ); + STIF_ASSERT_FALSE( iGenericQueryReply() ); + break; + case EQueryAccepted: + iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iGenericQueryReply(), ETrue ); + STIF_ASSERT_TRUE( iGenericQueryReply() ); + break; + default: + iLog -> Log( _L("Option unavailable") ); + return KErrNotFound; + } + + iNotifier -> Close(); + iLog -> Log( _L("Test case passed") ); + + return KErrNone; + } + + +TInt CBtNotifApiTest::GetGenericQueryNoteType( TPtrC aTypeString, TBTGenericQueryNoteType& aGenericQueryNoteType ) + { + if ( !aTypeString.Compare( _L( "EBTReceiveMessageQuery" ) ) ) + { + aGenericQueryNoteType = EBTReceiveMessageQuery; + iLog -> Log( _L("Generic query message type: EBTReceiveMessageQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTReceiveMessagePairedQuery" ) ) ) + { + aGenericQueryNoteType = EBTReceiveMessagePairedQuery; + iLog -> Log( _L("Generic query message type: EBTReceiveMessagePairedQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTIsOffQuery" ) ) ) + { + aGenericQueryNoteType = EBTIsOffQuery; + iLog -> Log( _L("Generic query message type: EBTIsOffQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTActivateOffLineQuery" ) ) ) + { + aGenericQueryNoteType = EBTActivateOffLineQuery; + iLog -> Log( _L("Generic query message type: EBTActivateOffLineQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTNoDevicesFoundQuery" ) ) ) + { + aGenericQueryNoteType = EBTNoDevicesFoundQuery; + iLog -> Log( _L("Generic query message type: EBTNoDevicesFoundQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTAcceptRequestQuery" ) ) ) + { + aGenericQueryNoteType = EBTAcceptRequestQuery; + iLog -> Log( _L("Generic query message type: EBTAcceptRequestQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTBlockConnectionQuery" ) ) ) + { + aGenericQueryNoteType = EBTBlockConnectionQuery; + iLog -> Log( _L("Generic query message type: EBTBlockConnectionQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTBlockPairedConnectionQuery" ) ) ) + { + aGenericQueryNoteType = EBTBlockPairedConnectionQuery; + iLog -> Log( _L("Generic query message type: EBTBlockPairedConnectionQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTIsNotShownQuery" ) ) ) + { + aGenericQueryNoteType = EBTIsNotShownQuery; + iLog -> Log( _L("Generic query message type: EBTIsNotShownQuery") ); + } + else if ( !aTypeString.Compare( _L( "EBTIsOffJavaQuery" ) ) ) + { + aGenericQueryNoteType = EBTIsOffJavaQuery; + iLog -> Log( _L("Generic query message type: EBTIsOffJavaQuery") ); + } + else + { + iLog -> Log( _L("Generic query message type: No type matched") ); + return KErrNotFound; + } + + return KErrNone; + } + + +// ----------------------------------------------------------------------------- +// CBtNotifApiTest::GetTestOption +// ----------------------------------------------------------------------------- +// + +TInt CBtNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption ) + { + if ( !aOptionString.Compare( _L( "DISCARD" ) ) ) + { + aOption = EQueryDiscarded; + iLog -> Log( _L("Test type: EQueryDiscarded") ); + } + else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) ) + { + aOption = EQueryAccepted; + iLog -> Log( _L("Test type: EQueryAccepted") ); + } + else if ( !aOptionString.Compare( _L( "PASSKEY" ) ) ) + { + aOption = ECheckPasskey; + iLog -> Log( _L("Test type: ECheckPasskey") ); + } + else if ( !aOptionString.Compare( _L( "CANCEL" ) ) ) + { + aOption = EQueryCanceled; + iLog -> Log( _L("Test type: EQueryCanceled") ); + } + else + return KErrNotFound; + + return KErrNone; + } + +TInt CBtNotifApiTest::TurnLightsOn( CStifItemParser& aItem ) + { + TInt res; + res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn); + return res; + } + + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// [End of File] - Do not remove diff -r 000000000000 -r f63038272f30 bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtSettingsObserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtSettingsObserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 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 "BtSettingsObserver.h" + +CBtSettingsObserver::CBtSettingsObserver() + { + } + +CBtSettingsObserver::~CBtSettingsObserver() + { + delete iSettings; + if( iWaiter->IsStarted() ) + { + iWaiter->AsyncStop(); + } + delete iWaiter; + } + +CBtSettingsObserver* CBtSettingsObserver::NewLC() + { + CBtSettingsObserver* self = new ( ELeave ) CBtSettingsObserver(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CBtSettingsObserver* CBtSettingsObserver::NewL() + { + CBtSettingsObserver* self = CBtSettingsObserver::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +void CBtSettingsObserver::ConstructL() + { + iWaiter = new ( ELeave ) CActiveSchedulerWait(); + iSettings = CBTEngSettings::NewL( this ); + iError = KErrNone; + } + +void CBtSettingsObserver::PowerStateChanged( TBTPowerStateValue /*aState*/ ) + { + if( iWaiter->IsStarted() ) + { + iWaiter->AsyncStop(); + } + } + +void CBtSettingsObserver::VisibilityModeChanged( TBTVisibilityMode /*aState*/ ) + { + if( iWaiter->IsStarted() ) + { + iWaiter->AsyncStop(); + } + } + +TInt CBtSettingsObserver::GetPowerState( TBTPowerStateValue& aState ) + { + iError = iSettings->GetPowerState( aState ); + return iError; + } + +TInt CBtSettingsObserver::SetPowerState( TBTPowerStateValue aState ) + { + TBTPowerStateValue state; + + iError = iSettings->GetPowerState( state ); + if( iError ) + { + return iError; + } + else if( state != aState ) + { + if( state == EBTPowerOff ) + { + iError = iSettings->SetPowerState( EBTPowerOn ); + } + else + { + iError = iSettings->SetPowerState( EBTPowerOff ); + } + + if( iError ) + { + return iError; + } + else + { + if ( !iWaiter->IsStarted() ) + { + iWaiter->Start(); + } + } + } + return iError; + } + +TInt CBtSettingsObserver::GetVisibilityMode( TBTVisibilityMode& /*aMode*/ ) + { + return KErrNone; + } + +TInt CBtSettingsObserver::SetVisibilityMode( TBTVisibilityMode /*aMode*/, TInt /*aTime*/ ) + { + return KErrNone; + } + +TInt CBtSettingsObserver::GetLocalName( TDes& aName ) + { + iError = iSettings -> GetLocalName( aName ); + return iError; + } + +TInt CBtSettingsObserver::SetLocalName( const TDes& aName ) + { + iError = iSettings -> SetLocalName( aName ); + return iError; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/data/1020896E.RSS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/data/1020896E.RSS Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2007-2007 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: BTEngine plugin resource definition +* +*/ + +#include +#include + +// --------------------------------------------------------------------------- +// theInfo +// BTPBAP plugin registry information +// --------------------------------------------------------------------------- +// +RESOURCE REGISTRY_INFO theInfo +{ + resource_format_version = RESOURCE_FORMAT_VERSION_2; + dll_uid = 0x1020896E; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x2000277B; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020896E; + version_no = 1; + display_name = "BPAP Plugin"; + default_data = "1130"; + opaque_data = ""; + rom_only = 1; + } + }; + } + }; +} + diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2007-2007 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: Build information file for project btpbap +* +*/ + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../rom/btpbap.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btpbap.iby) + + +PRJ_MMPFILES +../group/btpbap.mmp diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/group/btpbap.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/group/btpbap.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2007-2007 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: Project definition file for project btpbap +* +*/ + +#include + + +TARGET btpbap.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x1020896E + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +START RESOURCE ../data/1020896E.RSS + TARGET btpbap.rsc +END // RESOURCE + +SOURCEPATH ../src + +SOURCE Pbapplugin.cpp +SOURCE PbapProxy.cpp +SOURCE DisconnectHelper.cpp + + +USERINCLUDE ../inc + +APP_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE ../../inc +SYSTEMINCLUDE ../../../inc +SYSTEMINCLUDE /epoc32/include/ecom + + +LIBRARY euser.lib // Kernel API +LIBRARY ECom.lib +LIBRARY pbapcli.lib +LIBRARY bluetooth.lib +DEBUGLIBRARY flogger.lib // File logging + diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/inc/DisconnectHelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/inc/DisconnectHelper.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2007-2007 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: This is the Disconnection helper class +* +*/ + + +#ifndef DISCONNECTHELPER_H +#define DISCONNECTHELPER_H + +#include + +/** + * Callback interface for completing disconnection helper + * + * @since S60 v3.2 + */ +class MDisconnectionCallback + { + +public: + + /** + * From MDisconnectionCallback. + * Callback funtion for completing asynchronous disconnection request + * + * @since S60 v3.2 + */ + virtual void CompleteDisconnection()=0; + }; + + +/** + * Helper class for handling asynchronous disconnection request + * + * @since S60 v3.2 + */ +class CDisconnectHelper : public CActive + { + +public: + + /** + * Two-phased constructor. + * @param aParams the LocodServicePluginParams + */ + static CDisconnectHelper* NewL( MDisconnectionCallback* aObserver ); + + /** + * Destructor. + */ + ~CDisconnectHelper(); + + /** + * Activate helper class for handling asynchronous disconnection + * + * @since S60 v3.2 + * @return Error code + */ + TInt Activate(); + + /** + * From CActive + * + * @since S60 v3.2 + */ + void RunL(); + + /** + * From CActive + * + * @since S60 v3.2 + */ + void DoCancel(); + +private: + + CDisconnectHelper( MDisconnectionCallback* aObserver ); + + void ConstructL(); + +private: // data + + /* + * Callback interface, which is used when disconnect helper + * is completed. + * Not own. + */ + MDisconnectionCallback* iObserver; + + }; + +#endif // BTPBAPPLUGIN diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/inc/Pbapplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/inc/Pbapplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,208 @@ +/* +* Copyright (c) 2007-2007 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: This is the btpbap ecom plugin class declaration. +* +*/ + +#ifndef BTPBAPPLUGIN_H +#define BTPBAPPLUGIN_H + +#include +#include +#include +#include "DisconnectHelper.h" + + +/** + * BTPBAP plugin class + * + * This is the CBTEngPlugin implementation + * @since S60 v3.2 + */ +NONSHARABLE_CLASS ( CPBAPplugin ) : public CBTEngPlugin, + public MDisconnectionCallback + { +public: + + + /** + * Two-phased constructor. + */ + static CPBAPplugin* NewL(); + + /** + * Destructor. + */ + ~CPBAPplugin(); + + + /** + * From CBTEngPlugin. + * Sets the observer for receiving connection events through the + * MBTEngPluginObserver interface. This method MUST be called + * before any command is given to the plug-in + * + * @since S60 v3.2 + * @param aObserver The observer of connection events. + */ + void SetObserver( MBTEngPluginObserver* aObserver ); + + /** + * From CBTEngPlugin. + * Gets the list of profiles implemented by this plug-in. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v3.2 + * @param aProfiles Array of integers identifying the BT profiles + * implemented by this plug-in. + */ + void GetSupportedProfiles( RProfileArray& aProfiles ); + + /** + * From CBTEngPlugin. + * Indicates if this plug-in implements the specified profiles. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v3.2 + * @param aProfile Integer identifying the BT profile. + * @return ETrue if the plug-in implements the requested profile, + * otherwise EFalse. + */ + TBool IsProfileSupported( const TBTProfile aProfile ) const ; + + /** + * From CBTEngPlugin. + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::ConnectComplete with + * the appropriate error code. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * @return KErrNone on success, otherwise an appropriate error code. + */ + TInt Connect( const TBTDevAddr& aAddr ); + + /** + * From CBTEngPlugin. + * Instructs the plug-in to cancel the creation a service-level + * connection with the specified Bluetooth address. + * + * In addition, as this is part of an asynchronous operation, the plug-in + * completes the outstanding asyncronous request status with KErrCancel. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + */ + void CancelConnect( const TBTDevAddr& aAddr ); + + /** + * From CBTEngPlugin. + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::DisconnectComplete with + * the appropriate error code. + * + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * In case the address is the NULL address, the plug-in is + * expected to disconnect all its connections. + * @param aDiscType The type of disconnection; + * EGraceful for graceful (normal) disconnection, + * EImmediate for immediate (forced) disconnection. + * @return KErrNone on success, otherwise an appropriate error code. + */ + TInt Disconnect( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ); + + /** + * From CBTEngPlugin. + * Gets the addresses of the connected devices for the specified profile. + * + * @since S60 v3.2 + * @param aAddrArray On return, holds the Bluetooth device addresses + * of the connected Bluetooth devices for the + * requested profile. + * @param aConnectedProfile The profile for which the existing + * connections are requested. + * @return None. + */ + void GetConnections( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ); + + /** + * From CBTEngPlugin. + * Indicates if this plug-in has a service-level connection + * with the specified Bluetooth address. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * @return The status of the connection according to the TConnectionStatus + * enumeration. EConnecting is interpreted that at least one + * incoming connection request has been completed, but that not + * all service-level connections have been fully established. + */ + TBTEngConnectionStatus IsConnected( const TBTDevAddr& aAddr ); + + +private: + + + /** + * From MDisconnectionCallback. + * Callback function for completing asynchronous disconnection request + * + * @since S60 v3.2 + */ + void CompleteDisconnection(); + +private: + + CPBAPplugin(); + + void ConstructL(); + +private: // data + + /* + * Callback interface for completing asynchronous + * disconnection event. + * Not own. + */ + MBTEngPluginObserver* iObserver; + + /* + * Pbap server client session + */ + RPbapSession iBPAP; + + /* + * Helper class for asynchronous disconnection + * Own. + */ + CDisconnectHelper* iDisconnectHelper; + + /* + * BT device address to be disconnected + */ + TBTDevAddr iAddr; + }; +#endif // BTPBAPPLUGIN diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/inc/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,220 @@ +/* +* Copyright (c) 2007-2007 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: Logging definition +* +*/ + + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +/** + * Owerflow handler for 16 bit descriptor + * + * @since S60 S60 v3.2 + */ +NONSHARABLE_CLASS( TOverflowTruncate16 ) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +/** + * Owerflow handler for 8bit descriptor + * + * @since S60 S60 v3.2 + */ +NONSHARABLE_CLASS( TOverflowTruncate8 ) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +/** + * Log requested lines with serial logging or file logging + * + * @since S60 S60_3.2 + * @param aFmt a Data to be printed + * @return None. + */ +inline void Trace( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); +#else + TBuf16 theFinalString; + theFinalString.Append( KTracePrefix16 ); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList( aFmt, list, &overflow ); + RDebug::Print( theFinalString ); +#endif + } + + +/** + * Log requested lines with serial logging or file logging + * + * @since S60 S60_3.2 + * @param aFmt a Data to be printed + * @return None. + */ +inline void Trace( TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); +#else + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append( KTracePrefix8 ); + buf8.AppendFormatList( aFmt, list, &overflow ); + TBuf16 buf16( buf8.Length() ); + buf16.Copy(buf8); + TRefByValue tmpFmt( _L("%S") ); + RDebug::Print( tmpFmt, &buf16 ); +#endif + } + +/** + * Log panics + * + * @since S60 S60_3.2 + * @param aFile a File where panic happens + * @param aLine a Line where panic happens + * @param aPanicCode a Panic code + * @param aPanicCategory a Panic category + * @return None. + */ +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName( (const TUint8*)aFile ); + TPtrC8 fileName( fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1 ); + TBuf8 buf; + buf.Append( KPanicPrefix8 ); + buf.AppendFormat( _L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName ); + Trace( buf ); + User::Panic( aPanicCategory, aPanicCode ); + } + +/** + * Log panics + * + * @since S60 S60_3.2 + * @param aFile a File where leave happens + * @param aLine a Line where leave happens + * @param aReason a Reason for leave + * @return None. + */ +inline void TraceLeave( char* aFile, TInt aLine, TInt aReason ) + { + TPtrC8 fullFileName( (const TUint8*)aFile ); + TPtrC8 fileName( fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1 ); + TBuf8 buf; + buf.Append( KLeavePrefix8 ); + buf.AppendFormat( _L8("%d at line %d in file %S"), aReason, aLine, &fileName ); + Trace( buf ); + User::LeaveIfError( aReason ); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic( __FILE__, __LINE__, CODE, KPanicCategory); } + +#define PANIC(CODE) TracePanic( __FILE__, __LINE__, CODE, KPanicCategory ) + +#define LEAVE_IF_ERROR(REASON) {if ( REASON ) TraceLeave( __FILE__, __LINE__, REASON );} + +#define LEAVE(REASON) {TraceLeave( __FILE__, __LINE__, REASON );} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8( (TUint8*)__PRETTY_FUNCTION__ ); Trace( KFuncEntryFormat8, &ptr8 );}} + +#define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace( KFuncEntryThisFormat8, &ptr8, this );}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace( KFuncExitFormat8, &ptr8 );}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8( (TUint8*)__PRETTY_FUNCTION__ ); Trace( KFuncFormat8, &ptr8 );}} + +#define TRACE_FUNC_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8( (TUint8*)__PRETTY_FUNCTION__ ); Trace( KFuncThisFormat8, &ptr8, this );}} + +#define RETURN_IF_ERR(ERR) {if( ERR ) { TPtrC8 ptr8((TUint8*)__FILE__ ); Trace( _L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__ ); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast( User::LeaveIfError( REASON ) );} + +#define LEAVE(REASON) {static_cast( User::Leave(REASON ) );} + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY_THIS + +#define TRACE_FUNC_EXIT + +#define TRACE_FUNC + +#define TRACE_FUNC_THIS + +#define RETURN_IF_ERR( ERR ) {if( ERR ) return ERR;} +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2007-2007 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: Project configure file. +* +*/ + +#ifndef OBEXSM_DEBUGCONFIG_H +#define OBEXSM_DEBUGCONFIG_H + +#include "prjconfig.h" + + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"pbap.txt"); +_LIT(KLogDir,"pbap"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[pbap] "); +_LIT8(KTracePrefix8, "[pbap] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "pbap"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +#endif // OBEXSM_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2007-2007 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: Project configure file. +* +*/ + +#ifndef OBEXSM_PRJCONFIG_H +#define OBEXSM_PRJCONFIG_H + +/** + * Traces are enabled via RDebug::Print() in UDEB build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * Traces will be written to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + +#endif // OBEXSM_PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/rom/btpbap.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/rom/btpbap.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2007-2007 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: Image description file for project btpbap +* +*/ + +#ifndef BTPBAP_IBY +#define BTPBAP_IBY + +#ifdef __BT + #ifdef __BT_PBAP + ECOM_PLUGIN(btpbap.dll,btpbap.rsc) + #endif +#endif +#endif // BTPBAP + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/src/DisconnectHelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/src/DisconnectHelper.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2007-2007 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: This is the bteng ecom plugin class implementation. +* +*/ + + +#include "DisconnectHelper.h" +#include "debug.h" + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +CDisconnectHelper* CDisconnectHelper::NewL( MDisconnectionCallback* aObserver ) + { + TRACE_FUNC + CDisconnectHelper* self = new (ELeave) CDisconnectHelper( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +CDisconnectHelper::~CDisconnectHelper() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Constructor +// --------------------------------------------------------------------------- +// +CDisconnectHelper::CDisconnectHelper( MDisconnectionCallback* aObserver ): + CActive( CActive::EPriorityStandard ), + iObserver( aObserver ) + { + } + +// --------------------------------------------------------------------------- +// ConstructL +// --------------------------------------------------------------------------- +// +void CDisconnectHelper::ConstructL() + { + TRACE_FUNC + if ( !iObserver ) + { + User::Leave(KErrArgument); + } + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------- +// CPBAPplugin::Activate +// --------------------------------------------------------- +// +TInt CDisconnectHelper::Activate() + { + if ( IsActive() ) + { + return KErrInUse; + } + iStatus = KRequestPending; + SetActive(); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + return KErrNone; + } + +// --------------------------------------------------------- +// From class CActive +// CPBAPplugin::RunL +// --------------------------------------------------------- +// +void CDisconnectHelper::RunL( ) + { + if ( iObserver ) + { + iObserver->CompleteDisconnection(); + } + } + +// --------------------------------------------------------- +// From class CActive +// CPBAPplugin::DoCancel +// --------------------------------------------------------- +// +void CDisconnectHelper::DoCancel() + { + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/src/PbapProxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/src/PbapProxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2007-2007 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: Export ECom interface implementations +* +*/ + + +#include //ECom header file +#include "Pbapplugin.h" + +// --------------------------------------------------------------------------- +// An array of TImplementationProxy objects which onnect each +// implemeation with its instantiation function +// --------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x1020896E , CPBAPplugin::NewL) + }; + +// --------------------------------------------------------------------------- +// Exported proxy function to resolve instantiation methods for an Ecom plug-in DLL +// --------------------------------------------------------------------------- +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt & aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btpbap/src/Pbapplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btpbap/src/Pbapplugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2007-2007 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: This is the btpbap bteng ecom plugin class implementation. +* +*/ + +#include "Pbapplugin.h" +#include "DisconnectHelper.h" +#include "debug.h" + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +CPBAPplugin* CPBAPplugin::NewL() + { + TRACE_FUNC + CPBAPplugin* self = new ( ELeave ) CPBAPplugin(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +CPBAPplugin::~CPBAPplugin() + { + TRACE_FUNC_ENTRY + if( iBPAP.Handle() ) + { + iBPAP.Close(); + } + delete iDisconnectHelper; + iDisconnectHelper = NULL; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Constructor +// --------------------------------------------------------------------------- +// +CPBAPplugin::CPBAPplugin() : iDisconnectHelper( NULL ) + { + } + +// --------------------------------------------------------------------------- +// ConstructL +// --------------------------------------------------------------------------- +// +void CPBAPplugin::ConstructL() + { + TRACE_FUNC_ENTRY + TInt error; + iDisconnectHelper=CDisconnectHelper::NewL( this ); + error=iBPAP.Connect(); + if ( error == KErrNone ) + { + error=iBPAP.Start(); + if( error ) + { + TRACE_ERROR(( _L("[PBAP]\tPBAP\tCPBAPplugin::ConstructL() start failed %d"), error) ); + User::Leave( error ); + } + } + else + { + TRACE_ERROR(( _L("[PBAP]\tPBAP\tCPBAPplugin::ConstructL() connect failed %d"), error ) ); + User::Leave( error ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::SetObserver +// --------------------------------------------------------- +// +void CPBAPplugin::SetObserver( MBTEngPluginObserver* aObserver ) + { + iObserver = aObserver; + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::GetSupportedProfiles +// --------------------------------------------------------- +// +void CPBAPplugin::GetSupportedProfiles( RProfileArray& aProfiles ) + { + aProfiles.Append( EBTProfilePBAP ); + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::IsProfileSupported +// --------------------------------------------------------- +// +TBool CPBAPplugin::IsProfileSupported( const TBTProfile aProfile ) const + { + if ( aProfile == EBTProfilePBAP ) + { + return ETrue; + } + return EFalse; + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::Connect +// --------------------------------------------------------- +// +TInt CPBAPplugin::Connect( const TBTDevAddr& /*aAddr*/ ) + { + return KErrNotSupported; + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::CancelConnect +// --------------------------------------------------------- +// +void CPBAPplugin::CancelConnect( const TBTDevAddr& /*aAddr*/ ) + { + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::Disconnect +// --------------------------------------------------------- +// +TInt CPBAPplugin::Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType /*aDiscType*/ ) + { + if ( iObserver ) + { + return KErrGeneral; + } + iAddr = aAddr; + return iDisconnectHelper->Activate(); + } + +// --------------------------------------------------------- +// From class CBTEngPlugin +// CPBAPplugin::GetConnections +// --------------------------------------------------------- +// +void CPBAPplugin::GetConnections( RBTDevAddrArray& /*aAddrArray*/, TBTProfile /*aConnectedProfile*/ ) + { + } + +// --------------------------------------------------------- +// CPBAPplugin::IsConnected, from CBTEngPlugin +// --------------------------------------------------------- +// +TBTEngConnectionStatus CPBAPplugin::IsConnected( const TBTDevAddr& /*aAddr*/ ) + { + return EBTEngNotConnected; + } + +// --------------------------------------------------------- +// From class MDisconnectionCallback +// CPBAPplugin::CompleteDisconnection +// --------------------------------------------------------- +// +void CPBAPplugin::CompleteDisconnection() + { + + iBPAP.Stop(); + TInt err = iBPAP.Start(); + TRACE_INFO((_L("Failed to start RPbapSession err = %d"), err)); + static_cast(err); + if ( iObserver ) + { + iObserver->DisconnectComplete( iAddr, EBTProfilePBAP, KErrNone ); + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/data/10208978.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/data/10208978.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2005-2006 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: Declares information of BTRCC ECom implementation +* +*/ + + +#include // KBTAccPluginInterfaceUid +#include +#include "btrccPluginImplUid.h" + +// Declares info for implementation +RESOURCE REGISTRY_INFO BTRCC_Info + { + // UID for the DLL + dll_uid = 0x10208978; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = KBTAccPluginInterfaceUid; + implementations = + { + // Info for BTRCC + IMPLEMENTATION_INFO + { + implementation_uid = KBTRCCPluginImplUid; + version_no = 1; + display_name = "BT Remote Control Controller"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2005 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: Provides information for building BTsac. +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/config/prj_urel_config.h |../inc/prjconfig.h + +PRJ_MMPFILES +../group/btrcc.mmp + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/group/btrcc.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/group/btrcc.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2005-2006 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: Project specification file for BTRCC +* +*/ + +#include + +// Uses the default ECom Plugin capabilities +// Look at defaultcaps.hrh for a list of capabilities +CAPABILITY CAP_ECOM_PLUGIN + +// Manufacturer or platform specific Vender ID (VID). A VID to be granted to +// all software from the same manufacturer. +VENDORID VID_DEFAULT + +TARGET btrcc.dll +TARGETTYPE PLUGIN + + +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +// ECom Dll recognition UID followed by the unique UID for this dll +UID 0x10009D8D 0x10208978 + +SOURCEPATH ../src +SOURCE btrccmain.cpp +SOURCE btrccLinker.cpp +SOURCE btrccPlugin.cpp +SOURCE btrccAbsoluteVolumeLevelController.cpp +SOURCE btrccplayerstarter.cpp +SOURCE btrccBrowsingAdapter.cpp +SOURCE btrccLegacyVolumeLevelController.cpp +SOURCE btrccVolumeLevelControllerBase.cpp +SOURCE btrccActive.cpp + +USERINCLUDE ../inc ../../common +SYSTEMINCLUDE ../../../inc ../../../../inc +SYSTEMINCLUDE /epoc32/include/ecom /epoc32/include/mmf/server +MW_LAYER_SYSTEMINCLUDE + +START RESOURCE ../data/10208978.rss +TARGET btrcc.rsc +END + +LIBRARY ECom.lib // Symbian E-Com Plugin definitions and types +LIBRARY euser.lib // User library +LIBRARY esock.lib // Socket services +LIBRARY bluetooth.lib // Bluetooth type definitions +LIBRARY btdevice.lib // BT Device + +// RemCon client +LIBRARY remconclient.lib +LIBRARY remcontypes.lib +DEBUGLIBRARY flogger.lib // File logging services + +LIBRARY remconcoreapi.lib // For controller role +LIBRARY remconinterfacebase.lib // For controller role +LIBRARY remconbatterystatusapi.lib +LIBRARY remconmediabrowseapi.lib +LIBRARY remconabsolutevolume.lib +LIBRARY mmfdevsound.lib +LIBRARY mpxcommon.lib +#ifdef BTRCCTEST_MPXCOLLECTIONSTUB +LIBRARY mpxcollectionutilitystub.dll +#else +LIBRARY mpxcollectionutility.lib +#endif +LIBRARY apgrfx.lib apparc.lib estor.lib + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccAbsoluteVolumeLevelController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccAbsoluteVolumeLevelController.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2005-2006 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: This class implements volume control of AVRCP Controller. +* +* +*/ + + +#ifndef BTRCCABSOLUTEVOLUMELEVELCONTROLLER_H +#define BTRCCABSOLUTEVOLUMELEVELCONTROLLER_H + +// INCLUDES +#include +#include // BT protocol wide types +#include "btrccVolumeLevelControllerBase.h" +#include "absolutevolumeapicontrollerobserver.h" +#include "absolutevolumeapicontroller.h" +#include "absolutevolumeapitargetobserver.h" +//#include + +// FORWARD DECLARATIONS +class CRemConInterfaceSelector; +class CRemConCoreApiController; +class CBTRCCActive; + +// CLASS DECLARATION + +/** +* A listener for incoming handsfree attachments/detachments. +*/ +NONSHARABLE_CLASS(CBTRCCAbsoluteVolumeLevelController) : + public CBTRCCVolumeLevelControllerBase, + public MRemConAbsoluteVolumeControllerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * + */ + static CBTRCCAbsoluteVolumeLevelController* NewL(CRemConInterfaceSelector& aInterfaceSelector, MBTRCCVolumeControllerObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBTRCCAbsoluteVolumeLevelController(); + + + private: + + /** + * C++ default constructor. + */ + CBTRCCAbsoluteVolumeLevelController(MBTRCCVolumeControllerObserver& aObserver); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(CRemConInterfaceSelector& aInterfaceSelector); + + public: // From MBTRCCActiveObserver + + void RequestCompletedL(CBTRCCActive& aActive, TInt aErr); + + void CancelRequest(TInt aServiceId); + + public: // From CBTRCCVolumeLevelControllerBase + + void DoStart(TInt aInitialVolume); // Set the initial volume. + + void DoStop(); // Stop monitoring for volume level changes. + + void DoReset(); // Reset the volume level. + + private: // From CBTRCCVolumeLevelControllerBase + + void AdjustRemoteVolume(TInt aVolume); + + TInt GetPhoneVolume(TInt &aVol); + + public: // New methods + + + private: // From MRemConAbsoluteVolumeControllerObserver + + void MrcavcoCurrentVolume(TUint32 aVolume, TUint32 aMaxVolume, TInt aError); + + void MrcavcoSetAbsoluteVolumeResponse(TUint32 aVolume, TUint32 aMaxVolume, TInt aError); + + void MrcavcoAbsoluteVolumeNotificationError(); + + private: + void AccessoryChangedVolume(TUint32 aVolume, TUint32 aMaxVolume, TInt aError); + TBool ValidVolumeParams(TUint32 aVolume, TUint32 aMaxVolume); + + void RegisterVolumeChangeNotification(); + + private: // Data + + CRemConAbsoluteVolumeController* iRemConAbsoluteVolumeController; // changes the accessory's volume level. + + // This active object listens to the absolute volume API. + CBTRCCActive *iBtrccAbsoluteVolumeActive; + + // Not owned + CRemConInterfaceSelector *iInterfaceSelector; + + TInt iLocalMaxVolume; // maximum volume level of phone + + TUint iNumRemotes; // not used, but needed for the remote controlling API. + + TInt iRetryCounter; + }; + +#endif // BTRCCABSOLUTEVOLUMELEVELCONTROLLER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccActive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccActive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 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: General active object offering asynchronous service +* +*/ + + +#ifndef BTRCCACTIVE_H +#define BTRCCACTIVE_H + +// INCLUDES +#include + +class CBTRCCActive; + +class MBTRCCActiveObserver + { + public: + virtual void RequestCompletedL(CBTRCCActive& aActive, TInt aErr) = 0; + + virtual void CancelRequest(TInt aServiceId) = 0; + }; + +/** +* CBTRCCActive listens to the Volume PS Key changes. +*/ +NONSHARABLE_CLASS(CBTRCCActive) : public CActive + { + public: + + /** + * Two-phased constructor. + */ + static CBTRCCActive* NewL(MBTRCCActiveObserver& aObserver, TInt aServiceId = 0, + CActive::TPriority aPriority = EPriorityStandard /*TPriority::EPriorityStandard*/); + + static CBTRCCActive* NewLC(MBTRCCActiveObserver& aObserver, TInt aServiceId = 0, + CActive::TPriority aPriority = EPriorityStandard /*TPriority::EPriorityStandard*/); + + /** + * Destructor. + */ + ~CBTRCCActive(); + + public: + + virtual void GoActive(); + + TInt ServiceId() const; + + void SetServiceId(TInt aServiceId); + + protected: + + /** + * From CActive. Called when asynchronous request completes. + * @since 3.0 + * @param None + * @return None + */ + virtual void RunL(); + + virtual void DoCancel(); + + protected: + + /** + * C++ default constructor. + */ + CBTRCCActive(MBTRCCActiveObserver& aObserver, + TInt aServiceId, CActive::TPriority aPriority); + + MBTRCCActiveObserver& Observer(); + + private: + MBTRCCActiveObserver& iObserver; + TInt iServiceId; + }; + +#endif // BTRCCACTIVE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccBrowsingAdapter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccBrowsingAdapter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2005-2006 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: Browsing adapter between RemCon an MPX Framework. +* +*/ + + +#ifndef BTRCCBROWSINGADAPTER_H_ +#define BTRCCBROWSINGADAPTER_H_ + +// INCLUDES +#include +#include +#include +#include +#include + +// DATA TYPES + +// FORWARD DECLARATIONS +class CRemConInterfaceSelector; + +// CLASS DECLARATION + + +NONSHARABLE_CLASS(CBTRCCBrowsingAdapter) : + public MRemConDatabaseAwareMediaLibraryBrowseObserver, + public MRemConDatabaseAwareNowPlayingBrowseObserver, + public MMPXCollectionObserver + { + public: // Constructors and destructor + /** + * Two-phased constructor. + * + */ + static CBTRCCBrowsingAdapter* NewL(CRemConInterfaceSelector& aInterfaceSelector); + + /** + * Destructor. + */ + virtual ~CBTRCCBrowsingAdapter(); + + + private: + /** + * C++ default constructor. + */ + CBTRCCBrowsingAdapter(); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(CRemConInterfaceSelector& aInterfaceSelector); + + private: // From MRemConDatabaseAwareMediaLibraryBrowseObserver + void MrcdamlboGetFolderListing(TRemConFolderScope aScope, TUint aStartItem, TUint aEndItem); + TInt MrcdamlboGetItem(TRemConFolderScope aScope, + const TRemConItemUid& aItemId, + TMediaAttributeIter& aIter, + TUint16 aMediaLibraryStateCookie); + void MrcdamlboFolderUp(TUint16 aMediaLibraryStateCookie); + void MrcdamlboFolderDown(const TRemConItemUid& aFolder, TUint16 aMediaLibraryStateCookie); + void MrcdamlboGetPath(RPointerArray& aPath); + void MrcdamlboSearch(const TDesC8& aSearch); + + private: // From MRemConDatabaseAwareNowPlayingBrowseObserver + void MrcdanpboGetFolderListing(TUint aStartItem, TUint aEndItem); + TInt MrcdanpboGetItem(const TRemConItemUid& aItemId, TMediaAttributeIter& aIter, TUint16 aMediaLibraryStateCookie); + + private: // From MMPXCollectionObserver + void HandleCollectionMessage(CMPXMessage* aMsg, TInt /*aErr*/); + void HandleOpenL(const CMPXMedia& aEntries, TInt aIndex,TBool aComplete,TInt aError); + void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError); + void HandleCommandComplete(CMPXCommand* /*aCommandResult*/, TInt /*aError*/); + + private: // From MMPXCollectionMediaObserver + void HandleCollectionMediaL(const CMPXMedia& aMedia, TInt aError); + + private: + void SubscribeL(); + + private: + enum TMediaLOpcode + { + EMediaLOpIdle, + EMediaLOpFolderListing + }; + + enum TOpenLOpcode + { + EOpenLOpIdle, + EOpenLOpOpen + }; + + private: // Data + CRemConDatabaseAwareMediaBrowseTarget* iMediaBrowseTarget; + MRemConDatabaseAwareMediaLibraryBrowse* iMlInterface; + MRemConDatabaseAwareNowPlayingBrowse* iNpInterface; + + MMPXCollectionUtility* iCollectionUtility; + + TUint16 iCookie; + TMediaLOpcode iCurrentMediaLOp; // current MediaL operation + TOpenLOpcode iCurrentOpenLOp; // current OpenL operation + }; + +#endif /* BTRCCBROWSINGADAPTER_H_ */ diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccLegacyVolumeLevelController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccLegacyVolumeLevelController.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2005-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: This class implements legacy volume control of AVRCP Controller. +* +* +*/ + +#ifndef BTRCCLEGACYVOLUMELEVELCONTROLLER_H +#define BTRCCLEGACYVOLUMELEVELCONTROLLER_H + +// INCLUDES +#include +#include +#include // BT protocol wide types +#include "btrccVolumeLevelControllerBase.h" + +// FORWARD DECLARATIONS +class CRemConInterfaceSelector; +class CRemConCoreApiController; +class CBTRCCActive; + +// CLASS DECLARATION + + +NONSHARABLE_CLASS(CBTRCCLegacyVolumeLevelController) : + public CBTRCCVolumeLevelControllerBase, + public MRemConCoreApiControllerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * + */ + static CBTRCCLegacyVolumeLevelController* NewL(CRemConInterfaceSelector& aInterfaceSelector, MBTRCCVolumeControllerObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBTRCCLegacyVolumeLevelController(); + + private: + enum TState + { + EStateWaitingForVolumeLevelChanges, + EStateDelay, + EStateVolumeUpTiming, + EStateVolumeUp, + EStateVolumeDownTiming, + EStateVolumeDown, + }; + + /** + * C++ default constructor. + */ + CBTRCCLegacyVolumeLevelController(MBTRCCVolumeControllerObserver& aObserver); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(CRemConInterfaceSelector& aInterfaceSelector); + + /** + * Decides the next operation for volume controlling + */ + void DoRemoteControl(); + + /** + * Starts a timer. The timeout value is specified by aInterval + */ + void StartTimer(TInt aInterval); + + /** + * Send a volume up or down command decided by aDirection. + */ + void SendVolumeCommand(TInt aDirection); + + public: // From CBTRCCVolumeLevelControllerBase + void DoStart(TInt aInitialVolume); // Starts monitoring for volume level changes. + void DoStop(); // Stop monitoring for volume level changes. + void DoReset(); // Reset the volume level. + + public: // From MBTRCCActiveObserver + void RequestCompletedL(CBTRCCActive& aActive, TInt aErr); + void CancelRequest(TInt aServiceId); + + private: // From CBTRCCVolumeLevelControllerBase + void AdjustRemoteVolume(TInt aVolume); + TInt GetPhoneVolume(TInt &aVol); + + private: // From MRemConCoreApiControllerObserver + TInt MrccacoResponse(); + + private: // Data + CRemConCoreApiController* iRemConVolController; // changes the accessory's volume level. + + TUint iNumRemotes; + TState iState; + + TInt iPhoneVolume; // target volume level + TInt iCurrentPhoneVolume; // current volume level of phone + TInt iCurrentRemoteVolume; // current volume level of remote + TInt iLocalMaxVolume; // maximum volume level of phone + + // Active object for various timers and volume control operation. + CBTRCCActive *iBtrccLegacyVolumeActive; + + // Not owned + CRemConInterfaceSelector *iInterfaceSelector; + + RTimer iCtrlRTimer; + }; + +#endif // BTRCCLEGACYVOLUMELEVELCONTROLLER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccLinker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccLinker.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,330 @@ +/* +* Copyright (c) 2005-2006 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: State Machine of BTRCC +* +*/ + + +#ifndef BTRCCLINKER_H +#define BTRCCLINKER_H + + +// INCLUDES +#include +#include // BT protocol wide types +#include // pub-sub definitions +#include +#include +#include +#include + +#include "btrccVolumeLevelControllerBase.h" + +// DATA TYPES +enum TBTRCCStateIndex + { + EStateIndexIdle = 0, + EStateIndexConnecting, + EStateIndexConnected, + EStateIndexDisconnect + }; + +// FORWARD DECLARATIONS +class MBTAccObserver; +class CRemConInterfaceSelector; +class CRemConCoreApiController; +class CBTRCCVolumeLevelController; +class CRemConCoreApiTarget; +class CPlayerStarter; +class CBTRCCBrowsingAdapter; + +// CLASS DECLARATION + +/** +* The main controller for BT Remote Control Profile. Notifies BT Accessory Server +* about changes in remote contorl profile connections. Perform requests from BT Accessory +* Server to disconnect the accessory. +*/ +NONSHARABLE_CLASS(CBTRCCLinker) : public CActive, public MRemConBatteryTargetObserver, public MBTRCCVolumeControllerObserver + { + private: + /** + * The base class of state + */ + class TState + { + public: + + /** + * Entry of this state + * @param aStatus the client status, will be completed when this state should exit. + */ + virtual void Enter() = 0; + + /** + * Called by parent's DoCancel + * Cancels the outstanding operations in this state. + */ + virtual void DoCancel(); + + virtual void Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + virtual void CancelConnect(const TBTDevAddr& aAddr); + + /** + * Makes a request to disconnect the connection. + * @param aBdAddress BT device address of remote side + */ + virtual void Disconnect(TRequestStatus& aStatus, const TBTDevAddr& aAddr); + + /** + * This will be called whenever an async operation to RemCon FW completes. + */ + virtual void RemConRequestCompleted(TInt aErr); + + virtual void UpdateRemoteVolumeControling(TBool aActivated); + + protected: + + /** + * Default constructor + */ + TState(CBTRCCLinker& aParent); + + protected: + CBTRCCLinker& iParent; + }; + friend class TState; + + class TStateIdle : public TState + { + public: + + TStateIdle(CBTRCCLinker& aParent); + + void Enter(); + + void DoCancel(); + + void Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void RemConRequestCompleted(TInt aErr); + }; + friend class TStateIdle; + + class TStateConnecting : public TState + { + public: + + TStateConnecting(CBTRCCLinker& aParent); + + void Enter(); + + void DoCancel(); + + void CancelConnect(const TBTDevAddr& aAddr); + + void RemConRequestCompleted(TInt aErr); + + private: + TBool iConnectCanceled; + }; + friend class TStateConnecting; + + class TStateConnected : public TState + { + public: + TStateConnected(CBTRCCLinker& aParent); + + void Enter(); + + void DoCancel(); + + void Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void Disconnect(TRequestStatus& aStatus, const TBTDevAddr& aAddr); + + void RemConRequestCompleted(TInt aErr); + + void UpdateRemoteVolumeControling(TBool aActivated); + }; + friend class TStateConnected; + + class TStateDisconnect : public TState + { + public: + TStateDisconnect(CBTRCCLinker& aParent); + + void Enter(); + + void DoCancel(); + + void RemConRequestCompleted(TInt aErr); + }; + friend class TStateDisconnect; + + public: // Constructors and destructor + + /** + * Two-phased constructor. + * After construction the instance is ready to serve requests. + * Also starts listening to incoming connections from BT audio + * accessories. + */ + static CBTRCCLinker* NewL(MBTAccObserver& aAccObserver); + + /** + * Destructor. + * Removes service and security registrations and stops listening to + * incoming connections. + */ + virtual ~CBTRCCLinker(); + + void MrcbstoBatteryStatus(TControllerBatteryStatus& aBatteryStatus); + + public: // New functions + + void Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void CancelConnect(const TBTDevAddr& aAddr); + + /** + * DiSconnects from the currently connected BT audio accessory. + * @return None. + */ + void Disconnect(TRequestStatus& aStatus, const TBTDevAddr& aAddr); + + MBTAccObserver& AccObserver(); + + void ActivateRemoteVolumeControl(); + + void DeActivateRemoteVolumeControl(); + + public: // From MBTRCCVolumeControllerObserver + void VolumeControlError(TInt aError); + + private: // From CActive + + /** + * Gets called when the asynchronous control connection open operation + * completes. Informs the control connection observer about the + * connection. + * @param None. + * @return None. + */ + void RunL(); + + /** + * Gets called if RunL leaves + * @param None. + * @return None. + */ + TInt RunError(TInt aError); + + /** + * Cancels the ongoing control connection open operation and informs + * the control connection observer about that. + * @param None. + * @return None. + */ + void DoCancel(); + + + private: + + /** + * C++ default constructor. + */ + CBTRCCLinker(MBTAccObserver& aAccObserver); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + /** + * Connect the accessory. + */ + void DoConnect(); + + void DoSubscribeConnetionStatus(); + + void DoCancelSubscribe(); + + /** + * DiSconnects from the currently connected BT audio accessory. + * @return None. + */ + void DoDisconnect(); + + void ChangeState(TBTRCCStateIndex aNextState); + + /** + * Re-orient AVRCP bearer plugin to the remote for the current connect /disconnect request + */ + TInt DoRemConOrientation(); + + /** + * aConnectedAddr will hold the remote BD address if there is a connection. + * otherwise it is TBTDevAddr() + */ + void DoGetRemConConnectionStatus(RArray& aConnects); + + void StartRemoteVolumeControl(); + + void StopRemoteVolumeControl(); + + void ResetVolmeControlSetting(); + + private: // Data + + CRemConInterfaceSelector *iInterfaceSelector; + + // For receiving the accessory battery status + CRemConBatteryApiTarget *iRemConBatteryTgt; + + CRemConCoreApiTarget* iCoreTarget; // not own + + CPlayerStarter* iPlayerStarter; // owned + + // For handling the browsing commands. + CBTRCCBrowsingAdapter *iBrowsingAdapter; + + // This is only needed for disconnecting a AVRCP connection + // when AVRCP Remote Volume Control is not supported. + CRemConInterfaceSelector *iInterfaceSelectorForDisconnectingTargetSession; + + TBTDevAddr iRemoteAddr; + + MBTAccObserver& iAccObserver; + + RPointerArray iStateArray; // Array of all states in BTRCC + TBTRCCStateIndex iCurrentStateIndex; // Index of current state + + TRequestStatus* iClientRequest; + TBool iRemConOriented; + + TBool iRvcActivated; + + CBTRCCVolumeLevelControllerBase* iVolController; + CBTRCCVolumeLevelControllerBase* iAbsoluteVolController; + CBTRCCVolumeLevelControllerBase* iLegacyVolController; + + TInt iRegisterVolumeChangeNotificationCounter;//Counter for re-register for remote volume control notification +}; + + +#endif // BTRCCLINKER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccPlugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2005-2006 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: BT Remote Control Controller class declaration. +* +*/ + + +#ifndef BTRCCPLUGIN_H +#define BTRCCPLUGIN_H + +// INCLUDES +#include +#include +#include + + +// Implement Interface provided by 'BT Accessory Server' component. E-com framework +// uses this interface to load this plugin +#include + +// FORWARD DECLARATIONS +class CBTRCCLinker; + +// CLASS DECLARATION + +/** +* The main controller for BT audio. Maintains e.g. the internal state of the +* Symbian side BT audio system and controls the serving of requests received +* both from the Symbian side and the DOS side of the system. +*/ +NONSHARABLE_CLASS(CBTRCCPlugin) + : public CBTAccPlugin + { + + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTRCCPlugin* NewL(TPluginParams& aParams); + + /** + * Destructor. + */ + ~CBTRCCPlugin(); + + private: // Functions from CBTAccPlugin + + void ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + void CancelConnectToAccessory(const TBTDevAddr& aAddr); + + /** + * Called by BT Acc Sever to disconnect from mono or stereo accessory + * @param aAddr Bluetooth Device address of the remote device + */ + virtual void DisconnectAccessory(const TBTDevAddr& aAddr,TRequestStatus& aStatus); + + /** + * BT Acc Server checks the type of this plugin + @return TProfiles Type of this plugin + */ + virtual TProfiles PluginType(); + + /** + * Called by BT Acc Sever to inform plugin that accessory is in use. + */ + virtual void AccInUse(); + + void ActivateRemoteVolumeControl(); + + void DeActivateRemoteVolumeControl(); + + private: + + /** + * C++ default constructor. + * @param aParms T-class used for call-back to BT Acc Server + */ + CBTRCCPlugin(TPluginParams& aParams); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + private: // Data + + CBTRCCLinker* iLinker; // owned; Pointer to the linker class + }; + + +#endif // BTRCCPLUGIN_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccPluginImplUid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccPluginImplUid.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2005-2006 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: Implementation Uid of BTRCC +* +*/ + +#ifndef BTRCC_PLUGIN_IMPL_UID_H +#define BTRCC_PLUGIN_IMPL_UID_H + + +#define KBTRCCPluginImplUid 0x10208979 + +#endif // BTRCC_PLUGIN_IMPL_UID_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccVolumeLevelControllerBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccVolumeLevelControllerBase.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2005-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: The base class for volume control of AVRCP Controller. +* +* +*/ + +#ifndef BTRCCVOLUMELEVELCONTROLLERBASE_H +#define BTRCCVOLUMELEVELCONTROLLERBASE_H + +// INCLUDES +#include +#include +#include // BT protocol wide types +#include +#include "btrccActive.h" + +// FORWARD DECLARATIONS +class CRemConInterfaceSelector; +class CRemConCoreApiController; + +// CLASS DECLARATION + +NONSHARABLE_CLASS(MBTRCCVolumeControllerObserver) + { + public: + virtual void VolumeControlError(TInt aError) = 0; + }; + +/*! + error code return by controller + */ +enum TBTRccControllerError + { + EVolumeAdjustmentFailed = 0, /*!< Adjust remote volume failed */ + ERegisterNotificationsFailed /*!< Register volume change notifications failed */ + }; +/** +* A listener for incoming handsfree attachments/detachments. +*/ +NONSHARABLE_CLASS(CBTRCCVolumeLevelControllerBase) : public CBase, public MBTRCCActiveObserver + { + public: // Constructors and destructor + + /** + * Destructor. + */ + virtual ~CBTRCCVolumeLevelControllerBase(); + + protected: + /** + * C++ default constructor. + */ + CBTRCCVolumeLevelControllerBase(MBTRCCVolumeControllerObserver &aObserver); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + public: + enum TVolControlState + { + ESubscribePhoneVolume, + ESetPhoneVolume + }; + + public: // From CBTRCCActiveObserver + virtual void RequestCompletedL(CBTRCCActive& aActive, TInt aErr); + + virtual void CancelRequest(TInt aServiceId); + + public: // New methods + + void Start(); // Starts monitoring for volume level changes. + + void Stop(); // Stop monitoring for volume level changes. + + void Reset(); // Reset the volume level. + + TInt GetLocalMaxVolume(); + + TInt GetCurrentLocalVolume(); + + void AccessoryChangedVolume(TInt aVolumeInPhoneScale); + + virtual void DoStart(TInt aInitialVolume) = 0; // Starts monitoring for volume level changes. + + virtual void DoStop() = 0; // Stop monitoring for volume level changes. + + virtual void DoReset() = 0; // Reset the volume level. + + virtual void VolumeControlError(TInt aError); + + virtual void RegisterVolumeChangeNotification(); + + private: + void SetPhoneVolume(); + + private: // New methods + + /** + * To be implemented by the specialization class. + */ + virtual void AdjustRemoteVolume(TInt aVolume) = 0; + + protected: + virtual TInt GetPhoneVolume(TInt &aVol); + + private: // Data + RProperty iVolLevelProperty; // owned + RProperty iVolKeyEventProperty; // owned + + // This active object listens to the PS key changes. + // Specialization classes may add more active objects if they need. + // Hence the ID in the CBTRCCActive. + CBTRCCActive *iBtrccActive; + + MBTRCCVolumeControllerObserver &iObserver; + + TInt iLocalMaxVolume; + TInt iPhoneVolume; + TInt iRemoteVolume; + + TVolControlState iState; + }; + +#endif // BTRCCVOLUMELEVELCONTROLLERBASE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2008 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: This class implements starting Music play +* +* +*/ + + +#ifndef BTRCCPLAYERSTATER_H +#define BTRCCPLAYERSTATER_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class CRemConCoreApiTarget; + +/** +* This class listens to AVRCP PLAY command by headset,if music player is not running +* when such a command is received, it will be launched and requested to start playing. +* */ +NONSHARABLE_CLASS(CPlayerStarter) : + public CActive, public MRemConCoreApiTargetObserver + { + +public: + + /** + * Two-phased constructor. + * + */ + static CPlayerStarter* NewL(); + + /** + * Set the reference for AVRCP Core API command receiving and + * responses to those command. + */ + void SetCoreTarget(CRemConCoreApiTarget& aTarget); + + /** + * Destructor. + */ + ~CPlayerStarter(); + +private: // From CActive + + /** + * Informs the observer that an accessory has created a control + * connection to our device. + * @param None. + * @return None. + */ + void RunL(); + + /** + * Handles a possible leave from RunL(). + * @param aError The leave code from RunL(). + * @return KErrNone. + */ + TInt RunError(TInt aError); + + /** + * Cancels the volume change operation. + * @param None. + * @return None. + */ + void DoCancel(); + + // from base class MRemConCoreApiTargetObserver + + /** + * From MRemConCoreApiTargetObserver + * A 'play' command has been received. + * + * @param aSpeed The playback speed. + * @param aButtonAct The button action associated with the command. + */ + void MrccatoPlay( + TRemConCoreApiPlaybackSpeed aSpeed, + TRemConCoreApiButtonAction aButtonAct ); + + /** + * From MRemConCoreApiTargetObserver + * A command has been received. + * + * @param aOperationId The operation ID of the command. + * @param aButtonAct The button action associated with the command. + */ + void MrccatoCommand( + TRemConCoreApiOperationId aOperationId, + TRemConCoreApiButtonAction aButtonAct ); + +private: + + /** + * C++ default constructor. + */ + CPlayerStarter(); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + /** + * Start music player if it is not running yet. + */ + void StartPlayIfNeeded(); + + /** + * Tells if MPX music player is running or not. + */ + TBool IsMusicPlayerRunning(); + + /** + * Launch MPX player. + */ + void LaunchMusicPlayerL(); + +private: + enum TOpState + { + EIdle = 0, + ERespondPlayOk , // responding OK to play command is outstanding + ERespondPlayNok, // responding NOT OK to play command is outstanding + EPlayMusicTiming, // scheduling internal PLAY command to player + }; + +private: // Data + + CRemConCoreApiTarget* iCoreTarget; // not own + + RTimer iTimer; + + TOpState iState; + }; + +#endif // BTRCCACLLINKLISTENER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/config/prj_urel_config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/config/prj_urel_config.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2006 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: Debug configure file. +* +*/ + + +#ifndef DEBUGCONFIG_H +#define DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ + + // BT Remote Controller panic codes +enum TBTRCCPanicCode + { + EBtrccPanicNullPointer = 33300, + EBtrccPanicPointerExists, + EBtrccPanicAOIsActive, + EBtrccPanicUnexpectedRemote, // the given remote BD address not matched + EBtrccPanicUnhandledCase, + EBtrccPanicAvrcpVolCTNotSupported, + EBtrccPanicOutOfRangeState, + }; + +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btrcc.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTRCC] "); +_LIT8(KTracePrefix8, "[BTRCC] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTRCC"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccAbsoluteVolumeLevelController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccAbsoluteVolumeLevelController.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,272 @@ +/* +* Copyright (c) 2005-2006 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: This class listens to notification coming from Remote Control framework. +* BTRCC is interested in only those of initiated by BT Remote Control Plugin. +* +*/ + + +// INCLUDE FILES +#include // KRemConBearerAvrcpImplementationUid = 0x1020685f +#include +#include +#include + +#include "btrccAbsoluteVolumeLevelController.h" +#include "debug.h" + +const TInt KAbsoluteVolumeLevelSetServiceId = 0x02; +const TInt KMaxRetries = 3; + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCAbsoluteVolumeLevelController* CBTRCCAbsoluteVolumeLevelController::NewL(CRemConInterfaceSelector& aInterfaceSelector, MBTRCCVolumeControllerObserver& aObserver) + { + CBTRCCAbsoluteVolumeLevelController* self = new (ELeave) CBTRCCAbsoluteVolumeLevelController(aObserver); + CleanupStack::PushL(self); + self->ConstructL(aInterfaceSelector); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::CBTRCCAbsoluteVolumeLevelController +// C++ constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCAbsoluteVolumeLevelController::CBTRCCAbsoluteVolumeLevelController(MBTRCCVolumeControllerObserver& aObserver) +: CBTRCCVolumeLevelControllerBase(aObserver) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::ConstructL(CRemConInterfaceSelector& aInterfaceSelector) + { + TRACE_FUNC + CBTRCCVolumeLevelControllerBase::ConstructL(); + iLocalMaxVolume = GetLocalMaxVolume(); + iInterfaceSelector = &aInterfaceSelector; + + iRemConAbsoluteVolumeController = CRemConAbsoluteVolumeController::NewL(aInterfaceSelector, + *this, + iLocalMaxVolume); + TRACE_INFO((_L("CRemConAbsoluteVolumeController created"))) + iBtrccAbsoluteVolumeActive = CBTRCCActive::NewL(*this, KAbsoluteVolumeLevelSetServiceId); + TRACE_INFO((_L("CBTRCCActive created"))) + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTRCCAbsoluteVolumeLevelController::~CBTRCCAbsoluteVolumeLevelController() + { + TRACE_FUNC + delete iBtrccAbsoluteVolumeActive; + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::DoStart +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::DoStart(TInt aInitialVolume) + { + TRACE_FUNC + AdjustRemoteVolume(aInitialVolume); + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::DoStop +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::DoStop() + { + TRACE_FUNC + iRemConAbsoluteVolumeController->CancelAbsoluteVolumeNotification(); + iRemConAbsoluteVolumeController->CancelSetAbsoluteVolume(); + iBtrccAbsoluteVolumeActive->Cancel(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::DoReset +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::DoReset() + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::AdjustRemoteVolume +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::AdjustRemoteVolume(TInt aVolume) + { + TRACE_INFO((_L("Setting volume to %d"), aVolume)) + + if(iBtrccAbsoluteVolumeActive->IsActive()) + { + iRemConAbsoluteVolumeController->CancelSetAbsoluteVolume(); + iBtrccAbsoluteVolumeActive->Cancel(); + } + + //Try to register volume change notification + RegisterVolumeChangeNotification(); + + // iNumRemotes is not needed by us, but the method requires it. + iRemConAbsoluteVolumeController->SetAbsoluteVolume(iBtrccAbsoluteVolumeActive->iStatus, + aVolume, iNumRemotes); + iBtrccAbsoluteVolumeActive->GoActive(); + } + + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::RegisterVolumeChangeNotification +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::RegisterVolumeChangeNotification() + { + + iRemConAbsoluteVolumeController->CancelAbsoluteVolumeNotification(); + iRemConAbsoluteVolumeController->RegisterAbsoluteVolumeNotification(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::GetPhoneVolume +// ----------------------------------------------------------------------------- +// +TInt CBTRCCAbsoluteVolumeLevelController::GetPhoneVolume(TInt &aVol) + { + TRACE_FUNC + return CBTRCCVolumeLevelControllerBase::GetPhoneVolume(aVol); + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::RequestCompletedL(CBTRCCActive& aActive, TInt aErr) + { + TRACE_FUNC + if( aActive.ServiceId() != KAbsoluteVolumeLevelSetServiceId ) + { + // This is something the base class can handle. + CBTRCCVolumeLevelControllerBase::RequestCompletedL(aActive, aErr); + } + else if(aErr && iRetryCounter < KMaxRetries) // else it is KAbsoluteVolumeLevelSetServiceId + { + TRACE_INFO((_L("Sending abs vol cmd failed with error %d"), aErr)) + iRetryCounter++; + AdjustRemoteVolume(GetCurrentLocalVolume()); + } + else + { + if(iRetryCounter >= KMaxRetries) + { + VolumeControlError(EVolumeAdjustmentFailed); + } + iRetryCounter = 0; + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::CancelRequest(TInt aServiceId) + { + TRACE_FUNC + if( aServiceId != KAbsoluteVolumeLevelSetServiceId ) + { + // This is something the base class can handle. + CBTRCCVolumeLevelControllerBase::CancelRequest(aServiceId); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::MrcavcoCurrentVolume +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::MrcavcoCurrentVolume(TUint32 aVolume, + TUint32 aMaxVolume, + TInt aError) + { + TRACE_FUNC + AccessoryChangedVolume(aVolume, aMaxVolume, aError); + /*if(aError != KErrNone) + { + // Register again to the notifications. + iRemConAbsoluteVolumeController->RegisterAbsoluteVolumeNotification(); + }*/ + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::MrcavcoSetAbsoluteVolumeResponse +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::MrcavcoSetAbsoluteVolumeResponse(TUint32 aVolume, + TUint32 aMaxVolume, + TInt aError) + { + TRACE_FUNC + TRACE_INFO((_L("Accessory volume is %d / %d"), aVolume, aMaxVolume)) + AccessoryChangedVolume(aVolume, aMaxVolume, aError); + } + +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::MrcavcoAbsoluteVolumeNotificationError +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::MrcavcoAbsoluteVolumeNotificationError() + { + TRACE_FUNC + // This is called when there's some error with writing the commands. + // It means that we can't send notifications or responses to those, so + // it's better to stop volume controlling and reset the link. + VolumeControlError(ERegisterNotificationsFailed); + } +// ----------------------------------------------------------------------------- +// CBTRCCAbsoluteVolumeLevelController::AccessoryChangedVolume +// ----------------------------------------------------------------------------- +// +void CBTRCCAbsoluteVolumeLevelController::AccessoryChangedVolume(TUint32 aVolume, TUint32 aMaxVolume, TInt aError) + { + TRACE_FUNC + TRACE_INFO((_L("Accessory volume is %d / %d"), aVolume, aMaxVolume)) + if( ValidVolumeParams(aVolume, aMaxVolume) && (aError == KErrNone) ) + { + // Convert volume scale to phone's volume scale. (User reals and round in the end.) + TInt volumeInPhoneScale = (TReal)aVolume * ((TReal)iLocalMaxVolume / (TReal)aMaxVolume) + 0.5; + ASSERT(volumeInPhoneScale <= iLocalMaxVolume); + TRACE_INFO((_L("Volume in phone scale is %d"), volumeInPhoneScale)) + CBTRCCVolumeLevelControllerBase::AccessoryChangedVolume(volumeInPhoneScale); + } + } + +TBool CBTRCCAbsoluteVolumeLevelController::ValidVolumeParams(TUint32 aVolume, TUint32 aMaxVolume) + { + return (( aMaxVolume > 0 ) && (aVolume <= aMaxVolume)); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccActive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccActive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 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: General Active Object offering asynchronous service +* +*/ + + +#include "btrccActive.h" +#include "debug.h" + + +// ----------------------------------------------------------------------------- +// CBTRCCActive::NewL +// ----------------------------------------------------------------------------- +CBTRCCActive* CBTRCCActive::NewL(MBTRCCActiveObserver& aObserver, + TInt aServiceId, CActive::TPriority aPriority) + { + CBTRCCActive* self = CBTRCCActive::NewLC(aObserver, aServiceId, aPriority); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTRCCActive::NewLC +// ----------------------------------------------------------------------------- +CBTRCCActive* CBTRCCActive::NewLC(MBTRCCActiveObserver& aObserver, + TInt aServiceId, CActive::TPriority aPriority) + { + CBTRCCActive* self = new (ELeave) CBTRCCActive(aObserver, aServiceId, aPriority); + CleanupStack::PushL(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTRCCActive::~CBTRCCActive +// ----------------------------------------------------------------------------- +CBTRCCActive::~CBTRCCActive() + { + Cancel(); + TRACE_FUNC + } + +// ------------------------------------------------------------------------------- +// CBTRCCActive::GoActive +// ------------------------------------------------------------------------------- +void CBTRCCActive::GoActive() + { + TRACE_ASSERT(!IsActive(), KErrGeneral); + SetActive(); + TRACE_FUNC + } + +TInt CBTRCCActive::ServiceId() const + { + return iServiceId; + } + +void CBTRCCActive::SetServiceId(TInt aServiceId) + { + iServiceId = aServiceId; + } + +// ------------------------------------------------------------------------------- +// CBTRCCActive::RunL +// ------------------------------------------------------------------------------- +void CBTRCCActive::RunL() + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("Completed service %d, status %d"), iServiceId, iStatus.Int())) + iObserver.RequestCompletedL(*this, iStatus.Int()); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBTRCCActive::DoCancel +// ------------------------------------------------------------------------------- +void CBTRCCActive::DoCancel() + { + TRACE_INFO((_L("DoCancel service %d"), iServiceId)) + iObserver.CancelRequest(iServiceId); + } + +// ----------------------------------------------------------------------------- +// CBTRCCActive::CBTRCCActive +// ----------------------------------------------------------------------------- +CBTRCCActive::CBTRCCActive(MBTRCCActiveObserver& aObserver, + TInt aServiceId, CActive::TPriority aPriority) + : CActive(aPriority), iObserver(aObserver), iServiceId(aServiceId) + { + CActiveScheduler::Add(this); + TRACE_FUNC + } + +MBTRCCActiveObserver& CBTRCCActive::Observer() + { + return iObserver; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccBrowsingAdapter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccBrowsingAdapter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,548 @@ +/* +* Copyright (c) 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: Browsing adapter between RemCon an MPX Framework. +* +*/ + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "btrccBrowsingAdapter.h" +#include "debug.h" + +#ifdef BTRCCTEST_MPXCOLLECTIONSTUB +#include +#endif + + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCBrowsingAdapter* CBTRCCBrowsingAdapter::NewL(CRemConInterfaceSelector& aInterfaceSelector) + { + CBTRCCBrowsingAdapter* self = new (ELeave) CBTRCCBrowsingAdapter(); + CleanupStack::PushL(self); + self->ConstructL(aInterfaceSelector); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::CBTRCCBrowsingAdapter +// C++ constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCBrowsingAdapter::CBTRCCBrowsingAdapter() + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::ConstructL(CRemConInterfaceSelector& aInterfaceSelector) + { + TRACE_FUNC + iMediaBrowseTarget = CRemConDatabaseAwareMediaBrowseTarget::NewL( + aInterfaceSelector, *this, *this, EFalse, + iMlInterface, iNpInterface, iCookie); + +#ifdef BTRCCTEST_MPXCOLLECTIONSTUB + iCollectionUtility = CMPXCollectionUtilityStubImpl::NewL(this, KMcModeDefault); +#else + iCollectionUtility = MMPXCollectionUtility::NewL(this, KMcModeDefault); +#endif + + iCurrentOpenLOp = EOpenLOpOpen; + iCollectionUtility->Collection().OpenL(EMPXOpenDefault); + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTRCCBrowsingAdapter::~CBTRCCBrowsingAdapter() + { + TRACE_FUNC + delete iMediaBrowseTarget; + delete iCollectionUtility; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdamlboGetFolderListing +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::MrcdamlboGetFolderListing(TRemConFolderScope aScope, + TUint /*aStartItem*/, TUint /*aEndItem*/) + { + TRACE_FUNC + + // Check that the aScope is in filesystem scope. + if (aScope != EBrowseFolder) + { + // Not supported. + return; + } + + // ToDo: Check that we don't have any other operation ongoing. + // If we do, put the new operation in queue + + TInt err = KErrNone; + CMPXCollectionPath* path = NULL; + TRAP(err, path = iCollectionUtility->Collection().PathL()) + + if(!err) + { + TRAP(err, path->SelectAllL()) + } + if(!err) + { + RArray attrs; + attrs.Append( KMPXMediaGeneralId ); + attrs.Append( KMPXMediaGeneralTitle ); + TRAP(err, iCollectionUtility->Collection().MediaL(*path, attrs.Array())) + } + if(!err) + { + iCurrentMediaLOp = EMediaLOpFolderListing; + } + TRACE_INFO((_L("Get folder listing %d"), err)) + + +/* CMPXCollectionPath* path = iCollectionUtility->Collection().PathL(); + CleanupStack::PushL( path ); + if ( path->Levels() == KVcxMpxLevelVideos + && path->Count() > aIndex + && aIndex >= 0 ) + { + // Marks the item that will be handled + path->SelectL( aIndex ); + + RArray dummy; // No need to set this parameter + CleanupClosePushL( dummy ); + iCollectionUtility->Collection().MediaL( *path, dummy.Array() ); + CleanupStack::PopAndDestroy( &dummy ); + } + CleanupStack::PopAndDestroy( path ); */ + + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdamlboGetItem +// This function is called to request for indicidual item's properties. +// ----------------------------------------------------------------------------- +// +TInt CBTRCCBrowsingAdapter::MrcdamlboGetItem(TRemConFolderScope /*aScope*/, + const TRemConItemUid& /*aItemId*/, + TMediaAttributeIter& /*aIter*/, + TUint16 /*aMediaLibraryStateCookie*/) + { + TRACE_FUNC + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdamlboFolderUp +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::MrcdamlboFolderUp(TUint16 aMediaLibraryStateCookie) + { + TRACE_FUNC + if(aMediaLibraryStateCookie == iCookie) + { + TRAPD( err, iCollectionUtility->Collection().BackL() ); + if(err) + { + } + // --> HandleOpenL will called + } + else + { + + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdamlboFolderDown +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::MrcdamlboFolderDown(const TRemConItemUid& aFolder, + TUint16 aMediaLibraryStateCookie) + { + TRACE_FUNC + if(aMediaLibraryStateCookie == iCookie) + { + TInt err = KErrNone; + CMPXCollectionPath* path = NULL; + TRAP( err, path = iCollectionUtility->Collection().PathL() ); + if(!err) + { + TMPXItemId index = path->IdOfIndex((TInt)aFolder); + if(index != KMPXInvalidItemId) + { + TRAP( err, iCollectionUtility->Collection().OpenL(index) ); + // --> HandleOpenL will called. + } + } + } + else + { + + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdamlboGetPath +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::MrcdamlboGetPath(RPointerArray& /*aPath*/) + { + TRACE_FUNC + TInt err = KErrNone; + CMPXCollectionPath* browsePath = NULL; + CMPXCollectionPath* container = NULL; + + TRAP( err, browsePath = iCollectionUtility->Collection().PathL() ); + + // Split path into levels until root level is reached. + TRAP( err, container = browsePath->ContainerPathL() ); + + // Store the path information into received refToPath. + // --> do something + + // Path information stored, inform RemCon + //iMlInterface->MrcdamlbGetPathResult(TUint aItemCount, TUint16 aMediaLibraryStateCookie, TInt aResult); + + delete browsePath; + delete container; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdanpboGetFolderListing +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::MrcdanpboGetFolderListing(TUint /*aStartItem*/, TUint /*aEndItem*/) + { + TRACE_FUNC + // Use the current path to +// iCollectionUtility->Collection().MediaL(path, aAttrs, ) + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdanpboGetItem +// ----------------------------------------------------------------------------- +// +TInt CBTRCCBrowsingAdapter::MrcdanpboGetItem(const TRemConItemUid& /*aItemId*/, TMediaAttributeIter& /*aIter*/, TUint16 /*aMediaLibraryStateCookie*/) + { + TRACE_FUNC + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::MrcdamlboSearch +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::MrcdamlboSearch(const TDesC8& /*aSearch*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::HandleCollectionMessage +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::HandleCollectionMessage(CMPXMessage* aMsg, TInt /*aErr*/) + { + TRACE_FUNC + if(iMlInterface && aMsg) + { + if( aMsg->IsSupported(KMPXMessageMediaGeneralCategory) && + aMsg->IsSupported(KMPXMessageChangeEventType) ) + { + TInt event( aMsg->ValueTObjectL( KMPXMessageMediaGeneralCategory ) ); + TInt op( aMsg->ValueTObjectL( KMPXMessageChangeEventType ) ); + + if( event == EMPXCollection ) + { + if( op == EMPXItemDeleted || + op == EMPXItemInserted || + op == EMPXItemModified ) + { + // how cookie is really composed?? + iCookie = op; + iMlInterface->MrcdamlbMediaLibraryStateChange(iCookie); + } + } + } + } + + /* Example from mpxdeletehelper.cpp + if( aMessage && + aMessage->IsSupported(KMPXMessageGeneralEvent) && + aMessage->IsSupported(KMPXMessageGeneralType) ) + { + TInt event( aMessage->ValueTObjectL( KMPXMessageGeneralEvent ) ); + TInt op( aMessage->ValueTObjectL( KMPXMessageGeneralType ) ); + + MPX_DEBUG3( "CMPXDeleteHelper::HandleCollectionMessageL event = %d, type = %d", + event, op ); + + if( event == TMPXCollectionMessage::EBroadcastEvent ) + { + if( op == EMcMsgFormatStart || + op == EMcMsgDiskRemoved || + op == EMcMsgUSBMassStorageStart || + op == EMcMsgUSBMTPStart ) + { + iCancelled = ETrue; + Cancel(); + } + } + + }*/ + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::HandleOpenL +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::HandleOpenL(const CMPXMedia& /*aEntries*/, TInt /*aIndex*/, TBool /*aComplete*/, TInt aError) + { + // This is called when a folder has been opened. We could store a path here. + TRACE_FUNC + if(!aError) + { + switch(iCurrentOpenLOp) + { + case EOpenLOpOpen: + break; + default: + break; + } + } + iCurrentOpenLOp = EOpenLOpIdle; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::HandleOpenL +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/,TInt /*aError*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::HandleCommandComplete +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::HandleCommandComplete(CMPXCommand* /*aCommandResult*/, TInt /*aError*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::HandleCollectionMediaL +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::HandleCollectionMediaL(const CMPXMedia& aMedia, TInt aError) + { + TRACE_FUNC + RArray folderListing; + TInt cookie = 0; + if(!aError) + { + switch(iCurrentMediaLOp) + { + case EMediaLOpFolderListing: + { + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, EMediaLOpFolderListing"))) + + TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer, EMPXMediaArrayContents ); + // Check if there is more than one item in aMedia + if( aMedia.IsSupported( mediaArrayAttr ) ) + { + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, media array is supported."))) + const CMPXMediaArray* mediaArray = aMedia.ValueCObjectL( mediaArrayAttr ); + //User::LeaveIfNull( const_cast( mediaArray )); + + TInt error = KErrNone; + if(mediaArray) + { + for(TInt i = 0; i < mediaArray->Count() ; ++i) + { + CMPXMedia* ptrToElement = mediaArray->AtL(i); + TMPXAttribute uidAttr(KMPXMediaIdGeneral, EMPXMediaGeneralId); + TMPXAttribute typeAttr(KMPXMediaIdGeneral, EMPXMediaGeneralType); + if( ptrToElement->IsSupported(uidAttr) && ptrToElement->IsSupported(typeAttr) ) + { + TRemConItem item; + const TUid& id = ptrToElement->ValueTObjectL(uidAttr); + item.iUid = id.iUid; + const TMPXGeneralType& type = ptrToElement->ValueTObjectL(typeAttr); + + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, id %d"), id)) + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, type %d"), type)) + + if(type == EMPXGroup) + { + item.iType = ERemConFolderItem; + } + else if(type == EMPXItem) + { + item.iType = ERemConMediaItem; + } + else + { + continue; // skip appending if the type wasn't folder or item. + } + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, Append data"))) + folderListing.Append(item); + } + else + { + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, Not supported, item index %d."), i)) + } + } + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, pass media to RemCon"))) + + } + else + { + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, No media!"))) + error = KErrMediaBrowseInvalidOffset; + } + iMlInterface->MrcdamlbFolderListing(folderListing.Array(), cookie, error); + } + else + { + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, Array Content Not Supported."))) + // "Single" elements should handled separately ?? + } + } + break; + } + } + else + { + TRACE_INFO((_L("CBTRCCBrowsingAdapter::HandleCollectionMediaL, error %d"), aError)) + iMlInterface->MrcdamlbFolderListing(folderListing.Array(), cookie, aError); + //HandleErrorL(aError); + } + folderListing.Close(); + iCurrentMediaLOp = EMediaLOpIdle; + } + +// ----------------------------------------------------------------------------- +// CBTRCCBrowsingAdapter::SubscribeL +// ----------------------------------------------------------------------------- +// +void CBTRCCBrowsingAdapter::SubscribeL() + { + TRACE_FUNC + // Create subscription items + CMPXSubscription* subscription( CMPXSubscription::NewL() ); + CleanupStack::PushL( subscription ); + + CMPXSubscriptionItem* subItem1( CMPXSubscriptionItem::NewL() ); + CleanupStack::PushL( subItem1 ); + + subItem1->SetTObjectValueL( KMPXMessageCollectionId, KMPXMessageGeneral ); + subItem1->SetTObjectValueL( KMPXMessageMediaGeneralCategory, EMPXCollection ); + subItem1->SetTObjectValueL( KMPXMessageChangeEventType, EMPXItemDeleted ); + subscription->AddItemL( *subItem1 ); + + CMPXSubscriptionItem* subItem2( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem2 ); + subItem2->SetTObjectValueL( KMPXMessageChangeEventType, EMPXItemInserted ); + subscription->AddItemL( *subItem2 ); + + CMPXSubscriptionItem* subItem3( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem3 ); + subItem3->SetTObjectValueL( KMPXMessageChangeEventType, EMPXItemModified ); + subscription->AddItemL( *subItem3 ); + + iCollectionUtility->Collection().AddSubscriptionL( *subscription ); + + CleanupStack::PopAndDestroy( subItem3 ); + CleanupStack::PopAndDestroy( subItem2 ); + CleanupStack::PopAndDestroy( subItem1 ); + CleanupStack::PopAndDestroy( subscription ); + + /* Example + // Subscribe to only a few messages from collection utility + subItem1->SetTObjectValueL( KMPXMessageGeneralId, KMPXMessageGeneral ); + subItem1->SetTObjectValueL( KMPXMessageGeneralEvent, TMPXCollectionMessage::EBroadcastEvent ); + subItem1->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgDiskRemoved ); + subscription->AddItemL( *subItem1 ); + + CMPXSubscriptionItem* subItem2( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem2 ); + subItem2->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgUSBMassStorageStart ); + subscription->AddItemL( *subItem2 ); + CMPXSubscriptionItem* subItem3( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem3 ); + subItem3->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgUSBMTPStart ); + subscription->AddItemL( *subItem3 ); + CMPXSubscriptionItem* subItem4( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem4 ); + subItem4->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgFormatStart ); + subscription->AddItemL( *subItem4 ); + CMPXSubscriptionItem* subItem5( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem5 ); + subItem5->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgUSBMassStorageEnd ); + subscription->AddItemL( *subItem5 ); + CMPXSubscriptionItem* subItem6( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem6 ); + subItem6->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgUSBMTPEnd ); + subscription->AddItemL( *subItem6 ); + CMPXSubscriptionItem* subItem7( CMPXSubscriptionItem::CopyL( *subItem1 )); + CleanupStack::PushL( subItem7 ); + subItem7->SetTObjectValueL( KMPXMessageGeneralType, EMcMsgFormatEnd ); + subscription->AddItemL( *subItem7 ); + CMPXSubscriptionItem* subItem8( CMPXSubscriptionItem::NewL() ); + CleanupStack::PushL( subItem8 ); + subItem8->SetTObjectValueL( KMPXMessageGeneralId, KMPXMessageGeneral ); + subItem8->SetTObjectValueL( KMPXMessageGeneralEvent, TMPXCollectionMessage::EPathChanged ); + subItem8->SetTObjectValueL( KMPXMessageGeneralType, EMcPathChangedByOpen ); + subItem8->SetTObjectValueL( KMPXMessageGeneralData, EMcItemOpened ); + subscription->AddItemL( *subItem8 ); + iCollectionUtility->Collection().AddSubscriptionL( *subscription ); + CleanupStack::PopAndDestroy( subItem8 ); + CleanupStack::PopAndDestroy( subItem7 ); + CleanupStack::PopAndDestroy( subItem6 ); + CleanupStack::PopAndDestroy( subItem5 ); + CleanupStack::PopAndDestroy( subItem4 ); + CleanupStack::PopAndDestroy( subItem3 ); + CleanupStack::PopAndDestroy( subItem2 ); + CleanupStack::PopAndDestroy( subItem1 ); + CleanupStack::PopAndDestroy( subscription ); */ + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccLegacyVolumeLevelController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccLegacyVolumeLevelController.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,411 @@ +/* +* Copyright (c) 2005-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: This class implements legacy volume control of AVRCP Controller. +* +* +*/ + +// INCLUDE FILES +#include // KRemConBearerAvrcpImplementationUid = 0x1020685f +#include +#include +#include +#include +#include + +#include "btrccLegacyVolumeLevelController.h" +#include "debug.h" + +const TInt KVolumeNotSynchronized = -1; +const TInt KLegacyVolumeLevelSetServiceId = 0x03; + +const TInt KVolumeSyncRecheckTimer = 500000; // 0.5 second +const TInt KVolumeCommandInterval = 50000; // 0.05 second + +const TInt KVolumeScaleMax = 15; + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCLegacyVolumeLevelController* CBTRCCLegacyVolumeLevelController::NewL(CRemConInterfaceSelector& aInterfaceSelector, MBTRCCVolumeControllerObserver& aObserver) + { + CBTRCCLegacyVolumeLevelController* self = new (ELeave) CBTRCCLegacyVolumeLevelController(aObserver); + CleanupStack::PushL(self); + self->ConstructL(aInterfaceSelector); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::CBTRCCVolumeLevelController +// C++ constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCLegacyVolumeLevelController::CBTRCCLegacyVolumeLevelController(MBTRCCVolumeControllerObserver& aObserver) + : CBTRCCVolumeLevelControllerBase(aObserver), iState(EStateWaitingForVolumeLevelChanges), iPhoneVolume(KVolumeNotSynchronized), + iCurrentPhoneVolume(KVolumeNotSynchronized), iCurrentRemoteVolume(KVolumeNotSynchronized) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::ConstructL(CRemConInterfaceSelector& aInterfaceSelector) + { + TRACE_FUNC + CBTRCCVolumeLevelControllerBase::ConstructL(); + iInterfaceSelector = &aInterfaceSelector; + iRemConVolController = CRemConCoreApiController::NewL(aInterfaceSelector, *this); + TRACE_INFO((_L("CRemConCoreApiController created"))) + iBtrccLegacyVolumeActive = CBTRCCActive::NewL(*this, KLegacyVolumeLevelSetServiceId); + TRACE_INFO((_L("CBTRCCActive created"))) + iCtrlRTimer.CreateLocal(); + TRACE_INFO((_L("RTimer created"))) + iLocalMaxVolume = GetLocalMaxVolume(); + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTRCCLegacyVolumeLevelController::~CBTRCCLegacyVolumeLevelController() + { + TRACE_FUNC + delete iBtrccLegacyVolumeActive; + iCtrlRTimer.Close(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::DoStart +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::DoStart(TInt aInitialVolume) + { + TRACE_FUNC + AdjustRemoteVolume(aInitialVolume); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::DoStop +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::DoStop() + { + TRACE_FUNC + iBtrccLegacyVolumeActive->Cancel(); + iState = EStateWaitingForVolumeLevelChanges; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::DoReset +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::DoReset() + { + TRACE_FUNC + iBtrccLegacyVolumeActive->Cancel(); + iCurrentRemoteVolume = KVolumeNotSynchronized; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::AdjustRemoteVolume +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::AdjustRemoteVolume(TInt aVolume) + { + // A call to this is made when PS Key changes. + TRACE_INFO((_L("CBTRCCLegacyVolumeLevelController::AdjustRemoteVolume, volume %d, state %d"), aVolume, iState)) + iPhoneVolume = aVolume; + + if(iCurrentRemoteVolume == KVolumeNotSynchronized) + { + // We set current phone volume level as the reference synchronization point + // if we haven't done it yet. Otherwise we synchronize remote to the current level. + // Just synchronize volumes and return, there is nothing else to do at this point. + iCurrentRemoteVolume = iPhoneVolume; + return; + } + + switch(iState) + { + case EStateWaitingForVolumeLevelChanges: + // Just break here. + break; + case EStateDelay: + // Sharp volume jump handling is ongoing. In this case we want to update + // new volume level immediately. + if( iBtrccLegacyVolumeActive->IsActive() ) + { + iBtrccLegacyVolumeActive->Cancel(); + } + break; + default: + // We are middle of timing or volume up/down processing. New value + // is stored, just return here. New value is updated after previous + // job is done. + return; + } + + DoRemoteControl(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::DoRemoteControl +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::DoRemoteControl() + { + TRACE_INFO((_L("target volume level %d"), iPhoneVolume)) + TRACE_INFO((_L("phone current volume level %d"), iCurrentPhoneVolume)) + TRACE_INFO((_L("remote current volume level %d"), iCurrentRemoteVolume)) + + TState preState = iState; + iState = EStateWaitingForVolumeLevelChanges; + + if ( iPhoneVolume != iCurrentRemoteVolume ) + { + TInt prevPhoneVolume = iCurrentPhoneVolume; + iCurrentPhoneVolume = iPhoneVolume; + + if ( iCurrentPhoneVolume == 0 && prevPhoneVolume > 1 ) + { + // A sharp volume jump, most probably caused by audio stream switching. + // Delay the starting of audio adjustment for 0.5 seconds. + iState = EStateDelay; + } + else if (iCurrentPhoneVolume > iCurrentRemoteVolume) + { + iState = preState == EStateVolumeUpTiming ? EStateVolumeUp : EStateVolumeUpTiming; + } + else if (iCurrentPhoneVolume < iCurrentRemoteVolume) + { + iState = preState == EStateVolumeDownTiming ? EStateVolumeDown : EStateVolumeDownTiming; + } + } + + switch (iState) + { + case EStateVolumeUpTiming: + { + TRACE_INFO(_L("Volume up timing")) + StartTimer(KVolumeCommandInterval); + break; + } + case EStateVolumeUp: + { + TRACE_INFO(_L("Volume up")) + SendVolumeCommand(EStateVolumeUp); + break; + } + case EStateVolumeDownTiming: + { + TRACE_INFO(_L("Volume down timing")) + StartTimer(KVolumeCommandInterval); + break; + } + case EStateVolumeDown: + { + TRACE_INFO(_L("Volume down")) + SendVolumeCommand(EStateVolumeDown); + break; + } + case EStateDelay: + { + TRACE_INFO(_L("Delay before updating volume")) + StartTimer( KVolumeSyncRecheckTimer ); + break; + } + case EStateWaitingForVolumeLevelChanges: + { + TRACE_INFO(_L("Waiting volume change")) + break; + } + default: + { + // Not possible + } + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::GetPhoneVolume +// ----------------------------------------------------------------------------- +// +TInt CBTRCCLegacyVolumeLevelController::GetPhoneVolume(TInt &aVol) + { + TRACE_FUNC + TInt err = CBTRCCVolumeLevelControllerBase::GetPhoneVolume(aVol); + + // Converts volume level scale used in DevSound Audio (0 - 10000) into 0 - KVolumeScaleMax. + if( aVol <= 0 ) + { + // 0 level and -1 (no stream) don't need adjustment. + return err; + } + + TReal tgt; + TReal src(aVol); + TReal maxScale(KVolumeScaleMax); + TReal maxDevSound(iLocalMaxVolume); + TReal scale = maxScale/maxDevSound; + Math::Round( tgt, src*scale, 0); + + if( TInt(tgt) == 0 ) + { + // Only aVol value 0 is real zero (muted). All other scaled zero + // values have to be upgraded to level 1. + tgt = 1; + } + TRACE_INFO((_L("Volume scaled: original %d, scaled %d"), aVol, TInt(tgt))) + aVol = TInt(tgt); + return err; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::RequestCompletedL(CBTRCCActive& aActive, TInt aErr) + { + TRACE_FUNC + if( aActive.ServiceId() == KLegacyVolumeLevelSetServiceId ) + { + TRACE_INFO( (_L("CBTRCCLegacyVolumeLevelController iState: %d"), iState ) ) + if ( aErr != KErrNone ) + { + // Something wrong happened, could be e.g. the connection has + // been released while we are changing volume on remote device. + iState = EStateWaitingForVolumeLevelChanges; + return; + } + switch(iState) + { + case EStateVolumeUp: + { + ++iCurrentRemoteVolume; + break; + } + case EStateVolumeDown: + { + --iCurrentRemoteVolume; + break; + } + case EStateDelay: + case EStateWaitingForVolumeLevelChanges: + case EStateVolumeUpTiming: + case EStateVolumeDownTiming: + break; + default: + // Impossible to happen. + break; + } + DoRemoteControl(); + } + else + { + // This is something the base class can handle. + CBTRCCVolumeLevelControllerBase::RequestCompletedL(aActive, aErr); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::CancelRequest(TInt aServiceId) + { + TRACE_FUNC + if( aServiceId == KLegacyVolumeLevelSetServiceId ) + { + // Cancel possible active timers + iCtrlRTimer.Cancel(); + + if (iState == EStateVolumeUp) + { + ++iCurrentRemoteVolume; + } + else if (iState == EStateVolumeDown) + { + --iCurrentRemoteVolume; + } + } + else + { + // This is something the base class can handle. + CBTRCCVolumeLevelControllerBase::CancelRequest(aServiceId); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::StartTimer +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::StartTimer(TInt aInterval) + { + TRACE_FUNC + if( !iBtrccLegacyVolumeActive->IsActive() ) + { + iCtrlRTimer.After(iBtrccLegacyVolumeActive->iStatus, aInterval); + iBtrccLegacyVolumeActive->GoActive(); + } + else + { + TRACE_INFO(_L("CBTRCCLegacyVolumeLevelController::StartTimer() ERR, timer already active!")) + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::SendVolumeCommand +// ----------------------------------------------------------------------------- +// +void CBTRCCLegacyVolumeLevelController::SendVolumeCommand(TInt aDirection) + { + TRACE_FUNC + if( !iBtrccLegacyVolumeActive->IsActive() ) + { + if( aDirection == EStateVolumeUp ) + { + iRemConVolController->VolumeUp(iBtrccLegacyVolumeActive->iStatus, iNumRemotes, ERemConCoreApiButtonClick); + } + else + { + iRemConVolController->VolumeDown(iBtrccLegacyVolumeActive->iStatus, iNumRemotes, ERemConCoreApiButtonClick); + } + iBtrccLegacyVolumeActive->GoActive(); + } + else + { + TRACE_INFO(_L("CBTRCCLegacyVolumeLevelController::DoRemConControl() ERR, previous action ongoing!")) + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLegacyVolumeLevelController::MrccacoResponse() +// ----------------------------------------------------------------------------- +// +TInt CBTRCCLegacyVolumeLevelController::MrccacoResponse() + { + TRACE_FUNC + return 0; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccLinker.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,980 @@ +/* +* Copyright (c) 2005-2006 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: State Machine of BTRCC +* +*/ + +// INCLUDE FILES +#include +#include // KRemConBearerAvrcpImplementationUid = 0x1020685f +#include +#include +#include +#include +#include +#include +#include "btaudioremconpskeys.h" +#include "btrccLegacyVolumeLevelController.h" +#include "btrccAbsoluteVolumeLevelController.h" +#include "btrccLinker.h" +#include "btrccplayerstarter.h" +#include "btrccBrowsingAdapter.h" +#include "debug.h" +#include +#include + +#include "prjconfig.h" + +#ifdef PRJ_MODULETEST_BUILD +const TInt KAvrcpBearerUid = 0xEEEEAAAA; +#else +const TInt KAvrcpBearerUid = KRemConBearerAvrcpImplementationUid; +#endif + +const TInt KMaxRetries = 3; +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCLinker* CBTRCCLinker::NewL(MBTAccObserver& aAccObserver) + { + CBTRCCLinker* self = new (ELeave) CBTRCCLinker(aAccObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::CBTRCCLinker +// C++ constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::CBTRCCLinker(MBTAccObserver& aAccObserver) + : CActive(EPriorityNormal), iAccObserver(aAccObserver) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::ConstructL() + { + TRACE_FUNC_ENTRY + + iInterfaceSelector = CRemConInterfaceSelector::NewL(); + iVolController = NULL; + iRegisterVolumeChangeNotificationCounter = 0; + if (iAccObserver.IsAvrcpVolCTSupported()) + { + iAbsoluteVolController = CBTRCCAbsoluteVolumeLevelController::NewL(*iInterfaceSelector, *this); + iLegacyVolController = CBTRCCLegacyVolumeLevelController::NewL(*iInterfaceSelector, *this); + } + else + { + // If volume control is not supported, we'll need another interface selector session for disconnecting. + iInterfaceSelectorForDisconnectingTargetSession = CRemConInterfaceSelector::NewL(); + } + + iPlayerStarter = CPlayerStarter::NewL(); + iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *iPlayerStarter); + iPlayerStarter->SetCoreTarget(*iCoreTarget); + + iRemConBatteryTgt = CRemConBatteryApiTarget::NewL(*iInterfaceSelector, *this); + +// iBrowsingAdapter = CBTRCCBrowsingAdapter::NewL(*iInterfaceSelector); + + if (iAccObserver.IsAvrcpVolCTSupported()) + { + iInterfaceSelector->OpenControllerL(); + } + iInterfaceSelector->OpenTargetL(); + + // The insert order matters + LEAVE_IF_ERROR(iStateArray.Insert(new (ELeave) TStateIdle(*this), EStateIndexIdle)); + LEAVE_IF_ERROR(iStateArray.Insert(new (ELeave) TStateConnecting(*this), EStateIndexConnecting)); + LEAVE_IF_ERROR(iStateArray.Insert(new (ELeave) TStateConnected(*this), EStateIndexConnected)); + LEAVE_IF_ERROR(iStateArray.Insert(new (ELeave) TStateDisconnect(*this), EStateIndexDisconnect)); + ChangeState(EStateIndexIdle); + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::~CBTRCCLinker() + { + TRACE_FUNC_ENTRY + if (iClientRequest) + User::RequestComplete(iClientRequest, KErrAbort); + + delete iAbsoluteVolController; + delete iLegacyVolController; + delete iPlayerStarter; + Cancel(); + iStateArray.ResetAndDestroy(); + iStateArray.Close(); + delete iInterfaceSelector; + delete iInterfaceSelectorForDisconnectingTargetSession; + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::Connect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + if ( !iAccObserver.IsAvrcpVolCTSupported() ) + { + aStatus = KRequestPending; + TRequestStatus* ptr = &aStatus; + User::RequestComplete( ptr, KErrNotSupported ); + } + else + { + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->Connect(aAddr, aStatus); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::CancelConnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::CancelConnect(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->CancelConnect(aAddr); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::Disconnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::Disconnect(TRequestStatus& aStatus, const TBTDevAddr& aAddr) + { + TRACE_FUNC + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->Disconnect(aStatus, aAddr); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::ActivateRemoteVolumeControl +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::ActivateRemoteVolumeControl() + { + TRACE_FUNC + TRACE_ASSERT(iAccObserver.IsAvrcpVolCTSupported(), EBtrccPanicAvrcpVolCTNotSupported) + if (!iRvcActivated) + { + iRvcActivated = ETrue; + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->UpdateRemoteVolumeControling(iRvcActivated); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DeActivateRemoteVolumeControl +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DeActivateRemoteVolumeControl() + { + TRACE_FUNC + TRACE_ASSERT(iAccObserver.IsAvrcpVolCTSupported(), EBtrccPanicAvrcpVolCTNotSupported) + if (iRvcActivated) + { + iRvcActivated = EFalse; + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->UpdateRemoteVolumeControling(iRvcActivated); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::RunL +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::RunL() + { + TRACE_INFO((_L("CBTRCCLinker::RunL, %d"), iStatus.Int())) + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->RemConRequestCompleted(iStatus.Int()); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::RunError +// ----------------------------------------------------------------------------- +// +TInt CBTRCCLinker::RunError(TInt aError) + { + TRACE_INFO((_L("CBTRCCLinker::RunError, %d"), aError)) + (void) aError; + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DoCancel() + { + TRACE_FUNC + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->DoCancel(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::AccObserver +// ----------------------------------------------------------------------------- +// +MBTAccObserver& CBTRCCLinker::AccObserver() + { + return iAccObserver; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoConnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DoConnect() + { + TRACE_FUNC + TRACE_ASSERT(!IsActive(), EBtrccPanicAOIsActive) + DoRemConOrientation(); + if (iRemConOriented) + { + iInterfaceSelector->ConnectBearer(iStatus); + SetActive(); + } + else + { + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->RemConRequestCompleted(KErrCouldNotConnect); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoSubscribeConnetionStatus +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DoSubscribeConnetionStatus() + { + TRACE_FUNC + TRACE_ASSERT(!IsActive(), EBtrccPanicAOIsActive) + iInterfaceSelector->NotifyConnectionsChange(iStatus); + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoCancelSubscribe +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DoCancelSubscribe() + { + TRACE_FUNC + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoDisconnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DoDisconnect() + { + TRACE_FUNC + TRACE_ASSERT(!IsActive(), EBtrccPanicAOIsActive) + TInt err = KErrNone; + + // if AVRCP RVC is supported, we use InterfaceSelector to do disconnect. + if (iAccObserver.IsAvrcpVolCTSupported()) + { + err = DoRemConOrientation(); + } + else + { + // if AVRCP RVC is not supported, we must be a RemCon Controller for the + // disconnected. Use inner RemCon Controller here for not disturbing + // interfaceSelector. + TRAP(err, iInterfaceSelectorForDisconnectingTargetSession->OpenControllerL()); + TRACE_INFO((_L("open iInterfaceSelectorForDisconnectingTargetSession controller %d"), err)) + if (!err) + { + TRemConAddress addr; + addr.BearerUid() = TUid::Uid( KAvrcpBearerUid ); + addr.Addr() = iRemoteAddr.Des(); + TRAP(err, iInterfaceSelectorForDisconnectingTargetSession->GoConnectionOrientedL(addr)); + TRACE_INFO((_L("InterfaceSelectorForDisconnectingTargetSession GoConnectionOrientedL %d"), err)) + } + } + + if (!err) + { + if (iAccObserver.IsAvrcpVolCTSupported()) + { + iInterfaceSelector->DisconnectBearer(iStatus); + } + else + { + iInterfaceSelectorForDisconnectingTargetSession->DisconnectBearer(iStatus); + } + SetActive(); + } + else + { + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->RemConRequestCompleted(KErrCouldNotConnect); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::ChangeState +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::ChangeState(TBTRCCStateIndex aNextState) + { + TRACE_INFO((_L("CBTRCCLinker::ChangeState, STATE from %d to %d"), iCurrentStateIndex, aNextState)) + iCurrentStateIndex = aNextState; + TRACE_ASSERT(iCurrentStateIndex < iStateArray.Count(), EBtrccPanicOutOfRangeState); + iStateArray[iCurrentStateIndex]->Enter(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoRemConOrientation +// ----------------------------------------------------------------------------- +// +TInt CBTRCCLinker::DoRemConOrientation() + { + TRACE_FUNC + TInt err(KErrNone); + // the oriented remote might be a different device than the currently requested, + // Go connectionless first. + if (iRemConOriented) + { + TRAP(err, iInterfaceSelector->GoConnectionlessL()); + iRemConOriented = EFalse; + if (err) + { + TRACE_INFO((_L("GoConnectionless ret %d"), err)) + return err; + } + } + TRemConAddress addr; + addr.BearerUid() = TUid::Uid( KAvrcpBearerUid ); + addr.Addr() = iRemoteAddr.Des(); + TRAP(err, iInterfaceSelector->GoConnectionOrientedL(addr)); + TRACE_INFO((_L("GoConnectionOriented ret %d"), err)) + if (!err) + { + iRemConOriented = ETrue; + } + return err; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::DoGetRemConConnectionStatus +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::DoGetRemConConnectionStatus(RArray& aConnects) + { + TRACE_FUNC + TSglQue connections; + aConnects.Reset(); + if (iInterfaceSelector->GetConnections(connections) == KErrNone) + { + TSglQueIter iter(connections); + TRemConAddress* addr; + while((addr=iter++) != NULL) + { + if(addr->BearerUid() == TUid::Uid( KAvrcpBearerUid ) ) + { + // We have a BT Connection + if ((addr->Addr().Length() == KBTDevAddrSize) && (TBTDevAddr(addr->Addr()) != TBTDevAddr())) + { + TRACE_INFO(_L("RemCon bearer found from connections list")); + aConnects.Append(TBTDevAddr(addr->Addr())); + } + } + // We've copied the information we need, so delete + delete addr; + } + } + else + { + TRACE_INFO(_L("GetNotificationStatus(): FAILED !!!")); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::StartRemoteVolumeControl +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::StartRemoteVolumeControl() + { + TRACE_FUNC + if (iAccObserver.IsAvrcpVolCTSupported()) + { + // Choose based on SDP result whether to create + // absolute controller or legacy controller. + if(!iVolController) + { + if (iAccObserver.IsAbsoluteVolumeSupported(iRemoteAddr)) + { + iVolController = iAbsoluteVolController; + } + else + { + iVolController = iLegacyVolController; + } + } + } + if (iVolController) + { + iVolController->Start(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::StopRemoteVolumeControl +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::StopRemoteVolumeControl() + { + TRACE_FUNC + if (iVolController) + { + iVolController->Stop(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::ResetVolmeControlSetting +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::ResetVolmeControlSetting() + { + TRACE_FUNC + if (iVolController) + { + iVolController->Reset(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::VolumeControlError +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::VolumeControlError(TInt aError) + { + // This is called if there's an error with sending the volume commands out. + switch(aError) + { + case ERegisterNotificationsFailed: + if (iVolController && iRegisterVolumeChangeNotificationCounterRegisterVolumeChangeNotification(); + } + else + { + iRegisterVolumeChangeNotificationCounter = 0; + } + break; + case EVolumeAdjustmentFailed: + default: + { + StopRemoteVolumeControl(); + StartRemoteVolumeControl(); + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::MrcbstoBatteryStatus +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::MrcbstoBatteryStatus(TControllerBatteryStatus& aBatteryStatus) + { + RDebug::Printf("CBmbPlugin::MrcbstoBatteryStatus(), aBatteryStatus = %d",aBatteryStatus); + TBool showBatteryNote(EFalse); + + TBTGenericInfoNotiferParamsPckg pckg; + pckg().iRemoteAddr.Copy(iRemoteAddr.Des()); + switch(aBatteryStatus) + { + case EWarning: + pckg().iMessageType = ECmdShowBtBatteryLow; + showBatteryNote = ETrue; + break; + case ECritical: + pckg().iMessageType = ECmdShowBtBatteryCritical; + showBatteryNote = ETrue; + break; + default: + break; + } + + if (showBatteryNote) + { + RNotifier notifier; + TInt err = notifier.Connect(); + if (!err ) + { + TRequestStatus status; + notifier.StartNotifierAndGetResponse(status, KBTGenericInfoNotifierUid, pckg, pckg); + User::WaitForRequest(status); + notifier.Close(); + } + } + } + +// ================= TState MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::TState +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::TState::TState(CBTRCCLinker& aParent) +: iParent(aParent) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TState::DoCancel() + { + TRACE_INFO((_L("TState::DoCancel #Default# state %d"), iParent.iCurrentStateIndex)) + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::Connect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TState::Connect(const TBTDevAddr& /*aAddr*/, TRequestStatus& aStatus) + { + TRACE_INFO((_L("TState::Connect #Default# state %d"), iParent.iCurrentStateIndex)) + TRequestStatus* status = &aStatus; + aStatus = KRequestPending; + User::RequestComplete(status, KErrInUse); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::CancelConnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TState::CancelConnect(const TBTDevAddr& /*aAddr*/) + { + TRACE_INFO((_L("TState::CancelConnect #Default# state %d"), iParent.iCurrentStateIndex)) + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::Disconnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TState::Disconnect(TRequestStatus& aStatus, const TBTDevAddr& /*aAddr*/) + { + TRACE_INFO((_L("TState::Disconnect #Default# state %d"), iParent.iCurrentStateIndex)) + // We assume disconnect is always succeeded and complete this request immediately, + // because a) disconnect is not able to be cancelled, and + // b) we can do nothing if disconnect fails + TRequestStatus* status = &aStatus; + aStatus = KRequestPending; + User::RequestComplete(status, KErrNone); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::RemConRequestCompleted +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TState::RemConRequestCompleted(TInt /*aErr*/) + { + TRACE_INFO((_L("TState::RemConRequestCompleted #Default# state %d"), iParent.iCurrentStateIndex)) + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TState::UpdateRemoteVolumeControling +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TState::UpdateRemoteVolumeControling(TBool /*aActivated*/) + { + TRACE_INFO((_L("TState::UpdateRemoteVolumeControling #Default# state %d"), iParent.iCurrentStateIndex)) + } + +// ================= TStateIdle MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateIdle::TStateIdle +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::TStateIdle::TStateIdle(CBTRCCLinker& aParent) + : TState(aParent) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateIdle::Enter +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateIdle::Enter() + { + TRACE_FUNC + iParent.iRemoteAddr = TBTDevAddr(); + iParent.DoSubscribeConnetionStatus(); + iParent.ResetVolmeControlSetting(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateIdle::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateIdle::DoCancel() + { + TRACE_FUNC + iParent.iInterfaceSelector->NotifyConnectionsChangeCancel(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateIdle::Connect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateIdle::Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + iParent.iRemoteAddr = aAddr; + aStatus = KRequestPending; + iParent.iClientRequest = &aStatus; + iParent.DoCancelSubscribe(); + iParent.ChangeState(EStateIndexConnecting); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateIdle::RemConRequestCompleted +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateIdle::RemConRequestCompleted(TInt aErr) + { + TRACE_FUNC + if (!aErr) + { + RArray connects; + iParent.DoGetRemConConnectionStatus(connects); + + // There can only be maximum one AVRCP connection at this time, as BTRCC is running + // as long as BT is ON. + if (connects.Count()) + { + iParent.iRemoteAddr = connects[0]; + if (iParent.iAccObserver.IsAvrcpVolCTSupported()) + { + iParent.DoRemConOrientation(); + } + iParent.ChangeState(EStateIndexConnected); + // This function call is safe after state transition because the state machine + // keeps all state instances in memory. + // AVRCP Controller initiates connection with AVRCP Traget. Thus we assume the remote + // is a CT. + iParent.AccObserver().NewAccessory(iParent.iRemoteAddr, ERemConCT); + } + else + { + // Remain in this state, re-subsrcibe + iParent.DoSubscribeConnetionStatus(); + } + connects.Close(); + } + else if (aErr != KErrServerTerminated) + { + // some error returned in subscribe, redo if the reason is other than server termination. + iParent.DoSubscribeConnetionStatus(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnecting::TStateConnecting +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::TStateConnecting::TStateConnecting(CBTRCCLinker& aParent) + : TState(aParent) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnecting::Enter +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnecting::Enter() + { + TRACE_FUNC + iConnectCanceled = EFalse; + iParent.DoConnect(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnecting::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnecting::DoCancel() + { + TRACE_FUNC + iParent.iInterfaceSelector->ConnectBearerCancel(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnecting::CancelConnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnecting::CancelConnect(const TBTDevAddr& aAddr) + { + TRACE_INFO(_L("TStateConnecting::CancelConnect")) + if (aAddr == iParent.iRemoteAddr) + { + // RemCon FW doesn't bring down AVRCP linking in ConnectBearerCancel(), so + // we set the flag which will be checked when the completion of connecting request. + iConnectCanceled = ETrue; + if (iParent.iClientRequest) + User::RequestComplete(iParent.iClientRequest, KErrCancel); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnecting::RemConRequestCompleted +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnecting::RemConRequestCompleted(TInt aErr) + { + TRACE_FUNC + TBTRCCStateIndex nextState = (aErr) ? EStateIndexIdle : EStateIndexConnected; + if (!aErr && iConnectCanceled) + { + nextState = EStateIndexDisconnect; + aErr = KErrCancel; + } + if (iParent.iClientRequest) + User::RequestComplete(iParent.iClientRequest, aErr); + iParent.ChangeState(nextState); + } + +// ================= TStateConnected MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::TStateConnected +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::TStateConnected::TStateConnected(CBTRCCLinker& aParent) + : TState(aParent) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::Enter +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnected::Enter() + { + TRACE_FUNC + iParent.DoSubscribeConnetionStatus(); + if (iParent.iRvcActivated) + { + iParent.StartRemoteVolumeControl(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnected::DoCancel() + { + TRACE_FUNC + iParent.iInterfaceSelector->NotifyConnectionsChangeCancel(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::Connect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnected::Connect(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + TInt err = KErrNone; + if (iParent.iRemoteAddr != aAddr) + { + err = KErrInUse; + } + TRequestStatus* status = &aStatus; + aStatus = KRequestPending; + User::RequestComplete(status, err); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::Disconnect +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnected::Disconnect(TRequestStatus& aStatus, const TBTDevAddr& aAddr) + { + TRACE_FUNC + TState::Disconnect(aStatus, aAddr); + if (iParent.iRemoteAddr == aAddr) + { + iParent.DoCancelSubscribe(); + iParent.StopRemoteVolumeControl(); + iParent.ChangeState(EStateIndexDisconnect); + } + } + +// ----------------------------------------------------------------------------- +// Find +// ----------------------------------------------------------------------------- +// +TBool Find(const RArray& aList, const TBTDevAddr& aAddr) + { + TInt count = aList.Count(); + for (TInt i = 0; i < count; i++) + { + if (aList[i] == aAddr) + { + return ETrue; + } + } + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::RemConRequestCompleted +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnected::RemConRequestCompleted(TInt aErr) + { + TRACE_FUNC + if (!aErr) + { + RArray connects; + iParent.DoGetRemConConnectionStatus(connects); + + // There might be more than one AVRCP connections at this time, + // We only check if the connection maintained by BTRCC exists or not. + // For connection with other devices, we are not interested since currently + // BT audio design only allows single HFP/A2DP/AVRCP connection. + if (!Find(connects, iParent.iRemoteAddr)) + { + iParent.AccObserver().AccessoryDisconnected(iParent.iRemoteAddr, EAnyRemConProfiles); + iParent.StopRemoteVolumeControl(); + iParent.ChangeState(EStateIndexIdle); + } + else + { + // not interested connection status change, remain in this state and re-subscribe + iParent.DoSubscribeConnetionStatus(); + } + connects.Close(); + } + else if (aErr == KErrServerTerminated || aErr == KErrCommsBreak) + { + // Serious error, requires a restart. + // ToDo: Check and possibly redesign the connection/disconnection + // To enable it from this class. + + // Must at least inform the parent that there was a disconnection, + // Or should we just connect back silently? + + // iRemoteAddr stores the address so this is possible in theory. + } + else + { + // Other error, subscribe again. + iParent.DoSubscribeConnetionStatus(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateConnected::UpdateRemoteVolumeControling +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateConnected::UpdateRemoteVolumeControling(TBool aActivated) + { + TRACE_FUNC + if (aActivated) + { + iParent.StartRemoteVolumeControl(); + } + else + { + iParent.StopRemoteVolumeControl(); + } + } + + +// ================= TStateDisconnect MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateDisconnect::TStateDisconnect +// ----------------------------------------------------------------------------- +// +CBTRCCLinker::TStateDisconnect::TStateDisconnect(CBTRCCLinker& aParent) + : TState(aParent) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateDisconnect::Enter +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateDisconnect::Enter() + { + TRACE_FUNC + iParent.DoDisconnect(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateDisconnect::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateDisconnect::DoCancel() + { + TRACE_FUNC + if (iParent.iAccObserver.IsAvrcpVolCTSupported()) + { + iParent.iInterfaceSelector->DisconnectBearerCancel(); + } + else + { + iParent.iInterfaceSelectorForDisconnectingTargetSession->DisconnectBearerCancel(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCLinker::TStateDisconnect::RemConRequestCompleted +// ----------------------------------------------------------------------------- +// +void CBTRCCLinker::TStateDisconnect::RemConRequestCompleted(TInt /*aErr*/) + { + TRACE_FUNC + iParent.ChangeState(EStateIndexIdle); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccPlugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2005-2006 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: BT Remote Control Controller class declaration. +* +*/ + + +// INCLUDE FILES + +#include +#include +#include + +#include "btrccPlugin.h" +#include "debug.h" +#include "btrccLinker.h" + +// CONSTANTS + +#ifdef _DEBUG +// Length of a BT hardware address (BD_ADDR) as a descriptor +const TUint8 KBTRCCBTDevAddrDesLength = KBTDevAddrSize * 2; +#endif + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::NewL +// ----------------------------------------------------------------------------- +// +CBTRCCPlugin* CBTRCCPlugin::NewL(TPluginParams& aParams) + { + CBTRCCPlugin* self = new (ELeave) CBTRCCPlugin(aParams); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTRCCPlugin::~CBTRCCPlugin() + { + TRACE_FUNC + delete iLinker; + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::CBTRCCPlugin +// C++ default constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCPlugin::CBTRCCPlugin(TPluginParams& aParams) + : CBTAccPlugin(aParams) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::ConstructL() + { + TRACE_FUNC + iLinker = CBTRCCLinker::NewL(Observer()); + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::ConnectToAccessory +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + iLinker->Connect(aAddr, aStatus); + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::CancelConnectToAccessory +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::CancelConnectToAccessory(const TBTDevAddr& aAddr) + { + TRACE_FUNC + iLinker->CancelConnect(aAddr); + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::DisconnectAccessory +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::DisconnectAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + iLinker->Disconnect(aStatus, aAddr); + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::AccInUse +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::AccInUse() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::PluginType +// ----------------------------------------------------------------------------- +// +TProfiles CBTRCCPlugin::PluginType() + { + TRACE_FUNC + return EAnyRemConProfiles; + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::ActivateRemoteVolumeControl +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::ActivateRemoteVolumeControl() + { + TRACE_FUNC + iLinker->ActivateRemoteVolumeControl(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCPlugin::PluginType +// ----------------------------------------------------------------------------- +// +void CBTRCCPlugin::DeActivateRemoteVolumeControl() + { + TRACE_FUNC + iLinker->DeActivateRemoteVolumeControl(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccVolumeLevelControllerBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccVolumeLevelControllerBase.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,262 @@ +/* +* Copyright (c) 2005-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: Base class implements volume control of AVRCP Controller. +* +* +*/ + +// INCLUDE FILES +#include // KRemConBearerAvrcpImplementationUid = 0x1020685f +#include +#include // for volume pubsub +#include +#include +#include +#include +#include + +#include "btrccVolumeLevelControllerBase.h" +#include "debug.h" + + +// MODULE DATA STRUCTURES +const TInt KVolumeChangeListenerServiceId = 0x01; + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::CBTRCCVolumeLevelController +// C++ constructor. +// ----------------------------------------------------------------------------- +// +CBTRCCVolumeLevelControllerBase::CBTRCCVolumeLevelControllerBase(MBTRCCVolumeControllerObserver &aObserver): + iObserver(aObserver), iLocalMaxVolume(0), iState(ESubscribePhoneVolume) + { + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::ConstructL() + { + TRACE_FUNC + LEAVE_IF_ERROR(iVolLevelProperty.Attach(KPSUidMediaStreamProperties, KMediaStreamCurrentVolume)) + LEAVE_IF_ERROR(iVolKeyEventProperty.Attach(KPSUidMediaKeysEventNotifier, KMediaKeysAccessoryVolumeEvent)) + iBtrccActive = CBTRCCActive::NewL(*this, KVolumeChangeListenerServiceId); + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTRCCVolumeLevelControllerBase::~CBTRCCVolumeLevelControllerBase() + { + TRACE_FUNC + delete iBtrccActive; + iVolLevelProperty.Close(); + iVolKeyEventProperty.Close(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::Start +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::Start() + { + TRACE_FUNC + + iVolLevelProperty.Subscribe(iBtrccActive->iStatus); + iBtrccActive->GoActive(); + + (void) GetPhoneVolume(iPhoneVolume); + if( iPhoneVolume > -1) + { + DoStart( iPhoneVolume ); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::Stop +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::Stop() + { + TRACE_FUNC + iBtrccActive->Cancel(); + DoStop(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::Reset +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::Reset() + { + TRACE_FUNC + iBtrccActive->Cancel(); + DoReset(); + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::RegisterVolumeChangeNotification +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::RegisterVolumeChangeNotification() + { + TRACE_FUNC + return; + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::GetLocalMaxVolume +// ----------------------------------------------------------------------------- +// +TInt CBTRCCVolumeLevelControllerBase::GetLocalMaxVolume() + { + TRACE_FUNC + if(iLocalMaxVolume == 0) + { + // fetch max volume from adaptation and cache it. + CMMFDevSound* devSound = NULL; + TRAPD( err, devSound = CMMFDevSound::NewL() ); + if(!err) + { + iLocalMaxVolume = devSound->MaxVolume(); + TRACE_INFO((_L("Maximum volume is %d"), iLocalMaxVolume)) + delete devSound; // This is not needed for anything else. + } + } + return iLocalMaxVolume; + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::AccessoryChangedVolume +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::AccessoryChangedVolume(TInt aVolumeInPhoneScale) + { + TRACE_FUNC + iRemoteVolume = aVolumeInPhoneScale; + TInt vol; + TInt err = GetPhoneVolume(vol); + if(!err) + { + iPhoneVolume = vol; + SetPhoneVolume(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::SetPhoneVolume +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::SetPhoneVolume() + { + TRACE_FUNC + TRACE_INFO((_L("iRemoteVolume = %d, iPhoneVolume = %d"), iRemoteVolume, iPhoneVolume)) + if (iRemoteVolume != iPhoneVolume) + { + TInt event = (iRemoteVolume > iPhoneVolume) ? KPSVolumeUpClicked : KPSVolumeDownClicked; + TInt err = iVolKeyEventProperty.Set(event); + if (err) + { + TRACE_ERROR((_L("Set KMediaKeysVolumeKeyEvent err %d"), err)); + } + iState = ESetPhoneVolume; + } + else + { + iState = ESubscribePhoneVolume; + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::GetPhoneVolume +// ----------------------------------------------------------------------------- +// +TInt CBTRCCVolumeLevelControllerBase::GetPhoneVolume(TInt &aVol) + { + aVol = -1; + TInt err = iVolLevelProperty.Get(aVol); + TRACE_INFO((_L("Get volume P&S ret %d vol %d"), err, aVol)) + return err; + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::GetCurrentLocalVolume +// ----------------------------------------------------------------------------- +// +TInt CBTRCCVolumeLevelControllerBase::GetCurrentLocalVolume() + { + return iPhoneVolume; + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::RequestCompletedL(CBTRCCActive& aActive, TInt aErr) + { + TRACE_FUNC + if(aActive.ServiceId() == KVolumeChangeListenerServiceId) + { + TInt err = GetPhoneVolume(iPhoneVolume); + + if(!err && !aErr && iPhoneVolume > -1) + { + switch(iState) + { + case ESubscribePhoneVolume: + // Tell the specialization of the new volume level. + AdjustRemoteVolume(iPhoneVolume); + break; + case ESetPhoneVolume: + SetPhoneVolume(); + break; + } + } + + iVolLevelProperty.Subscribe(iBtrccActive->iStatus); + iBtrccActive->GoActive(); + } + } + +// ----------------------------------------------------------------------------- +// CBTRCCVolumeLevelControllerBase::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBTRCCVolumeLevelControllerBase::CancelRequest(TInt aServiceId) + { + TRACE_FUNC + switch (aServiceId) + { + case KVolumeChangeListenerServiceId: + { + iVolLevelProperty.Cancel(); + break; + } + default: + break; + } + } + +void CBTRCCVolumeLevelControllerBase::VolumeControlError(TInt aError) + { + iObserver.VolumeControlError(aError); + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccmain.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2005-2006 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: Contains the DLL entry point. +* +*/ + +#ifndef BTRCCPLUGINECOMIMPL_H +#define BTRCCPLUGINECOMIMPL_H + +// INCLUDE FILES +#include +#include +#include "btrccPlugin.h" +#include "btrccPluginImplUid.h" + +// ================= OTHER EXPORTED FUNCTIONS ============== +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KBTRCCPluginImplUid, CBTRCCPlugin::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif // BTRCCPLUGINECOMIMPL_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2008 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: This class launchs music player, then send play command +* to the player at 2 seconds timeout. +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include "btrccplayerstarter.h" +#include "btaudioremconpskeys.h" +#include "debug.h" + +// MODULE DATA STRUCTURES + +// mpx playeris name is mpx.exe in 5.0. +// it is musicplayer.exe in 3.2. +_LIT(KMpxPlayerExeName, "mpx.exe"); + +_LIT(KMpxPlayerSearchPatternBySID, "*102072c3*"); + +static const TInt KPlayCmdToPlayerDelay = 6000000; // value will be tuned later + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CPlayerStarter::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CPlayerStarter* CPlayerStarter::NewL() + { + CPlayerStarter* self = new (ELeave) CPlayerStarter(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CPlayerStarter::SetCoreTarget(CRemConCoreApiTarget& aTarget) + { + iCoreTarget = &aTarget; + } + +// ----------------------------------------------------------------------------- +// CPlayerStarter::CPlayerStarter +// C++ constructor. +// ----------------------------------------------------------------------------- +// +CPlayerStarter::CPlayerStarter() + :CActive(EPriorityNormal) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CPlayerStarter::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CPlayerStarter::ConstructL() + { + TRACE_FUNC + iTimer.CreateLocal(); + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CPlayerStarter::~CPlayerStarter() + { + TRACE_FUNC + // Starting player is not finished yet, send play command. Just wish the player + // can receive it. + if (IsActive() && iState != ERespondPlayNok) + { + RProperty::Set(KBTAudioRemCon, KBTAudioPlayerControl, + EBTAudioResumePlayer); + } + Cancel(); + iTimer.Close(); + } + +// ----------------------------------------------------------------------------- +// CPlayerStarter::RunL +// ----------------------------------------------------------------------------- +// +void CPlayerStarter::RunL() + { + TRACE_INFO((_L("CPlayerStarter::RunL() state %d, status %d"), iState, iStatus.Int())); + if (iStatus != KErrNone) + { + iState = EIdle; + return; + } + switch (iState) + { + case ERespondPlayOk: + { + // Response OK has been sent to the remote device, start timer waiting + // for player's initialization. + iTimer.After(iStatus, KPlayCmdToPlayerDelay); + SetActive(); + iState = EPlayMusicTiming; + TRACE_INFO(_L("schedule PLAY command ...")); + break; + } + case EPlayMusicTiming: + { + // Player should have fully up and running. Send PLAY command to it + // through our internal Play API. + RProperty::Set(KBTAudioRemCon, KBTAudioPlayerControl, + EBTAudioResumePlayer); + TRACE_INFO(_L("PLAY command sent to btmonobearer")); + iState = EIdle; + break; + } + default: + { + iState = EIdle; + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CPlayerStarter::RunError +// ----------------------------------------------------------------------------- +// +TInt CPlayerStarter::RunError(TInt aError) + { + TRACE_FUNC + (void) aError; + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CPlayerStarter::DoCancel +// ----------------------------------------------------------------------------- +// +void CPlayerStarter::DoCancel() + { + TRACE_FUNC + switch (iState) + { + case ERespondPlayOk: + case ERespondPlayNok: + { + // This cancel won't cancel the response sending to the remote + // device. (RemCon FW's cancel mechanism is only completing client's request. + // the real operation in its server side won't be stopped.) + iCoreTarget->Cancel(); + break; + } + case EPlayMusicTiming: + { + iTimer.Cancel(); + break; + } + } + } +// --------------------------------------------------------------------------- +// A 'play' command has been received. +// --------------------------------------------------------------------------- +// +void CPlayerStarter::MrccatoPlay( + TRemConCoreApiPlaybackSpeed /* aSpeed */, + TRemConCoreApiButtonAction aButtonAct ) + { + TRACE_FUNC + if ( ( aButtonAct == ERemConCoreApiButtonClick ) || + ( aButtonAct == ERemConCoreApiButtonPress ) ) + { + StartPlayIfNeeded(); + } + } + +// --------------------------------------------------------------------------- +// A command has been received. +// --------------------------------------------------------------------------- +// +void CPlayerStarter::MrccatoCommand( + TRemConCoreApiOperationId aOperationId, + TRemConCoreApiButtonAction aButtonAct ) + { + TRACE_INFO((_L("CPlayerStarter::MrccatoCommand opId %d, button %d"), + aOperationId, aButtonAct)); + switch (aOperationId) + { + case ERemConCoreApiPlay: + { + if ( ( aButtonAct == ERemConCoreApiButtonClick ) || + ( aButtonAct == ERemConCoreApiButtonPress ) ) + { + StartPlayIfNeeded(); + } + break; + } + case ERemConCoreApiStop: + case ERemConCoreApiPause: + { + if ( ( aButtonAct == ERemConCoreApiButtonClick ) || + ( aButtonAct == ERemConCoreApiButtonPress ) ) + { + // if starting player is ongoing, possibly PLAY command has been scheduled + // need to abort it. + Cancel(); + } + break; + } + default: + { + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CPlayerStarter::StartPlayIfNeeded +// ----------------------------------------------------------------------------- +// +void CPlayerStarter::StartPlayIfNeeded() + { + TRACE_FUNC + // unfinished business ongoing, eat the event. + if (IsActive()) + { + return; + } + if (!IsMusicPlayerRunning()) + { + TRAPD(err, LaunchMusicPlayerL()); + // Send the response of play command to remote device + iCoreTarget->PlayResponse(iStatus, err); + SetActive(); + iState = (err) ? ERespondPlayNok : ERespondPlayOk; + } + } + +TBool CPlayerStarter::IsMusicPlayerRunning() + { + TRACE_FUNC + // Music player is running if we can find a thread whose name contains + // S60 Music Player's SID. + TFindThread findt(KMpxPlayerSearchPatternBySID); + TFullName result; + TBool running(EFalse); + if (!findt.Next(result)) + { + TRACE_INFO((_L("Thread '%S'is found"), &result)); + running = ETrue; + } + return running; + } + +void CPlayerStarter::LaunchMusicPlayerL() + { + RApaLsSession ls; + User::LeaveIfError(ls.Connect()); + CleanupClosePushL(ls); + CApaCommandLine* cmd = CApaCommandLine::NewL(); + CleanupStack::PushL(cmd); + cmd->SetExecutableNameL( KMpxPlayerExeName ); + cmd->SetCommandL( EApaCommandOpen ); + User::LeaveIfError(ls.StartApp( *cmd )); + CleanupStack::PopAndDestroy(2); // cmd, ls + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/common/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/common/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2006 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: Logging definition +* +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); +#endif + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); +#endif + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + User::LeaveIfError(aReason); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_FUNC_STATIC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/data/10208973.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/data/10208973.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2002 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: BT Stero Audio Controller +* +*/ + + +#include "registryinfo.rh" +#include "btsacpluginuid.h" +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x10208973; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = KBTAccPluginInterfaceUid; + implementations = + { + // Info for BTSAC + IMPLEMENTATION_INFO + { + implementation_uid = KBTSACUid; + version_no = 1; + display_name = "BT Stereo AudioController"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2005 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: Provides information for building BTsac. +* +*/ + +#include "../btrcc/group/bld.inf" + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/btsacpluginuid.h |../../inc/btsacpluginuid.h +../inc/btaudioremconpskeys.h |../../inc/btaudioremconpskeys.h +../rom/btsac.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btsac.iby) + +PRJ_MMPFILES +../group/btsac.mmp + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/group/btsac.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/group/btsac.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2005 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: Lists information necessary to compile and link the component +* +*/ + +#include + +// Defines the capability which process would require to load the DLL +// i.e., a process with less capability cannot load this DLL +// Look at defaultcaps.hrh for a list of capabilities +CAPABILITY CAP_ECOM_PLUGIN + +// Manufacturer or platform specific Vender ID (VID). A VID to be granted to +// all software from the same manufacturer. +VENDORID VID_DEFAULT + +TARGET btsac.dll +TARGETTYPE PLUGIN + + +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +// ECom Dll recognition UID followed by the unique UID for this dll +UID 0x10009D8D 0x10208973 + +SOURCEPATH ../src +SOURCE Proxy.cpp +SOURCE btsacGavdp.cpp +SOURCE btsacactive.cpp +SOURCE btsaController.cpp +SOURCE btsacStreamerController.cpp +SOURCE btsacStreamEndPoint.cpp +SOURCE btsacSEPManager.cpp +SOURCE btsacState.cpp +SOURCE btsacStateIdle.cpp +SOURCE btsacStateListening.cpp +SOURCE btsacStateConnecting.cpp +SOURCE btsacStateConfiguring.cpp +SOURCE btsacStateConnected.cpp +SOURCE btsacStateConfigured.cpp +SOURCE btsacStateStreaming.cpp +SOURCE btsacStateSuspended.cpp +SOURCE btsacStateAborting.cpp +SOURCE btsacActivePacketDropIoctl.cpp + +START RESOURCE ../data/10208973.rss +TARGET btsac.rsc +END + +USERINCLUDE ../inc ../common +SYSTEMINCLUDE ../../inc ../../../inc /epoc32/include/ecom +MW_LAYER_SYSTEMINCLUDE + + +LIBRARY euser.lib // Kernel API includes symbian basic class and type definitions and error codes +LIBRARY esock.lib // RSocketServ is used to open Gavdp +LIBRARY bluetooth.lib // Bluetooth library is used to access bluetooth types and API's +LIBRARY bluetoothAV.lib // A2DP type definitions are needed to use Gavdp +LIBRARY gavdp.lib // Bluetooth Generic Audio/Video Distribution Profile (GAVDP) API +LIBRARY ECom.lib // Symbian E-Com Plugin definitions and types +LIBRARY sdpdatabase.lib // SDP registeration for Advanced Audio Distribution Profile (A2DP) +LIBRARY btaudiostreamer.lib // Series 60 Bluetooth Audio Streamer component's API +LIBRARY btengdiscovery.lib // Register A2DP SDP service record +DEBUGLIBRARY flogger.lib // File logging services in debug.h + + +// end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btaudioremconpskeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btaudioremconpskeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2007 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: P&S key as a tunnel for btsac and btaudioservice. +* +*/ + + +#ifndef BTAUDIOREMCONPSKEYS_H +#define BTAUDIOREMCONPSKEYS_H + +const TUid KBTAudioRemCon = {0x10208971}; + +const TUint KBTAudioPlayerControl = 0x01; + +enum TBTAudioPlayerControlValue + { + EBTAudioUndefined, + EBTAudioPausePlayer, + EBTAudioResumePlayer + }; + +#endif + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btaudiostreaminputbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btaudiostreaminputbase.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2005 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: ?Description +* +*/ + + +#ifndef __BTAUDIOSTREAMINPUTBASE_H__ +#define __BTAUDIOSTREAMINPUTBASE_H__ + +#include +#include +#include + +/** + * Observer interface for receiving the audio data buffers. + * + * This class defines an observer interface to be implemented by the + * class that is going to receive the audio data. + * + * @lib btaudioadaptation.lib + * @since S60 v3.1 + */ +class MBTAudioStreamObserver +{ +public: + /** + * Method for receiving audio data and an associated timestamp. + * + * @since S60 v3.1 + * @param aBuffer the audio data frames from the encoder. + * @param aTimestamp the timestamp of the first audio frame in the aBuffer + * @return a Symbian OS wide error code. + */ + virtual TInt Receive(const TDesC8& aBuffer, TTimeIntervalMicroSeconds aTimestamp) = 0; + + /** + * Method for receiving audio data. + * + * @since S60 v3.1 + * @param aBuffer the audio data frames from the encoder. + * @return a Symbian OS wide error code. + */ + virtual TInt Receive(const TDesC8& aBuffer) = 0; +}; + +/** + * Observer interface for receiving the audio adaptation errors. + * + * This class defines an observer interface to be implemented by the + * class that is going to receive the errors that have occurred in + * BT Audio Adaptation or in the audio subsystem. + * + * To be implemented by a class who uses this adaptation class. + * @lib btaudioadaptation.lib + * @since S60 v3.1 + */ +class MBTAudioErrorObserver +{ +public: + /** + * Method for receiving the errors. + * + * @since S60 v3.1 + * @param aError a Symbian OS wide error code. + * @return a Symbian OS wide error code. + */ + virtual TInt Error(const TInt aError) = 0; +}; + +/** + * This class specifies the interface for receiving audio data from audio subsystem. + * + * This class contains the interface definition. It can't be instantiated directly, + * but instead the implementation is done in the class inherited from this class. + * + * Also, the factory method for the base class must be implemented by the + * implementator of this interface. + * + * @lib btaudioadaptation.lib + * @since S60 v3.1 + */ +class CBTAudioStreamInputBase : public CBase +{ +public: + IMPORT_C static CBTAudioStreamInputBase* NewL( MBTAudioStreamObserver &aStreamObserver, MBTAudioErrorObserver &aErrorObserver ); + + /** + * This method is for connecting to the audio subsystem. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt Connect() = 0; + + /** + * This method is for disconnecting from the audio subsystem. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param void. + * @return void + */ + virtual void Disconnect() = 0; + + /** + * This method is for passing the custom interfaces that are + * needed sometimes for configuring the hardware encoder. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param aInterfaceId specifies the id of custom interface that the client + * wants to get. + * @return A pointer to the requested interface. Client must cast it into a correct class. + */ + virtual TAny *EncoderInterface(TUid aInterfaceId) = 0; + + /** + * This method is for choosing the encoder for the audio data. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param aDesiredFourCC specifies the encoder that the client wants to use. + * @return a Symbian OS wide error code. + */ + virtual TInt SetFormat(TFourCC aDesiredFourCC) = 0; + + /** + * This method is for starting the recording from the audio subsystem. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual TInt Start() = 0; + + /** + * This method is for stopping the recording from the audio subsystem. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param void. + * @return a Symbian OS wide error code. + */ + virtual void Stop() = 0; + + /** + * This method is called when the client has processed the buffer it got + * from the Receive method. + * + * See BT Audio Adaptation API and BT Audio Adaptation Design specifications + * for detailed explanation. + * + * @since S60 v3.1 + * @param aBuffer refers to the buffer that was received earlier in the Receive method. + * @return void + */ + virtual void BufferEmptied( const TDesC8 &aBuffer ) = 0; +}; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsaController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsaController.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,254 @@ +/* +* Copyright (c) 2005 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: Declaration for CBTSAController class. This class is advertised +* to E-com framework (@see proxy.cpp) so that it loads this class when +* this plugin gets loaded. That is why this class implements the interface +* of the module (currently BT Accessory Server) which loads this plugin. Being +* main class, this class constructs other classes and also recieves callbacks, +* hence implementing their interfaces. +* +*/ + + +#ifndef BTSACONTROLLER_H +#define BTSACONTROLLER_H + + + +// INCLUDES + +// Implement Interface provided by 'BT Accessory Server' component. E-com framework +// uses this interface to load this plugin +#include +#include +#include "btsacdefs.h" +#include "btsacStreamerController.h" //MBTAudioAdaptationObserver +#include "btsacActiveObserver.h" //MBtsacActiveObserver + + +// CONSTANTS + +// DATA TYPES + +// FORWARD DECLARATIONS +class CBtsacState; +class CBTSACGavdp; +class CBTSACSEPManager; +class CBTSACStreamerController; + +// CLASS DECLARATION + +/** +* +* +* +*/ +NONSHARABLE_CLASS(CBTSAController) : public CBTAccPlugin, public MBTAudioAdaptationObserver, public MBtsacActiveObserver + { +public: // Constructors and destructor + + /** + * Two-phased constructor. + * After construction the instance is ready to serve requests. + * Also starts listening to incoming connections from BT Stereo + * audio accessories. + */ + static CBTSAController* NewL(TPluginParams& aParams); + + /** + * Destructor. + * Removes service and security registrations and stops listening to + * incoming connections. + */ + virtual ~CBTSAController(); + + /** + * State transition + * + * @since S60 v3.1 + * @param aState the next state to be entered. + */ + void ChangeStateL(CBtsacState* aState); + +public: + void ResetRemoteCache(); + void InitializeSEPManager(); + void CleanSockets(); + void StoreAccInfo(); + void DeleteAccInfo(); + TBool IsAccInfoAvailable(); + TInt AbortStream(); + + void NewAccessory(const TBTDevAddr& aBDAddr); + void DisconnectedFromRemote(const TBTDevAddr& aAddr, TInt aError ); + void AccessoryOpenedAudio(const TBTDevAddr& aBDAddr); + void AccessoryClosedAudio(const TBTDevAddr& aBDAddr); + void AccessorySuspendedAudio(const TBTDevAddr& aBDAddr); + void CompletePendingRequests(TUint aCompleteReq, TInt aError); + + void SetRemoteAddr(const TBTDevAddr& aRemoteAddr); + TBTDevAddr GetRemoteAddr() const; + TBool IsOpenAudioReqFromAccFWPending() const; + void SetSEPIndex(TInt aIndex); + TInt GetSEPIndex() const; + void SetResetAudioInput(TBool aReset); + TBool GetResetAudioInput() const; + CBtsacActive* GetGavdpErrorActive() const; + void GAVDP_Error(TInt aError) ; + +private: + + /** + * C++ default constructor. + */ + CBTSAController(TPluginParams& aParams); + + /** + * Symbian 2nd phase constructor. + * Starts listening to incoming connections from BT Stereo + * audio accessories. + * Gets ready to accept requests from clients. + */ + void ConstructL(/*TPluginParams& aParams*/); + +public: // From MBTAudioAdaptationObserver + + virtual void NotifyError(TInt aError); + +private: // Functions from CBTAccPlugin + + /** + * BT Acc Server learns if plugin supports mono audio or not + * while loading the plugin + @param None. + @return ETrue if plugin supports mono audio, TFalse otherwise. + */ + virtual TProfiles PluginType(); + + /** + * Called by BT Acc Sever to connect to mono or stereo accessory + * @param aAddr Bluetooth Device address of the remote device + * @return result of operation + */ + virtual void ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to connect to mono or stereo accessory + * @param aAddr Bluetooth Device address of the remote device + * @return result of operation + */ + virtual void CancelConnectToAccessory(const TBTDevAddr& aAddr); + + /** + * Called by BT Acc Sever to connect to mono or stereo accessory + * @param aAddr Bluetooth Device address of the remote device + * @return result of operation + */ + virtual void DisconnectAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to open audio link + * @param aAddr Bluetooth Device address of the remote device + * @return result of operation + */ + virtual void OpenAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to cancel opening of audio link + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + void CancelOpenAudioLink(const TBTDevAddr& aAddr ); + + /** + * Called by BT Acc Sever to connect to mono or stereo accessory + @param aAddr Bluetooth Device address of the remote device + @return result of operation + */ + void CloseAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); + + /** + * Called by BT Acc Sever to cancel closing of audio link + @param aAddr Bluetooth Device address of the remote device + @return + */ + void CancelCloseAudioLink(const TBTDevAddr& aAddr ); + + /** + * BTAccServer informs BTSAC to start streaming after getting permission + * from Acc Fw + */ + virtual void StartRecording(); + + /* + * Defaults from MBtsacActiveObserver + */ + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBtsacActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtsacActive& aActive); + + +private: + + /** + * Called by BT Acc Sever to inform plugin that accessory is in use. + @param None. + @return None. + */ + virtual void AccInUse(); + +public: // Data + CBTSACGavdp* iGavdp; + CBTSACStreamerController* iStreamer; + CBTSACSEPManager* iLocalSEPs; + CBTSACSEPManager* iRemoteSEPs; + RArray iStreamingSockets; + +private: // Data + /** + * the current state. + */ + CBtsacState* iState; + + /** + * AO for handling gavdp errors. + */ + CBtsacActive* iGavdpErrorActive; + + TBTDevAddr iRemoteAddr; + TInt iSBCSEPIndex; // SBC SEP Index in iRemoteSEPs array + TBool iResetAudioInput; + TRequestStatus* iConnectStatus; + TRequestStatus* iDisconnectStatus; + TRequestStatus* iOpenAudioStatus; + TRequestStatus* iCloseAudioStatus; + RPointerArray iAccDb; // one SEP manager for each accessory + }; + + +#endif // BTSAC_CONTROLLER_H + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacActiveObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacActiveObserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2005-2006 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: The observer of CBtsacActive's request events +* +*/ + + +#ifndef M_BTSACACTIVEOBSERVER_H +#define M_BTSACACTIVEOBSERVER_H + +// INCLUDES +#include + +class CBtsacActive; + +/** + * The observer of CBtsacActive's request events + * + * This class defines the interface to handle a async request events from CBtsacActive. + * + * @since S60 v3.1 + */ +class MBtsacActiveObserver + { + +public: + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBtsacActive& aActive) = 0; + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtsacActive& aActive) = 0; + + }; + +#endif // M_BTSACACTIVEOBSERVER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacActivePacketDropIoctl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacActivePacketDropIoctl.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2005 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: ?Description +* +*/ + + +#ifndef __BTSACACTIVEPACKETDROPIOCTL_H__ +#define __BTSACACTIVEPACKETDROPIOCTL_H__ + +#include +#include +#include + +/** + * An observer pattern. + * + * This class defines an observer interface for BT Audio Streamer. + * + * @lib btaudiostreamer.lib + * @since S60 v3.1 + */ +class MActivePacketDropIoctlObserver + { + public: + virtual void PacketsDropped(TInt aPacketCount) = 0; + }; + +class CActivePacketDropIoctl : public CActive + { +public: + static CActivePacketDropIoctl* NewL(MActivePacketDropIoctlObserver &aObserver, RSocket &aPendingSocket); + CActivePacketDropIoctl(MActivePacketDropIoctlObserver &aObserver, RSocket &aPendingSocket); + ~CActivePacketDropIoctl(); + void DoCancel(); + void RunL(); + void Start(); +private: + MActivePacketDropIoctlObserver &iObserver; + RSocket iPendingSocket; + TPckgBuf iPacketsLostPkgBuf; + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacGavdp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacGavdp.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,262 @@ +/* +* Copyright (c) 2005 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: Contains definition of CBTSACGavdp class which uses GAVDP API. +* Two other classes CAVStreamEndPoint and CAVSEPManager are helper +* classes to use GAVDP. This class also constructs CBTSACStreamerController +* class. +* +*/ + + +#ifndef BTSAC_GAVDP_H +#define BTSAC_GAVDP_H + + + +// INCLUDES +#include // Register SDP record for A2DP +#include // symbian Bluetooth GAVDP API + + +// CONSTANTS + +// DATA TYPES + +// FORWARD DECLARATIONS +class CBTSACStreamerController; +class CBTSACSEPManager; +class MInternalGavdpUser; + + +// CLASS DECLARATION + +/** +* +* +* +*/ +NONSHARABLE_CLASS(CBTSACGavdp) : public CBase, public MGavdpUser + + { + public: // Constructors and destructor + + + /** + * Two-phased constructor. + * + * + * + */ + static CBTSACGavdp* NewL( MInternalGavdpUser* aObserver ); + + /** + * + * + * + */ + virtual ~CBTSACGavdp(); + + public: // New Functions + + /* + * + * + */ + void RegisterObserver(MInternalGavdpUser* aObserver, const TDesC& aName); + + /* + * + * + */ + TInt StartSrc(CBTSACSEPManager& aLocalSEPs, TSBCCodecCapabilities& aSbc); + + /* + * + * + */ + void StopSrc(); // disconnect from accessory + + /* + * Connect with remote accessory + * @param aAddr bluetooth address of the device to be connected + * @return KErrNone if connection is successfull, error otherwise. + */ + void Connect( const TBTDevAddr& aAddr ); + + /* + * + * + */ + TInt Listen(); + + /* + * + * + */ + void Cancel(); + + /* + * + * + */ + void DiscoverSEPs(); + + /* + * Stop streaming to the connected remote accessory + * @param None. + * @return None. + */ + void AbortStreaming(TSEID& aRemoteSEPId); + + + /* + * Disconnects the RGavdp session from the signalling channel, but does not destroy the local SEPs owned + * by the signalling channel. Must only be called if there is no stream present - + * if a stream is present AbortStream() should be called. + * @param None. + * @return None. + */ + TInt CBTSACGavdp::Shutdown(); + + /** + * Suspend (Pause) streaming to remote accessory + * @ param None. + * @return KErrNone if streaming could be suspended successfully, error otherwise + */ + void SuspendStreams(TSEID& aRemoteSEPId); + + /* + * + * + */ + TInt ConnectAsSrc(); // Not implemented yet + + /* + * + * + */ + TInt CreateBearers(TSEID& aRemoteSEPId); + + /* + * + * + */ + TInt ConfigureSEP(TSEID aLocalSEPId, TSEID aRemoteSEPId, + TSBCCodecCapabilities& aSBCCaps, TAvdtpMediaTransportCapabilities& aMedTranCaps ); + + /* + * + * + */ + void DoSink(); // Not implemented yet + + /* + * + * + */ + void StartStreams(TSEID& aRemoteSEPId); + + /* + * + * + */ + void GetCapabilities(TSEID& aId); + + /* + * + * + */ + void SendSecurityControl(); + + /* + * Closes the stream + */ + void Close(); + + /* + * Opens a RGavdp session + */ + TInt Open(); + + /* + * Registers Stream endpoint to gavdp + * + */ + TInt RegisterSEPs(CBTSACSEPManager& aLocalSEPs, TSBCCodecCapabilities& aSbc ); + + private: + + /** + * C++ default constructor. + */ + CBTSACGavdp(); + + /** + * C++ default constructor. + */ + CBTSACGavdp( MInternalGavdpUser* aObserver ); + + /** + * Symbian 2nd phase constructor. + * + * + * + * + */ + void ConstructL(); + + + + private: // GAVDP callbacks - @see gavdp.h for definitions + + virtual void GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEP); + virtual void GAVDP_SEPDiscoveryComplete(); + virtual void GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability); + virtual void GAVDP_SEPCapabilityComplete(); + virtual void GAVDP_AbortStreamConfirm(); + virtual void GAVDP_StartStreamsConfirm(); + virtual void GAVDP_SuspendStreamsConfirm(); + virtual void GAVDP_SecurityControlConfirm(const TDesC8& aResponseData); + virtual void GAVDP_ConfigurationConfirm(); // configuration complete and SEP selected *AND* reconfigure confirm + virtual void GAVDP_Error(TInt aError, const TDesC8& aErrorData); + virtual void GAVDP_ConnectConfirm(const TBTDevAddr& aAddr); + virtual void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID); + virtual TInt GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability); + virtual TInt GAVDP_ConfigurationEndIndication(); + virtual TInt GAVDP_StartIndication(TSEID aSEID); + virtual TInt GAVDP_SuspendIndication(TSEID aSEID); + virtual TInt GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityData); + virtual void GAVDP_AbortIndication(TSEID aSEID); + virtual void GAVDP_ReleaseIndication(TSEID aSEID); + virtual void GAVDP_BearerReady(RSocket aNewSocket, const TAvdtpSockAddr& aAddr); + + + private: // Data + + MInternalGavdpUser* iObserver; + + CBTSACStreamerController* iStreamer; + RSocketServ iSockServ; + RGavdp iGavdp; + + // Handle to the AVDTP SOURCE SDP service record, which is + // created to our local SDP database + TSdpServRecordHandle iA2dpSourceSDPrecordHandle; + CBTEngDiscovery* iBTConnectionPtr; + }; + + +#endif // BTSAC_STREAMER_H + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacGavdpObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacGavdpObserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2005 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: +* +* +* +* +*/ + + +#ifndef BTSAC_GAVDP_OBSERVER_H +#define BTSAC_GAVDP_OBSERVER_H + +#include + +class MInternalGavdpUser +/** +Mixin class for GAVDP-related events. + +To enforce thinking about the sequence of GAVDP events, these are pure +@publishedPartner +@released +*/ + { +public: +/** +Callback when a signalling channel has successfully been created +Note this can be called by GAVDP without the client having called RGavdp::Connect +The reason being that as soon as a GAVDP session is created AVDTP begins listening +Therefore a remote device can connect to us. +The GAVDP client can check the address to confirm if the device is that they originally Connect()ed +@param aDeviceAddr the Bluetooth device address for which a signalling channel has been created +*/ + virtual void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr) =0; +/** +Callback when a remote SEP has been discovered +@param aSEP the details of the remote SEP +@see TAvdtpSEPInfo +*/ + virtual void GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEP) =0; +/** +Callback when no more SEPs have been discovered on the remote device. +This may be called without GAVDP_SEPDiscovered being called if the remote has no SEPs +(such a remote would be in contravention of the specification however) +*/ + virtual void GAVDP_SEPDiscoveryComplete() =0; +/** +Callback when a capability from a remote SEP has been retrieved +The client takes owenership of the capability given +@param aCapability pointer to a capability. Ownership is transferred to the MGavdpUser implementor. +@see TAvdtpServiceCapability +*/ + virtual void GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability) =0; // transfers ownership +/** +Callback when remote SEP has no more capabilities to be discovered +*/ + virtual void GAVDP_SEPCapabilityComplete() =0; +/** +Callback when the locally-initiated Abort stream has successfully completed +*/ + virtual void GAVDP_AbortStreamConfirm()=0; +/** +Callback when the locally-initiated Start stream has successfully completed +*/ + virtual void GAVDP_StartStreamsConfirm()=0; +/** +Callback when the locally-initiated Suspend stream has successfully completed +*/ + virtual void GAVDP_SuspendStreamsConfirm()=0; +/** +Callback when the locally-initiated Security Control message successfully completed +@param aResponseData The data returned by the ACP - may be the same or different to that supplied by INT +*/ + virtual void GAVDP_SecurityControlConfirm(const TDesC8& aResponseData)=0; + +/** +Callback when locally-initiated (re)configuration procedure successfully completes +*/ + virtual void GAVDP_ConfigurationConfirm()=0; // configuration complete and SEP selected *AND* reconfigure confirm + +/** +Callback when remote is beginning to configure a local SEP +This cannot be rejected by the client at this stage - it must examine each +capability proposed by the GAVDP peer. +@param aLocalSEID the SEID of the local SEP being configured +@param aRemoteSEID the SEID of the remote SEP configuring us +*/ + virtual void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID) =0; + +/** +Callback when each capability is being proposed by the peer during configuration +Each capability can be refused, but doing so completes whole configure operation +@return the client's result - eg whether it is accepting or rejecting the configuration +@param aCapability The capability being proposed. Ownership transferred to client. +*/ + virtual TInt GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability) =0; + +/** +Callback when remotely initiated configuration of local SEP is completed +The client can still error, as the local side may have expected to see more capabilities proposed +@return The client's acceptance or rejection of the whole configuration +*/ + virtual TInt GAVDP_ConfigurationEndIndication() =0; + +/** +Callback when the remote is trying to Start a stream +@param aSEID the SEID of the local SEP being started +*/ + virtual TInt GAVDP_StartIndication(TSEID aSEID) =0; +/** +Callback when the remote is trying to Suspend a stream +@param aSEID the SEID of the local SEP being suspended +*/ + virtual TInt GAVDP_SuspendIndication(TSEID aSEID) =0; +/** +Callback when the remote is sending Security Control information +@param aSEID the SEID of the local SEP for which security control is for +@param aSecurityDataInOut Security Data inbound. The client may change this descriptor for the outbound response +*/ + virtual TInt GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityDataInOut) =0; + +/** +Callback when the remote has Aborted the stream +@param aSEID the SEID of the local SEP which has been Aborted +*/ + virtual void GAVDP_AbortIndication(TSEID aSEID) =0; + +/** +Callback when the remote end has Released a stream +The user-plane bearers will subsequently error with KErrDisconnected. +@param aSEID the SEID of the local SEP which was been released +*/ + virtual void GAVDP_ReleaseIndication(TSEID aSEID) =0; +/** +Callback when a bearer has been created for a session in the stream. +The session the bearer is for can be examined from the socket address given in the callback +Each socket created in this way is created on the client's socket server session, +and responsibility for socket closure is ceded to the client. +@param aSocket the socket created on the client's socket server session. +@param aAddress the socket address (containing SEID, Session type) +@see TAvdtpSockAddr +*/ + virtual void GAVDP_BearerReady(RSocket aSocket, const TAvdtpSockAddr& aAddress)=0; + +/** +Callback when a GAVDP error occurs +@param aError system-wide or GAVDP or AVDTP error code +@param aErrorData extra data relating to the error - the client can deduce the nature based on their GAVDP state and the spec +@see TAvdtpConfigRejectPckgBuf as an example of what may be passed back +*/ + virtual void GAVDP_Error(TInt aError, const TDesC8& aErrorData) =0; + }; + +#endif // BTSAC_GAVDP_OBSERVER_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacSEPManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacSEPManager.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2005 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: Contains definition of CBTSACGavdp class which uses GAVDP API. +* Two other classes CAVStreamEndPoint and CBTSACSEPManager are helper +* classes to use GAVDP. This class also constructs CBTSACStreamerController +* class. +* +*/ + + +#ifndef BTSAC_SEP_MANAGER_H +#define BTSAC_SEP_MANAGER_H + +#include "btsacStreamEndPoint.h" + + +// DATA TYPES +_LIT(KSEPIdle, "Idle"); +_LIT(KSEPDiscoveredRemote, "Remote"); +_LIT(KSEPRegistered, "Registered"); +_LIT(KSEPLocallyConfigured, "Configured"); +_LIT(KSEPRemotelyBound, "Remotely bound"); +_LIT(KSEPOpen, "Open"); +_LIT(KSEPStreaming, "Streaming"); +_LIT(KSEPSuspended, "Suspended"); +_LIT(KSEPAborted, "Aborted"); +_LIT(KSEPErrored, "Errored"); + + +// FORWARD DECLARATION + + +NONSHARABLE_CLASS(CBTSACSEPManager) : public CBase + { +public: + static CBTSACSEPManager* NewL(const TBTDevAddr& aAddr); + + TInt SetState(TSEID aSEID, CBTSACStreamEndPoint::TSEPState aState, const TAny* aBlob=NULL); + void BindSEPs(TSEID aLocalSEID, TSEID aRemoteSEID); + void NewSEPL(const TAvdtpSEPInfo& aInfo); + TInt GetSEP(TSEID aSEID, CBTSACStreamEndPoint& aSEP); + TInt NoOfSEPs(); + TInt GetInfo(TInt aIndex, TAvdtpSEPInfo& aInfo); + TInt StoreCaps( TInt aIndex, TAvdtpServiceCapability* aCaps ); + TInt GetCaps(TInt aIndex, RPointerArray& ); + virtual ~CBTSACSEPManager(); + const TBTDevAddr& GetDeviceAddr(); +private: + TInt FindSEP(TSEID aSEID, CBTSACStreamEndPoint& aSEP); + CBTSACSEPManager(); + CBTSACSEPManager(const TBTDevAddr& aAddr); +private: + RPointerArray iStreamEndPoints; + TBTDevAddr iAddr; + }; + + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacState.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,228 @@ +/* +* Copyright (c) 2005-2006 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: The base state declaration +* +*/ + + +#ifndef C_BTSACSTATE_H +#define C_BTSACSTATE_H + +#include +#include +#include +#include "btsacGavdpObserver.h" // MInternalGavdpUser +#include "btsacActiveObserver.h" +#include "btsaController.h" + +enum TStateIndex + { + EStateIdle, + EStateListening, + EStateConnecting, + EStateConfiguring, + EStateConnected, + EStateConfigured, + EStateStreaming, + EStateSuspended, + EStateAborting + }; + +/** + * the base class of the state machine + * + * @since S60 v3.1 + */ +class CBtsacState : public CBase, public MInternalGavdpUser + { +public: + + virtual ~CBtsacState(); + + /** + * Entry of this state. + * + * @since S60 v3.1 + */ + virtual void EnterL() = 0; + + /** + * Returns the next state if EnterL leaves. + * + * @since S60 v3.1 + * @return the next state + */ + virtual CBtsacState* ErrorOnEntryL(TInt aReason); + + /** + * Connect to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void ConnectL(const TBTDevAddr& aAddr); + + /** + * Cancel the outstanding connecting operation + * + * @since S60 v3.1 + */ + virtual void CancelConnectL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aStatus On completion, will contain an error code + */ + virtual void DisconnectL(); + + /** + * Open audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void OpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * Cancel the outstanding operation + * + * @since S60 v3.1 + */ + virtual void CancelOpenAudioLinkL(); + + /** + * Close the audio link (synchronous) to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + virtual void CloseAudioLinkL(const TBTDevAddr& aAddr); + + /** + * Cancel the outstanding operation + * + * @since S60 v3.1 + */ + virtual void CancelCloseAudioLink(const TBTDevAddr& aAddr); + + /** + * + * @return an error. Default implementation returns KErrNotFound + */ + virtual void Configure(); + + /** + * Called when the connection is disconnected from remote side or there + * is error on reading/writing data packet. + * @param aErr the error code of event + */ + virtual void DisconnectedFromRemoteOrError(TInt aErr); + + /** + * BTAccServer informs BTSAC to start streaming after getting permission + * from Acc Fw + */ + virtual void StartRecording(); + + /** + * Default for handling gavdp errors + */ + virtual void HandleGavdpErrorL(TInt aError); + + /** + * Gets the index of the state + */ + TStateIndex GetStateIndex() const; + + /* + * Defaults from MInternalGavdpUser @see btsacGavdpObserver.h for definitions + */ + +public: + + virtual void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr); + virtual void GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEP); + virtual void GAVDP_SEPDiscoveryComplete(); + virtual void GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability); // transfers ownership + virtual void GAVDP_SEPCapabilityComplete(); + virtual void GAVDP_AbortStreamConfirm(); + virtual void GAVDP_StartStreamsConfirm(); + virtual void GAVDP_SuspendStreamsConfirm(); + virtual void GAVDP_SecurityControlConfirm(const TDesC8& aResponseData); + virtual void GAVDP_ConfigurationConfirm(); // configuration complete and SEP selected *AND* reconfigure confirm + virtual void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID); + virtual TInt GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability); + virtual TInt GAVDP_ConfigurationEndIndication(); + virtual TInt GAVDP_StartIndication(TSEID aSEID); + virtual TInt GAVDP_SuspendIndication(TSEID aSEID); + virtual TInt GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityDataInOut); + virtual void GAVDP_AbortIndication(TSEID aSEID); + virtual void GAVDP_ReleaseIndication(TSEID aSEID); + virtual void GAVDP_BearerReady(RSocket aSocket, const TAvdtpSockAddr& aAddress); + virtual void GAVDP_Error(TInt aError, const TDesC8& aErrorData); + + /* + * Defaults from MBtsacActiveObserver + */ + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBtsacActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtsacActive& aActive); + +protected: + + CBtsacState(CBTSAController& aParent, TStateIndex aStateIndex); + + /** + * Gets the owner of the state machine + * + * @since S60 v3.1 + * @return the state machine owner + */ + CBTSAController& Parent(); + + CBtsacActive* GavdpErrorActive(); + +private: + + /** + * the owner of the state machine + * Not own. + */ + CBTSAController& iParent; + + /** + * State name. + */ + TStateIndex iStateIndex; + }; + +#endif // C_BTSACSTATE_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateAborting.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateAborting.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2006 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: state Aborting declaration. +* +*/ + + +#ifndef C_BTSACABORTING_H +#define C_BTSACABORTING_H + +#include "btsacState.h" + +/** + * The state Aborting + * + * + * @since S60 v3.1 + */ +class CBtsacAborting : public CBtsacState + { + +public: + + static CBtsacAborting* NewL(CBTSAController& aParent); + + virtual ~CBtsacAborting(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + void HandleGavdpErrorL(TInt aError); + +private: + + CBtsacAborting(CBTSAController& aParent); + }; + +#endif // C_BTSACABORTING_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateConfigured.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateConfigured.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2006 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: state Configured declaration. +* +*/ + + +#ifndef C_BTSACCONFIGURED_H +#define C_BTSACCONFIGURED_H + +#include "btsacState.h" + +/** + * The state Configured + * + * + * @since S60 v3.1 + */ +class CBtsacConfigured : public CBtsacState, public MBtsacActiveObserver + { + +public: + + static CBtsacConfigured* NewL(CBTSAController& aParent, RSocket aNewSocket, TAudioOpenedBy aAudioOpenedBy, TStreamConfiguredBy aStreamConfiguredBy); + + virtual ~CBtsacConfigured(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(); + + /** + * From CBtsacState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * From CBtsacState + * Cancels Open audio link request + * + * @since S60 v3.1 + */ + void CancelOpenAudioLinkL(); + + /** + * From CBtsacState + * Cancel the outstanding connecting operation + * + * @since S60 v3.1 + */ + void CancelConnectL(); + + // From class MInternalGavdpUser + void GAVDP_StartStreamsConfirm(); + TInt GAVDP_StartIndication(TSEID aSEID); + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBtsacActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtsacActive& aActive); + + void StartTimer(TTimeIntervalMicroSeconds32 aTimeout); + void StopTimer(); + + void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset); + void HandleGavdpErrorL(TInt aError); + +private: + + CBtsacConfigured(CBTSAController& aParent, RSocket aNewSocket, TAudioOpenedBy aAudioOpenedBy, TStreamConfiguredBy aStreamConfiguredBy); + void ConstructL(); + +private: + enum TStartStreamStatus + { + EStartNone, + EStartSendBySrc, + EStartCollision + }; + /** + * AO for configuration timer. + */ + CBtsacActive* iTimerActive; + + /** + * Configuration timer + */ + RTimer iTimer; + + TAudioOpenedBy iAudioOpenedBy; + TStreamConfiguredBy iStreamConfiguredBy; + TStartStreamStatus iStartStreamStatus; + }; + +#endif // C_BTSACCONFIGURED_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateConfiguring.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateConfiguring.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2006 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: state Listening declaration. +* +*/ + + +#ifndef C_BTSACCONFIGURING_H +#define C_BTSACCONFIGURING_H + +#include "btsacState.h" + +/** + * The state Connected + * + * + * @since S60 v3.1 + */ +class CBtsacConfiguring : public CBtsacState + { + +public: + + static CBtsacConfiguring* NewL(CBTSAController& aParent, TSEID aLocalSEID, TSEID aRemoteSEID); + + virtual ~CBtsacConfiguring(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(); + + /** + * From CBtsacState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr); + + + /** + * From CBtsacState + * Cancel the outstanding connecting operation + * + * @since S60 v3.1 + */ + void CancelConnectL(); + + + // From class MInternalGavdpUser + void GAVDP_BearerReady(RSocket aSocket, const TAvdtpSockAddr& aAddress); + TInt GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability); + TInt GAVDP_ConfigurationEndIndication(); + TInt GAVDP_StartIndication(TSEID aLocalSEID); + + void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset); + void HandleGavdpErrorL(TInt aError); + +private: + + CBtsacConfiguring(CBTSAController& aParent, TSEID aLocalSEID, TSEID aRemoteSEID); + +private: + + TSEID iLocalSEID; + TSEID iRemoteSEID; + TBool iSEPFound; + TInt iRemoteSEPIndex; + TAudioOpenedBy iAudioOpenedBy; + }; + +#endif // C_BTSACCONFIGURING_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateConnected.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateConnected.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2006 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: state Listening declaration. +* +*/ + + +#ifndef C_BTSACCONNECTED_H +#define C_BTSACCONNECTED_H + +#include "btsacState.h" + +/** + * The state Connected + * + * + * @since S60 v3.1 + */ + +class CBtsacConnected : public CBtsacState, public MBtsacActiveObserver + { + +public: + + static CBtsacConnected* NewL(CBTSAController& aParent, TBTConnType aConnType); + + virtual ~CBtsacConnected(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(); + + /** + * From CBtsacState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * From CBtsacState + * Cancel the outstanding connecting operation + * + * @since S60 v3.1 + */ + void CancelConnectL(); + + void CancelOpenAudioLinkL(); + + void ConfigureL(); + void GetCapabilitiesOfAllSEPs(); + + // From class MInternalGavdpUser + void GAVDP_ConfigurationConfirm(); + void GAVDP_BearerReady(RSocket aSocket, const TAvdtpSockAddr& aAddress); + void GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEP); + void GAVDP_SEPDiscoveryComplete(); + void GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability); + void GAVDP_SEPCapabilityComplete(); + void GAVDP_AbortIndication(TSEID aSEID); + void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID); + + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + void RequestCompletedL(CBtsacActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtsacActive& aActive); + + void StartTimer(TTimeIntervalMicroSeconds32 aTimeout, TInt aRequestId); + void StopTimer(); + + void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset); + void HandleGavdpErrorL(TInt aError); + + void StartConfigurationL(); + +private: + + CBtsacConnected(CBTSAController& aParent, TBTConnType aConnType); + void ConstructL(); + +private: + enum TBTSACSepFound + { + ESEPNotInitialized, + ESEPConfigure, + ESEPInUse, + ESEPCodecTypeNotAllowed + }; + + /** + * AO for configuration timer. + */ + CBtsacActive* iTimerActive; + + /** + * Configuration timer + */ + RTimer iTimer; + + TBool iSuitableSEPFoundAlready; + TBTConnType iConnType; // Connection type: incoming/outgoing + TBool iFirstConn; // used to learn if configuration should be done + TBTSACSepFound iSEPFound; + TInt iRemoteSEPIndex; + TBool iBearersQuery; + TBool iCancelConnectReq; + TAudioOpenedBy iAudioOpenedBy; + }; + +#endif // C_BTSACCONNECTED_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateConnecting.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateConnecting.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2006 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: state Listening declaration. +* +*/ + + +#ifndef C_BTSACCONNECTING_H +#define C_BTSACCONNECTING_H + +#include "btsacState.h" + +/** + * The state Idle + * + * + * @since S60 v3.1 + */ +class CBtsacConnecting : public CBtsacState + { + +public: + + static CBtsacConnecting* NewL(CBTSAController& aParent, TBTConnType aConnType); + + virtual ~CBtsacConnecting(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * From CBtsacState + * Cancels connect request to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void CancelConnectL(); + + /** + * From CBtsacState + * Cancels open audio request + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void CancelOpenAudioL(const TBTDevAddr& aAddr); + + // From base class MInternalGavdpUser + + void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr); + + void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset); + void HandleGavdpErrorL(TInt aError); + + +private: + CBtsacConnecting(CBTSAController& aParent, TBTConnType aConnType); + +private: + TBTConnType iConnType; // Connection type: incoming/outgoing + }; + +#endif // C_BTSACCONNECTING_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateIdle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateIdle.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2006 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: state Idle declaration. +* +*/ + + +#ifndef C_BTSACIDLE_H +#define C_BTSACIDLE_H + +#include "btsacState.h" + +/** + * The state Idle + * + * + * @since S60 v3.1 + */ +class CBtsacIdle : public CBtsacState + { + +public: + + static CBtsacIdle* NewL(CBTSAController& aParent); + + virtual ~CBtsacIdle(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + // From base class MInternalGavdpUser + + void GAVDP_ConfigurationConfirm(); + void GAVDP_Error(TInt aError, const TDesC8& aErrorData); + +private: + + CBtsacIdle(CBTSAController& aParent); + }; + +#endif // C_BTSACIDLE_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateListening.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateListening.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2006 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: state Listening declaration. +* +*/ + + +#ifndef C_BTSACLISTENING_H +#define C_BTSACLISTENING_H + +#include "btsacState.h" + +enum TBTInitProcedure + { + EInitProcedureNone, + EInitProcedureOngoing, + EInitProcedureWaitingConfConfirmed, + EInitProcedureDone + }; + +/** + * The state Idle + * + * + * @since S60 v3.1 + */ +class CBtsacListening : public CBtsacState, public MBtsacActiveObserver + { + +public: + + static CBtsacListening* NewL(CBTSAController& aParent, TBTSACGavdpResetReason aGavdpResetReason, TInt aDisconnectReason); + + virtual ~CBtsacListening(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * From CBtsacState + * Connect to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void ConnectL(const TBTDevAddr& aAddr); + + /** + * From CBtsacState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * From CBtsacState + * Cancels Open audio link request + * + * @since S60 v3.1 + */ + void CancelOpenAudioLinkL(); + + // From base class MInternalGavdpUser + void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr); + void GAVDP_ConfigurationConfirm(); + void GAVDP_AbortStreamConfirm(); + void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID); + + void HandleGavdpErrorL(TInt aError); + + void DoSelfComplete(TInt aError); + + /* + * Defaults from MBtsacActiveObserver + */ + /** + * Handles the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CBtsacActive& aActive); + + /** + * Handles the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CBtsacActive& aActive); + + TInt ResetGavdp(TBTSACGavdpResetReason aReason); + void GoListen(); + void DeleyedOpenAudioAndConnectL(); + +private: + + CBtsacListening(CBTSAController& aParent, TBTSACGavdpResetReason aGavdpResetReason, TInt aDisconnectReason); + void ConstructL(); + +private: + TBTSACGavdpResetReason iGavdpResetReason; + TInt iDisconnectReason; + TInt iPendingRequests; + TBTInitProcedure iInitializationProcedure; + TBool iUnfinishedGavdpError; + + /** + * AO for self completing. + */ + CBtsacActive* iSelfCompleteActive; + }; + +#endif // C_BTSACLISTENING_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateStreaming.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateStreaming.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2006 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: state Streaming declaration. +* +*/ + + +#ifndef C_BTSACSTREAMING_H +#define C_BTSACSTREAMING_H + +#include "btsacState.h" + +/** + * The state Configured + * + * + * @since S60 v3.1 + */ +class CBtsacStreaming : public CBtsacState + { + +public: + + static CBtsacStreaming* NewL(CBTSAController& aParent,TAudioOpenedBy aAudioOpenedBy, TBool aStartCollision); + + virtual ~CBtsacStreaming(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(); + + /** + * From CBtsacState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * From CBtsacState + * Close the audio link to the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void CloseAudioLinkL(const TBTDevAddr& aAddr); + + /** + * From CBtsacState + * Cancels close the audio link request + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void CancelCloseAudioLink(const TBTDevAddr& aAddr); + + // From class MInternalGavdpUser + void GAVDP_AbortIndication(TSEID aSEID); + TInt GAVDP_SuspendIndication(TSEID aSEID); + void GAVDP_ReleaseIndication(TSEID aSEID); + void GAVDP_SuspendStreamsConfirm(); + + void StartRecording(); + void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset); + void HandleGavdpErrorL(TInt aError); + +private: + + CBtsacStreaming(CBTSAController& aParent, TAudioOpenedBy aAudioOpenedBy, TBool aStartCollision); + +private: + + TBool iSuspending; + TAudioOpenedBy iAudioOpenedBy; + TBool iStartCollision; + }; + +#endif // C_BTSACSTREAMING_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStateSuspended.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStateSuspended.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2006 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: state Suspended declaration. +* +*/ + + +#ifndef C_BTSACSUSPENDED_H +#define C_BTSACSUSPENDED_H + +#include "btsacState.h" + +/** + * The state Configured + * + * + * @since S60 v3.1 + */ +class CBtsacSuspended : public CBtsacState + { + +public: + + static CBtsacSuspended* NewL(CBTSAController& aParent); + + virtual ~CBtsacSuspended(); + +private: + + // From base class CBtsacState + + /** + * From CBtsacState + * Entry of this state. + */ + void EnterL(); + + /** + * disconnect the connected accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void DisconnectL(); + + /** + * From CBtsacState + * Open audio link to BT accessory + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void OpenAudioLinkL(const TBTDevAddr& aAddr); + + /** + * Cancels the open audio link request + * + * @since S60 v3.1 + * @param aAddr the BD address of the accessory + * @param aStatus On completion, will contain an error code + */ + void CancelOpenAudioL(const TBTDevAddr& aAddr); + + + // From class MInternalGavdpUser + void GAVDP_StartStreamsConfirm(); + TInt GAVDP_StartIndication(TSEID aSEID); + void GAVDP_ReleaseIndication(TSEID aSEID); + + void CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset); + void HandleGavdpErrorL(TInt aError); + +private: + + CBtsacSuspended(CBTSAController& aParent); + + TBool iOpenAudioReq; + }; + +#endif // C_BTSACSUSPENDED_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStreamEndPoint.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStreamEndPoint.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2005 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: +* +* +* +* +*/ + + +#ifndef BTSAC_STREAM_END_POINT_H +#define BTSAC_STREAM_END_POINT_H + +#include // Protocol definitions, e.g., TAvdtpMediaCodecCapabilities + + +NONSHARABLE_CLASS(CBTSACStreamEndPoint) : public CBase + { +public: +enum TSEPState + { + EIdle, + EDiscoveredRemote, + ERegistered, + ELocallyConfigured, + ERemotelyBound, + EOpen, + EStreaming, + ESuspended, + EAborted, + }; +public: + static CBTSACStreamEndPoint* NewL(const TAvdtpSEPInfo& aInfo); + void SetState(TSEPState aState, const TAny* aBlob=NULL); + void GetInfo(TAvdtpSEPInfo& aInfo); + void StoreCaps(TAvdtpServiceCapability* aCaps); + void GetCaps(RPointerArray& aCaps); + virtual ~CBTSACStreamEndPoint(); + inline TSEID SEID() const + { + return iInfo.SEID(); + } +private: + CBTSACStreamEndPoint(); + CBTSACStreamEndPoint(const TAvdtpSEPInfo& aInfo); +private: + const TAvdtpSEPInfo iInfo; + TBool iIsRemote; + RPointerArray iSEPCapabilities; + }; + + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacStreamerController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacStreamerController.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2005 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: Declaration for CBTSACStreamerController class. This class constructs and +* communicates with 'BT Audio Streamer' component to do RTP streaming. + +* +*/ + + +#ifndef BTSAC_STREAMER_H +#define BTSAC_STREAMER_H + +// INCLUDES + +#include +#include +#include // Protocol definitions, e.g., TSBCCodecCapabilities +#include "btsacActivePacketDropIoctl.h" +#include // uuid of SBC Encoder + + +class MBTAudioAdaptationObserver + { + public: + virtual void NotifyError(TInt aError) = 0; + }; + +// CONSTANTS + +// DATA TYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** +* +* +* +*/ + +class TBitpoolData + { +public: + TInt iMaxBitpoolValue; + TInt iMaxDeviation; + //TInt iUpgradeDelay; + TInt iIndex; + TInt iDownBitpoolIndex; + TInt iUpBitpoolIndex; + TBool iMinimumMaxBitpool; + }; + +NONSHARABLE_CLASS(CBTSACStreamerController) : public CActive, MBTAudioErrorObserver, MActivePacketDropIoctlObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * + * + * + */ + static CBTSACStreamerController* NewL(MBTAudioAdaptationObserver& aObserver); + + /** + * Destructor. + * + * + */ + virtual ~CBTSACStreamerController(); + + public: + // From MBTAudioErrorObserver + virtual TInt Error(const TInt aError); + + // From MActivePacketDropIoctlObserver + virtual void PacketsDropped(TInt aPacketCount); + + + public: // New functions + + /** + * + * + * @param aStatus + * @return None. + */ + TInt StartStream(RSocket& aSocket, TInt aFrameLength); + + /** + * + * + * @param aStatus + * @return None. + */ + TInt StopStream(); + + /** + * + * + * @param aStatus + * @return None. + */ + void ResetAudioInput(); + + /** + * + * + * @param aStatus + * @return None. + */ + TInt FillCapabilities( TSBCCodecCapabilities& aSbc ); + + /** + * + * + * @param aStatus + * @return None. + */ + TInt ConfigureSEP( TSBCCodecCapabilities& aDec ); + + /** + * + * + * @param aStatus + * @return None. + */ + TInt FrameLength() const; + + /** + * + * + * @param none + * @return TSBCCodecCapabilities. + */ + TSBCCodecCapabilities &GetCaps(); + + protected: // Functions from CActive + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + void RunL(); + + /** + * DoCancel() has to be implemented by all the classes deriving CActive. + * Request cancellation routine. + * @param none + * @return none + */ + void DoCancel(); + + /** + * RunError is called if RunL() leaves + */ + TInt RunError(TInt aError); + + + private: // Data definitions + + enum TBTSACStreamingState + { + EStateStreaming, + EStateIdle, + EStateError + }; + + typedef enum EOngoingAction + { + ENone, + EErrorSending, + EDowngradeBitrate, + EUpgradeBitrate, + EStartStabilizingTimer, + EStabilize + }; + + private: + + /** + * C++ default constructor. + */ + CBTSACStreamerController(MBTAudioAdaptationObserver& aObserver); + + /** + * Symbian 2nd phase constructor. + * + * + * + * + */ + void ConstructL(); + + void CheckAndAdjustBitpool(TSBCCodecCapabilities& aDec); + TInt GetMatchingCaps(TSBCCodecCapabilities& aCaps); + TInt ConfigureSEPBitpool(EOngoingAction aAction); + void DoSelfComplete(EOngoingAction aAction, TInt aError); + + void SetBlockLen(TSBCCodecCapabilities& aCap, TUint8 aBlockLen); + TInt GetBlockLen(TSBCCodecCapabilities& aCap) const; + void SetSamplingFrequency(TSBCCodecCapabilities& aCap, TUint8 aFrequency); + TInt GetSamplingFrequency(TSBCCodecCapabilities& aCap) const; + TInt FrameLengthFormula(TSBCCodecCapabilities& aCap) const; + TInt GetNumOfChannels(TSBCCodecCapabilities& aCap) const; + void SetNumOfSubbands(TSBCCodecCapabilities& aCap, TUint8 aNumOfSubbands); + TInt GetNumOfSubbands(TSBCCodecCapabilities& aCap) const; + void SetBitpoolValues(TSBCCodecCapabilities& aCap); + void SetAllocationMethod(TSBCCodecCapabilities& aCap, TUint8 aAllocationMethod); + void SetChannelMode(TSBCCodecCapabilities& aCap, TUint8 aChannelMode); + + TInt SetCurrentBitpoolData(TInt aBitpool); + void InitializeBitpoolDataL(); + void ReorganizeBitpoolTable(TInt aNegotiatedMaxBitpool); + TBitpoolData* GetBitpoolData(TInt aIndex); + TInt GetIndex(TInt aBitpool); + TBool IndexValid(TInt aIndex); + + private: // Data + + CBTAudioStreamer* iBTStreamer; // Bluetooth Audio Streamer component + CBTAudioStreamInputBase* iAudioInput; + TBTSACStreamingState iState; + EOngoingAction iOngoingAction; + TSBCCodecCapabilities iLocalCap; // local copy of Audio Adapatation capabilities + TSBCCodecCapabilities iMatchCap; // local copy of capabilites used to configure accessory + RLibrary iLib; // for loading BTAudioStreamer and BTAudioAdaptation dll + TInt iCurrentBitrate; + TInt iCurrentFrameLength; + RTimer iTimer; + CActivePacketDropIoctl* iPacketDropIoctl; + RThread iThread; + CSbcEncoderIntfc *iEncoderCI; + MBTAudioAdaptationObserver& iObserver; + TInt iTotalNbrOfDroppedPackets; + TTime iFirstPacketDropTime; + TInt iPacketDropDeviation; + RArray iBitpoolData; + TBitpoolData* iCurrentBitpoolData; + }; + + +#endif // BTSAC_STREAMER_H + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2005-2006 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: The base active object declaration +* +*/ + + +#ifndef C_BTSACACTIVE_H +#define C_BTSACACTIVE_H + +// INCLUDES +#include +#include "btsacActiveObserver.h" + +/** + * The base class of Active Object. + * + * This class provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CBtsacActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CBtsacActive : public CActive + { + +public: + + static CBtsacActive* NewL(MBtsacActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + static CBtsacActive* NewLC(MBtsacActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + virtual ~CBtsacActive(); + +public: + + /** + * Calls SetActive(). + * + * @since S60 v3.1 + */ + virtual void GoActive(); + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @return the request identifier + */ + TInt RequestId() const; + + /** + * Sets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @param the request identifier + */ + void SetRequestId(TInt aRequestId); + +protected: + + /** + * From CActive. + * cancels the outstanding request. + * + * @since S60 v3.1 + */ + virtual void DoCancel(); + + /** + * From CActive. + * Handles the request completion event. + * + * @since S60 v3.1 + */ + virtual void RunL(); + + /** + * From CActive. + * Handles the leave from RunL(). + * + * @since S60 v3.1 + * @param aError the leave code in RunL() + * @return the error code to Active Scheduler + */ + virtual TInt RunError(TInt aError); + +protected: + + CBtsacActive(MBtsacActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + MBtsacActiveObserver& Observer(); + +private: + + /** + * The observer which is interested in the request handling events. + * Not own. + */ + MBtsacActiveObserver& iObserver; + + /** + * The request identifier assigned to this active object. + */ + TInt iRequestId; + + }; + +#endif // C_BTSACACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacdefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacdefs.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2006 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: type declaration. +* +*/ + + +#ifndef BTSACDEFS_H +#define BTSACDEFS_H + +const TInt KBTDevAddrReadable = KBTDevAddrSize * 2; + +const TUint8 KRequestNone = 0x00; +const TUint8 KConnectReq = 0x01; +const TUint8 KDisconnectReq = 0x02; +const TUint8 KOpenAudioReq = 0x04; +const TUint8 KCloseAudioReq = 0x08; +const TUint8 KCompleteAllReqs = 0xff; + + +const TInt KRequestIdWaitRemoteConfStart = 0xfffb; +const TInt KRequestIdGavdpError = 0xfffc; +const TInt KRequestIdTimer = 0xfffd; +const TInt KRequestIdSelfComplete = 0xfffe; + +enum TBTConnType + { + EOutgoingConn, + EOutgoingConnNoDiscovery, + EOutgoingConnWithAudio, + EOutgoingConnWithAudioNoDiscovery, + EIncomingConn, + EConnExists + }; + +enum TAudioOpenedBy + { + EAudioOpenedByNone, + EAudioOpenedByAFW, + EAudioOpenedByAcc + }; + +enum TStreamConfiguredBy + { + EStreamConfiguredBySrc, + EStreamConfiguredBySink + }; + +enum TBTSACGavdpResetReason + { + EGavdpResetReasonNone, + EGavdpResetReasonGeneral, + EGavdpResetReasonCancelOpenAudio, + EGavdpResetReasonDisconnect + }; + +//Panic codes +enum TBTPanicCode + { + EBTPanicNullPointer = 33400, + EBTPanicSocketExists + }; + +#endif // BTSACDEFS_H + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/btsacpluginuid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/btsacpluginuid.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2002 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: +* Defines Implementation Uid for BT Stereo Audio +* E-Com Plugin +* +* +*/ + +#ifndef BTSACPLUGINUID_H +#define BTSACPLUGINUID_H + +/** +The implementation UID of the Stereo Audio plugin. +*/ +#define KBTSACUid 0x10208974 + +#endif // BTSACPLUGINUID_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 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: Debug configure file. +* +*/ + + +#ifndef DEBUGCONFIG_H +#define DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btsac.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTSAC] "); +_LIT8(KTracePrefix8, "[BTSAC] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTSAC"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 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: Project configure file. +* +*/ + + +#ifndef PRJCONFIG_H +#define PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/rom/btsac.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/rom/btsac.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef __BTSAC_IBY__ +#define __BTSAC_IBY__ + +#include + +#ifdef __BT_STEREO_AUDIO + +//file content + +ECOM_PLUGIN(btsac.dll, btsac.rsc) +ECOM_PLUGIN(btrcc.dll, btrcc.rsc) + +#endif + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/Proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/Proxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2005 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: Implementation table defines the main class to be loaded by +* E-com framework. +* +*/ + + + +#include // E-Com entry definition +#include "btsaController.h" // definition of controller class +#include "btsacpluginuid.h" + +// Map the interface UIDs to implementation factory functions +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KBTSACUid, CBTSAController::NewL), + }; + +// Exported proxy for instantiation method resolution +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsaController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsaController.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,684 @@ +/* +* Copyright (c) 2005 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: Implementation for CBTSAController class. This class is advertised +* to E-com framework (@see proxy.cpp) so that it loads this class when +* this plugin gets loaded. That is why this class implements the interface +* of the module (currently BT Accessory Server) which loads this plugin.Being +* main class, this class constructs other classes and also recieves callbacks, +* hence implementing their interfaces. +* +*/ + + +// INCLUDE FILES +#include "btsaController.h" +#include "btsacactive.h" +#include "btsacStateIdle.h" +#include "btsacStateListening.h" +#include "btsacStreamerController.h" +#include "btsacSEPManager.h" +#include "btsacGavdp.h" +#include "debug.h" +#include +#include "btaudioremconpskeys.h" + +_LIT_SECURITY_POLICY_C1( KPSKeyReadPolicy, + ECapabilityLocalServices); +_LIT_SECURITY_POLICY_C1( KPSKeyWritePolicy, + ECapabilityLocalServices); + +// CONSTANTS + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTSAController::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTSAController* CBTSAController::NewL(TPluginParams& aParams) + { + CBTSAController* self = new (ELeave) CBTSAController(aParams); + CleanupStack::PushL(self); + self->ConstructL( ); + CleanupStack::Pop(self); + return self; + } + + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTSAController::~CBTSAController() + { + TRACE_FUNC + if(iStreamingSockets.Count()) + { + TRACE_INFO((_L("[SOCKET] closed."))) + iStreamingSockets[0].Close(); + } + iStreamingSockets.Close(); + delete iStreamer; + delete iGavdp; + delete iState; + delete iGavdpErrorActive; + delete iLocalSEPs; + delete iRemoteSEPs; + iAccDb.ResetAndDestroy(); + iAccDb.Close(); + RProperty::Delete( KBTAudioRemCon, KBTAudioPlayerControl ); + TRACE_INFO((_L("CBTSAController::~CBTSAController() completed"))) + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CBTSAController +// C++ default constructor. +// ----------------------------------------------------------------------------- +// +CBTSAController::CBTSAController(TPluginParams& aParams) + : CBTAccPlugin(aParams) + { + TRACE_FUNC + } + + +// ----------------------------------------------------------------------------- +// CBTSAController::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTSAController::ConstructL() + { + TRACE_FUNC_ENTRY + CBtsacState* state = CBtsacIdle::NewL(*this); + CleanupStack::PushL(state); + iStreamer = CBTSACStreamerController::NewL(*this); + // Initially idle state is registered as observer of GAVDP + iGavdp = CBTSACGavdp::NewL(state); + iLocalSEPs = CBTSACSEPManager::NewL(TBTDevAddr()); + iGavdpErrorActive = CBtsacActive::NewL(*this, CActive::EPriorityStandard, KRequestIdGavdpError); + ChangeStateL(state); + CleanupStack::Pop(state); + + ResetRemoteCache(); + + TInt err = RProperty::Define( KBTAudioRemCon, + KBTAudioPlayerControl, RProperty::EInt, + KPSKeyReadPolicy, + KPSKeyWritePolicy ); + TRACE_INFO((_L("PS define err %d"), err)) + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::ChangeStateL +// ----------------------------------------------------------------------------- +// +void CBTSAController::ChangeStateL(CBtsacState* aState) + { + TRACE_FUNC_ENTRY + TRACE_ASSERT(!!aState, EBTPanicNullPointer); + if(iState) + { + if(aState->GetStateIndex() == iState->GetStateIndex()) + { + // We already are in desired state, delete the state which came in and return + TRACE_INFO((_L("CBTSAController::ChangeStateL(), already in desired state."))) + delete aState; + return; + } + } + CBtsacState *CurrentState = iState; + iState = aState; + TInt err = KErrNone; + TRAP(err, iState->EnterL()); + if (err) + { + ChangeStateL(iState->ErrorOnEntryL(err)); + } + delete CurrentState; + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::ResetRemoteCache +// ----------------------------------------------------------------------------- +// +void CBTSAController::ResetRemoteCache() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTSAController::InitializeSEPManager +// ----------------------------------------------------------------------------- +// +void CBTSAController::InitializeSEPManager() + { + TRACE_FUNC + iSBCSEPIndex = 0; // SBC SEP Index in iRemoteSEPs array + if( iRemoteSEPs ) + { + delete iRemoteSEPs; + iRemoteSEPs = NULL; + } + TRAPD(ret, iRemoteSEPs = CBTSACSEPManager::NewL(iRemoteAddr)); + if (ret) + { + TRACE_INFO((_L("CBTSAController::InitializeSEPManager(), ERROR"))) + } + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CleanSockets +// ----------------------------------------------------------------------------- +// +void CBTSAController::CleanSockets() + { + TRACE_FUNC + if(iStreamingSockets.Count()) + { + // Close possible streaming socket(s) + TRACE_INFO((_L("[SOCKET] closed."))) + iStreamingSockets[0].Close(); + iStreamingSockets.Remove(0); + iStreamingSockets.Reset(); + } + } + +// ----------------------------------------------------------------------------- +// CBTSAController::PluginType +// ----------------------------------------------------------------------------- +// +TProfiles CBTSAController::PluginType() + { + TRACE_FUNC + return EStereo; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::ConnectToAccessory +// ----------------------------------------------------------------------------- +// +void CBTSAController::ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); + Trace(_L("[REQUEST] Connect request, BT Addr %S"), &buf);}) + iConnectStatus = &aStatus; + aStatus = KRequestPending; + TRAPD(err, iState->ConnectL(aAddr)); + if (err) + { + CompletePendingRequests(KConnectReq, err); + } + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CancelConnectToAccessory +// ----------------------------------------------------------------------------- +// +void CBTSAController::CancelConnectToAccessory(const TBTDevAddr& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + if (aAddr != iRemoteAddr) + { + TRACE_INFO((_L("CBTSAController::CancelConnectToAccessory() Invalid address, error."))) + CompletePendingRequests(KConnectReq, KErrArgument); + return; + } + TRAP_IGNORE(iState->CancelConnectL()); + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::DisconnectAccessory +// ----------------------------------------------------------------------------- +// +void CBTSAController::DisconnectAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); + Trace(_L("[REQUEST] Disconnect request, BT Addr %S"), &buf);}) + + // if we have an open/close audio request pending, complete it + CompletePendingRequests((KOpenAudioReq | KCloseAudioReq), KErrDisconnected); + iDisconnectStatus = &aStatus; + aStatus = KRequestPending; + if (aAddr != iRemoteAddr ) + { + TRACE_INFO((_L("CBTSAController::DisconnectAccessory() Invalid address, error."))) + CompletePendingRequests(KDisconnectReq, KErrArgument); + return; + } + TRAPD(err, iState->DisconnectL()); + if (err) + { + CompletePendingRequests(KDisconnectReq, err); + return; + } + SetResetAudioInput(ETrue); + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::OpenAudioLink +// ----------------------------------------------------------------------------- +// +void CBTSAController::OpenAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); + Trace(_L("[REQUEST] Open audio request, BT Addr %S"), &buf);}) + iOpenAudioStatus = &aStatus; + aStatus = KRequestPending; + TRAPD(err, iState->OpenAudioLinkL(aAddr)); + if (err) + { + CompletePendingRequests(KOpenAudioReq, err); + } + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CancelOpenAudioLink +// ----------------------------------------------------------------------------- +// +void CBTSAController::CancelOpenAudioLink(const TBTDevAddr& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + if(aAddr != iRemoteAddr) + { + TRACE_INFO((_L("CBTSAController::CancelOpenAudioLink() Invalid address, error."))) + CompletePendingRequests(KOpenAudioReq, KErrArgument); + return; + } + if(IsOpenAudioReqFromAccFWPending()) + { + TRAP_IGNORE(iState->CancelOpenAudioLinkL()); + } + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CloseAudioLink +// ----------------------------------------------------------------------------- +// +void CBTSAController::CloseAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); + Trace(_L("[REQUEST] Close audio request, BT Addr %S"), &buf);}) + iCloseAudioStatus = &aStatus; + aStatus = KRequestPending; + TRAPD(err, iState->CloseAudioLinkL(aAddr)); + if (err) + { + CompletePendingRequests(KCloseAudioReq, err); + } + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CancelCloseAudioLink +// ----------------------------------------------------------------------------- +// +void CBTSAController::CancelCloseAudioLink(const TBTDevAddr& aAddr) + { + TRACE_FUNC_ENTRY + TRACE_INFO_SEG( + {TBuf buf; aAddr.GetReadable(buf); Trace(_L("BT Addr %S"), &buf);}) + if(aAddr != iRemoteAddr) + { + TRACE_INFO((_L("CBTSAController::CancelCloseAudioLink() Invalid address, error."))) + CompletePendingRequests(KCloseAudioReq, KErrArgument); + return; + } + if(iCloseAudioStatus) + { + iState->CancelCloseAudioLink(aAddr); + } + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBTSAController::AccInUse +// ----------------------------------------------------------------------------- +// +void CBTSAController::AccInUse() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTSAController::StartRecording +// ----------------------------------------------------------------------------- +// +void CBTSAController::StartRecording() + { + TRACE_FUNC + iState->StartRecording(); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::StoreAccInfo +// ----------------------------------------------------------------------------- +// +void CBTSAController::StoreAccInfo() + { + TRACE_FUNC + iAccDb.Append(iRemoteSEPs); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::DeleteAccInfo +// ----------------------------------------------------------------------------- +// +void CBTSAController::DeleteAccInfo() + { + TRACE_FUNC + for(TInt i = 0 ; i < iAccDb.Count() ; i++) + { + iAccDb.Remove(i); + } + iAccDb.Reset(); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::IsAccInfoAvailable +// ----------------------------------------------------------------------------- +// +TBool CBTSAController::IsAccInfoAvailable() + { + TRACE_INFO((_L("CBTSAController::IsAccInfoAvailable() Count: %d"), iAccDb.Count())) + for (TInt i=0; iGetDeviceAddr() == iRemoteAddr ) + { + iRemoteSEPs = iAccDb[i]; // retrieve SEP Manager + return ETrue; + } + } + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::AbortStream +// ----------------------------------------------------------------------------- +// +TInt CBTSAController::AbortStream() + { + TRACE_FUNC + TAvdtpSEPInfo SEPInfo; + if (iRemoteSEPs->GetInfo(iSBCSEPIndex, SEPInfo)) + { + TRACE_INFO((_L("CBTSAController::AbortStream() Couldn't retrieve SEP Info !"))) + return KErrGeneral; + } + TSEID remoteSEPid = SEPInfo.SEID(); + iGavdp->AbortStreaming(remoteSEPid); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::NewAccessory +// ----------------------------------------------------------------------------- +// +void CBTSAController::NewAccessory(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TInt connectedProfiles = Observer().ConnectionStatus( aAddr ); + if( !(connectedProfiles & EStereo) ) + { + Observer().NewAccessory( aAddr, EStereo ); + } + } + +// ----------------------------------------------------------------------------- +// CBTSAController::DisconnectedFromRemote +// ----------------------------------------------------------------------------- +// +void CBTSAController::DisconnectedFromRemote(const TBTDevAddr& aAddr, TInt /*aError*/) + { + TRACE_FUNC + Observer().AccessoryDisconnected(aAddr, EStereo ); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::AccessoryOpenedAudio +// ----------------------------------------------------------------------------- +// +void CBTSAController::AccessoryOpenedAudio(const TBTDevAddr& aBDAddr) + { + TRACE_FUNC + Observer().RemoteAudioOpened(aBDAddr, EStereo ); + } + + +// ----------------------------------------------------------------------------- +// CBTSAController::AccessoryClosedAudio +// ----------------------------------------------------------------------------- +// +void CBTSAController::AccessoryClosedAudio(const TBTDevAddr& aBDAddr) + { + TRACE_FUNC + Observer().RemoteAudioClosed(aBDAddr, EStereo ); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::AccessorySuspendedAudio +// ----------------------------------------------------------------------------- +// +void CBTSAController::AccessorySuspendedAudio(const TBTDevAddr& aBDAddr) + { + TRACE_FUNC + RProperty::Set(KBTAudioRemCon, KBTAudioPlayerControl, EBTAudioPausePlayer); + Observer().RemoteAudioClosed(aBDAddr, EStereo ); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CompletePendingRequests +// ----------------------------------------------------------------------------- +// +void CBTSAController::CompletePendingRequests(TUint aCompleteReq, TInt aError) + { + TRACE_INFO((_L("CBTSAController::CompletePendingRequests() Request %d"), aCompleteReq)) + + if((aCompleteReq & KConnectReq) && iConnectStatus) + { + TRACE_INFO((_L("[REQUEST] Connect request completed with %d"), aError)) + User::RequestComplete(iConnectStatus, aError); + } + if((aCompleteReq & KDisconnectReq) && iDisconnectStatus) + { + TRACE_INFO((_L("[REQUEST] Disconnect request completed with %d"), aError)) + User::RequestComplete(iDisconnectStatus, aError); + } + if((aCompleteReq & KOpenAudioReq) && iOpenAudioStatus) + { + TRACE_INFO((_L("[REQUEST] Open audio request completed with %d"), aError)) + User::RequestComplete(iOpenAudioStatus, aError); + } + if((aCompleteReq & KCloseAudioReq) && iCloseAudioStatus) + { + TRACE_INFO((_L("[REQUEST] Close audio request completed with %d"), aError)) + User::RequestComplete(iCloseAudioStatus, KErrNone); // audio sw cant handle error codes. + } + } + +// ----------------------------------------------------------------------------- +// CBTSAController::SetRemoteAddr +// ----------------------------------------------------------------------------- +// +void CBTSAController::SetRemoteAddr(const TBTDevAddr& aRemoteAddr) + { + iRemoteAddr = aRemoteAddr; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::GetRemoteAddr +// ----------------------------------------------------------------------------- +// +TBTDevAddr CBTSAController::GetRemoteAddr() const + { + return iRemoteAddr; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::IsOpenAudioReqFromAccFWPending +// ----------------------------------------------------------------------------- +// +TBool CBTSAController::IsOpenAudioReqFromAccFWPending() const + { + if(iOpenAudioStatus) + return ETrue; + else + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::SetSEPIndex +// ----------------------------------------------------------------------------- +// +void CBTSAController::SetSEPIndex(TInt aIndex) + { + iSBCSEPIndex = aIndex; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::GetSEPIndex +// ----------------------------------------------------------------------------- +// +TInt CBTSAController::GetSEPIndex() const + { + return iSBCSEPIndex; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::SetResetAudioInput +// ----------------------------------------------------------------------------- +// +void CBTSAController::SetResetAudioInput(TBool aReset) + { + iResetAudioInput = aReset; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::GetResetAudioInput +// ----------------------------------------------------------------------------- +// +TBool CBTSAController::GetResetAudioInput() const + { + return iResetAudioInput; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::GetGavdpErrorActive +// ----------------------------------------------------------------------------- +// +CBtsacActive* CBTSAController::GetGavdpErrorActive() const + { + return iGavdpErrorActive; + } + +// ----------------------------------------------------------------------------- +// CBTSAController::NotifyError +// ----------------------------------------------------------------------------- +// +void CBTSAController::NotifyError(TInt /*aError*/) + { + TRACE_FUNC + if(iState->GetStateIndex() == EStateStreaming) + { + TRAP_IGNORE(iState->CloseAudioLinkL(GetRemoteAddr())); + } + else + { + TRAPD(err, ChangeStateL(CBtsacListening::NewL(*this, EGavdpResetReasonGeneral, EFalse))); + if (err) + { + TRACE_INFO((_L("CBTSAController::NotifyError() Couldn't change state."))) + } + } + CompletePendingRequests(KCompleteAllReqs, KErrCancel); + } + +// ----------------------------------------------------------------------------- +// CBTSAController::GAVDP_Error +// ----------------------------------------------------------------------------- +// +void CBTSAController::GAVDP_Error(TInt aError) + { + TRACE_INFO((_L("CBTSAController::GAVDP_Error(%d)"), aError)) + if(iGavdpErrorActive) + { + if (!iGavdpErrorActive->IsActive()) + { + TRequestStatus* sta = &(iGavdpErrorActive->iStatus); + iGavdpErrorActive->iStatus = KRequestPending; + User::RequestComplete(sta, aError); + iGavdpErrorActive->GoActive(); + } + } + else + { + TRACE_INFO((_L("CBTSAController::CBTSAController() AO doesn't exist."))) + } + } + +// ----------------------------------------------------------------------------- +// CBTSAController::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBTSAController::RequestCompletedL(CBtsacActive& aActive) + { + TRACE_FUNC + switch(aActive.RequestId()) + { + case KRequestIdGavdpError: + { + iState->HandleGavdpErrorL(aActive.iStatus.Int()); + break; + } + default: + { + TRACE_INFO((_L("CBTSAController::RequestCompletedL() Unknown request"))) + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CBTSAController::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBTSAController::CancelRequest(CBtsacActive& /*aActive*/) + { + TRACE_FUNC + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacActivePacketDropIoctl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacActivePacketDropIoctl.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2002-2005 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 FILES +#include "debug.h" +#include "btsacActivePacketDropIoctl.h" +#include // Protocol definitions, e.g., TSBCCodecCapabilities + +// ================= MEMBER FUNCTIONS ======================= + +////////////////////////////////////////////////////////////////// + +CActivePacketDropIoctl* CActivePacketDropIoctl::NewL(MActivePacketDropIoctlObserver &aObserver, RSocket &aPendingSocket) + { + CActivePacketDropIoctl* self = new (ELeave) CActivePacketDropIoctl(aObserver, aPendingSocket); + return self; + } + +CActivePacketDropIoctl::CActivePacketDropIoctl(MActivePacketDropIoctlObserver &aObserver, RSocket &aPendingSocket) : CActive(0), iObserver(aObserver) + { + TRACE_FUNC + iPendingSocket = aPendingSocket; + CActiveScheduler::Add(this); + } + +CActivePacketDropIoctl::~CActivePacketDropIoctl() + { + TRACE_FUNC + Cancel(); + } + +void CActivePacketDropIoctl::DoCancel() + { + TRACE_FUNC + iPendingSocket.CancelIoctl(); + } + +void CActivePacketDropIoctl::Start() + { + TRACE_FUNC + if(!IsActive()) + { + iPendingSocket.Ioctl(ENotifyAvdtpMediaPacketDropped, iStatus, &iPacketsLostPkgBuf, KSolBtAVDTPMedia); + SetActive(); + } + } + +void CActivePacketDropIoctl::RunL() + { + TRACE_INFO((_L("CActivePacketDropIoctl::RunL() Packets Dropped Notification! %d packets lost"), iPacketsLostPkgBuf())) + iObserver.PacketsDropped(iPacketsLostPkgBuf()); + Start(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacGavdp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacGavdp.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,746 @@ +/* +* Copyright (c) 2002-2005 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: Contains implementation of CBTSACGavdp class which uses GAVDP API. +* Two other classes CAVStreamEndPoint and CAVSEPManager are helper +* classes to use GAVDP. This class also constructs CBTSACStreamerController +* class. +* +*/ + + +// INCLUDE FILES +#include "btsacGavdp.h" +#include "btsacGavdpObserver.h" +#include "debug.h" +#include "btsacStreamerController.h" +#include "btsacStreamEndPoint.h" +#include "btsacSEPManager.h" +#include "btsacdefs.h" + +// CONSTANTS + +// DATA TYPES + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTSACGavdp* CBTSACGavdp::NewL(MInternalGavdpUser* aObserver ) + { + CBTSACGavdp* self = new (ELeave) CBTSACGavdp(aObserver); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTSACGavdp::~CBTSACGavdp() + { + TRACE_FUNC + StopSrc(); + iSockServ.Close(); + + if(iA2dpSourceSDPrecordHandle != 0) // unregister sdp + { + if(iBTConnectionPtr) + { + TRACE_INFO((_L("CBTSACGavdp::~CBTSACGavdp():Unregister SDP Settings"))) + TInt err = iBTConnectionPtr->DeleteSdpRecord(iA2dpSourceSDPrecordHandle); + if(err) + { + TRACE_INFO((_L("CBTSACGavdp::~CBTSACGavdp():Unregister SDP Settings failed %d."), err)) + } + } + iA2dpSourceSDPrecordHandle = 0; + } + delete iBTConnectionPtr; + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::CBTSACGavdp +// C++ default constructor. +// ----------------------------------------------------------------------------- +// +CBTSACGavdp::CBTSACGavdp( MInternalGavdpUser* aObserver ) + : iObserver ( aObserver ), + iA2dpSourceSDPrecordHandle( 0 ) + { + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::ConstructL() + { + TRACE_FUNC + TSessionPref pref; + pref.iAddrFamily = KBTAddrFamily; + pref.iProtocol = KAVDTP; + User::LeaveIfError(iSockServ.Connect(pref, KESockDefaultMessageSlots)); + iBTConnectionPtr = CBTEngDiscovery::NewL(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::StartSrc +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::StartSrc(CBTSACSEPManager& aLocalSEPs, TSBCCodecCapabilities& aSbc) + { + TRACE_FUNC + TInt err = KErrGeneral; + // register sdp + // For hardware only, in ConstructL SDP is not ready and hence this causes a crash in emulator + TRACE_INFO((_L("CBTSACGavdp::StartSrc():Register A2DP SDP settings."))) + if(iBTConnectionPtr) + { + err = iBTConnectionPtr->RegisterSdpRecord( + KAudioSourceUUID, // btsdp.h + 0, // There is no channel number used for A2DP + iA2dpSourceSDPrecordHandle ); + } + + if( !err ) + { + err = iGavdp.Open(*this, iSockServ); + if ( !err ) + { + err = RegisterSEPs(aLocalSEPs, aSbc); + } + } + + TRACE_INFO((_L("CBTSACGavdp::StartSrc() completed. Return: %d"), err)) + return err; + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::RegisterSEPs +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::RegisterSEPs(CBTSACSEPManager& aLocalSEPs, TSBCCodecCapabilities& aSbc ) + { + TRACE_FUNC + + // This hard-coded value would be recieved from Audio Subsystem later + // Currently our implementation supports only SBC Encoding + const TInt KNumSEPs = 1; + + TInt err; + TFixedArray sepInfos; + + for (TInt i=0; i secBuf(_L8("Danger!")); + iGavdp.SendSecurityControl(TSEID(seid, EFalse), secBuf); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GetCapabilities +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GetCapabilities(TSEID& aId) + { + TRACE_FUNC + // we're getting all capabilities + // we could register interest in only those capabilities that we can select + // we keep it so in order to print out all capabilities in GAVDP_SEPCapability + TAvdtpServiceCategories caps; + caps.SetCapability(EAllServiceCategories); + iGavdp.GetRemoteSEPCapabilities(aId, caps); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::Connect +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::Connect( const TBTDevAddr& aAddr ) + { + TRACE_FUNC + RProperty property; + TBuf8 addr; + TInt err = property.Get(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothLocalDeviceAddress, addr); + + if ((err) || (addr.Length()!=KBTDevAddrSize)) + { + TRACE_INFO((_L("CBTSACGavdp::Connect() P&S: ERROR retrieving local address"))) + } + else + { + TBTDevAddr localAddr(addr); + TRACE_INFO_SEG( + {TBuf bufLocal; TBuf bufRemote; localAddr.GetReadable(bufLocal); aAddr.GetReadable(bufRemote); + Trace(_L("CBTSACGavdp::Connect() Local address = 0x%S, Using Remote Addr = 0x%S"), &bufLocal, &bufRemote);}) + } + iGavdp.Connect(aAddr); + TRACE_INFO((_L("CBTSACGavdp::Connect() completed"))) + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::Listen +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::Listen() + { + TRACE_FUNC + return iGavdp.Listen(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::Cancel +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::Cancel() + { + TRACE_FUNC + iGavdp.Cancel(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::CreateBearers +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::CreateBearers(TSEID& aRemoteSEPId) + { + TRACE_FUNC + TInt ret; + ret = iGavdp.CreateBearerSockets(aRemoteSEPId, EFalse, EFalse); + TRACE_INFO((_L("CBTSACGavdp::CreateBearers() Asking for Bearers..(sync_result) %d."), ret)) + return ret; + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::DiscoverSEPs +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::DiscoverSEPs() + { + TRACE_FUNC + iGavdp.DiscoverRemoteSEPs(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::Close +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::Close() + { + TRACE_FUNC + iGavdp.Close(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::Open +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::Open() + { + TRACE_FUNC + return( iGavdp.Open(*this, iSockServ) ); + } + + +///////////////////// Call Backs from GAVDP /////////////////// + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SEPCapability +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Capability = %d"), aCapability->Category())) + + switch (aCapability->Category()) + { + case EServiceCategoryMediaCodec: + { + // print name of codec + TAvdtpMediaCodecCapabilities& codecCaps = static_cast(*aCapability); + switch ( codecCaps.MediaType() ) + { + case EAvdtpMediaTypeAudio: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Audio:"))) + break; + case EAvdtpMediaTypeVideo: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Video:"))) + break; + case EAvdtpMediaTypeMultimedia: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Multimedia:"))) + break; + } + switch (codecCaps.MediaCodecType()) + { + case EAudioCodecSBC: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() SBC"))) + break; + case EAudioCodecMPEG12Audio: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() MPEG1,2 Audio"))) + break; + case EAudioCodecMPEG24AAC: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() MPEG 2,4 AAC"))) + break; + case EAudioCodecATRAC: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() ATRAC"))) + break; + + default: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Unknown codec"))) + break; + } + break; + } // case + + case EServiceCategoryRecovery: + { + TAvdtpRecoveryCapabilities* RecCaps = static_cast(aCapability); + switch ( RecCaps->RecoveryType() ) + { + case EForbiddenRecovery: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Forbidden Recovery"))) + break; + case ERFC2733Recovery: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() RFC2733 Recovery"))) + break; + default: + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Unknown Recovery"))) + break; + } + break; + } // case + + case EServiceCategoryReporting: + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Capable of Reporting"))) + break; + }//case + + case EServiceCategoryMediaTransport: + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapability() Capable of a Media Transport"))) + break; + } + + } // switch Category + + // state handles the call-back + iObserver->GAVDP_SEPCapability(aCapability); + + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SEPDiscoveryComplete +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_SEPDiscoveryComplete() + { + TRACE_FUNC + // state handles the call-back + iObserver->GAVDP_SEPDiscoveryComplete(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SEPCapabilityComplete +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_SEPCapabilityComplete() + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SEPCapabilityComplete() GAVDP:SEP has no more capabilities."))) + iObserver->GAVDP_SEPCapabilityComplete(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_ConnectConfirm +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_ConnectConfirm(const TBTDevAddr& aAddr) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConnectConfirm() Signalling channel connected = GAVDP ready"))) + // inform observer + iObserver->GAVDP_ConnectConfirm(aAddr); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SEPDiscovered +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEPInfo) + { + TRACE_FUNC + // state handles the call-back + iObserver->GAVDP_SEPDiscovered(aSEPInfo); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_AbortStreamConfirm +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_AbortStreamConfirm() + { + TRACE_FUNC + // state handles the call-back + iObserver->GAVDP_AbortStreamConfirm(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SecurityControlConfirm +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_SecurityControlConfirm(const TDesC8& aResponseData) + { + TRACE_FUNC + // state handles the call-back + iObserver->GAVDP_SecurityControlConfirm(aResponseData); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_StartStreamsConfirm +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_StartStreamsConfirm() + { + TRACE_FUNC + iObserver->GAVDP_StartStreamsConfirm(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SuspendStreamsConfirm +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_SuspendStreamsConfirm() + { + TRACE_FUNC + // state handles the call-back + iObserver->GAVDP_SuspendStreamsConfirm(); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_ConfigurationConfirm +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_ConfigurationConfirm() + { + TRACE_FUNC + // state handles the call-back + iObserver->GAVDP_ConfigurationConfirm(); + } + + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_Error +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_Error(TInt aError, const TDesC8& aErrorData) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_Error() **Error**: %d:"), aError)) + iObserver->GAVDP_Error(aError, aErrorData); + } + + +// passive gubbins +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_ConfigurationStartIndication +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID) + { + // ah - remote is attempting to confuigure us + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigurationStartIndication() Remote SEP [SEID %d] is configuring Local SEP [SEID %d]"), aRemoteSEID.SEID(), aLocalSEID.SEID())) + // state handles the call-back + iObserver->GAVDP_ConfigurationStartIndication(aLocalSEID, aRemoteSEID); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_ConfigurationIndication +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability) + { + // the new capability proposed by remote + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigurationIndication() Configuration proposed: category %d"), aCapability->Category())) + // state handles the call-back + return (iObserver->GAVDP_ConfigurationIndication(aCapability)); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_ConfigurationEndIndication +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::GAVDP_ConfigurationEndIndication() + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigurationEndIndication() Remote configuration proposals now finished"))) + // state handles the call-back + TInt ret = iObserver->GAVDP_ConfigurationEndIndication(); + return (ret); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_StartIndication +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::GAVDP_StartIndication(TSEID aLocalSEID) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_StartIndication() Start indication for Local SEID %d"), aLocalSEID.SEID())) + // state handles the call-back + return (iObserver->GAVDP_StartIndication(aLocalSEID)); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_AbortIndication +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_AbortIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_AbortIndication() Stream %d ABORTED by peer"), aSEID.SEID())) + // state handles the call-back + iObserver->GAVDP_AbortIndication(aSEID); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_ReleaseIndication +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_ReleaseIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ReleaseIndication() Stream %d RELEASED by peer"), aSEID.SEID())) + // state handles the call-back + iObserver->GAVDP_ReleaseIndication(aSEID); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SuspendIndication +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::GAVDP_SuspendIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SuspendIndication() Suspend indication for seid %d!"), aSEID.SEID())) + // state handles the call-back + return iObserver->GAVDP_SuspendIndication(aSEID); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_SecurityControlIndication +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityData) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_SecurityControlIndication() Got security control data length %d for SEID %d"), aSEID.SEID(), aSecurityData.Length())) + // state handles the call-back + return (iObserver->GAVDP_SecurityControlIndication(aSEID, aSecurityData)); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::GAVDP_BearerReady +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::GAVDP_BearerReady(RSocket aNewSocket, const TAvdtpSockAddr& aAddr) + { + // wrap socket with active wrapper... + TRACE_INFO((_L("CBTSACGavdp::GAVDP_BearerReady() Got a bearer, for session %d"), aAddr.Session())) + + // AV sockets don't foward opts yet so use addr version + RBTPhysicalLinkAdapter phy; + TBTDevAddr RemoteBDAddr = aAddr.BTAddr(); + TInt err = phy.Open(iSockServ, RemoteBDAddr); + TUint16 packets = EAnyACLPacket; + err = phy.RequestChangeSupportedPacketTypes(packets); + TRACE_INFO((_L("CBTSACGavdp::GAVDP_BearerReady() Modified PHY, result %d"), err)) + + // state handles the call-back + iObserver->GAVDP_BearerReady(aNewSocket, aAddr); + } +///////////////////// Call Backs from GAVDP End./////////////////// + + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::StartStreams +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::StartStreams(TSEID& aRemoteSEPId) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_StartStreams() Starting remoteSEP %d streaming..."), aRemoteSEPId.SEID())) + iGavdp.StartStream(aRemoteSEPId); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::SuspendStreams +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::SuspendStreams(TSEID& aRemoteSEPId) + { + TRACE_INFO((_L("CBTSACGavdp::SuspendStreams() Suspending remoteSEP %d streaming..."), aRemoteSEPId.SEID())) + iGavdp.SuspendStream(aRemoteSEPId); + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::ConfigureSEP +// ----------------------------------------------------------------------------- +// +TInt CBTSACGavdp::ConfigureSEP(TSEID aLocalSEPId, TSEID aRemoteSEPId, + TSBCCodecCapabilities& aSBCCaps, TAvdtpMediaTransportCapabilities& aMedTranCaps ) + { + TRACE_INFO((_L("CBTSACGavdp::ConfigureSEP() Local SEP Id: %d, Remote SEP Id: %d"), aLocalSEPId.SEID(), aRemoteSEPId.SEID())) + + TInt res; + res = iGavdp.BeginConfiguringRemoteSEP(aRemoteSEPId, aLocalSEPId); + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigureSEP() Begin configuring remote SEP returned %d"), res)) + + if (res) + { + return res; + } + + res = iGavdp.AddSEPCapability(aMedTranCaps); + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigureSEP() AddSEPCapability returned %d"), res)) + + if ( res ) + { + return res; + } + + res = iGavdp.AddSEPCapability(aSBCCaps); + if ( !res ) + { + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigureSEP() Commiting configuration..."))) + iGavdp.CommitSEPConfiguration(); + } + TRACE_INFO((_L("CBTSACGavdp::GAVDP_ConfigureSEP() completed: %d"), res)) + return res; + } + +// ----------------------------------------------------------------------------- +// CBTSACGavdp::RegisterObserver +// ----------------------------------------------------------------------------- +// +void CBTSACGavdp::RegisterObserver(MInternalGavdpUser* aObserver, const TDesC& aName) + { + TRACE_INFO((_L("CBTSACGavdp::RegisterObserver(%S)"), &aName)) + (void) aName; + iObserver = aObserver; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacSEPManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacSEPManager.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,219 @@ +/* +* Copyright (c) 2002-2005 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 FILES +#include + +#include "btsacSEPManager.h" +#include "btsacStreamEndPoint.h" +#include "debug.h" + + +// CONSTANTS +const TInt KBTAddLength = 12; // BT address length + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::NewL +// ----------------------------------------------------------------------------- +// +CBTSACSEPManager* CBTSACSEPManager::NewL(const TBTDevAddr& aAddr) + { + return new(ELeave) CBTSACSEPManager(aAddr); + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::CBTSACSEPManager +// ----------------------------------------------------------------------------- +// +CBTSACSEPManager::CBTSACSEPManager(const TBTDevAddr& aAddr) +: iAddr(aAddr) + { + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTSACSEPManager::~CBTSACSEPManager() + { + TRACE_FUNC + iStreamEndPoints.ResetAndDestroy(); + iStreamEndPoints.Close(); + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::FindSEP +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::FindSEP(TSEID aSEID, CBTSACStreamEndPoint& aSEP) + { + TRACE_FUNC + CBTSACStreamEndPoint* SEP = &aSEP; + SEP = SEP; // remove compiler warning + for (TInt i=0;iSEID()==aSEID) + { + SEP = iStreamEndPoints[i]; + return KErrNone; + } + } + TRACE_INFO((_L("CBTSACSEPManager::FindSEP() SEP Not Found !"))) + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::GetSEP +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::GetSEP(TSEID aSEID, CBTSACStreamEndPoint& aSEP) + { + TRACE_FUNC + return FindSEP(aSEID, aSEP); + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::SetState +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::SetState(TSEID aSEID, CBTSACStreamEndPoint::TSEPState aState, const TAny* aBlob) + { + TRACE_FUNC + CBTSACStreamEndPoint* SEP = NULL; + + if (!FindSEP(aSEID, *SEP) ) + { + SEP->SetState(aState, aBlob); + return KErrNone; + } + else + { + TRACE_INFO((_L("CBTSACSEPManager::SetState() SEP Not Found !"))) + return KErrNotFound; + } + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::GetDeviceAddr +// ----------------------------------------------------------------------------- +// +const TBTDevAddr& CBTSACSEPManager::GetDeviceAddr() + { + TRACE_FUNC + TBuf bdaddrbuf; + iAddr.GetReadable( bdaddrbuf ); + TRACE_INFO((_L("CBTSACSEPManager::GetDeviceAddr() %S"), &bdaddrbuf)) + return iAddr; + } + + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::StoreCaps +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::StoreCaps(TInt aIndex, TAvdtpServiceCapability* aCaps) + { + TRACE_INFO((_L("CBTSACSEPManager::StoreCaps() %d"), aIndex)) + if (aIndex < iStreamEndPoints.Count() ) + { + iStreamEndPoints[aIndex]->StoreCaps(aCaps); + return KErrNone; + } + else + { + TRACE_INFO((_L("CBTSACSEPManager::StoreCaps() SEP Not Found !"))) + return KErrNotFound; + } + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::GetCaps +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::GetCaps(TInt aIndex, RPointerArray& aCaps ) + { + TRACE_INFO((_L("CBTSACSEPManager::GetCaps() %d"), aIndex)) + if (aIndex < iStreamEndPoints.Count() ) + { + iStreamEndPoints[aIndex]->GetCaps(aCaps); + return KErrNone; + } + else + { + TRACE_INFO((_L("CBTSACSEPManager::GetCaps() SEP Not Found !"))) + return KErrNotFound; + } + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::NoOfSEPs +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::NoOfSEPs() + { + TRACE_INFO((_L("CBTSACSEPManager::NoOfSEPs() %d"), iStreamEndPoints.Count())) + return iStreamEndPoints.Count(); + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::GetInfo +// ----------------------------------------------------------------------------- +// +TInt CBTSACSEPManager::GetInfo(TInt aIndex, TAvdtpSEPInfo& aSEPInfo) + { + TRACE_INFO((_L("CBTSACSEPManager::GetInfo() %d"), aIndex)) + if (aIndex < iStreamEndPoints.Count() ) + { + iStreamEndPoints[aIndex]->GetInfo(aSEPInfo); + return KErrNone; + } + else + { + TRACE_INFO((_L("CBTSACSEPManager::GetInfo() SEP Not Found !"))) + return KErrNotFound; + } + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::BindSEPs +// ----------------------------------------------------------------------------- +// +void CBTSACSEPManager::BindSEPs(TSEID /*aLocalSEID*/, TSEID /*aRemoteSEID*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBTSACSEPManager::NewSEPL +// ----------------------------------------------------------------------------- +// +void CBTSACSEPManager::NewSEPL(const TAvdtpSEPInfo& aInfo) + { + TRACE_FUNC + CBTSACStreamEndPoint* sep = CBTSACStreamEndPoint::NewL(aInfo); + CleanupStack::PushL(sep); + User::LeaveIfError(iStreamEndPoints.Append(sep)); + CleanupStack::Pop(sep); + } + +// end of class diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacState.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,407 @@ +/* +* Copyright (c) 2002-2005 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: Default implementation of BTSAC state machine handles +* methods which the active state is not supposed to handle +* +*/ + + +// INCLUDE FILES +#include "btsacactive.h" +#include "btsacState.h" +#include "btsacStateIdle.h" +#include "btsacStateListening.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacState::CBtsacState +// ----------------------------------------------------------------------------- +// +CBtsacState::CBtsacState(CBTSAController& aParent, TStateIndex aStateIndex) +: iParent(aParent), iStateIndex(aStateIndex) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacState::~CBtsacState +// ----------------------------------------------------------------------------- +// +CBtsacState::~CBtsacState() + { + } + +// ----------------------------------------------------------------------------- +// CBtsacState::ErrorOnEntryL +// ----------------------------------------------------------------------------- +// +CBtsacState* CBtsacState::ErrorOnEntryL(TInt /*aReason*/) + { + TRACE_FUNC + return CBtsacListening::NewL(iParent, EGavdpResetReasonNone, KErrNone); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::Parent +// ----------------------------------------------------------------------------- +// + CBTSAController& CBtsacState::Parent() + { + return iParent; + } + + // ----------------------------------------------------------------------------- +// CBtsacState::GavdpErrorActive +// ----------------------------------------------------------------------------- +// + CBtsacActive* CBtsacState::GavdpErrorActive() + { + return iParent.GetGavdpErrorActive(); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::ConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacState::ConnectL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + Parent().CompletePendingRequests(KConnectReq, KErrInUse); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::CancelConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacState::CancelConnectL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KConnectReq, KErrNotSupported); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::DisconnectL +// ----------------------------------------------------------------------------- +// +void CBtsacState::DisconnectL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KDisconnectReq, KErrCouldNotDisconnect); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::DisconnectedFromRemoteOrError +// ----------------------------------------------------------------------------- +// +void CBtsacState::DisconnectedFromRemoteOrError(TInt /*aErr*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::Configure() +// ----------------------------------------------------------------------------- +// +void CBtsacState::Configure() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::OpenAudioLinkL() +// ----------------------------------------------------------------------------- +// +void CBtsacState::OpenAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + Parent().CompletePendingRequests(KOpenAudioReq, KErrNotSupported); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::CancelOpenAudioLinkL() +// ----------------------------------------------------------------------------- +// +void CBtsacState::CancelOpenAudioLinkL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KOpenAudioReq, KErrNotSupported); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::CloseAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacState::CloseAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + Parent().CompletePendingRequests(KCloseAudioReq, KErrNotSupported); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::CancelCloseAudioLink +// ----------------------------------------------------------------------------- +// +void CBtsacState::CancelCloseAudioLink(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + Parent().CompletePendingRequests(KCloseAudioReq, KErrNotSupported); + } + +// ----------------------------------------------------------------------------- +// CBtsacState::StartRecording +// ----------------------------------------------------------------------------- +// +void CBtsacState::StartRecording() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_ConnectConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_ConnectConfirm(const TBTDevAddr& /*aDeviceAddr*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SEPDiscovered +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_SEPDiscovered(const TAvdtpSEPInfo& /*aSEP*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SEPDiscoveryComplete +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_SEPDiscoveryComplete() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SEPCapability +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_SEPCapability(TAvdtpServiceCapability* /*aCapability*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SEPCapabilityComplete +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_SEPCapabilityComplete() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_AbortStreamConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_AbortStreamConfirm() + { + TRACE_INFO((_L("CBtsacState::GAVDP_AbortStreamConfirm(), state %d"), GetStateIndex())) + Parent().CompletePendingRequests(KCompleteAllReqs, KErrAbort); + TRAPD(err, Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected))); + if (err) + { + TRACE_INFO((_L("CBtsacState::GAVDP_AbortStreamConfirm() Couldn't change state."))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_StartStreamsConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_StartStreamsConfirm() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SuspendStreamsConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_SuspendStreamsConfirm() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SecurityControlConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_SecurityControlConfirm(const TDesC8& /*aResponseData*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_ConfigurationConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_ConfigurationConfirm() + { + TRACE_FUNC + // configuration complete and SEP selected *AND* reconfigure confirm + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_ConfigurationStartIndication +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_ConfigurationStartIndication(TSEID /*aLocalSEID*/, TSEID /*aRemoteSEID*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_ConfigurationIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacState::GAVDP_ConfigurationIndication(TAvdtpServiceCapability* /*aCapability*/) + { + TRACE_FUNC + return KErrGeneral; + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_ConfigurationEndIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacState::GAVDP_ConfigurationEndIndication() + { + TRACE_FUNC + return KErrGeneral; + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_StartIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacState::GAVDP_StartIndication(TSEID /*aSEID*/) + { + TRACE_FUNC + return KErrGeneral; + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SuspendIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacState::GAVDP_SuspendIndication(TSEID /*aSEID*/) + { + TRACE_FUNC + return KErrGeneral; + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_SecurityControlIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacState::GAVDP_SecurityControlIndication(TSEID /*aSEID*/, TDes8& /*aSecurityDataInOut*/) + { + TRACE_FUNC + return KErrGeneral; + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_AbortIndication +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_AbortIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBtsacState::GAVDP_AbortIndication(), state %d, SEID:%d"), GetStateIndex(), aSEID.SEID())) + (void)aSEID; + Parent().CompletePendingRequests(KCompleteAllReqs, KErrDisconnected); + TRAPD(err, Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected))) + if(err) + { + TRACE_INFO((_L("CBtsacState::GAVDP_AbortIndication(), error! Couldn't change state"))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_ReleaseIndication +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_ReleaseIndication(TSEID /*aSEID*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_BearerReady +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_BearerReady(RSocket /*aSocket*/, const TAvdtpSockAddr& /*aAddress*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBtsacState::RequestCompletedL(CBtsacActive& /*aActive*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBtsacState::CancelRequest(CBtsacActive& /*aActive*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacState::HandleGavdpErrorL(TInt /*aError*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GetState +// ----------------------------------------------------------------------------- +// +TStateIndex CBtsacState::GetStateIndex() const + { + return iStateIndex; + } + +// ----------------------------------------------------------------------------- +// CBtsacState::GAVDP_Error +// ----------------------------------------------------------------------------- +// +void CBtsacState::GAVDP_Error(TInt aError, const TDesC8& /*aErrorData*/) + { + TRACE_INFO((_L("CBtsacState::GAVDP_Error(%d)"), aError)) + Parent().GAVDP_Error(aError); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateAborting.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateAborting.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2002-2005 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: In this state, BTSAC is waiting for a confirmation for abort +* operation from GAVDP API. +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateAborting.h" +#include "btsacStateListening.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "debug.h" + + +// ================= MEMBER FUNCTIONS ======================= +// ----------------------------------------------------------------------------- +// CBtsacAborting::NewL +// ----------------------------------------------------------------------------- +// +CBtsacAborting* CBtsacAborting::NewL(CBTSAController& aParent) + { + CBtsacAborting* self = new( ELeave ) CBtsacAborting(aParent); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacAborting::CBtsacAborting +// ----------------------------------------------------------------------------- +// +CBtsacAborting::CBtsacAborting(CBTSAController& aParent) +: CBtsacState(aParent, EStateAborting) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacAborting::~CBtsacAborting +// ----------------------------------------------------------------------------- +// +CBtsacAborting::~CBtsacAborting() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacAborting::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacAborting::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Aborting")) + _LIT(KName, "CBtsacStateAborting"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + } + +// ----------------------------------------------------------------------------- +// CBtsacAborting::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacAborting::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + Parent().CompletePendingRequests(KCompleteAllReqs, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateConfigured.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateConfigured.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,388 @@ +/* +* Copyright (c) 2002-2005 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: In this state, avdtp link is ready to be used and btsac opens +* audio automatically if there is request pending otherwise +* it will wait open audio request. +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateConfigured.h" +#include "btsacStateListening.h" +#include "btsacStateStreaming.h" +#include "btsacStateAborting.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "debug.h" + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + +const TInt KStartIndicationDelay = 1000000; // 1 sec + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::NewL +// ----------------------------------------------------------------------------- +// +CBtsacConfigured* CBtsacConfigured::NewL(CBTSAController& aParent, RSocket aNewSocket, + TAudioOpenedBy aAudioOpenedBy, TStreamConfiguredBy aStreamConfiguredBy) + { + CBtsacConfigured* self = new( ELeave ) CBtsacConfigured(aParent, aNewSocket, aAudioOpenedBy, aStreamConfiguredBy); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::CBtsacConfigured +// ----------------------------------------------------------------------------- +// +CBtsacConfigured::CBtsacConfigured(CBTSAController& aParent, RSocket aNewSocket, + TAudioOpenedBy aAudioOpenedBy, TStreamConfiguredBy aStreamConfiguredBy) +: CBtsacState(aParent, EStateConfigured), iAudioOpenedBy(aAudioOpenedBy), + iStreamConfiguredBy(aStreamConfiguredBy), iStartStreamStatus(EStartNone) + { + TRACE_ASSERT(Parent().iStreamingSockets.Count() == 0, EBTPanicSocketExists) + TRACE_INFO((_L("[SOCKET] created."))) + Parent().iStreamingSockets.Append(aNewSocket); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::ConstructL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::ConstructL() + { + iTimerActive = CBtsacActive::NewL(*this, CActive::EPriorityStandard, KRequestIdTimer); + iTimer.CreateLocal(); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::~CBtsacConfigured +// ----------------------------------------------------------------------------- +// +CBtsacConfigured::~CBtsacConfigured() + { + TRACE_FUNC + delete iTimerActive; + iTimerActive = NULL; + iTimer.Close(); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Configured")) + _LIT(KName, "CBtsacStateConfigured"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + + // ** OPEN AUDIO automatically ** + if(iStreamConfiguredBy == EStreamConfiguredBySrc) + { + if(Parent().IsOpenAudioReqFromAccFWPending()) + { + TInt err; + TRAP(err, OpenAudioLinkL(Parent().GetRemoteAddr())); + if( err ) + { + Parent().CompletePendingRequests(KOpenAudioReq, err); + } + } + } + else // Stream configured by sink + { + if(iAudioOpenedBy == EAudioOpenedByAcc) + { + GAVDP_StartIndication(TSEID(1, ETrue)); + } + else if(Parent().IsOpenAudioReqFromAccFWPending()) + { + // Start timer to protect such a situation that we will not receive StartIndication from remote end. + StartTimer(KStartIndicationDelay); + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::StartTimer +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::StartTimer(TTimeIntervalMicroSeconds32 aTimeout) + { + TRACE_FUNC + if (iTimerActive) + { + if(!iTimerActive->IsActive()) + { + iTimer.After(iTimerActive->iStatus, aTimeout); + iTimerActive->GoActive(); + } + } + else + { + TRACE_INFO((_L("CBtsacConfigured::StartTimer, Timer Active doesn't exist."))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::StopTimer +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::StopTimer() + { + TRACE_FUNC + if (iTimerActive) + { + iTimerActive->Cancel(); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::CancelActionL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) + { + TRACE_FUNC + Parent().CompletePendingRequests(KOpenAudioReq, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::CancelConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::CancelConnectL() + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::OpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::OpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + if((iStreamConfiguredBy == EStreamConfiguredBySrc) || (iAudioOpenedBy == EAudioOpenedByAFW)) + { + TAvdtpSEPInfo SEPInfo; + iStartStreamStatus = EStartSendBySrc; + if (Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo) || (aAddr != Parent().GetRemoteAddr() )) + { + TRACE_INFO((_L("TStateConfigured::OpenAudio Couldn't retrieve SEP Info !"))) + Parent().CompletePendingRequests(KOpenAudioReq, KErrGeneral); + return; + } + Parent().SetRemoteAddr(aAddr); + TSEID remoteSEPid = SEPInfo.SEID(); + Parent().iGavdp->StartStreams(remoteSEPid); + } + else + { + // Remote end (sink) has configured us. We can't call StartStreams. Complete audio req later, + // after we have received start indication from the remote (sink). + + // Start timer to protect such a situation that we will not receive StartIndication from remote end. + StartTimer(KStartIndicationDelay); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::CancelOpenAudioLinkL() +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::CancelOpenAudioLinkL() + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::DisconnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::DisconnectL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KDisconnectReq, KErrNone); + // Cancel all other requests + Parent().CompletePendingRequests(KCompleteAllReqs, KErrCancel); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrNone)); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::GAVDP_StartStreamsConfirm() +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::GAVDP_StartStreamsConfirm() + { + TRACE_FUNC + if ( Parent().iStreamer->StartStream(Parent().iStreamingSockets[0], Parent().iStreamer->FrameLength()) != KErrNone ) + { + TRACE_INFO((_L("CBtsacConfigured::GAVDP_StartStreamsConfirm() [ERR] Could not start streaming!"))) + TInt err = Parent().AbortStream(); + if(err) + { + TRACE_INFO((_L("CBtsacConfigured::GAVDP_StartStreamsConfirm() [ERR] Couldn't abort stream."))) + } + TRAP_IGNORE(CancelActionL(KErrNotReady, EGavdpResetReasonGeneral)); + } + else + { + TBool Collision = iStartStreamStatus == EStartCollision ? ETrue : EFalse; + Parent().CompletePendingRequests(KOpenAudioReq, KErrNone); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacStreaming::NewL(Parent(), EAudioOpenedByAFW, Collision))); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::GAVDP_StartIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacConfigured::GAVDP_StartIndication(TSEID aLocalSEID) + { + TRACE_INFO((_L("CBtsacConfigured::GAVDP_StartIndication() aLocalSEID:%d"), aLocalSEID.SEID())) + (void) aLocalSEID; + StopTimer(); + // Check if acc fw has already requested to open audio + if(Parent().IsOpenAudioReqFromAccFWPending()) + { + if(iStartStreamStatus == EStartSendBySrc) + { + // Src has also sent start stream cmd. + iStartStreamStatus = EStartCollision; + } + + GAVDP_StartStreamsConfirm(); + } + else + { + // Accessory has send this indication. + // CBtsacStreaming state can use this indication to start audio automatically then later. + TRAPD(err, Parent().ChangeStateL(CBtsacStreaming::NewL(Parent(), EAudioOpenedByAcc, EFalse))); + if (err) + { + TRACE_INFO((_L("CBtsacConfigured::GAVDP_StartIndication() Couldn't change state."))) + return KErrNoMemory; + } + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::RequestCompletedL(CBtsacActive& aActive) + { + TRACE_FUNC + switch(aActive.RequestId()) + { + case KRequestIdTimer: + { + if(Parent().IsOpenAudioReqFromAccFWPending()) + { + // Well, seems that accessory didn't send us GAVDP_StartIndication. Let's try to open audio. + // Over write iAudioOpenedBy previous value and call open audio + iAudioOpenedBy = EAudioOpenedByAFW; + OpenAudioLinkL(Parent().GetRemoteAddr()); + } + break; + } + default: + { + TRACE_INFO((_L("CBtsacConfigured::RequestCompletedL() Unknown request"))) + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::CancelRequest(CBtsacActive& aActive) + { + TRACE_FUNC + if(aActive.RequestId() == KRequestIdTimer ) + { + iTimer.Cancel(); + } + else + { + TRACE_INFO((_L("CBtsacConfigured::CancelRequest() Unknown request"))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfigured::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacConfigured::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + StopTimer(); + switch (aError) + { + case KErrAvdtpRequestTimeout: // -18005 + case (KErrAvdtpSignallingErrorBase - EAvdtpBadState): // 18094 + { + TRACE_INFO((_L("CBtsacConfigured::HandleGavdpErrorL() Request TIMEOUT/Bad state"))) + TInt err = Parent().AbortStream(); + if(!err) + { + // Complete Connect/Audio requests in Aborting state + Parent().ChangeStateL(CBtsacAborting::NewL(Parent())); + } + else + { + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + } + break; + } + case KErrHCILinkDisconnection: // -6305 + case KErrDisconnected: // -36 + { + TRACE_INFO((_L("CBtsacConfigured::HandleGavdpErrorL() Signalling disconnected."))) + CancelActionL(aError, EGavdpResetReasonNone); + break; + } + default: + { + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + break; + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateConfiguring.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateConfiguring.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,319 @@ +/* +* Copyright (c) 2002-2005 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: In this state, a stereo audio accessory is configuring us. +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateConfiguring.h" +#include "btsacStateConfigured.h" +#include "btsacStateListening.h" +#include "btsacStateAborting.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "debug.h" + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::NewL +// ----------------------------------------------------------------------------- +// +CBtsacConfiguring* CBtsacConfiguring::NewL(CBTSAController& aParent, TSEID aLocalSEID, TSEID aRemoteSEID) + { + CBtsacConfiguring* self = new( ELeave ) CBtsacConfiguring(aParent, aLocalSEID, aRemoteSEID); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::CBtsacConfiguring +// ----------------------------------------------------------------------------- +// +CBtsacConfiguring::CBtsacConfiguring(CBTSAController& aParent, TSEID aLocalSEID, TSEID aRemoteSEID) +: CBtsacState(aParent, EStateConfiguring), iLocalSEID(aLocalSEID), iRemoteSEID(aRemoteSEID), + iSEPFound(EFalse), iRemoteSEPIndex(0), iAudioOpenedBy(EAudioOpenedByNone) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::~CBtsacConfiguring +// ----------------------------------------------------------------------------- +// +CBtsacConfiguring::~CBtsacConfiguring() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Configuring")) + _LIT(KName, "CBtsacStateConfiguring"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + + if ( iLocalSEID.SEID() != 1) // we have only one local SEP, SBC + { + TRACE_INFO((_L("CBtsacConfiguring::EnterL() Wrong Local SEP being configured !!!"))) + } + + // we have registered only one local SBC SEP, so aRemoteSEID should be a SBC Audio SEP, + // atleast we assume that. So stash it as SBC Audio SEP + TAvdtpSEPInfo info = TAvdtpSEPInfo(); + info.SetIsSink(ETrue); + info.SetMediaType(EAvdtpMediaTypeAudio); + info.SetSEID(iRemoteSEID); + TRAPD(err, Parent().iRemoteSEPs->NewSEPL(info)); + if (!err) + { + Parent().iRemoteSEPs->SetState(info.SEID(), CBTSACStreamEndPoint::EDiscoveredRemote, &info); + } + else // internal problem + { + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::CancelActionL +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) + { + TRACE_FUNC + Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::CancelConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::CancelConnectL() + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); // do no cancel till gavdp_error call back recieved + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::OpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::OpenAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + // Handle open audio completion later, after configuration is ready (completion will happen + // in CBtsacConfigured state after we receive GAVDP_StartIndication). + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::DisconnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::DisconnectL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KDisconnectReq, KErrNone); + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::GAVDP_BearerReady +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::GAVDP_BearerReady(RSocket aNewSocket, const TAvdtpSockAddr& aAddr) + { + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_BearerReady() SEID: %d"), aAddr.SEID().SEID())) + (void) aAddr.SEID(); + Parent().NewAccessory(Parent().GetRemoteAddr()); + + // If there is pending connect request, complete it. + Parent().CompletePendingRequests(KConnectReq, KErrNone); + + // only one socket in this implementation at the moment, + // as we dont have recovery and reporting yet + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConfigured::NewL(Parent(), aNewSocket, iAudioOpenedBy, EStreamConfiguredBySink))); + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::GAVDP_ConfigurationIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacConfiguring::GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability) + { + TRACE_FUNC + Parent().iRemoteSEPs->StoreCaps(iRemoteSEPIndex, aCapability); + if ( aCapability->Category() == EServiceCategoryMediaCodec ) + { + TAvdtpMediaCodecCapabilities& codecCaps = static_cast(*aCapability); + if ( codecCaps.MediaCodecType() == EAudioCodecSBC ) // found SEP that we are interested in + { + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_SEPCapability() Found SBC Audio Sink SEP !!!"))) + iSEPFound = ETrue; + Parent().SetSEPIndex(iRemoteSEPIndex); + } + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::GAVDP_ConfigurationEndIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacConfiguring::GAVDP_ConfigurationEndIndication() + { + TRACE_FUNC + if ( iSEPFound ) // proposed SEP has SBC (and media transport!) caps + { + RPointerArray SEPCapabilities; + if ((Parent().iRemoteSEPs->GetCaps(Parent().GetSEPIndex(), SEPCapabilities)) ) + { + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Couldn't retrieve Capabilities !"))) + SEPCapabilities.Close(); + TRAPD(err, CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + if(err) + { + return KErrNoMemory; + } + return KErrGeneral; + } + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Retrieve %d capabilities"), SEPCapabilities.Count())) + // loop through all capablities to find sbc codec capablities + TSBCCodecCapabilities SBCCaps; + TAvdtpMediaTransportCapabilities MedTransCaps; + for (TInt index=0; index < SEPCapabilities.Count(); index++) + { + TAvdtpServiceCapability* cap = SEPCapabilities[index]; + TAvdtpServiceCategory cat = cap->Category(); + if ( cat == EServiceCategoryMediaCodec ) + { + SBCCaps = static_cast(*cap); + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() SBC Caps retrieved."))) + } + else if ( cat == EServiceCategoryMediaTransport ) + { + MedTransCaps = static_cast(*cap); + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Media Transport Caps retrieved."))) + } + } + SEPCapabilities.Close(); + + //Parent().StoreAccInfo(); // stores iRemoteSEPs (SEPManager) into database + + // Check if headset's capabilities suits us + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Sampling Frequencies: %d"), SBCCaps.SamplingFrequencies())) + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Channel modes: %d"), SBCCaps.ChannelModes())) + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Blocks: %d"), SBCCaps.BlockLengths())) + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory SubBands: %d"), SBCCaps.Subbands())) + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Alloc method: %d"), SBCCaps.AllocationMethods())) + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Max bitpool: %d"), SBCCaps.MaxBitpoolValue())) + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Accessory Min bitpool: %d"), SBCCaps.MinBitpoolValue())) + if (Parent().iStreamer->ConfigureSEP(SBCCaps) ) + { + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() Streamer couldn't configure SEP !"))) + TRAPD(err, CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + if(err) + { + return KErrNoMemory; + } + return KErrGeneral; // capabilites doesn't suit us + } + // Everyting has been done on behalf of us, let's wait GAVDP_BearerReady indication. + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_ConfigurationEndIndication() completed"))) + return KErrNone; + } + else + { + return KErrNotFound; // remote is missing SBC (or media transport!) caps in SEP it proposed + } + } + +// ------------------------------------------------------------- +// CBtsacConfiguring::GAVDP_StartIndication +// ------------------------------------------------------------- +// +TInt CBtsacConfiguring::GAVDP_StartIndication(TSEID aLocalSEID) + { + TRACE_INFO((_L("CBtsacConfiguring::GAVDP_StartIndication(), LocalSEID:%d"), aLocalSEID.SEID())) + (void)aLocalSEID; + + // accessory has send this indication right after GAVDP_ConfigurationEndIndication + // but we must be waiting for Gavdp_BearerReady. In order to solve this, just flag + // our indication that an open audio request exists + // CBtsacConfigured state can use this indication to start audio automatically then later + + // If we have already audio open request pending (from accessory FW), let keep it that way. + // We have to complete open audio request later + if(!Parent().IsOpenAudioReqFromAccFWPending()) + { + iAudioOpenedBy = EAudioOpenedByAcc; + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtsacConfiguring::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacConfiguring::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + switch(aError) + { + case KErrAvdtpRequestTimeout: // -18005 + { + TRACE_INFO((_L("CBtsacConfiguring::HandleGavdpErrorL() Request TIMEOUT"))) + // Go to listening state, gavdp will be shutdown in listening state + CancelActionL(KErrDisconnected, EGavdpResetReasonNone); + break; + } + + case KErrHCILinkDisconnection: // -6305 + case KErrDisconnected: // -36 + { + TRACE_INFO((_L("CBtsacConfiguring::HandleGavdpErrorL() Signalling disconnected."))) + // for both outgoing or incoming connection, if we have an error, + // this means there is disconnection + CancelActionL(aError, EGavdpResetReasonNone); + break; + } + + default: + //case KErrNotReady: // -18 + //case KErrInUse: // -14 + { + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + break; + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateConnected.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateConnected.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,690 @@ +/* +* Copyright (c) 2002-2005 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: In this state, BTSAC is listening for remote connection +* from a stereo audio accessory +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateConnected.h" +#include "btsacStateConfigured.h" +#include "btsacStateConfiguring.h" +#include "btsacStateListening.h" +#include "btsacStateAborting.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "debug.h" + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + +const TInt KSEPDiscoverResponseDelay = 5000000; // 5 sec +const TInt KGetCapabilitiesResponseDelay = 4000000; // 4 sec +const TInt KSEPConfigureResponseDelay = 4000000; // 4 sec +const TInt KCreateBearersResponseDelay = 5000000; // 5 sec +const TInt KWaitConfStartIndicationDelay = 3000000; // 3 sec +const TInt KOneSecondDelay = 1000000; // 1 sec + + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacConnected::NewL +// ----------------------------------------------------------------------------- +// +CBtsacConnected* CBtsacConnected::NewL(CBTSAController& aParent, TBTConnType aConnType) + { + CBtsacConnected* self = new( ELeave ) CBtsacConnected(aParent, aConnType); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::CBtsacConnected +// ----------------------------------------------------------------------------- +// +CBtsacConnected::CBtsacConnected(CBTSAController& aParent, TBTConnType aConnType) +: CBtsacState(aParent, EStateConnected), iSuitableSEPFoundAlready(EFalse), iConnType(aConnType), + iSEPFound(ESEPNotInitialized), iRemoteSEPIndex(0), iBearersQuery(EFalse), iCancelConnectReq(EFalse), + iAudioOpenedBy(EAudioOpenedByNone) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::ConstructL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::ConstructL() + { + iTimerActive = CBtsacActive::NewL(*this, CActive::EPriorityStandard, KRequestIdTimer); + iTimer.CreateLocal(); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::~CBtsacConnected +// ----------------------------------------------------------------------------- +// +CBtsacConnected::~CBtsacConnected() + { + TRACE_FUNC_ENTRY + delete iTimerActive; + iTimerActive = NULL; + iTimer.Close(); + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Connected")) + _LIT(KName, "CBtsacStateConnected"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + + switch(iConnType) + { + case EOutgoingConnWithAudio: + case EOutgoingConn: + { + if(iConnType == EOutgoingConnWithAudio) + { + iAudioOpenedBy = EAudioOpenedByAFW; + } + StartTimer(KSEPDiscoverResponseDelay, KRequestIdTimer); + Parent().iGavdp->DiscoverSEPs(); // start with SEP discovery + break; + } + case EOutgoingConnWithAudioNoDiscovery: + case EOutgoingConnNoDiscovery: + { + if(iConnType == EOutgoingConnWithAudioNoDiscovery) + { + iAudioOpenedBy = EAudioOpenedByAFW; + } + ConfigureL(); + break; + } + case EIncomingConn: + { + Parent().NewAccessory(Parent().GetRemoteAddr()); + break; + } + case EConnExists: + break; + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::StartTimer +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::StartTimer(TTimeIntervalMicroSeconds32 aTimeout, TInt aRequestId) + { + TRACE_FUNC + if (iTimerActive) + { + if(!iTimerActive->IsActive()) + { + iTimerActive->SetRequestId(aRequestId); + iTimer.After(iTimerActive->iStatus, aTimeout); + iTimerActive->GoActive(); + } + } + else + { + TRACE_INFO((_L("CBtsacConnected::StartTimer, Timer Active doesn't exist."))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::StopTimer +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::StopTimer() + { + TRACE_FUNC + if (iTimerActive) + { + iTimerActive->Cancel(); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::CancelActionL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) + { + TRACE_FUNC + StopTimer(); + Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::OpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::OpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + + if (Parent().GetRemoteAddr() != aAddr) + { + TRACE_INFO((_L("CBtsacConnected::OpenAudio, Error!"))) + CancelActionL(KErrNotFound, EGavdpResetReasonGeneral); + return; + } + iAudioOpenedBy = EAudioOpenedByAFW; + Parent().SetRemoteAddr(aAddr); + + if(iConnType == EIncomingConn) + { + // Accessory has created connection to us. Don't open audio immediately, + // let's wait for a while if accessory starts configuration. This way + // we can avoid configure collision. + StartTimer(KOneSecondDelay, KRequestIdWaitRemoteConfStart); + } + else + { + StartConfigurationL(); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::CancelOpenAudioLinkL() +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::CancelOpenAudioLinkL() + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::DisconnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::DisconnectL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KDisconnectReq, KErrNone); + CancelActionL(KErrCancel, EGavdpResetReasonDisconnect); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::CancelConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::CancelConnectL() + { + TRACE_FUNC + if(!iBearersQuery) + { + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + else + { + // We have to wait bearers to be completed + TRACE_INFO((_L("CBtsacConnected::CancelConnectL() Wait for BearerReady."))) + iCancelConnectReq = ETrue; + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::StartConfigurationL() +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::StartConfigurationL() + { + TRACE_FUNC + if (!Parent().iRemoteSEPs->NoOfSEPs()) // if accessory info not stored already + { + iRemoteSEPIndex = 0; + Parent().InitializeSEPManager(); + StartTimer(KSEPDiscoverResponseDelay, KRequestIdTimer); + Parent().iGavdp->DiscoverSEPs(); // start with SEP discovery + } + else // otherwise we have explored this accessory before - go straight to configure + { + ConfigureL(); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::ConfigureL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::ConfigureL() + { + TRACE_FUNC + + RPointerArray SEPCapabilities; + if ((Parent().iRemoteSEPs->GetCaps(Parent().GetSEPIndex(), SEPCapabilities)) ) + { + TRACE_INFO((_L("CBtsacConnected::Configure() Couldn't retrieve Capabilities !"))) + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + SEPCapabilities.Close(); + return; + } + + TRACE_INFO((_L("CBtsacConnected::Configure() Retrieve %d capabilities"), SEPCapabilities.Count())) + // loop through all capablities to find sbc codec capablities + TSBCCodecCapabilities SBCCaps; + TAvdtpMediaTransportCapabilities MedTransCaps; + for (TInt index=0; index < SEPCapabilities.Count(); index++) + { + TAvdtpServiceCapability* cap = SEPCapabilities[index]; + TAvdtpServiceCategory cat = cap->Category(); + if ( cat == EServiceCategoryMediaCodec ) + { + SBCCaps = static_cast(*cap); + TRACE_INFO((_L("CBtsacConnected::Configure() SBC Caps retrieved."))) + } + else if ( cat == EServiceCategoryMediaTransport ) + { + MedTransCaps = static_cast(*cap); + TRACE_INFO((_L("CBtsacConnected::Configure() Media Transport Caps retrieved."))) + } + } + SEPCapabilities.Close(); + + // Check if headset's capabilities suits us + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory Sampling Frequencies: %d"), SBCCaps.SamplingFrequencies())) + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory Channel modes: %d"), SBCCaps.ChannelModes())) + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory Blocks: %d"), SBCCaps.BlockLengths())) + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory SubBands: %d"), SBCCaps.Subbands())) + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory Alloc method: %d"), SBCCaps.AllocationMethods())) + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory Max bitpool: %d"), SBCCaps.MaxBitpoolValue())) + TRACE_INFO((_L("CBtsacConnected::Configure() Accessory Min bitpool: %d"), SBCCaps.MinBitpoolValue())) + + if (Parent().iStreamer->ConfigureSEP(SBCCaps) ) + { + TRACE_INFO((_L("CBtsacConnected::Configure() Streamer couldn't configure SEP !"))) + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + return; // capabilites doesn't suit us + } + + TAvdtpSEPInfo SEPInfo; + if (Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo)) + { + TRACE_INFO((_L("CBtsacConnected::Configure() Couldn't retrieve SEP Info !"))) + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + return; // capabilites doesn't suit us + } + TSEID remoteSEPid = SEPInfo.SEID(); + // local sep index is hard coded cause current implementation is only sbc encoded + TSEID localSEPid = TSEID(1, ETrue); + + StartTimer(KSEPConfigureResponseDelay, KRequestIdTimer); + if ( Parent().iGavdp->ConfigureSEP(localSEPid, remoteSEPid , SBCCaps, MedTransCaps ) ) + { + TRACE_INFO((_L("CBtsacConnected::Configure() ConfigureSEP returned Error !!!"))) + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GetCapabilitiesOfAllSEPs +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GetCapabilitiesOfAllSEPs() + { + TRACE_INFO((_L("CBtsacConnected::GetCapabilitiesOfAllSEPs() CurrentSEP:%d"), iRemoteSEPIndex)) + TRACE_INFO((_L("CBtsacConnected::GetCapabilitiesOfAllSEPs() Total Remote SEPs registered:%d"), Parent().iRemoteSEPs->NoOfSEPs())) + + if ( iRemoteSEPIndex < Parent().iRemoteSEPs->NoOfSEPs() ) + { + TAvdtpSEPInfo SEPInfo; + if (!Parent().iRemoteSEPs->GetInfo(iRemoteSEPIndex, SEPInfo)) + { + TSEID id = SEPInfo.SEID(); + Parent().iGavdp->GetCapabilities(id); + } + } + else // we have covered all SEPs + { + StopTimer(); + // store all info in our db + //Parent().StoreAccInfo(); // stores iRemoteSEPs (SEPManager) into database + iSuitableSEPFoundAlready = EFalse; + + if ( iSEPFound == ESEPConfigure ) + { + TRAP_IGNORE(ConfigureL()); + } + else if ( iSEPFound == ESEPInUse ) + { + // We have open audio or connect request pending but do not complete it yet. We expect that + // accessory will start configure us. We should receive GAVDP_ConfigurationStartIndication + // from the remote and remote will configure us. Eventually acc FW's open audio request + // will be completed in CBTsacConfigured state and connect request will be completed in + // CBTsacConfiguring state. + + // For safety's sake start timer to protect the situation where we do not receive + // GAVDP_ConfigurationStartIndication. + StartTimer(KWaitConfStartIndicationDelay, KRequestIdTimer); + } + else // no audio sbc sink sep found + { + TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_SEPDiscovered +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEPInfo) + { + TRACE_INFO((_L("CBtsacConnected:::GAVDP_SEPDiscovered() SEID: %d InUse: %d MediaType: %d IsSink: %d"), + aSEPInfo.SEID().SEID(), aSEPInfo.InUse(), aSEPInfo.MediaType(), aSEPInfo.IsSink())) + + // BTSAC cares only about audio SEPs which are sink + if (aSEPInfo.MediaType() == EAvdtpMediaTypeAudio && aSEPInfo.IsSink() ) + { + TRAPD(err, Parent().iRemoteSEPs->NewSEPL(aSEPInfo)) + if (!err) + { + Parent().iRemoteSEPs->SetState(aSEPInfo.SEID(), CBTSACStreamEndPoint::EDiscoveredRemote, &aSEPInfo); + } + else // internal problem + { + TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_SEPDiscoveryComplete +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_SEPDiscoveryComplete() + { + TRACE_FUNC + StopTimer(); + if ( Parent().iRemoteSEPs->NoOfSEPs() ) + { + StartTimer(KGetCapabilitiesResponseDelay, KRequestIdTimer); + GetCapabilitiesOfAllSEPs(); + } + else // remote A2DP has no 'audio' 'sink' SEPs ! naughty remote + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_SEPDiscoveryComplete() Remote A2dP has no 'audio' 'sink' SEPs !"))) + TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_SEPCapability +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability) + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_SEPCapability(%d)"), aCapability->Category())) + + Parent().iRemoteSEPs->StoreCaps(iRemoteSEPIndex, aCapability); + + if( iSuitableSEPFoundAlready ) + { + return; + } + + if ( aCapability->Category() == EServiceCategoryMediaCodec ) + { + TAvdtpMediaCodecCapabilities& codecCaps = static_cast(*aCapability); + TAvdtpSEPInfo SEPInfo; + TBool InUse = EFalse; + + if ( !Parent().iRemoteSEPs->GetInfo(iRemoteSEPIndex, SEPInfo)) + { + InUse = SEPInfo.InUse(); + } + else + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_SEPCapability() Couldn't retrieve SEP Info !"))) + return; + } + + if ( (codecCaps.MediaCodecType() == EAudioCodecSBC) && !InUse) // found SEP that we are interested in + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_SEPCapability() Found SBC Audio Sink SEP !!!"))) + iSuitableSEPFoundAlready = ETrue; + iSEPFound = ESEPConfigure; + Parent().SetSEPIndex(iRemoteSEPIndex); + } + else + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_SEPCapability() Remote SEP In Use or Codec Type not suitable !!!"))) + iSEPFound = InUse ? ESEPInUse : ESEPCodecTypeNotAllowed; + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_SEPCapabilityComplete +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_SEPCapabilityComplete() + { + TRACE_FUNC + iRemoteSEPIndex++; + GetCapabilitiesOfAllSEPs(); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_ConfigurationConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_ConfigurationConfirm() + { + TRACE_FUNC + StopTimer(); + TAvdtpSEPInfo SEPInfo; + if (Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo)) + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_ConfigurationConfirm Couldn't retrieve SEP Info !"))) + TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + return; // cannot get remote SEP capabilites + } + TSEID remoteSEPid = SEPInfo.SEID(); + TRACE_INFO((_L("CBtsacConnected::GAVDP_ConfigurationConfirm() Asking for bearer for remote SEID(%d)"), remoteSEPid.SEID())) + iBearersQuery = ETrue; + StartTimer(KCreateBearersResponseDelay, KRequestIdTimer); + Parent().iGavdp->CreateBearers(remoteSEPid); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_BearerReady +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_BearerReady(RSocket aNewSocket, const TAvdtpSockAddr& aAddr) + { + TRACE_FUNC + TRACE_INFO((_L("CBtsacConnected::GAVDP_BearerReady() SEID: %d"), aAddr.SEID().SEID())) + (void)aAddr.SEID(); + StopTimer(); + if(!iCancelConnectReq) + { + if(iConnType != EIncomingConn) + { + // New accessory has been already informed if connection type is incoming, + // otherwise tell about new accessory + Parent().NewAccessory(Parent().GetRemoteAddr()); + } + + if(iConnType == EOutgoingConn || iConnType == EOutgoingConnNoDiscovery) + { + // If connection is without audio, just complete pending connect request if any. + // Otherwise pending request(s) is/are completed in configured state. + Parent().CompletePendingRequests(KConnectReq, KErrNone); + } + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConfigured::NewL(Parent(), aNewSocket, iAudioOpenedBy, EStreamConfiguredBySrc))); + } + else + { + TRACE_ASSERT(Parent().iStreamingSockets.Count() == 0, EBTPanicSocketExists) + TRACE_INFO((_L("[SOCKET] created."))) + Parent().iStreamingSockets.Append(aNewSocket); + Parent().CompletePendingRequests(KCompleteAllReqs, KErrCancel); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrNone))); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_AbortIndication +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_AbortIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_AbortIndication() SEID:%d"), aSEID.SEID())) + (void)aSEID; + TRAP_IGNORE(CancelActionL(KErrDisconnected, EGavdpResetReasonNone)); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::GAVDP_ConfigurationStartIndication +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID) + { + TRACE_INFO((_L("CBtsacConnected::GAVDP_ConfigurationStartIndication() LocalSEID: %d, RemoteSEID: %d"), aLocalSEID.SEID(), aRemoteSEID.SEID())) + StopTimer(); + Parent().InitializeSEPManager(); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConfiguring::NewL(Parent(), aLocalSEID, aRemoteSEID))); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::RequestCompletedL(CBtsacActive& aActive) + { + TRACE_FUNC + switch(aActive.RequestId()) + { + case KRequestIdTimer: + { + if(!iBearersQuery) + { + // Go to listening state, gavdp will be shutdown in listening state + CancelActionL(KErrCancel, EGavdpResetReasonNone); + } + else + { + // If bearers query timer has expired, lets handle it separately. + Parent().iGavdp->Cancel(); + TInt err = Parent().AbortStream(); + if(!err) + { + Parent().ChangeStateL(CBtsacAborting::NewL(Parent())); + } + else + { + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + } + break; + } + case KRequestIdWaitRemoteConfStart: + { + // Remote didn't configure us and we have open audio request from acc fw. + // Let's configure the link and open audio by our selves. + StartConfigurationL(); + break; + } + default: + { + TRACE_INFO((_L("CBtsacConnected::RequestCompletedL() Unknown request"))) + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::CancelRequest(CBtsacActive& aActive) + { + TRACE_FUNC + (void)aActive; + iTimer.Cancel(); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnected::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacConnected::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + StopTimer(); + switch (aError) + { + case KErrAvdtpRequestTimeout: // -18005 + { + TRACE_INFO((_L("CBtsacConnected::HandleGavdpErrorL() Request TIMEOUT"))) + // Go to listening state, gavdp will be shutdown in listening state + CancelActionL(KErrDisconnected, EGavdpResetReasonNone); + break; + } + + case KErrHCILinkDisconnection: // -6305 + case KErrDisconnected: // -36 + { + TRACE_INFO((_L("CBtsacConnected::HandleGavdpErrorL() Signalling disconnected."))) + // for both outgoing or incoming connection, if we have an error, + // this means there is disconnection + CancelActionL(aError, EGavdpResetReasonGeneral); + break; + } + + case (KErrAvdtpSignallingErrorBase - EAvdtpSEPInUse): // -18064 + { + // Remote SEP is in use. + // Wait for a while, accessory might configure us. If we don't receive + // start ind during KOneSecondDelay, go to listening state. + StartTimer(KOneSecondDelay, KRequestIdTimer); + break; + } + + default: + // KErrNotReady -18 + // KErrInUse -14 + // KErrCorrupt -20 + // (KErrAvdtpSignallingErrorBase - EAvdtpBadState) -18094 + { + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateConnecting.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateConnecting.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2002-2005 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: In this state, BTSAC is listening for remote connection +* from a stereo audio accessory +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateConnecting.h" +#include "btsacStateConnected.h" +#include "btsacStateListening.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "debug.h" + + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::NewL +// ----------------------------------------------------------------------------- +// +CBtsacConnecting* CBtsacConnecting::NewL(CBTSAController& aParent, TBTConnType aConnType) + { + CBtsacConnecting* self = new( ELeave ) CBtsacConnecting(aParent, aConnType); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::CBtsacConnecting +// ----------------------------------------------------------------------------- +// +CBtsacConnecting::CBtsacConnecting(CBTSAController& aParent, TBTConnType aConnType) +: CBtsacState(aParent, EStateConnecting), iConnType(aConnType) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::~CBtsacConnecting +// ----------------------------------------------------------------------------- +// +CBtsacConnecting::~CBtsacConnecting() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacConnecting::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Connecting")) + _LIT(KName, "CBtsacStateConnecting"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); // gavdp call-backs + Parent().iGavdp->Connect(Parent().GetRemoteAddr()); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::CancelActionL +// ----------------------------------------------------------------------------- +// +void CBtsacConnecting::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) + { + TRACE_FUNC + Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::CancelOpenAudioL() +// ----------------------------------------------------------------------------- +// +void CBtsacConnecting::CancelOpenAudioL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::CancelConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacConnecting::CancelConnectL() + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::GAVDP_ConnectConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacConnecting::GAVDP_ConnectConfirm(const TBTDevAddr& aAddr) + { + TRACE_INFO((_L("CBtsacConnecting::GAVDP_ConnectConfirm() Connected with accessory."))) + if (Parent().GetRemoteAddr() == aAddr) + { + // Complete connect request when configuration is complete + // cause BT Acc Server will not send a seperate configure request + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), iConnType))); + } + else // not the accessory that we are trying to connect to ! + // only possibility is that another accessory has made incoming connection, after we have sent a connect request + // what a coincidence ! + { + TRAP_IGNORE(CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral)); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacConnecting::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacConnecting::HandleGavdpErrorL(TInt /*aError*/) + { + TRACE_FUNC + // Seen error codes: + // KErrDied -13 + // KErrInUse -14 + // KErrCouldNotConnect -34 + // KErrL2CAPRequestTimeout -6312 + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateIdle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateIdle.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2002-2005 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: In this state, BTSAC is listening for remote connection +* from a stereo audio accessory +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateIdle.h" +#include "btsacactive.h" +#include "btsacStateListening.h" +#include "btsacGavdp.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "debug.h" + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacIdle::NewL +// ----------------------------------------------------------------------------- +// +CBtsacIdle* CBtsacIdle::NewL(CBTSAController& aParent) + { + CBtsacIdle* self = new( ELeave ) CBtsacIdle(aParent); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacIdle::TStateIdle +// ----------------------------------------------------------------------------- +// +CBtsacIdle::CBtsacIdle(CBTSAController& aParent) +: CBtsacState(aParent, EStateIdle) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacIdle::TStateIdle +// ----------------------------------------------------------------------------- +// +CBtsacIdle::~CBtsacIdle() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacIdle::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacIdle::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Idle")) + _LIT(KName, "CBtsacStateIdle"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + + TSBCCodecCapabilities sbc; + TInt err = Parent().iStreamer->FillCapabilities(sbc); + if ( err ) + { + TRACE_INFO((_L("CBtsacIdle::EnterL() Couldn't fill capabilities. Error: %d"), err)) + User::Leave(KErrAvdtpBaseError); + } + // start with registering sdp, open gavdp and registering local SEPs + err = Parent().iGavdp->StartSrc(*Parent().iLocalSEPs, sbc); + if ( err ) + { + TRACE_INFO((_L("CBtsacIdle::EnterL() Couldn't start Gavdp. Error: %d"), err)) + User::Leave(KErrAvdtpBaseError); + } + // Let's wait GAVDP_ConfigurationConfirm callback + } + +// ----------------------------------------------------------------------------- +// CBtsacIdle::GAVDP_ConfigurationConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacIdle::GAVDP_ConfigurationConfirm() + { + TRACE_INFO((_L("CBtsacIdle::GAVDP_ConfigurationConfirm() Local SEPs registered successfully."))) + TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrNone))); + } + +// ----------------------------------------------------------------------------- +// CBtsacIdle::GAVDP_Error +// ----------------------------------------------------------------------------- +// +void CBtsacIdle::GAVDP_Error(TInt aError, const TDesC8& /*aErrorData*/) + { + TRACE_INFO((_L("CBtsacIdle::GAVDP_Error(%d)"), aError)) + (void)aError; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateListening.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateListening.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,442 @@ +/* +* Copyright (c) 2002-2005 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: In this state, BTSAC is listening for remote connection +* from a stereo audio accessory +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateListening.h" +#include "btsacStateConnected.h" +#include "btsacStateConnecting.h" +#include "btsacStateConfiguring.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacListening::NewL +// ----------------------------------------------------------------------------- +// +CBtsacListening* CBtsacListening::NewL(CBTSAController& aParent, + TBTSACGavdpResetReason aGavdpResetReason, TInt aDisconnectReason) + { + CBtsacListening* self = new( ELeave ) CBtsacListening(aParent, aGavdpResetReason, aDisconnectReason); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::CBtsacListening +// ----------------------------------------------------------------------------- +// +CBtsacListening::CBtsacListening(CBTSAController& aParent, + TBTSACGavdpResetReason aGavdpResetReason, TInt aDisconnectReason) +: CBtsacState(aParent, EStateListening), iGavdpResetReason(aGavdpResetReason), + iDisconnectReason(aDisconnectReason), iPendingRequests(KRequestNone), + iInitializationProcedure(EInitProcedureOngoing), iUnfinishedGavdpError(EFalse) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::ConstructL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::ConstructL() + { + iSelfCompleteActive = CBtsacActive::NewL(*this, CActive::EPriorityStandard, KRequestIdSelfComplete); + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::~CBtsacListening +// ----------------------------------------------------------------------------- +// +CBtsacListening::~CBtsacListening() + { + TRACE_FUNC + delete iSelfCompleteActive; + iSelfCompleteActive = NULL; + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Listening")) + _LIT(KName, "CBtsacStateListening"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + + Parent().ResetRemoteCache(); + Parent().CleanSockets(); + + // RGavdp.Close (which is called from ResetGavdp method) should not be called from + // within a client's implementation of any MGavdpUser (upcall) method. Do self + // complete first then call ResetGavdp. + + // Need for self completion is gavdp user up calls but we will do self complete every time + // when we enter into listening state. + DoSelfComplete(KErrNone); + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::ConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::ConnectL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + iPendingRequests = KConnectReq; + if(iInitializationProcedure == EInitProcedureDone) + { + // we have a connection already with this accessory + if ( Parent().GetRemoteAddr() == aAddr ) + { + Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), EOutgoingConnNoDiscovery)); + } + else + { + Parent().SetRemoteAddr(aAddr); // first update address cause InitializeSEPManager uses it + Parent().InitializeSEPManager(); // initializes iRemoteSEPs + Parent().ChangeStateL(CBtsacConnecting::NewL(Parent(), EOutgoingConn)); + } + } + else + { + // Save the address, reset procedure is not completed yet. + Parent().SetRemoteAddr(aAddr); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::OpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::OpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + iPendingRequests = KOpenAudioReq; + if(iInitializationProcedure == EInitProcedureDone) + { + // we have a connection already with this accessory + if ( Parent().GetRemoteAddr() == aAddr ) + { + Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), EOutgoingConnWithAudioNoDiscovery)); + } + else + { + Parent().SetRemoteAddr(aAddr); // first update address cause InitializeSEPManager uses it + Parent().InitializeSEPManager(); // initializes iRemoteSEPs + Parent().ChangeStateL(CBtsacConnecting::NewL(Parent(), EOutgoingConnWithAudio)); + } + } + else + { + // Save the address, reset procedure is not completed yet. + Parent().SetRemoteAddr(aAddr); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::CancelOpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::CancelOpenAudioLinkL() + { + TRACE_FUNC + // We can have only one request active at the time, so we can reset pending requests + iPendingRequests = KRequestNone; + GoListen(); + Parent().CompletePendingRequests(KOpenAudioReq, KErrCancel); + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::DeleyedOpenAudioAndConnectL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::DeleyedOpenAudioAndConnectL() + { + TRACE_FUNC + if(iPendingRequests & (KConnectReq | KOpenAudioReq)) + { + Parent().InitializeSEPManager(); + if(iPendingRequests & KOpenAudioReq) + { + Parent().ChangeStateL(CBtsacConnecting::NewL(Parent(), EOutgoingConnWithAudio)); + } + else + { + Parent().ChangeStateL(CBtsacConnecting::NewL(Parent(), EOutgoingConn)); + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::GAVDP_ConfigurationConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacListening::GAVDP_ConfigurationConfirm() + { + TRACE_INFO((_L("CBtsacListening::GAVDP_ConfigurationConfirm() Local SEPs registered successfully."))) + // Local SEPs got registered, so start listening + TInt err = Parent().iGavdp->Listen(); + if (err) + { + TRACE_INFO((_L("CBtsacListening::GAVDP_ConfigurationConfirm() Listen returned error:%d."), err)) + ResetGavdp(EGavdpResetReasonGeneral); + return; + } + if(iInitializationProcedure == EInitProcedureWaitingConfConfirmed) + { + iInitializationProcedure = EInitProcedureDone; + TRAP_IGNORE(DeleyedOpenAudioAndConnectL()); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::GAVDP_ConnectConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacListening::GAVDP_ConnectConfirm(const TBTDevAddr& aAddr) + { + TRACE_INFO((_L("CBtsacListening::GAVDP_ConnectConfirm() Accessory made connection."))) + Parent().SetRemoteAddr(aAddr); // first update address cause InitializeSEPManager uses it + Parent().InitializeSEPManager(); // initializes iRemoteSEPs + TRAPD(err, Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), EIncomingConn))); + if(err) + { + TRACE_INFO((_L("CBtsacListening::GAVDP_ConnectConfirm(), NewL failed."))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::GAVDP_AbortStreamConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacListening::GAVDP_AbortStreamConfirm() + { + TRACE_FUNC + GoListen(); + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::GAVDP_ConfigurationStartIndication +// ----------------------------------------------------------------------------- +// +void CBtsacListening::GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID) + { + TRACE_FUNC + Parent().InitializeSEPManager(); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConfiguring::NewL(Parent(), aLocalSEID, aRemoteSEID))); + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::RequestCompletedL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::RequestCompletedL(CBtsacActive& aActive) + { + TRACE_FUNC + switch(aActive.RequestId()) + { + case KRequestIdSelfComplete: + { + TBTDevAddr remoteAddr = Parent().GetRemoteAddr(); + if(iUnfinishedGavdpError) + { + // We have unfinished gavdp error, force gavdp reset + iGavdpResetReason = EGavdpResetReasonGeneral; + } + if(iGavdpResetReason != EGavdpResetReasonNone) + { + ResetGavdp(iGavdpResetReason); + } + else + { + GoListen(); + } + if(iDisconnectReason == KErrDisconnected || iDisconnectReason == KErrHCILinkDisconnection) + { + if(remoteAddr != TBTDevAddr()) + { + Parent().DisconnectedFromRemote(remoteAddr, iDisconnectReason); + } + Parent().SetResetAudioInput(ETrue); + } + if(Parent().GetResetAudioInput()) + { + Parent().SetResetAudioInput(EFalse); + Parent().iStreamer->ResetAudioInput(); + } + if(iInitializationProcedure != EInitProcedureWaitingConfConfirmed) + { + iInitializationProcedure = EInitProcedureDone; + DeleyedOpenAudioAndConnectL(); + } + break; + } + default: + { + TRACE_INFO((_L("CBtsacListening::RequestCompletedL() Unknown request"))) + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::GoListen +// ----------------------------------------------------------------------------- +// +void CBtsacListening::GoListen() + { + TRACE_INFO((_L("CBtsacListening::GoListen(), Disconnect signalling channel"))) + if(iPendingRequests == KRequestNone) + { + Parent().SetRemoteAddr(TBTDevAddr()); + } + TInt err = Parent().iGavdp->Shutdown(); + if(!err) + { + TRACE_INFO((_L("CBtsacListening::GoListen(), Signalling disconnected, Re-listen..."))) + // Starts to listen for inbound signalling channel connections. + err = Parent().iGavdp->Listen(); + } + if(err) + { + // Shutdown failed, reset gavdp + TRACE_INFO((_L("CBtsacListening::GoListen(), error = %d."), err)) + ResetGavdp(EGavdpResetReasonGeneral); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::ResetGavdp +// ----------------------------------------------------------------------------- +// +TInt CBtsacListening::ResetGavdp(TBTSACGavdpResetReason aReason) + { + TRACE_FUNC + Parent().iGavdp->Close(); + if( Parent().iGavdp->Open() == KErrNone ) + { + iInitializationProcedure = EInitProcedureWaitingConfConfirmed; + if(aReason != EGavdpResetReasonCancelOpenAudio) + { + if(iPendingRequests == KRequestNone) + { + TRACE_INFO((_L("CBtsacListening::ResetGavdp() Remote Addr reseted."))) + Parent().SetRemoteAddr(TBTDevAddr()); + } + } + return Parent().iGavdp->RegisterSEPs(*Parent().iLocalSEPs, Parent().iStreamer->GetCaps()); + } + else + { + TRACE_INFO((_L("CBtsacListening::ResetGavdp() Couldn't open gavdp."))) + return KErrGeneral; + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::CancelRequest +// ----------------------------------------------------------------------------- +// +void CBtsacListening::CancelRequest(CBtsacActive& /*aActive*/) + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::DoSelfComplete +// ----------------------------------------------------------------------------- +// +void CBtsacListening::DoSelfComplete(TInt aError) + { + TRACE_FUNC + if(iSelfCompleteActive) + { + if (!iSelfCompleteActive->IsActive()) + { + TRequestStatus* sta = &(iSelfCompleteActive->iStatus); + iSelfCompleteActive->iStatus = KRequestPending; + User::RequestComplete(sta, aError); + iSelfCompleteActive->GoActive(); + } + } + else + { + TRACE_INFO((_L("CBtsacListening::DoSelfComplete() AO doesn't exist."))) + } + } + +// ----------------------------------------------------------------------------- +// CBtsacListening::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacListening::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + if(iInitializationProcedure != EInitProcedureDone) + { + TRACE_INFO((_L("CBtsacListening::HandleGavdpErrorL() error ignored, initialization procedure ongoing."))) + iUnfinishedGavdpError = ETrue; + return; + } + switch(aError) + { + case KErrHCILinkDisconnection: // -6305 + case KErrDisconnected: // -36 + { + // If address is zero, initialization procedure is already executed, so there is no need + // to tell gavdp to go listen and no need to inform btaudioman about the disconnection + if(Parent().GetRemoteAddr() != TBTDevAddr()) + { + GoListen(); + // for both outgoing or incoming connection, if we have an error, + // this means there is disconnection + Parent().DisconnectedFromRemote(Parent().GetRemoteAddr(), aError); + Parent().SetRemoteAddr(TBTDevAddr()); + Parent().iStreamer->ResetAudioInput(); + } + break; + } + + case KErrCouldNotConnect: // -34 + { + GoListen(); + break; + } + + default: + // KErrAbort -39 + // KErrDied -13 + // KErrInUse -14 + { + ResetGavdp(EGavdpResetReasonGeneral); + break; + } + } + Parent().CompletePendingRequests(KCompleteAllReqs, aError); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateStreaming.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateStreaming.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,364 @@ +/* +* Copyright (c) 2002-2005 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: In this state, streaming is active. +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateStreaming.h" +#include "btsacStateListening.h" +#include "btsacStateSuspended.h" +#include "btsacStateConnected.h" +#include "btsacStateAborting.h" +#include "btsacactive.h" +#include "btsacGavdp.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "debug.h" + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::NewL +// ----------------------------------------------------------------------------- +// +CBtsacStreaming* CBtsacStreaming::NewL(CBTSAController& aParent, TAudioOpenedBy aAudioOpenedBy, TBool aStartCollision) + { + CBtsacStreaming* self = new( ELeave ) CBtsacStreaming(aParent, aAudioOpenedBy, aStartCollision); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::CBtsacStreaming +// ----------------------------------------------------------------------------- +// +CBtsacStreaming::CBtsacStreaming(CBTSAController& aParent, TAudioOpenedBy aAudioOpenedBy, TBool aStartCollision) +: CBtsacState(aParent, EStateStreaming), iSuspending(EFalse), iAudioOpenedBy(aAudioOpenedBy), + iStartCollision(aStartCollision) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::~CBtsacStreaming +// ----------------------------------------------------------------------------- +// +CBtsacStreaming::~CBtsacStreaming() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Streaming")) + _LIT(KName, "CBtsacStateStreaming"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + if( iAudioOpenedBy == EAudioOpenedByAcc ) + { + Parent().AccessoryOpenedAudio(Parent().GetRemoteAddr()); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::CancelActionL +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) + { + TRACE_FUNC + TInt ret = Parent().iStreamer->StopStream(); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::Cancel() iStreamer.StopStream() returned error(%d) !!!"), ret)) + } + Parent().CompletePendingRequests(KCompleteAllReqs, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::OpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::OpenAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + // It is not allowed to open audio in streaming state, audio is allready opened + // by an accessory. Inform accessory fw about this by returning KErrInUse. + Parent().CompletePendingRequests(KOpenAudioReq, KErrInUse); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::CloseAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::CloseAudioLinkL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + iStartCollision = EFalse; + TInt ret = Parent().iStreamer->StopStream(); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::CloseAudio() iStreamer.StopStream() returned error(%d) !!!"), ret)) + } + TAvdtpSEPInfo SEPInfo; + ret = Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::CloseAudio() Couldn't retrieve SEP Info !"))) + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + return; + } + // Suspend audio + TSEID remoteSEPid = SEPInfo.SEID(); + TRACE_INFO((_L("CBtsacStreaming::CloseAudio() Suspending remote SEID(%d)"), remoteSEPid.SEID())) + iSuspending = ETrue; + Parent().iGavdp->SuspendStreams(remoteSEPid); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::CancelCloseAudioLink +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::CancelCloseAudioLink(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + // For safety sake complete all pending requests + Parent().CompletePendingRequests(KCompleteAllReqs, KErrNone); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected))); + } + + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::StartRecording +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::StartRecording() + { + TRACE_FUNC + iStartCollision = EFalse; + if ( Parent().iStreamer->StartStream(Parent().iStreamingSockets[0], Parent().iStreamer->FrameLength()) != KErrNone ) + { + TRACE_INFO((_L("CBtsacStreaming::StartRecording() [ERR] Could not start streaming!"))) + TInt err = Parent().AbortStream(); + if(err) + { + TRACE_INFO((_L("CBtsacStreaming::StartRecording() Couldn't abort stream."))) + } + TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected))); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::DisconnectL +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::DisconnectL() + { + TRACE_FUNC + TInt ret = Parent().iStreamer->StopStream(); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::DisconnectL() StopStream() returned error: %d"), ret)) + } + Parent().CompletePendingRequests(KDisconnectReq, ret); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonDisconnect, KErrNone)); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::GAVDP_SuspendStreamsConfirm +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::GAVDP_SuspendStreamsConfirm() + { + TRACE_FUNC + // so remote supports suspend + iSuspending = EFalse; + Parent().CompletePendingRequests(KCloseAudioReq, KErrNone); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacSuspended::NewL(Parent()))); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::GAVDP_AbortIndication +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::GAVDP_AbortIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBtsacStreaming::GAVDP_AbortIndication() Local SEP Id: %d"), aSEID.SEID())) + (void)aSEID; + TInt ret = Parent().iStreamer->StopStream(); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::Cancel() iStreamer.StopStream() returned error(%d) !!!"), ret)) + } + + // It is possible the remote disconnected while we have active close audio request. + Parent().CompletePendingRequests(KCompleteAllReqs, KErrNone); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, KErrDisconnected))); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::GAVDP_ReleaseIndication +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::GAVDP_ReleaseIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBtsacStreaming::GAVDP_ReleaseIndication() aSEID: %d"), aSEID.SEID())) + (void)aSEID; + if(!iSuspending) + { + TInt ret = Parent().iStreamer->StopStream(); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::GAVDP_ReleaseIndication() [ERR: %d] Could not stop streaming!"), ret)) + } + Parent().AccessoryClosedAudio(Parent().GetRemoteAddr()); + } + else + { + // We are trying to suspend the stream and remote end has sent release indication. + // Stream is already stopped but we have pending close audio request, complete it. + Parent().CompletePendingRequests(KCloseAudioReq, KErrNone); + } + Parent().CleanSockets(); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), EConnExists))); + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::GAVDP_SuspendIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacStreaming::GAVDP_SuspendIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBtsacStreaming::GAVDP_SuspendIndication() aSEID: %d"), aSEID.SEID())) + (void)aSEID; + if(!iSuspending) + { + TInt ret = Parent().iStreamer->StopStream(); + if ( ret ) + { + TRACE_INFO((_L("CBtsacStreaming::GAVDP_SuspendIndication() iStreamer.StopStream() returned error(%d) !!!"), ret)) + } + Parent().AccessorySuspendedAudio(Parent().GetRemoteAddr()); + TRAPD(err, Parent().ChangeStateL(CBtsacSuspended::NewL(Parent()))); + if(err) + { + return KErrNoMemory; + } + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtsacStreaming::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacStreaming::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + TInt err = KErrNone; + + if(aError == (KErrAvdtpSignallingErrorBase - EAvdtpBadState) && iStartCollision) + { + // Start stream collision has happened (src and snk have sent start stream cmd simultaneously). + // iStreamStartIndCollision flag is set in configured state to indicate possible collision + // situations. + // Error can be ignored and we can continue streaming. + iStartCollision = EFalse; + TRACE_INFO((_L("CBtsacStreaming::HandleGavdpErrorL() Ignore error, continue streaming."))) + return; + } + + if(iSuspending) + { + iSuspending = EFalse; + if(aError == (KErrAvdtpSignallingErrorBase - EAvdtpBadState)) // -18094 + { + // For some reason remote rejected our suspend command. According to the specification + // it is acceptor's responsibilty to cope with this situation, so we can move to suspended + // state and wait for acceptor's reaction. + Parent().CompletePendingRequests(KCloseAudioReq, KErrNone); + Parent().ChangeStateL(CBtsacSuspended::NewL(Parent())); + return; + } + else if(aError == (KErrAvdtpSignallingErrorBase - EAvdtpNotSupportedCommand)) // -18070 + { + // remote doesn't support suspend so close audio + Parent().CleanSockets(); + Parent().CompletePendingRequests(KCloseAudioReq, KErrNone); + Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), EConnExists)); + return; + } + } + else + { + err = Parent().iStreamer->StopStream(); + if (err) + { + TRACE_INFO((_L("CBtsacStreaming::HandleGavdpErrorL() [error: %d] Could not stop streaming!"), err)) + } + } + + switch (aError) + { + case KErrAvdtpRequestTimeout: // -18005 + case (KErrAvdtpSignallingErrorBase - EAvdtpBadState): // 18094 + { + err = Parent().AbortStream(); + if(!err) + { + // Complete pending requests in Aborting state + Parent().ChangeStateL(CBtsacAborting::NewL(Parent())); + } + else + { + Parent().CompletePendingRequests(KCompleteAllReqs, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)); + } + break; + } + case KErrHCILinkDisconnection: // -6305 + case KErrDisconnected: // -36 + { + Parent().CompletePendingRequests(KCompleteAllReqs, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonNone, aError)); + break; + } + default: + { + // Unknown error. For safety's sake let's disconnect a2dp link and inform btaudioman + TRACE_INFO((_L("CBtsacStreaming::HandleGavdpErrorL() Unknown error, goes to listening"))) + Parent().CompletePendingRequests(KCompleteAllReqs, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), EGavdpResetReasonGeneral, KErrDisconnected)); + break; + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStateSuspended.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStateSuspended.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,259 @@ +/* +* Copyright (c) 2002-2005 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: In this state, BTSAC is waiting for open audio request. +* +*/ + + + + +// INCLUDE FILES +#include "btsacStateSuspended.h" +#include "btsacStateListening.h" +#include "btsacStateStreaming.h" +#include "btsacStateConnected.h" +#include "btsacStateAborting.h" +#include "btsacactive.h" +#include "btsacSEPManager.h" +#include "btsacStreamerController.h" +#include "btsacGavdp.h" +#include "debug.h" +#include +#include "btaudioremconpskeys.h" + +// A2DP codec-specific element definitions +// in bluetoothAV.h +using namespace SymbianBluetoothAV; + + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::NewL +// ----------------------------------------------------------------------------- +// +CBtsacSuspended* CBtsacSuspended::NewL(CBTSAController& aParent) + { + CBtsacSuspended* self = new( ELeave ) CBtsacSuspended(aParent); + return self; + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::CBtsacSuspended +// ----------------------------------------------------------------------------- +// +CBtsacSuspended::CBtsacSuspended(CBTSAController& aParent) +: CBtsacState(aParent, EStateSuspended), iOpenAudioReq(EFalse) + { + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::~CBtsacSuspended +// ----------------------------------------------------------------------------- +// +CBtsacSuspended::~CBtsacSuspended() + { + TRACE_FUNC + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::EnterL +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::EnterL() + { + TRACE_STATE(_L("[BTSAC State] Suspended")) + _LIT(KName, "CBtsacStateSuspended"); + const TDesC& Name = KName; + Parent().iGavdp->RegisterObserver(this, Name); + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::CancelActionL +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) + { + TRACE_FUNC + Parent().CompletePendingRequests(KOpenAudioReq, aError); + Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::OpenAudioLinkL +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::OpenAudioLinkL(const TBTDevAddr& aAddr) + { + TRACE_FUNC + TAvdtpSEPInfo SEPInfo; + if (Parent().iRemoteSEPs->GetInfo(Parent().GetSEPIndex(), SEPInfo) || (aAddr != Parent().GetRemoteAddr())) + { + TRACE_INFO((_L("CBtsacSuspended::OpenAudioLinkL() Couldn't retrieve SEP Info!"))) + Parent().CompletePendingRequests(KOpenAudioReq, KErrGeneral); + return; + } + iOpenAudioReq = ETrue; + Parent().SetRemoteAddr(aAddr); + TSEID remoteSEPid = SEPInfo.SEID(); + Parent().iGavdp->StartStreams(remoteSEPid); + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::CancelOpenAudioL +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::CancelOpenAudioL(const TBTDevAddr& /*aAddr*/) + { + TRACE_FUNC + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::DisconnectL +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::DisconnectL() + { + TRACE_FUNC + Parent().CompletePendingRequests(KDisconnectReq, KErrNone); + CancelActionL(KErrCancel, EGavdpResetReasonGeneral); + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::GAVDP_StartStreamsConfirm() +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::GAVDP_StartStreamsConfirm() + { + TRACE_FUNC + if ( Parent().iStreamer->StartStream(Parent().iStreamingSockets[0], Parent().iStreamer->FrameLength()) != KErrNone ) + { + TRACE_INFO((_L("CBtsacSuspended::GAVDP_StartStreamsConfirm() [ERR] Could not start streaming!"))) + TInt err = Parent().AbortStream(); + if(err) + { + TRACE_INFO((_L("CBtsacSuspended::GAVDP_StartStreamsConfirm() Couldn't abort stream."))) + } + TRAP_IGNORE(CancelActionL(KErrCancel, EGavdpResetReasonGeneral)); + } + else + { + Parent().CompletePendingRequests(KOpenAudioReq, KErrNone); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacStreaming::NewL(Parent(), EAudioOpenedByAFW, EFalse))); + } + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::GAVDP_StartIndication +// ----------------------------------------------------------------------------- +// +TInt CBtsacSuspended::GAVDP_StartIndication(TSEID aLocalSEID) + { + TRACE_INFO((_L("CBtsacSuspended::GAVDP_StartIndication() aLocalSEID: %d"), aLocalSEID.SEID())) + (void)aLocalSEID; + // Accessory has send this indication. + // TStateStreaming state can use this indication to start audio automatically then later. + RProperty::Set(KBTAudioRemCon, KBTAudioPlayerControl, EBTAudioResumePlayer); + TRAPD(err, Parent().ChangeStateL(CBtsacStreaming::NewL(Parent(), EAudioOpenedByAcc, EFalse))); + if(err) + { + return KErrNoMemory; + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::GAVDP_ReleaseIndication +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::GAVDP_ReleaseIndication(TSEID aSEID) + { + TRACE_INFO((_L("CBtsacSuspended::GAVDP_ReleaseIndication() aSEID:%d"), aSEID.SEID())) + (void)aSEID; + Parent().AccessoryClosedAudio(Parent().GetRemoteAddr()); + Parent().CleanSockets(); + Parent().CompletePendingRequests(KOpenAudioReq, KErrCancel); + TRAP_IGNORE(Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), EConnExists))); + } + +// ----------------------------------------------------------------------------- +// CBtsacSuspended::HandleGavdpErrorL +// ----------------------------------------------------------------------------- +// +void CBtsacSuspended::HandleGavdpErrorL(TInt aError) + { + TRACE_FUNC + TInt err = KErrNone; + + switch (aError) + { + case KErrAvdtpRequestTimeout: // -18005 + { + TRACE_INFO((_L("CBtsacSuspended::HandleGavdpErrorL() Request TIMEOUT"))) + err = Parent().AbortStream(); + if(!err) + { + // Complete pending request(s) in Aborting state + Parent().ChangeStateL(CBtsacAborting::NewL(Parent())); + } + else + { + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + } + break; + } + case (KErrAvdtpSignallingErrorBase - EAvdtpBadState): // -18094 + { + if(iOpenAudioReq) + { + err = Parent().AbortStream(); + if(!err) + { + // Complete Audio request in Aborting state + Parent().ChangeStateL(CBtsacAborting::NewL(Parent())); + } + else + { + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + } + } + else + { + // For some reason remote rejected our suspend command (which was initiated in streaming state). + // According to the specification it is acceptor's responsibilty to cope with this situation, + // so we can stay in suspended state. + // For safety's sake complete close audio request if any. + Parent().CompletePendingRequests(KCloseAudioReq, KErrNone); + } + break; + } + case KErrHCILinkDisconnection: // -6305 + case KErrDisconnected: // -36 + { + TRACE_INFO((_L("CBtsacSuspended::HandleGavdpErrorL() Signalling disconnected."))) + CancelActionL(aError, EGavdpResetReasonNone); + break; + } + default: + { + // Unknown error. For safety's sake let's disconnect a2dp link and inform btaudioman + TRACE_INFO((_L("CBtsacSuspended::HandleGavdpErrorL() Unknown error, goes to listening"))) + CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); + break; + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStreamEndPoint.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStreamEndPoint.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2002-2005 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 FILES +#include + +#include "btsacSEPManager.h" +#include "debug.h" + + +// ----------------------------------------------------------------------------- +// CBTSACStreamEndPoint::NewL +// ----------------------------------------------------------------------------- +// +CBTSACStreamEndPoint* CBTSACStreamEndPoint::NewL(const TAvdtpSEPInfo& aInfo) + { + CBTSACStreamEndPoint* sep = new(ELeave) CBTSACStreamEndPoint(aInfo); + return sep; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamEndPoint::CBTSACStreamEndPoint +// C++ default constructor. +// ----------------------------------------------------------------------------- +// +CBTSACStreamEndPoint::CBTSACStreamEndPoint(const TAvdtpSEPInfo& aInfo) +: iInfo(aInfo) + { + + } + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTSACStreamEndPoint::~CBTSACStreamEndPoint() + { + iSEPCapabilities.ResetAndDestroy(); + iSEPCapabilities.Close(); + } + + +// ----------------------------------------------------------------------------- +// CBTSACStreamEndPoint::GetInfo +// ----------------------------------------------------------------------------- +// +void CBTSACStreamEndPoint::GetInfo(TAvdtpSEPInfo& aInfo) + { + TRACE_FUNC + aInfo = iInfo; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamEndPoint::StoreCaps +// ----------------------------------------------------------------------------- +// +void CBTSACStreamEndPoint::StoreCaps(TAvdtpServiceCapability* aCaps) + { + TRACE_FUNC + iSEPCapabilities.Append(aCaps); + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamEndPoint::GetCaps +// ----------------------------------------------------------------------------- +// +void CBTSACStreamEndPoint::GetCaps(RPointerArray& aCaps) + { + TRACE_FUNC + TInt count = iSEPCapabilities.Count(); + for (TInt i = 0; i < count; i++) + { + aCaps.Append(iSEPCapabilities[i]); + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamEndPoint::SetState +// ----------------------------------------------------------------------------- +// +void CBTSACStreamEndPoint::SetState(TSEPState aState, const TAny* /*aBlob=NULL*/) + { + TRACE_FUNC + switch (aState) + { + case EIdle: + { + TRACE_INFO((_L("CBTSACStreamEndPoint::SetState KSEPIdle"))) + break; + } + case EDiscoveredRemote: + case ERegistered: + case ERemotelyBound: + { + // ERemotelyBound -> extra param is the remote to which we are bound + break; + } + case ELocallyConfigured: + { + TRACE_INFO((_L("CBTSACStreamEndPoint::SetState KSEPLocallyConfigured"))) + break; + } + case EOpen: + case EStreaming: + case ESuspended: + case EAborted: + { + break; + } + + default: + { + TRACE_INFO((_L("CBTSACStreamEndPoint::SetState ***UNKNOWN***"))) + } + } + } + +// end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacStreamerController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacStreamerController.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1358 @@ +/* +* Copyright (c) 2005-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: Implementation for CBTSACStreamerController class. This class constructs and +* communicates with 'BT Audio Streamer' component to do RTP streaming. +* +*/ + + +// INCLUDE FILES +#include "btsacStreamerController.h" +#include "debug.h" + +// Subband codec-specific values +// in bluetoothAV.h +using namespace SymbianSBC; + + +// CONSTANTS +_LIT(KBTAADLL, "btaudioadaptation.dll"); + +//const TInt KUpgradeTimerDelay = 120000000; // 2 minutes. How often we sill try to upgrade back to a better quality audio. +const TInt KRetryTimerDelay = 2000000; // 2 seconds. If something fails, how soon should we retry. +const TInt KStabilizationDelay = 2000000; // 2 seconds. Wait this long after bitpool change then start mononitor packet drops again +const TInt KDataCollectDelay = 600000; // Time (600ms) to collect packet drop data + +// All tables below have to formed such a way that highest max bitpool value has to be in position 0 and etc. +const TInt KMaxBitpoolValues[] = {59, 48, 40, 34}; // Max bitpool values +const TInt KDeviationValues[] = {1000, 100000, 300000, 300000}; // maximum time (ys) between first and last packet dropped event + +const TInt KNumOfBitpoolValues = sizeof(KMaxBitpoolValues)/sizeof(TInt); +#define MAXBITPOOLVALUEMAX KMaxBitpoolValues[0] +#define MAXBITPOOLVALUEMIN KMaxBitpoolValues[KNumOfBitpoolValues-1] + +const float KReconfigureLimitFactor = 0.02; // 2% of during KDataCollectDelay transferred data +const float KLimitCheckInterval = ((float)KDataCollectDelay/1000000.0); // Time (seconds) to collect packet drop data + +// MODULE DATA STRUCTURES + +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBTSACStreamerController* CBTSACStreamerController::NewL(MBTAudioAdaptationObserver& aObserver ) + { + CBTSACStreamerController* self = new (ELeave) CBTSACStreamerController (aObserver); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// ----------------------------------------------------------------------------- +// Destructor. +// ----------------------------------------------------------------------------- +// +CBTSACStreamerController::~CBTSACStreamerController() + { + TRACE_FUNC + Cancel(); + if(iAudioInput) + { + iAudioInput->Stop(); + iAudioInput->Disconnect(); + } + delete iPacketDropIoctl; + delete iEncoderCI; + delete iBTStreamer; + delete iAudioInput; + iLib.Close(); + iTimer.Close(); + iBitpoolData.Close(); + TRACE_INFO((_L("CBTSACStreamerController::~CBTSACStreamerController() completed"))) + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::CBTSACStreamerController +// C++ default constructor. +// ----------------------------------------------------------------------------- +// +CBTSACStreamerController::CBTSACStreamerController(MBTAudioAdaptationObserver& aObserver) + : CActive( EPriorityNormal ), iObserver(aObserver) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::ConstructL +// Symbian 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::ConstructL( ) + { + TRACE_FUNC + + User::LeaveIfError(iTimer.CreateLocal()); + iThread = RThread(); + + iBTStreamer = CBTAudioStreamer::NewL(); + + LEAVE_IF_ERROR( iLib.Load( KBTAADLL ) ); + typedef TInt (*TOurLibraryFunction2)(MBTAudioStreamObserver&, MBTAudioErrorObserver&); + TOurLibraryFunction2 newL2 = reinterpret_cast(iLib.Lookup(1)); + iAudioInput = (CBTAudioStreamInputBase*)newL2(*iBTStreamer, *this); + + TInt ret; + ret = iAudioInput->Connect(); + if (ret) + { + TRACE_INFO((_L("CBTSACStreamerController::ConstructL() Audio Input Connect Error %d"), ret)) + User::Leave(ret); + } + + ret = iAudioInput->SetFormat(KMMFFourCCCodeSBC); + if (ret) + { + TRACE_INFO((_L("CBTSACStreamerController::ConstructL() Audio Input SetFormat Error %d"), ret)) + User::Leave(ret); + } + + iEncoderCI = reinterpret_cast (iAudioInput->EncoderInterface(KUidSbcEncoderIntfc)); + User::LeaveIfNull(iEncoderCI); + + InitializeBitpoolDataL(); + iState = EStateIdle; + + TRACE_INFO((_L("CBTSACStreamerController::ConstructL() completed"))) + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::StartStream +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::StartStream(RSocket& aSocket, TInt aFrameLength ) + { + TRACE_FUNC + + if (!(iBTStreamer) || !(iAudioInput) ) + { + return KErrNotFound; + } + + if (iState == EStateError) + { + iState = EStateIdle; + TInt err = iAudioInput->Connect(); + if (!err) + { + err = iAudioInput->SetFormat(KMMFFourCCCodeSBC); + } + if (err) + { + TRACE_INFO((_L("CBTSACStreamerController::StartStream() Audio Input initialization Error %d"), err)) + return err; + } + } + + if (iState == EStateIdle) + { + TInt err = KErrNone; + TRAP( err, iBTStreamer->StartL(aSocket, aFrameLength, iAudioInput, iCurrentBitrate)); + + if ( err == KErrNone ) + { + err = iAudioInput->Start(); + } + + if ( err == KErrNone ) + { + TRACE_INFO((_L("CBTSACStreamerController::StartStream() Sending packet drop IOCTL"))) + TRAP( err, iPacketDropIoctl = CActivePacketDropIoctl::NewL(*this, aSocket)); + + if( err == KErrNone ) + { + iPacketDropDeviation = 0; + iTotalNbrOfDroppedPackets = 0; + iState = EStateStreaming; + + if(iCurrentBitpoolData->iMaxBitpoolValue < iMatchCap.MaxBitpoolValue()) + { + TRACE_INFO((_L("CBTSACStreamerController::StartStream(), upgrade bitrate."))) + // Streaming was stopped when the bitrate was lower than maximum, so upgrade it for starters. + // iPacketDropIoctl->Start will be called after self completion. + + // Update current bitpool data to be highest possible. Highest possible bitpool value can be found from position + iCurrentBitpoolData = GetBitpoolData(0); + if(iCurrentBitpoolData) + { + DoSelfComplete(EUpgradeBitrate, KErrNone); + } + else + { + err = KErrArgument; + } + } + else if(iMatchCap.MaxBitpoolValue() > iBitpoolData[iBitpoolData.Count() - 1].iMaxBitpoolValue) + { + // Don't start receive packet drop events if max bitpool value is not bigger than min + // bitpool value (we can't downgrade bitpool, we already have lowest possible value). + DoSelfComplete(EStartStabilizingTimer, KErrNone); + } + TRACE_INFO((_L("CBTSACStreamerController::StartStream() completed"))) + } + } + if( err ) + { + // In case someting went wrong stop both audio adaptation and streamer + TRACE_INFO((_L("CBTSACStreamerController::StartStream() *Error: %d"), err)) + iAudioInput->Stop(); + iAudioInput->Disconnect(); + iBTStreamer->Stop(); + + //make sure iAudioInput->Connect() & SetFormat() get called in StartStream() + iState = EStateError; + } + return err; + } + else + { + return KErrAlreadyExists; + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::StopStream +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::StopStream() + { + TRACE_FUNC + Cancel(); + if (!(iBTStreamer) || !(iAudioInput)) + { + return KErrNotFound; + } + else if (iState != EStateIdle ) + { + iAudioInput->Stop(); + iBTStreamer->Stop(); + delete iPacketDropIoctl; + iPacketDropIoctl = NULL; + iState = EStateIdle; + return KErrNone; + } + else + { + return KErrAlreadyExists; + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::ResetAudioInput +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::ResetAudioInput() + { + TRACE_FUNC + iAudioInput->Stop(); + iAudioInput->Disconnect(); + TInt err = iAudioInput->Connect(); + if (!err) + { + err = iAudioInput->SetFormat(KMMFFourCCCodeSBC); + } + if (err) + { + TRACE_INFO((_L("CBTSACStreamerController::ResetAudioInput() Audio Input initialization Error %d"), err)) + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::FillCapabilities +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::FillCapabilities( TSBCCodecCapabilities& aSbc ) + { + TRACE_FUNC + + TUint8 itemp = 0x00; + // Sampling Frequency + TInt ret; + RArray SupportedSamplingFrequencies; + ret = iEncoderCI->GetSupportedSamplingFrequencies(SupportedSamplingFrequencies); + if ( !ret) + { + itemp = 0x00; + + for (TInt i=0; i SupportedChannelModes; + ret = iEncoderCI->GetSupportedChannelModes(SupportedChannelModes); + if ( !ret ) + { + itemp = 0x00; + + for (TInt i=0; i SupportedNumOfBlocks; + ret = iEncoderCI->GetSupportedNumOfBlocks(SupportedNumOfBlocks); + if ( !ret ) + { + itemp = 0x00; + + for (TInt i=0; i SupportedNumOfSubbands; + ret = iEncoderCI->GetSupportedNumOfSubbands(SupportedNumOfSubbands); + if ( !ret ) + { + itemp = 0x0; + for (TInt i=0; i SupportedAllocationMethods; + ret = iEncoderCI->GetSupportedAllocationMethods(SupportedAllocationMethods); + if ( !ret ) + { + itemp = 0x0; + for (TInt i=0; iGetSupportedBitpoolRange(MinSupportedBitpoolSize, + MaxSupportedBitpoolSize); + if ( !ret ) + { + if (MaxSupportedBitpoolSize > MAXBITPOOLVALUEMAX) + { + MaxSupportedBitpoolSize = MAXBITPOOLVALUEMAX; + } + // TUint8 to TInt + aSbc.SetMaxBitpoolValue(MaxSupportedBitpoolSize); + TRACE_INFO((_L("CBTSACStreamerController::FillCapabilities() Encoder Max bitpool: %d"), MaxSupportedBitpoolSize)) + aSbc.SetMinBitpoolValue(MinSupportedBitpoolSize); + TRACE_INFO((_L("CBTSACStreamerController::FillCapabilities() Encoder Min bitpool: %d"), MinSupportedBitpoolSize)) + } + else + { + return ret; + } + + // save our local copy, 9 bytes on stack + iLocalCap = aSbc; + + TRACE_INFO((_L("CBTSACStreamerController::FillCapabilities() Return: %d"), ret)); + return ret; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::ConfigureSEP +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::ConfigureSEP( TSBCCodecCapabilities& aDec ) + { + TRACE_FUNC + TInt err = KErrNone; + TRAP(err, InitializeBitpoolDataL()); + if(err) + return err; + + err = GetMatchingCaps(aDec); + if(!err) + { + CheckAndAdjustBitpool(aDec); + // Save the matching Caps + iMatchCap = aDec; + ReorganizeBitpoolTable(iMatchCap.MaxBitpoolValue()); + err = SetCurrentBitpoolData(iMatchCap.MaxBitpoolValue()); + if(!err) + { + iEncoderCI->SetBitpoolSize(iMatchCap.MaxBitpoolValue()); + // configure encoder + err = iEncoderCI->ApplyConfig(); + } + } + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEP() return: %d"), err)) + return err; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::ConfigureSEPBitpool +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::ConfigureSEPBitpool(EOngoingAction aAction) + { + TRACE_FUNC + TInt err = KErrNone; + TSBCCodecCapabilities newDecConfiguration; + memset(&newDecConfiguration, 0, sizeof(newDecConfiguration)); + newDecConfiguration = iMatchCap; + TInt nextIndex = (aAction == EDowngradeBitrate) ? iCurrentBitpoolData->iDownBitpoolIndex : iCurrentBitpoolData->iUpBitpoolIndex; + if(!IndexValid(nextIndex)) + { + return KErrArgument; + } + TInt BitpoolValue = iBitpoolData[nextIndex].iMaxBitpoolValue; + newDecConfiguration.SetMaxBitpoolValue(BitpoolValue); + CheckAndAdjustBitpool(newDecConfiguration); + + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEPBitpool() Current FrameLength: %d"), iCurrentFrameLength)) + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEPBitpool() Current Bitrate: %d"), iCurrentBitrate)) + + err = iBTStreamer->SetNewFrameLength(iCurrentFrameLength, iCurrentBitrate); + if(!err) + { + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEPBitpool(), Reconfiguring the encoder..."))) + iEncoderCI->SetBitpoolSize(newDecConfiguration.MaxBitpoolValue()); + // configure encoder + err = iEncoderCI->ApplyConfig(); + if(!err) + { + err = SetCurrentBitpoolData(newDecConfiguration.MaxBitpoolValue()); + if(!err) + { + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEPBitpool(): Current BP: %d"), iCurrentBitpoolData->iMaxBitpoolValue)) + } + } + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEPBitpool() The encoder reconfigured."))) + } + TRACE_INFO((_L("CBTSACStreamerController::ConfigureSEPBitpool() return: %d"), err)) + return err; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::FrameLength +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::FrameLength() const + { + TRACE_INFO((_L("CBTSACStreamerController::FrameLength() = %d"), iCurrentFrameLength)) + return iCurrentFrameLength; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetMatchingCaps +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::GetMatchingCaps(TSBCCodecCapabilities& aCaps) + { + TRACE_FUNC + TInt ret = KErrNone; + TUint8 MatchingFreq, MatchingChnl, MatchingBlck, MatchingSub, MatchingAlloc; + + MatchingFreq = (iLocalCap.SamplingFrequencies() & aCaps.SamplingFrequencies()); + MatchingChnl = (iLocalCap.ChannelModes() & aCaps.ChannelModes()); + MatchingBlck = (iLocalCap.BlockLengths() & aCaps.BlockLengths()); + MatchingSub = (iLocalCap.Subbands() & aCaps.Subbands()); + MatchingAlloc = (iLocalCap.AllocationMethods() & aCaps.AllocationMethods()); + + if ( MatchingFreq && + MatchingChnl && + MatchingBlck && + MatchingSub && + MatchingAlloc && + ( iLocalCap.MinBitpoolValue() <= aCaps.MaxBitpoolValue() ) && + ( iLocalCap.MaxBitpoolValue() >= aCaps.MinBitpoolValue() ) ) + { + TRACE_INFO((_L("CBTSACStreamerController::GetMatchingCaps() accessory configuration suits us"))) + + // Choose highest possible values that are supported + + // Sampling Frequency + SetSamplingFrequency(aCaps, MatchingFreq); + // Channel mode + SetChannelMode(aCaps, MatchingChnl); + // Blocks + SetBlockLen(aCaps, MatchingBlck); + // Subbands + SetNumOfSubbands(aCaps, MatchingSub); + // Allocation method + SetAllocationMethod(aCaps, MatchingAlloc); + // Bitpool + SetBitpoolValues(aCaps); + } + else // no match + { + TRACE_INFO((_L("CBTSACStreamerController::GetMatchingCaps() **No Matching Capabilities**"))) + ret = KErrNotFound; + } + return ret; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::CheckAndAdjustBitpool +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::CheckAndAdjustBitpool(TSBCCodecCapabilities& aCap) + { + TRACE_FUNC + // ******* Adjust bitpool if necessary ***** + TInt targetbitrate; + TInt nChnls = GetNumOfChannels(aCap); + TInt nSbands = GetNumOfSubbands(aCap); + TInt nBlck = GetBlockLen(aCap); + TInt Freq = GetSamplingFrequency(aCap); + TInt frameLength = FrameLengthFormula(aCap); + // Note: this is the bitrate of the transmission. + TInt bitrateInt = 8 * frameLength * Freq / nSbands / nBlck; + + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), nChnls = %d"), nChnls)) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), nSbands = %d"), nSbands)) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), nBlck = %d"), nBlck)) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), Freq = %d"), Freq)) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), MaxBP = %d"), aCap.MaxBitpoolValue())) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), Frame length = %d"), frameLength)) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), Bitrate = %d"), bitrateInt)) + + // max bit rate: 320kb/s for mono, + // 512kb/s for two-channel modes + if (aCap.ChannelModes() & EMono) + { + if (bitrateInt <= 320000.0) + { + targetbitrate = bitrateInt; + } + else // target bitrate=320kbps + { + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool() Adjusting..."))) + targetbitrate = 320000.0; + TInt BP = ( ((targetbitrate*nSbands*nBlck)/Freq) - 32 - (4*nSbands*nChnls) ) / (nBlck*nChnls); + aCap.SetMaxBitpoolValue(BP); + } + } + else + { + if (bitrateInt <= 512000.0) + { + targetbitrate = bitrateInt; + } + else // target bitrate=512kbps + { + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool() Adjusting..."))) + targetbitrate = 512000.0; + TInt BP = 0; + if (aCap.ChannelModes() & EDualChannel) + { + BP = ( ((targetbitrate*nSbands*nBlck)/Freq) - 32 - (4*nSbands*nChnls) ) / (nBlck*nChnls); + } + else + { + TInt join = (aCap.ChannelModes() & EJointStereo) ? 1 : 0; + BP = ( ((targetbitrate*nSbands*nBlck)/Freq) - 32 - (4*nSbands*nChnls) - (nSbands*join) ) / (nBlck); + } + + aCap.SetMaxBitpoolValue(BP); + // Calculate new frame length + frameLength = FrameLengthFormula(aCap); + } + } + + iCurrentFrameLength = frameLength; + iCurrentBitrate = targetbitrate; + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), After Adjustment MaxBP: %d"), aCap.MaxBitpoolValue())) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), After Adjustment Frame length: %d"), iCurrentFrameLength)) + TRACE_INFO((_L("CBTSACStreamerController::CheckAndAdjustBitpool(), After Adjustment Bitrate: %d"), iCurrentBitrate)) + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::RunL +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::RunL() + { + TRACE_FUNC + switch(iStatus.Int()) + { + case KErrNone: + { + switch( iOngoingAction ) + { + case EErrorSending: + { + TRACE_INFO((_L("CBTSACStreamerController::RunL(), ErrorSending"))) + + TRACE_INFO((_L("CBTSACStreamerController::RunL(), TotalNbrOfDroppedPackets: %d"), iTotalNbrOfDroppedPackets)) + TInt TotalNbrOfDroppedBits = iTotalNbrOfDroppedPackets*8; + TRACE_INFO((_L("CBTSACStreamerController::RunL(), Total dropped bits: %d"), TotalNbrOfDroppedBits)) + TRACE_INFO((_L("CBTSACStreamerController::RunL(), Current Bitrate: %d"), iCurrentBitrate)) + TInt ReconfigureLimit = KLimitCheckInterval*iCurrentBitrate*KReconfigureLimitFactor; + TRACE_INFO((_L("CBTSACStreamerController::RunL(), Limit for reconfigure : %d bits"), ReconfigureLimit)) + TRACE_INFO((_L("CBTSACStreamerController::RunL(), PacketDropDeviation: %d (limit %d)"), iPacketDropDeviation, iCurrentBitpoolData->iMaxDeviation)) + + if((TotalNbrOfDroppedBits > ReconfigureLimit) && (iPacketDropDeviation >= iCurrentBitpoolData->iMaxDeviation)) + { + iPacketDropIoctl->Cancel(); + + if(iCurrentBitpoolData->iMinimumMaxBitpool) + { + TRACE_INFO((_L("CBTSACStreamerController::RunL(), Minimum max bitpool reached."))) + TRACE_INFO((_L("CBTSACStreamerController::RunL(), Stop receive packet drops."))) + return; + } + + // Initialize values for upgrade timer. Only if setting min bitpool value fails, start retry timer. + TInt delay = KStabilizationDelay; + iOngoingAction = EStabilize; + TInt err = ConfigureSEPBitpool(EDowngradeBitrate); + if(err) + { + iOngoingAction = EDowngradeBitrate; + delay = KRetryTimerDelay; + } + + iTimer.After(iStatus, delay); + SetActive(); + } + + iPacketDropDeviation = 0; + iTotalNbrOfDroppedPackets = 0; + break; + } + + case EStabilize: + // Start receive overflow indications again + TRACE_INFO((_L("CBTSACStreamerController::RunL(), stabilize timer expired."))) + iPacketDropIoctl->Start(); + break; + + case EDowngradeBitrate: + case EUpgradeBitrate: + case EStartStabilizingTimer: + { + TRACE_INFO((_L("CBTSACStreamerController::RunL(), Action = %d"), iOngoingAction)) + TInt err = KErrNone; + TInt delay = KStabilizationDelay; + if(iOngoingAction != EStartStabilizingTimer) + { + err = ConfigureSEPBitpool(iOngoingAction); + } + if(err) + { + delay = KRetryTimerDelay; + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::RunL(), stabilize timer started"))) + iOngoingAction = EStabilize; + } + + iTimer.After(iStatus, delay); + SetActive(); + break; + } + } + break; + } + + case KErrGeneral: // We have received error from audio adaptation + { + TRACE_INFO((_L("CBTSACStreamerController::RunL(), KErrGeneral"))) + iAudioInput->Stop(); + iAudioInput->Disconnect(); + iObserver.NotifyError(KErrGeneral); + break; + } + + default: + TRACE_INFO((_L("CBTSACStreamerController::RunL(), #default"))) + break; + } + TRACE_INFO((_L("CBTSACStreamerController::RunL() completed"))) + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::DoCancel +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::DoCancel() + { + TRACE_FUNC + iTimer.Cancel(); + TRACE_INFO((_L("CBTSACStreamerController::DoCancel() completed"))) + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::RunError +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::RunError(TInt /*aError*/) + { + TRACE_FUNC + return 0; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::Error +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::Error(const TInt aError) + { + TRACE_INFO((_L("CBTSACStreamerController::Error() %d"), aError)) + TInt ret = KErrNone; + switch(aError) + { + case KErrOverflow: + case KErrUnderflow: + { + DoSelfComplete(EErrorSending, KErrNone); + break; + } + case KErrGeneral: + { + if(iState != EStateError) + { + iState = EStateError; + DoSelfComplete(iOngoingAction, KErrGeneral); + } + break; + } + default: + { + ret = KErrUnknown; + break; + } + } + return ret; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetCaps +// ----------------------------------------------------------------------------- +// +TSBCCodecCapabilities& CBTSACStreamerController::GetCaps() + { + return iLocalCap; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetBlockLen +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::SetBlockLen(TSBCCodecCapabilities& aCap, TUint8 aBlockLen) + { + // Set Block Lenght, select highest one + if ( aBlockLen & EBlockLenSixteen ) + { + iEncoderCI->SetNumOfBlocks(TUint(16)); + aCap.SetBlockLengths(EBlockLenSixteen); + TRACE_INFO((_L("CBTSACStreamerController::SetBlockLen(), BlockLength: EBlockLenSixteen"))) + } + else if ( aBlockLen & EBlockLenTwelve ) + { + iEncoderCI->SetNumOfBlocks(TUint(12)); + aCap.SetBlockLengths(EBlockLenTwelve); + TRACE_INFO((_L("CBTSACStreamerController::SetBlockLen(), BlockLength: EBlockLenTwelve"))) + } + else if ( aBlockLen & EBlockLenEight ) + { + iEncoderCI->SetNumOfBlocks(TUint(8)); + aCap.SetBlockLengths(EBlockLenEight); + TRACE_INFO((_L("CBTSACStreamerController::SetBlockLen(), BlockLength: EBlockLenEight"))) + } + else if ( aBlockLen & EBlockLenFour ) + { + iEncoderCI->SetNumOfBlocks(TUint(4)); + aCap.SetBlockLengths(EBlockLenFour); + TRACE_INFO((_L("CBTSACStreamerController::SetBlockLen(), BlockLength: EBlockLenFour"))) + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::SetBlockLen(), No matching Block Length"))) + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetBlockLen +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::GetBlockLen(TSBCCodecCapabilities& aCap) const + { + TInt nBlck = 0; + switch( aCap.BlockLengths() ) + { + case EBlockLenSixteen: + nBlck = 16; + break; + case EBlockLenTwelve: + nBlck = 12; + break; + case EBlockLenEight: + nBlck = 8; + break; + case EBlockLenFour: + nBlck = 4; + break; + default: + TRACE_INFO((_L("CBTSACStreamerController::GetBlockLen(), #default"))) + nBlck = 16; + break; + } + return nBlck; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetBitpoolValues +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::SetBitpoolValues(TSBCCodecCapabilities& aCap) + { + // Define max bitpool + TInt MaxBP = 0; + TBool ProperMaxBitpoolFound = EFalse; + for(TInt i = 0 ; i < KNumOfBitpoolValues ; i++) + { + if(aCap.MaxBitpoolValue() >= KMaxBitpoolValues[i]) + { + MaxBP = KMaxBitpoolValues[i]; + ProperMaxBitpoolFound = ETrue; + break; + } + } + if(!ProperMaxBitpoolFound) + { + // None of our proposed max bitpool values weren't suitable for accessory. + // Let's use the one which was proposed by the accessory. + MaxBP = aCap.MaxBitpoolValue(); + } + + // Define min bitpool. This bitpool value is negotiated with sink. + TInt MinBP = (iLocalCap.MinBitpoolValue() < aCap.MinBitpoolValue()) ? aCap.MinBitpoolValue() : iLocalCap.MinBitpoolValue(); + + // Define bitpool which is used for medium quality streaming (when streaming is interfered for some reason). + // This is real lowest bitpool value which is used for streaming. + + // Check if selected max bitpool value is smaller than our default min bitpool value, if it is, set + // minimum max bitpool value to be same as max value otherwise just update it with our default min value. + if(MaxBP < MAXBITPOOLVALUEMIN) + { + // Update the minumum bitpool data + iBitpoolData[iBitpoolData.Count()-1].iMaxBitpoolValue = MaxBP; + } + else if(MAXBITPOOLVALUEMIN < MinBP) // Check also that minimum max bitpool value is not smaller than bitpool which is negotiated for the link. + { + iBitpoolData[iBitpoolData.Count()-1].iMaxBitpoolValue = MinBP; + } + + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Remote Max Bitpool: %d"), aCap.MaxBitpoolValue())) + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Remote Min Bitpool: %d"), aCap.MinBitpoolValue())) + + aCap.SetMaxBitpoolValue(MaxBP); + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Max Bitpool: %d"), MaxBP)) + aCap.SetMinBitpoolValue(MinBP); + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Min Bitpool: %d"), MinBP)) + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetAllocationMethod +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::SetAllocationMethod(TSBCCodecCapabilities& aCap, TUint8 aAllocationMethod) + { + // Set Allocation Method, select highest one + if ( aAllocationMethod & ELoudness ) + { + iEncoderCI->SetAllocationMethod(CSbcEncoderIntfc::ESbcAllocationLoudness); + aCap.SetAllocationMethods(ELoudness); + TRACE_INFO((_L("CBTSACStreamerController::SetAllocationMethod(), AllocationMethod: ELoudness"))) + } + else if ( aAllocationMethod & ESNR ) + { + iEncoderCI->SetAllocationMethod(CSbcEncoderIntfc::ESbcAllocationSNR); + aCap.SetAllocationMethods(ESNR); + TRACE_INFO((_L("CBTSACStreamerController::SetAllocationMethod(), AllocationMethod: ESNR"))) + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::SetAllocationMethod(), No matching Allocation Method"))) + } + } +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetChannelMode +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::SetChannelMode(TSBCCodecCapabilities& aCap, TUint8 aChannelMode) + { + // Set Channel mode, select highest one + if ( aChannelMode & EJointStereo ) + { + iEncoderCI->SetChannelMode(CSbcEncoderIntfc::ESbcChannelJointStereo); + aCap.SetChannelModes(EJointStereo); + TRACE_INFO((_L("CBTSACStreamerController::SetChannelMode(), ChannelMode: EJointStereo"))) + } + else if ( aChannelMode & EStereo ) + { + iEncoderCI->SetChannelMode(CSbcEncoderIntfc::ESbcChannelStereo); + aCap.SetChannelModes(EStereo); + TRACE_INFO((_L("CBTSACStreamerController::SetChannelMode(), ChannelMode: EStereo"))) + } + else if ( aChannelMode & EDualChannel ) + { + iEncoderCI->SetChannelMode(CSbcEncoderIntfc::ESbcChannelDual); + aCap.SetChannelModes(EDualChannel); + TRACE_INFO((_L("CBTSACStreamerController::SetChannelMode(), ChannelMode: EDualChannel"))) + } + else if ( aChannelMode & EMono ) + { + iEncoderCI->SetChannelMode(CSbcEncoderIntfc::ESbcChannelMono); + aCap.SetChannelModes(EMono); + TRACE_INFO((_L("CBTSACStreamerController::SetChannelMode(), ChannelMode: EMono"))) + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::SetChannelMode(), No matching Channel Mode"))) + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetSamplingFrequency +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::SetSamplingFrequency(TSBCCodecCapabilities& aCap, TUint8 aFrequency) + { + // Set Sampling Frequency, select highest one + if ( aFrequency & E48kHz ) + { + iEncoderCI->SetSamplingFrequency(TUint(48000)); + aCap.SetSamplingFrequencies(E48kHz); + TRACE_INFO((_L("CBTSACStreamerController::SetSamplingFrequency(), Sampling Frequency: E48kHz"))) + } + else if ( aFrequency & E44100Hz ) + { + iEncoderCI->SetSamplingFrequency(TUint(44100)); + aCap.SetSamplingFrequencies(E44100Hz); + TRACE_INFO((_L("CBTSACStreamerController::SetSamplingFrequency(), Sampling Frequency: E44100Hz"))) + } + else if ( aFrequency & E32kHz ) + { + iEncoderCI->SetSamplingFrequency(TUint(32000)); + aCap.SetSamplingFrequencies(E32kHz); + TRACE_INFO((_L("CBTSACStreamerController::SetSamplingFrequency(), Sampling Frequency: E32kHz"))) + } + else if ( aFrequency & E16kHz ) + { + iEncoderCI->SetSamplingFrequency(TUint(16000)); + aCap.SetSamplingFrequencies(E16kHz); + TRACE_INFO((_L("CBTSACStreamerController::SetSamplingFrequency(), Sampling Frequency: E16kHz"))) + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::SetSamplingFrequency(), No matching Sampling Frequency"))) + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetSamplingFrequency +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::GetSamplingFrequency(TSBCCodecCapabilities& aCap) const + { + TInt Freq = 0; + switch( aCap.SamplingFrequencies() ) + { + case E48kHz: + Freq = 48000; + break; + case E44100Hz: + Freq = 44100; + break; + case E32kHz: + Freq = 32000; + break; + case E16kHz: + Freq = 16000; + break; + default: + TRACE_INFO((_L("CBTSACStreamerController::GetSamplingFrequency(), #default"))) + Freq = 48000; + break; + } + return Freq; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetNumOfChannels +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::GetNumOfChannels(TSBCCodecCapabilities& aCap) const + { + TInt nChnls = (aCap.ChannelModes() & EMono) ? 1 : 2; + return nChnls; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetNumOfSubbands +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::SetNumOfSubbands(TSBCCodecCapabilities& aCap, TUint8 aNumOfSubbands) + { + // Set Number of Subbands, select highest one + if ( aNumOfSubbands & EEightSubbands ) + { + iEncoderCI->SetNumOfSubbands(TUint(8)); + aCap.SetSubbands(EEightSubbands); + TRACE_INFO((_L("CBTSACStreamerController::SetNumOfSubbands(), Subband: EEightSubbands"))) + } + else if ( aNumOfSubbands & EFourSubbands ) + { + iEncoderCI->SetNumOfSubbands(TUint(4)); + aCap.SetSubbands(EFourSubbands); + TRACE_INFO((_L("CBTSACStreamerController::SetNumOfSubbands(), Subband: EFourSubbands"))) + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::SetNumOfSubbands(), No matching Subband"))) + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetNumOfSubbands +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::GetNumOfSubbands(TSBCCodecCapabilities& aCap) const + { + TInt nSbands = (aCap.Subbands() & EEightSubbands) ? 8 : 4; + return nSbands; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::FrameLengthFormula +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::FrameLengthFormula(TSBCCodecCapabilities& aCap) const + { + TInt join = ( aCap.ChannelModes() & EJointStereo ) ? 1 : 0; + TInt nChnls = GetNumOfChannels(aCap); + TInt nSbands = GetNumOfSubbands(aCap); + TInt nBlck = GetBlockLen(aCap); + + // For mono (and dual channel) mode the formula is slightly differend than for stereo mode(s). + TInt frameLength = + ( (aCap.ChannelModes() & EMono) || (aCap.ChannelModes() & EDualChannel) ) ? + 4 + ((4 * nSbands * nChnls) / 8) + ( (nBlck * nChnls * aCap.MaxBitpoolValue()) / 8): + 4 + ((4 * nSbands * nChnls) / 8) + ( (join * nSbands + nBlck * aCap.MaxBitpoolValue()) / 8)/* + join*/; + + // Note: last "+ join" in latter version of the formula is for joint stereo. + // Otherwise the formula doesn't calculate the extra byte that's in the header. + return frameLength; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::PacketsDropped +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::PacketsDropped(TInt aError) + { + TRACE_FUNC + if(!iTotalNbrOfDroppedPackets) + { + // This is first packet drop indication after previous sample interval + iFirstPacketDropTime.UniversalTime(); + } + TTime timeNow; + timeNow.UniversalTime(); + iPacketDropDeviation = static_cast(timeNow.MicroSecondsFrom(iFirstPacketDropTime).Int64()); + + iTotalNbrOfDroppedPackets += aError; + + if(!IsActive()) + { + iOngoingAction = EErrorSending; + iTimer.After(iStatus, KDataCollectDelay); + SetActive(); + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::SetCurrentBitpoolData +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::SetCurrentBitpoolData(TInt aBitpool) + { + TRACE_FUNC + TInt err = KErrNone; + TInt Index = GetIndex(aBitpool); + if(Index >= 0) + { + iCurrentBitpoolData = GetBitpoolData(Index); + } + else + { + err = KErrNotFound; + } + return err; + } +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetIndex +// ----------------------------------------------------------------------------- +// +TInt CBTSACStreamerController::GetIndex(TInt aBitpool) + { + TInt Bitpool = aBitpool; + if(aBitpool > iMatchCap.MaxBitpoolValue()) + { + Bitpool = iMatchCap.MaxBitpoolValue(); + } + for(TInt i = 0 ; i < iBitpoolData.Count() ; i++) + { + if(Bitpool == iBitpoolData[i].iMaxBitpoolValue) + { + return i; + } + } + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::IndexValid +// ----------------------------------------------------------------------------- +// +TBool CBTSACStreamerController::IndexValid(TInt aIndex) + { + if(aIndex >= 0 && aIndex < iBitpoolData.Count()) + return ETrue; + else + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::InitializeBitpoolData +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::InitializeBitpoolDataL() + { + TRACE_FUNC + TBitpoolData data; + iBitpoolData.Reset(); + for(TInt i = 0 ; i < KNumOfBitpoolValues ; i++) + { + data.iMaxBitpoolValue = KMaxBitpoolValues[i]; + data.iMaxDeviation = KDeviationValues[i]; + //data.iUpgradeDelay = KUpgradeDelays[i]; + data.iUpBitpoolIndex = (i == 0) ? i : i - 1; + data.iIndex = i; + data.iDownBitpoolIndex = (i == KNumOfBitpoolValues - 1) ? i : i + 1; + data.iMinimumMaxBitpool = (i == KNumOfBitpoolValues - 1) ? ETrue : EFalse; + iBitpoolData.AppendL(data); + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::GetBitpoolData +// ----------------------------------------------------------------------------- +// +TBitpoolData* CBTSACStreamerController::GetBitpoolData(TInt aIndex) + { + if(aIndex < 0 || aIndex >= iBitpoolData.Count()) + return NULL; + + return &iBitpoolData[aIndex]; + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::ReorganizeBitpoolTable +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::ReorganizeBitpoolTable(TInt aNegotiatedMaxBitpool) + { + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Negotiated Max Bitpool %d"), aNegotiatedMaxBitpool)) + // Start checking from the lowest possible bitpool value + for(TInt i = (KNumOfBitpoolValues - 1) ; i > 0 ; i--) + { + if(aNegotiatedMaxBitpool <= KMaxBitpoolValues[i]) + { + TInt ii; + for(ii = 0 ; ii < i ; ii++) + { + iBitpoolData.Remove(0); + } + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Tables removed: %d"), ii)) + for(TInt j = 0 ; j < iBitpoolData.Count() ; j++) + { + if(j == 0) + { + iBitpoolData[j].iMaxBitpoolValue = aNegotiatedMaxBitpool; + } + iBitpoolData[j].iIndex = j; + iBitpoolData[j].iUpBitpoolIndex = (j == 0) ? j : j - 1; + iBitpoolData[j].iDownBitpoolIndex = (j == iBitpoolData.Count() - 1) ? j : j + 1; + } + break; + } + } + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Tables left: %d"), iBitpoolData.Count())) + for(TInt k = 0 ; k < iBitpoolData.Count() ; k++) + { + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Table[%d] MaxBP: %d"), k, iBitpoolData[k].iMaxBitpoolValue)) + } + } + +// ----------------------------------------------------------------------------- +// CBTSACStreamerController::DoSelfComplete +// ----------------------------------------------------------------------------- +// +void CBTSACStreamerController::DoSelfComplete(EOngoingAction aAction, TInt aError) + { + TRACE_FUNC + if (IsActive()) + { + // Stop timer + Cancel(); + } + if (!IsActive()) + { + // Just self complete here, handle error in RunL + iOngoingAction = aAction; + TRequestStatus *status = &iStatus; + iStatus = KRequestPending; + iThread.RequestComplete(status, aError); + SetActive(); + } + else + { + TRACE_INFO((_L("CBTSACStreamerController::DoSelfComplete((), Couldn't do self complete"))) + } + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsac/src/btsacactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsac/src/btsacactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2005-2006 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: The base active class definition +* +*/ + + +#include "btsacactive.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +CBtsacActive* CBtsacActive::NewL(MBtsacActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CBtsacActive* self = CBtsacActive::NewLC(aObserver, aPriority, aRequestId); + CleanupStack::Pop(self); + return self; + } + +CBtsacActive* CBtsacActive::NewLC(MBtsacActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CBtsacActive* self = new (ELeave) CBtsacActive(aObserver, aPriority, aRequestId); + CleanupStack::PushL(self); + return self; + } + +CBtsacActive::~CBtsacActive() + { + TRACE_FUNC + Cancel(); + } + +void CBtsacActive::GoActive() + { + TRACE_FUNC + if( !IsActive() ) + SetActive(); + else + { + TRACE_INFO((_L("CBtsacActive::GoActive, Already active"))) + } + } + +TInt CBtsacActive::RequestId() const + { + return iRequestId; + } + +void CBtsacActive::SetRequestId(TInt aRequestId) + { + iRequestId = aRequestId; + } + +void CBtsacActive::DoCancel() + { + TRACE_FUNC + iObserver.CancelRequest(*this); + } + +void CBtsacActive::RunL() + { + TRACE_FUNC + iObserver.RequestCompletedL(*this); + } + +TInt CBtsacActive::RunError(TInt aError) + { + TRACE_FUNC + (void) aError; + return KErrNone; + } + +CBtsacActive::CBtsacActive(MBtsacActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + : CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) + { + TRACE_FUNC + CActiveScheduler::Add(this); + } + +MBtsacActiveObserver& CBtsacActive::Observer() + { + return iObserver; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/group/BTSap.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/group/BTSap.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2004-2006 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: +* Bluetooth SIM Access Profile project file. +* +*/ + + +#include + +//#define _DUMMY_CUSTOM_API +#ifdef _DUMMY_CUSTOM_API +MACRO "_DUMMY_CUSTOM_API" +#endif + +//#define _BTSAP_MT +#ifdef _BTSAP_MT +MACRO "_BTSAP_MT" +#endif + +TARGET BTSap.dll +TARGETTYPE PLUGIN +VENDORID VID_DEFAULT +CAPABILITY CAP_ECOM_PLUGIN +UID 0x10009D8D 0x101FFE46 + +SOURCEPATH ../src +SOURCE BTSapPlugin.cpp +SOURCE BTSapServerState.cpp +SOURCE BTSapState.cpp +SOURCE BTSapStateInit.cpp +SOURCE BTSapStateNotConnected.cpp +SOURCE BTSapStateConnect.cpp +SOURCE BTSapStateDisconnect.cpp +SOURCE BTSapStateIdle.cpp +SOURCE BTSapStateAPDU.cpp +SOURCE BTSapStateATR.cpp +SOURCE BTSapStatePowerOff.cpp +SOURCE BTSapStatePowerOn.cpp +SOURCE BTSapStateReset.cpp +SOURCE BTSapStateCardReaderStatus.cpp +SOURCE BTSapSocketHandler.cpp +SOURCE BTSapSocketStateListen.cpp +SOURCE BTSapSocketStateSend.cpp +SOURCE BTSapSocketStateRecv.cpp +SOURCE BTSapSocketStateCheckSecurity.cpp +SOURCE BTSapSecurityHandler.cpp +SOURCE BTSapRequestHandler.cpp +SOURCE BTSapSimCardStatusNotifier.cpp +SOURCE BTSapMessage.cpp +SOURCE BTSapSniffHandler.cpp +SOURCE BTSapHciExtensionMan.cpp + +USERINCLUDE ../inc +MW_LAYER_SYSTEMINCLUDE + +START RESOURCE 101FFE46.RSS +TARGET BTSap +END + +LIBRARY euser.lib // Kernel API +LIBRARY esock.lib // socket API +LIBRARY bluetooth.lib // BTDevAddr, BTSockAddr +LIBRARY CommonEngine.lib // Shared data settings +LIBRARY btengdiscovery.lib // Register SDP settings +LIBRARY btengdevman.lib +LIBRARY btmanclient.lib +LIBRARY etel.lib +LIBRARY etelmm.lib +LIBRARY ecom.lib +LIBRARY btdevice.lib // for getting passkey length +LIBRARY hciproxy.lib // for getting encryption key length + +#ifdef _DUMMY_CUSTOM_API +LIBRARY DummyCustomAPI.lib // Dummy Custom API +#else +LIBRARY CustomAPI.lib // Custom API +#endif + +DEBUGLIBRARY flogger.lib // File logging +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2004 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: +* This file provides the information required for building the +* whole BTSap component. +* +*/ + +#include + +PRJ_MMPFILES + +BTSap.mmp + +PRJ_EXPORTS +../rom/BTSap.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btsap.iby) + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapHciExtensionMan.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapHciExtensionMan.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2004 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: +* This class holds the HCI Extension Conduit singleton +* +* +*/ + +#ifndef BT_SERVER_HCIEXTENSIONMAN_H +#define BT_SERVER_HCIEXTENSIONMAN_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* This class holds the HCI Extension Conduit instance and is the single interface to +* access HCI enxtension functionality. +*/ +NONSHARABLE_CLASS(CBTHciExtensionMan) : public CBase, public MVendorSpecificHciConduit + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTHciExtensionMan* NewL(); + + /** + * Destructor. + */ + ~CBTHciExtensionMan(); + + public: // New functions + + /** + * Hanldes a request throught Hci extension + * @param aStatus: for signalling the completion of the operation + * @param aBTDevAddr: the BT device address + */ + void GetEncryptionKeyLengthL(const TBTDevAddr& aBTDevAddr, TRequestStatus& aStatus); + + /** + * Cancel the outstanding request if there is any + * @param aMessage the requested service + * @return TInt the error code of this operation + */ + void CancelRequest(); + + /** + * After the GetEncryptionKeyLengthL operation is completed + * the result can be read with the GetResult method + */ + TInt GetResultL(TUint8& aKeyLength); + + + private: //From MVendorSpecificHciConduit + + /** + * CommandCompleted is called when a vendor specific command issued through the conduit + * receives a completion from the hardware. + * @param aError : The error code with which the command completed. + **/ + void CommandCompleted(TInt aError); + + /** + * ReceiveEvent is called when a vendor specific command issued through the conduit + * receives a completion from the hardware. + * + * @param aEvent Returns raw vendor specific debug event data generated from the + * hardware (with no HCTL framing) + * @param aError An error indicating that the conduit did not successfully receive + * the event. + * @return If ETrue, the conduit will continue to listen for vendor specific + * debug events, + * If EFalse, the conduit stops listening for these events. + **/ + TBool ReceiveEvent(TDesC8& aEvent, TInt aError); + + private: + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + */ + CBTHciExtensionMan(); + + private: // DATA + CHciExtensionConduit* iConduit; + TRequestStatus* iStatus; + TUint8 iRequestOpcode; + TUint8 iKeyLength; + }; + +// Helper class +/** +* This class represents a HCI extension command +*/ +NONSHARABLE_CLASS(CBTHciExtensionCmd) : CBase + { + public: // Constrtuctor and destructor + + /** + * Two-phased constructor. + */ + static CBTHciExtensionCmd* NewL(TUint8 aOpcode); + + /** + * Two-phased constructor. Leave it in CleanupStack + */ + static CBTHciExtensionCmd* NewLC(TUint8 aOpcode); + + /** + * Destructor. + */ + ~CBTHciExtensionCmd(); + + public: // New Functions + + /** + * Gets the opcode of this command + */ + TUint8 Opcode() const; + + /** + * Gets the command descritpor + * @return the reference to the command descriptor + */ + TPtrC8 DesC() const; + + /** + * Sets the parameter in this command + */ + void SetParamL(const TDesC8& aParam); + + private: + + /** + * C++ default constructor. + */ + CBTHciExtensionCmd(TUint8 aOpcode); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Initialize command descritpor + */ + void InitializeCmdDesL(); + + protected: // DATA + TUint8 iChannelID; + TUint8 iOpcode; + HBufC8* iCmdDes; + TInt iParamTotalLength; + TInt iCmdLength; + }; + +/** +* This class represents the response to a hci extension functionality command +*/ +NONSHARABLE_CLASS(CBTHciExtensionCmdEvent) : CBase + { + public: // Constrtuctor and destructor + + /** + * Two-phased constructor. + */ + static CBTHciExtensionCmdEvent* NewL(const TDesC8& aEvent); + + /** + * Two-phased constructor. Leave it in CleanupStack + */ + static CBTHciExtensionCmdEvent* NewLC(const TDesC8& aEvent); + + /** + * Destructor. + */ + ~CBTHciExtensionCmdEvent(); + + public: // New Functions + + /** + * Gets the event opcode + */ + TUint8 Opcode() const; + + /** + * Gets the event descritpor + * @return the reference to the event descriptor + */ + TPtrC8 DesC() const; + + private: + + /** + * C++ default constructor. + */ + CBTHciExtensionCmdEvent(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(const TDesC8& aEvent); + + protected: // DATA + HBufC8* iEventDes; + }; +#endif // BT_SERVER_HCIEXTENSIONMAN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapMessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapMessage.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,229 @@ +/* +* Copyright (c) 2004-2005 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: +* This class handles SAP message encoding and decoding +* +*/ + +#ifndef BT_SAP_MESSAGE_H +#define BT_SAP_MESSAGE_H + +// INCLUDES +#include + +const TInt KMaxMsgSize = 4096; +const TInt KMinMsgSize = 275; // biggest size of apdu_req +const TInt KParaLenModulo = 4; + +const TInt KMsgIDRange = 18; +const TInt KParaIDRange = 8; +const TInt KMsgIDOffset = 0; +const TInt KParaNumOffset = 1; +const TInt KHeaderResvLen = 2; +const TInt KPayloadOffset = 4; +const TInt KParaIDLen = 1; +const TInt KParaResvLen = 1; +const TInt KParaLenLen = 2; +const TInt KParaResvValue = 0x00; +const TInt KHeaderResvValue = 0x0000; + +enum TMsgID + { + EConnectRequest, + EConnectResponse, + EDisconnectRequest, + EDisconnectResponse, + EDisconnectIndication, + ETransferAPDURequest, + ETransferAPDUResponse, + ETransferATRRequest, + ETransferATRResponse, + EPowerSimOffRequest, + EPowerSimOffResponse, + EPowerSimOnRequest, + EPowerSimOnResponse, + EResetSimRequest, + EResetSimResponse, + ETransferCardReaderStatusRequest, + ETransferCardReaderStatusResponse, + EStatusIndication, + EErrorResponse + }; + +enum TParaID + { + EParaMaxMsgSize, + EParaConnectionStatus, + EParaResultCode, + EParaDisconnectionType, + EParaCommandAPDU, + EParaResponseAPDU, + EParaATR, + EParaCardReaderStatus, + EParaStatusChange, + EParaCommandAPDU7816 = 0x10 // This parameter's ID is not sequential + }; + +enum TResultCode + { + EResultCodeOK, + EResultCodeUnknown, + EResultCodeNotAccessible, + EResultCodePowerOff, + EResultCodeCardRemoved, + EResultCodeAlreadyPowerOn, + EResultCodeDataNotAvailable, + EResultCodeReserved = 100 + }; + +enum TCardStatus + { + ECardStatusError, + ECardStatusReset, + ECardStatusNotAccessible, + ECardStatusRemoved, + ECardStatusInserted, + ECardStatusRecovered, + ECardStatusReserved = 100 + }; + +enum TConnectionStatus + { + EConnectionOK, + EConnectionErrReject, + EConnectionErrNotSupported, + EConnectionErrTooSmall + }; + +enum TValidationResult + { + EValidFormat, + EInvalidSegmented, + EInvalidMsgID, + EInvalidReservedBytes, + EInvalidParameterID, + EInvalidPaddingBytes, + EInvalidParaNumTooSmall, + EInvalidUnknown + }; + +const TInt KMapErrCode[] = + { + KErrNone, + KErrAlreadyExists, + KErrDisconnected, + KErrArgument, + KErrNotReady, + KErrInUse, + KErrCompletion, + KErrGeneral + }; + +const TResultCode KMapResultCode[] = + { + EResultCodeOK, + EResultCodeAlreadyPowerOn, + EResultCodePowerOff, + EResultCodeUnknown, + EResultCodeCardRemoved, + EResultCodeNotAccessible, + EResultCodeCardRemoved, + EResultCodeDataNotAvailable + }; + +const TMsgID KMapRequestID[] = + { + EConnectRequest, + EDisconnectRequest, + ETransferAPDURequest, + ETransferATRRequest, + EPowerSimOffRequest, + EPowerSimOnRequest, + EResetSimRequest, + ETransferCardReaderStatusRequest, + }; + +const TMsgID KMapMsgID[] = + { + EConnectRequest, + ETransferAPDURequest, + ETransferAPDURequest + }; + +const TParaID KMapParaID[] = + { + EParaMaxMsgSize, + EParaCommandAPDU, + EParaCommandAPDU7816 + }; + + +// CLASS DECLARATION + +/** +* SAP message format handler class. +*/ +class TBTSapMessage + { +public: + TBTSapMessage(); + + void SetMsgID(TMsgID aMsgID); + + TMsgID MsgID(); + + void AddParameter(TParaID aParaID, TInt aValue, TInt aLen = 1); + + void AddParameter(TParaID aParaID, const TDesC8& aValue); + + TInt GetParameter(TParaID aParaID, TDes8& aValue); + + TInt GetParameter(TParaID aParaID, TInt& aValue); + + // Copy data + void SetData(const TDes8& aData); + + TInt AppendData(const TDes8& aData); + + void Reset(); + + TDes8& Data(); + + TBool IsEmpty(); + + TValidationResult Validate(); + + TResultCode ToResultCode(TInt errorCode); + + TUint8 GetParaNum(); + + TInt GetParaID(const TUint8 index, TParaID &aParaID); + +private: + TInt FindParameter(TParaID aParaID, TInt& aValuePos, TInt& aValueLen); + + void AddParameter(TParaID aParaID, const TUint8* aValue, TInt aLen); + + TBool IsValidParaID(const TParaID aParaID, const TMsgID aMsgID) const; + + TBool IsValidRequestID(const TMsgID aRequestID) const; + +private: + TBuf8 iData; + }; + + +#endif // BT_SAP_MESSAGE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapPlugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 2004-2008 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: +* BTSap plugin header definition +* +*/ + + +#ifndef BT_SAP_PLUGIN_H +#define BT_SAP_PLUGIN_H + +// INCLUDES +#include + +enum TBTSapRejectReason + { + ERejectGeneralError, + ERejectReserved + }; + +enum TBTSapDisconnectType + { + EDisconnectGraceful, + EDisconnectImmediate + }; + +// FORWARD DECLARATIONS +class TBTDevAddr; +class CBTSapServerState; + +/* +* +*/ +class MSapAsyncObserver + { + public: + enum TOperation + { + EConnect, + ECancelConnect, + EDisconnect + }; + + virtual void OperationCompletedL(TOperation aOperation, TInt aError) = 0; + }; + +/* +* A class that proveides a utility service for calling +* CSapServerState methods asychronously +*/ +class CBTSapAsyncHelper : public CActive + { +public: + static CBTSapAsyncHelper* NewL(CBTSapServerState* aServerState, MSapAsyncObserver* aObserver); + virtual ~CBTSapAsyncHelper(); + + void AsyncConnect(const TBTDevAddr& aAddr); + void AsyncCancelConnect(const TBTDevAddr& aAddr); + void AsyncDisconnect(const TBTDevAddr& aAddr, TBTSapDisconnectType aDiscType); + +private: + void ConstructL(CBTSapServerState* aServerState, MSapAsyncObserver* aObserver); + CBTSapAsyncHelper(); + + // From CActive + virtual void DoCancel(); + virtual void RunL(); + +private: + MSapAsyncObserver::TOperation iOperation; + CBTSapServerState* iServerState; + MSapAsyncObserver* iObserver; + TBTSapDisconnectType iDiscType; + }; + + +/** +* CBTSapPlugin core class. +* Implements the BT Engine ECom interface +*/ +class CBTSapPlugin : public CBTEngPlugin, MSapAsyncObserver + { +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTSapPlugin* NewL(); + + /** + * Destructor. + */ + virtual ~CBTSapPlugin(); + +public: + // From CBTEngPlugin (ECom) + + virtual void GetSupportedProfiles( RProfileArray& aProfiles ); + + virtual void SetObserver( MBTEngPluginObserver* aObserver ); + + virtual TBool IsProfileSupported( const TBTProfile aProfile ) const; + + virtual TInt Connect( const TBTDevAddr& aAddr ); + + virtual void CancelConnect( const TBTDevAddr& aAddr ); + + virtual TInt Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType ); + + virtual void GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile ); + + virtual TBTEngConnectionStatus IsConnected( const TBTDevAddr& aAddr ); + + // From MSapAsyncObserver + + void OperationCompletedL(MSapAsyncObserver::TOperation aOperation, TInt aError); + +public: + + TInt AcceptSapConnection(); + + TInt RejectSapConnection(TBTSapRejectReason aReason = ERejectGeneralError); + + TInt DisconnectSapConnection(TBTSapDisconnectType aType = EDisconnectGraceful); + + TBool IsSapConnected(); + + TInt GetRemoteBTAddress(TBTDevAddr& aBTDevAddr); + + void ConnectComplete(); + +private: + + /** + * Default constructor + */ + CBTSapPlugin(); + + /** + * Two-Phase constructor + */ + void ConstructL(); + + void StartBTSapServiceL(); + + void StopBTSapServiceL(); + +private: // Data + + enum TBTSapServiceState + { + EServiceOff, + EServiceOn, + EServiceShuttingDown + }; + + CBTSapServerState* iBTSapServerState; + TBTSapServiceState iServiceState; + MBTEngPluginObserver* iObserver; + CBTSapAsyncHelper* iAsyncHelper; + TBTDevAddr iAddr; + }; + +#endif // BT_SAP_PLUGIN_H +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapRequestHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapRequestHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2004 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: +* This class handles SAP request message +* +* +*/ + +#ifndef BT_SAP_REQUEST_HANDLER_H +#define BT_SAP_REQUEST_HANDLER_H + +// INCLUDES +#include "BTSapServerState.h" + +const TBTSapServerState KStateByRequest[] = + { + EStateConnect, + EStateIdle, + EStateDisconnect, + EStateIdle, + EStateIdle, + EStateAPDU, + EStateIdle, + EStateATR, + EStateIdle, + EStatePowerOff, + EStateIdle, + EStatePowerOn, + EStateIdle, + EStateReset, + EStateIdle, + EStateCardReaderStatus + }; + +class CBTSapRequestHandler : public CActive +{ +private: + class CSegmentTimer : public CTimer + { + public: + static CSegmentTimer* NewL(CBTSapRequestHandler* aRequestHandler); + + private: + CSegmentTimer(CBTSapRequestHandler* aRequestHandler); + + void RunL(); + + private: + CBTSapRequestHandler* iRequestHandler; + }; + +public: + // Constructors + static CBTSapRequestHandler* NewL(CBTSapServerState& aServerState); + + // Destructor + ~CBTSapRequestHandler(); + +private: // From CActive + + /** + * DoCancel() has to be implemented by all the classes deriving CActive. + * Request cancellation routine. + * @param none + * @return none + */ + void DoCancel(); + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + void RunL(); + +public: + + void HandleSapData(const TDes8& aData); + + void HandleSegmentTimeout(); + +private: + + // Two-phase constructor + void ConstructL(); + + // Default constructor + CBTSapRequestHandler(CBTSapServerState& aServerState); + + void HandleSapMessage(const TValidationResult aResult); + +private: + + CBTSapServerState& iServerState; + TBTSapMessage& iRequestMessage; + TBTSapMessage iRawMessage; + CSegmentTimer* iSegmentTimer; +}; + +#endif // BT_SAP_REQUEST_HANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapSecurityHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapSecurityHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2004 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: +* This class handles SAP security checking +* +*/ + +#ifndef BT_SAP_SECURITY_HANDLER_H +#define BT_SAP_SECURITY_HANDLER_H + +// INCLUDES +#include +#include +#include + +// Vendor specific +const TUint8 KCmdInfo[] = {0xFC, 0x00, 0x00, 0x00, 0xFC, 0x04, 0xF0, 0x07, 0x00, 0x00}; +const TInt KExtCmdLen = 10; + +// Security settings +const TInt KRequiredPassKeyLen = 16; + +// FORWARD DECLARATIONS +class CBTEngDevMan; +class CBTHciExtensionMan; + +enum TBTSapSecurityCheckResult + { + ESecurityOK, + EGetEncryptionKeyFail, + EEncryptionKeyTooShort, + EPassKeyTooShort + }; + +class CBTSapSecurityHandler : public CActive, MBTEngDevManObserver + { +public: + // Constructors + static CBTSapSecurityHandler* NewL(); + + // Destructor + ~CBTSapSecurityHandler(); + +private: // From CActive + + /** + * DoCancel() has to be implemented by all the classes deriving CActive. + * Request cancellation routine. + * @param none + * @return none + */ + void DoCancel(); + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + void RunL(); + + /** + * RunError is used for handling leaves that occure inside RunL + */ + TInt RunError(TInt aError); + +public: + + void CheckSapSecurity(RSocket& aSocket, TRequestStatus& aStatus); + +private: + + // Two-phase constructor + void ConstructL(); + + // Default constructor + CBTSapSecurityHandler(); + + // from MBTEngDevManObserver + void HandleGetDevicesComplete(TInt aErr,CBTDeviceArray* aDeviceArray); + +private: + + enum TState + { + EEncryptionKeyLength, + EPassKeyLength + }; + +private: + + TRequestStatus *iSecurityStatus; + RSocket *iSocket; + CBTHciExtensionMan* iBtHci; + + CBTEngDevMan* iBtDevMan; + CBTDeviceArray* iBtDeviceArray; + TState iState; + + THCIConnHandle iHCIConnHandle; + TPckgBuf iHCIHandleBuf; + TBuf8 iExtCmd; + + TUint8 iEncryptionKeyLength; + }; + +#endif // BT_SAP_SECURITY_HANDLER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapServerState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapServerState.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,428 @@ +/* +* Copyright (c) 2004-2006 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: +* BTSap Plugin header definition +* +* +*/ + + +#ifndef BT_SAP_SERVER_STATE_H +#define BT_SAP_SERVER_STATE_H + +// INCLUDES +#include +#include + +#ifdef _DUMMY_CUSTOM_API +#include +#else +#include +#endif + +#include "BTSapPlugin.h" +#include "BTSapMessage.h" + +enum TBTSapServerState + { + EStateInit, + EStateNotConnected, + EStateConnect, + EStateDisconnect, + EStateIdle, + EStateAPDU, + EStateATR, + EStatePowerOff, + EStatePowerOn, + EStateReset, + EStateCardReaderStatus + }; + +enum TSapConnectionCompleteReason + { + EConnectionError, + EUserAccepted, + EUserRejected + }; + +enum TSapConnectionState + { + ESapNotConnected, + ESapConnecting, + ESapConnected + }; + +// FORWARD DECLARATIONS +class CBTSapSocketHandler; +class CBTSapRequestHandler; +class CBTSapSimCardStatusNotifier; +class RTelServer; +class RMobilePhone; +class MSapStatusObserver; + +/* +* An abstarct interface that defines a callback method +* for the SAP connection state observer. SapStatusChangedL +* is called by CBTSapStatusObserver when the SAP connection +* state has changed. aStatus represents the new status value. +*/ +class MSapStatusObserver + { + public: + virtual void SapStatusChangedL(TInt aStatus) = 0; + }; + +/* +* An observer that monitors KPSUidBluetoothSapConnectionState +* P&S key. The clients can call SubscribeSapStatusL in order to +* get a chenged new SAP connection status returned via +* MSapStatusObserver::SapStatusChangedL. +*/ +class CBTSapStatusObserver : public CActive + { +public: + /** + * Two-phased constructor. + */ + static CBTSapStatusObserver* NewL(); + /** + * Destructor. + */ + virtual ~CBTSapStatusObserver(); + + /** + * Starts listening KPSUidBluetoothSapConnectionState P&S key. + * When the key value is changed, the new state is indicated + * through the observer interface (MSapStatusObserver). + */ + void SubscribeSapStatusL(MSapStatusObserver* aObserver); + +private: + /** + * Two-Phase constructor + */ + void ConstructL(); + + /** + * Default constructor + */ + CBTSapStatusObserver(); + + // From CActive + virtual void DoCancel(); + virtual void RunL(); + +private: + MSapStatusObserver* iObserver; + RProperty iProperty; + }; + + +/** +* CBTSapServerState core class +* +*/ +class CBTSapServerState : public CActive, MSapStatusObserver + { +private: + class TState + { + public: + TState(CBTSapServerState& aServerState); + virtual void Enter(TRequestStatus& aStatus) = 0; + virtual TBTSapServerState Complete(TInt aReason = KErrNone) = 0; + virtual void Cancel() = 0; + + virtual TInt DisconnectSapConnection(TBTSapDisconnectType aType); + virtual TInt AcceptSapConnection(); + virtual TInt RejectSapConnection(TBTSapRejectReason aReason); + virtual void SimCardStatusChanged(TCardStatus aCardStatus); + virtual TInt ChangeState(TBTSapServerState& aNextState); + + void NotifySapState(TSapConnectionState aState); + void StartBTNotifier(TInt type); + TBool IsSimPresent(); + + protected: + TInt iSimStatus; + CBTSapServerState& iServerState; + TBTSapMessage& iResponseMessage; // + TRequestStatus* iStatus; // TState can't access parent's member directly + }; + + class TStateInit : public TState + { + public: + TStateInit(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + }; + + class TStateNotConnected : public TState + { + public: + TStateNotConnected(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + }; + + class TStateIdle : public TState + { + public: + TStateIdle(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt DisconnectSapConnection(TBTSapDisconnectType aType); + void SimCardStatusChanged(TCardStatus aCardStatus); + TInt ChangeState(TBTSapServerState& aNextState); + }; + + class TStateConnect : public TStateIdle + { + public: + TStateConnect(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt AcceptSapConnection(); + TInt RejectSapConnection(TBTSapRejectReason aReason); + TInt ChangeState(TBTSapServerState& aNextState); + void SimCardStatusChanged(TCardStatus aCardStatus); + + private: + void CheckMaxMsgSize(TConnectionStatus& aMsgSizeStatus); + TBool IsCallOngoing(); + + private: + TBool iConnectRequestOK; + TCardStatus iCardStatus; + RProperty iProperty; + }; + + class TStateDisconnect : public TStateIdle + { + public: + TStateDisconnect(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + }; + + class TStateAPDU : public TStateIdle + { + public: + TStateAPDU(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + + private: + TBuf8 iApduCmd; + TBuf8 iApduResp; + RMmCustomAPI::TApduParameters iApduParameters; + }; + + class TStateATR : public TStateIdle + { + public: + TStateATR(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + + private: + TBuf8 iATR; + }; + + class TStatePowerOff : public TStateIdle + { + public: + TStatePowerOff(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + }; + + class TStatePowerOn : public TStateIdle + { + public: + TStatePowerOn(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + void SimCardStatusChanged(TCardStatus aCardStatus); + + private: + TResultCode iResultCode; + TCardStatus iCardStatus; + }; + + class TStateReset : public TStateIdle + { + public: + TStateReset(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + void SimCardStatusChanged(TCardStatus aCardStatus); + + private: + TResultCode iResultCode; + TCardStatus iCardStatus; + }; + + class TStateCardReaderStatus : public TStateIdle + { + public: + TStateCardReaderStatus(CBTSapServerState& aServerState); + void Enter(TRequestStatus& aStatus); + TBTSapServerState Complete(TInt aReason); + void Cancel(); + + TInt ChangeState(TBTSapServerState& aNextState); + + private: + RMmCustomAPI::TSimCardReaderStatus iCardReaderStatus; + }; + +public: + /** + * Two-phased constructor. + */ + static CBTSapServerState* NewL(CBTSapPlugin& aBTSapPlugin); + /** + * Destructor. + */ + virtual ~CBTSapServerState(); + +public: + + void StartL(); + + void ChangeState(const TBTSapServerState aNextState); + + TBTSapServerState CurrentState(); + + TInt DisconnectSapConnection(TBTSapDisconnectType aType); + + TInt AcceptSapConnection(); + + TInt RejectSapConnection(TBTSapRejectReason aReason); + + TBool IsSapConnected(); + + TInt GetRemoteBTAddress(TBTDevAddr& aBTDevAddr); + + TInt CreateStatesL(); + + TInt ReleaseStatesL(); + + TInt DisconnectCompleteL(TInt aErr); + +public: + + TInt HandleStateChangeRequest(TBTSapServerState& aNextState); + + void SendErrorResponse(); + + void SimCardStatusChanged(TCardStatus aCardStatus); + + CBTSapSocketHandler& BTSapSocketHandler(); + + CBTSapSimCardStatusNotifier& BTSapSimCardStatusNotifier(); + + RMmCustomAPI& SubscriptionModule(); + + TBTSapMessage& BTSapRequestMessage(); + + TBTSapMessage& BTSapResponseMessage(); + + // From MSapStatusObserver + void SapStatusChangedL(TInt aStatus); + +private: + + void OpenSubscriptionModuleL(); + +private: // From CActive + + /** + * DoCancel() has to be implemented by all the classes deriving CActive. + * Request cancellation routine. + * @param none + * @return none + */ + virtual void DoCancel(); + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + virtual void RunL(); + +private: + + /** + * Default constructor + */ + CBTSapServerState(CBTSapPlugin& aBTSapPlugin); + + /** + * Two-Phase constructor + */ + void ConstructL(); + +private: // Data + + CBTSapPlugin& iBTSapPlugin; + CBTSapSocketHandler* iSocketHandler; + CBTSapRequestHandler* iRequestHandler; + CBTSapSimCardStatusNotifier* iSimCardStatusNotifier; + + TBTSapServerState iCurrentState; + RPointerArray iStateArray; + + RTelServer iTelServer; + RMobilePhone iPhone; + RMmCustomAPI iSubscriptionModule; + + TBTSapMessage iResponseMessage; + TBTSapMessage iRequestMessage; + CBTSapStatusObserver* iStatusObserver; + TBool iStatesCreated; + }; + +#endif // BT_SAP_SERVER_STATE_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapSession.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2004 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: +* BTSap session definition. +* +*/ + + +#ifndef BT_SAP_SESSION_H +#define BT_SAP_SESSION_H + +// INCLUDES +#include + +// Opcodes used in message passing between client and server +enum TBTSapRequest + { + EBTSapManageService, + EBTSapAcceptSapConnection, + EBTSapRejectSapConnection, + EBTSapDisconnectSapConnection, + EBTSapIsConnected, + EBTSapGetRemoteBTAddress + }; + +// FORWARD DECLARATIONS +class CBTSapServer; + +// CLASS DECLARATION + +/** +* CBTSapSession class represent session on server side +* +*/ +class CBTSapSession : public CSession2 + { + public: // Constructors and destructor + + /** + * Constructor. + */ + static CBTSapSession* NewL(); + + // 2nd phase construct for sessions - called byb the CServer2 framework + void CreateL(); + + /** + * Destructor. + */ + ~CBTSapSession(); + + public: // Functions from base classes + + /** + * From CSession ServiceL + * Client-server framework calls this function + * to handle messages from client. + * @param aMessage received message class + * @return None + */ + void ServiceL(const RMessage2 &aMessage); + + /** + * From CSession DispatchMessageL + * Dispatchs and calls appropriate methods to + * handle messages. + * @param aMessage received message class + * @return None + */ + void DispatchMessageL(const RMessage2 &aMessage); + + /** + * From CSession Server + * Returns reference to server. + * @param None + * @return Reference to server + */ + CBTSapServer& Server(); + + private: + + /** + * C++ default constructor. + */ + CBTSapSession(); + + + }; + +#endif // BT_SAP_SESSION_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapSimCardStatusNotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapSimCardStatusNotifier.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2004 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: +* This class sends SIM card status indication to a client +* +* +*/ + + +#ifndef BT_SAP_SIM_CARD_STATUS_NOTIFIER_H +#define BT_SAP_SIM_CARD_STATUS_NOTIFIER_H + +// INCLUDES +#include + +#ifdef _DUMMY_CUSTOM_API +#include +#else +#include +#endif + +// FORWARD DECLARATIONS +class CBTSapServerState; + +// CLASS DECLARATION + +/** +* SIM card status handler class. +*/ +class CBTSapSimCardStatusNotifier : public CActive + { +public: + + // Constructors + static CBTSapSimCardStatusNotifier* NewL(CBTSapServerState& aBTSapServerState); + + // Destructor + ~CBTSapSimCardStatusNotifier(); + +private: // From CActive + + /** + * DoCancel() has to be implemented by all the classes deriving CActive. + * Request cancellation routine. + * @param none + * @return none + */ + void DoCancel(); + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + void RunL(); + +public: + + /** + * Start waiting for SIM card status change notification + * @param None + * @return None. + */ + + void Start(); + +private: + + // Two-phase constructor + void ConstructL(); + + // Default constructor + CBTSapSimCardStatusNotifier(CBTSapServerState& aBTSapServerState); + +private: + + CBTSapServerState& iBTSapServerState; + RMmCustomAPI& iSubscriptionModule; + RMmCustomAPI::TSIMCardStatus iCardStatus; + }; + +#endif // BT_SAP_SIM_CARD_STATUS_NOTIFIER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapSniffHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapSniffHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2004 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: +* This class implements a handler, which sets the physical link to +* sniff-mode when the SAP link is inactive for some time +* +* +*/ + + +#ifndef BT_SAP_SNIFF_HANDLER_H +#define BT_SAP_SNIFF_HANDLER_H + +// INCLUDES +#include +#include + +// CLASS DECLARATION + +NONSHARABLE_CLASS(CBTSapSniffHandler) : public CTimer + { +public: + + // Constructor + static CBTSapSniffHandler* NewL(RSocket& aSocket, RSocketServ& aSocketServer); + + // Destructor + ~CBTSapSniffHandler(); + +private: // From CActive + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + void RunL(); + +public: + + void Enable(); + void Disable(); + void Pause(); + +private: + + // Default constructor + CBTSapSniffHandler(RSocket& aSocket, RSocketServ& aSocketServer); + +private: + + RSocket& iSocket; // Data socket + RSocketServ& iSocketServer; // Socket server + TBool iIsLinkAdapterOpen; // Keep physical link adapter's state + RBTPhysicalLinkAdapter iBTLinkAdapter; // Sniff mode controller + + }; + +#endif // BT_SAP_SNIFF_HANDLER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSapSocketHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSapSocketHandler.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,206 @@ +/* +* Copyright (c) 2004 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: +* This class handles data exchange via SAP Socketection initiated by a client +* +*/ + + +#ifndef BT_SAP_SOCKET_HANDLER_H +#define BT_SAP_SOCKET_HANDLER_H + +// INCLUDES +#include +#include + +#include "BTSapMessage.h" // KMaxMsgSize +#include "BTSapSniffHandler.h" + +enum TBTSapSocketState + { + EBTSapSocketStateListen, + EBTSapSocketStateRecv, + EBTSapSocketStateSend, + EBTSapSocketStateCheckSecurity, + EBTSapSocketStateRecvWrong + }; + +// FORWARD DECLARATIONS +class CBTEngDiscovery; +class CBTSapServerState; +class CBTSapRequestHandler; +class CBTSapSecurityHandler; +class TBTDevAddr; + +// CLASS DECLARATION + +/** +* SAP Bluetooth socket connection handler class. +*/ +class CBTSapSocketHandler : public CActive + { +private: + + class TState + { + public: + TState(RSocket& aSocket); + virtual void Enter(TRequestStatus& aStatus) = 0; + virtual TBTSapSocketState Complete(TInt aReason = KErrNone) = 0; + virtual void Cancel() = 0; + + protected: + RSocket& iSocket; + }; + + class TStateListen : public TState + { + public: + TStateListen(RSocketServ& aSockServ, RSocket& aSocket, RSocket& aListener, TUint aChannel); + void Enter(TRequestStatus& aStatus); + TBTSapSocketState Complete(TInt aReason); + void Cancel(); + + private: + RSocketServ& iSockServ; + RSocket& iListener; + TUint& iChannel; + }; + + class TStateRecv : public TState + { + public: + TStateRecv(RSocket& aSocket, CBTSapRequestHandler& aRequestHandler, CBTSapSniffHandler** aSniffHandler); + void Enter(TRequestStatus& aStatus); + TBTSapSocketState Complete(TInt aReason); + void Cancel(); + + private: + TBuf8 iRequestData; + TSockXfrLength iSockXfrLength; + CBTSapRequestHandler& iRequestHandler; + CBTSapSniffHandler** iSniffHandler; + }; + + class TStateSend : public TState + { + public: + TStateSend(RSocket& aSocket); + void Enter(TRequestStatus& aStatus); + TBTSapSocketState Complete(TInt aReason); + void Cancel(); + void SetResponseData(const TDesC8& aResponseData); + + private: + TBuf8 iResponseData; + }; + + class TStateCheckSecurity : public TState + { + public: + TStateCheckSecurity(RSocket& aSocket, CBTSapSecurityHandler*& aSecurityHandler); + void Enter(TRequestStatus& aStatus); + TBTSapSocketState Complete(TInt aReason); + void Cancel(); + + private: + CBTSapSecurityHandler*& iSecurityHandler; + }; + +public: + + // Constructors + static CBTSapSocketHandler* NewL(CBTSapServerState& aServerState, CBTSapRequestHandler& aRequestHandler); + + // Destructor + ~CBTSapSocketHandler(); + +private: // From CActive + + /** + * DoCancel() has to be implemented by all the classes deriving CActive. + * Request cancellation routine. + * @param none + * @return none + */ + void DoCancel(); + + /** + * RunL is called by framework after request is being completed. + * @param nones + * @return none + */ + void RunL(); + +public: + + /** + * Listen for incoming SAP socket connection + * @param None + * @return None. + */ + void Listen(); + + /** + * Send response message back to the SAP client + * @return None. + */ + void Send(const TDes8& aResponseData); + + TInt GetRemoteBTAddress(TBTDevAddr& aBTDevAddr); + + TBool IsSapConnected(); + +private: + + // Two-phase constructor + void ConstructL(); + + // Default constructor + CBTSapSocketHandler(CBTSapServerState& aServerState, CBTSapRequestHandler& aRequestHandler); + + void RegisterBTSapServiceL(); + + void UnregisterBTSapServiceL(); + +private: + + void ChangeState(); + +private: + + CBTSapServerState& iServerState; + CBTSapSecurityHandler* iSecurityHandler; + + TSdpServRecordHandle iSdpHandle; // Registering handle + CBTEngDiscovery* iBtDiscovery; // Bluetooth engine + RSocketServ iSockServ; // Socket server + RSocket iSocket; // Data socket + RSocket iListener; // Listenning socket for incoming connection + TUint iChannel; // Local BT channel + + TStateListen iStateListen; + TStateRecv iStateRecv; + TStateSend iStateSend; + TStateCheckSecurity iStateCheckSecurity; + RPointerArray iStateArray; + TBTSapSocketState iCurrentState; + TBTSapSocketState iNextState; + + CBTSapSniffHandler* iSniffHandler; + }; + +#endif // BT_SAP_SOCKET_HANDLER_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/BTSap_Conn_State_SD.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/BTSap_Conn_State_SD.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2004 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: +* An enumeration type defined for the values of the SharedData key: KSapState +* +*/ + + +#ifndef __BTSAP_CONN_STATE_SD_H__ +#define __BTSAP_CONN_STATE_SD_H__ + +// INCLUDES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +typedef enum TBTSap_Conn_State_SD + { + ESapNotConnected, + ESapConnecting, + ESapConnected + // TODO: Add further values here + } TBTSapConnectionState; + +#endif // __BTSAP_CONN_STATE_SD_H__ diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/inc/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2004-2005 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: +* Central place for nice debug-type macros & functions +* +*/ + + +#ifndef BT_SAP_DEBUG_H +#define BT_SAP_DEBUG_H + +#ifdef _DEBUG + +// Debugging options + +#define KBTSAP_TRACE_ERROR 0x00000001 // Print errors traces +#define KBTSAP_TRACE_FUNCTIONS 0x00000002 // Print function traces +#define KBTSAP_TRACE_STM 0x00000004 // Print state machine traces +#define KBTSAP_TRACE_MEMORY 0x00000008 // Print memory traces +#define KBTSAP_TRACE_INFO 0x00000010 // Print informational traces + +// Add desired tracing levels below +const TInt KBTSapDebugMask = KBTSAP_TRACE_ERROR | + KBTSAP_TRACE_FUNCTIONS | + KBTSAP_TRACE_STM | + KBTSAP_TRACE_MEMORY | + KBTSAP_TRACE_INFO; + +#ifdef __WINS__ + // File logging for WINS + #define __FLOGGING__ +#else + // RDebug logging for target HW + #define __CLOGGING__ +#endif + +#ifdef __FLOGGING__ + +#include +#include +#include + +_LIT(KLogFile,"BTSapLog.txt"); +_LIT(KLogDir,"BT"); + +inline void TraceMem() + { +#ifdef MEMTRACE + TInt size; + User::Heap().AllocSize(size); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, _L("Memory usage: %d high: %d"), size, User::Heap().Size()); +#endif + } + +inline void BTSapPrintTrace(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); + TraceMem(); + } + +inline void BTSapPrintTrace(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); + TraceMem(); + } + +#else // __CLOGGING__ + +#include + +inline void BTSapPrintTrace(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + TInt tmpInt = VA_ARG(list, TInt); + TInt tmpInt2 = VA_ARG(list, TInt); + TInt tmpInt3 = VA_ARG(list, TInt); + VA_END(list); + RDebug::Print(aFmt, tmpInt, tmpInt2, tmpInt3); + } + +inline void BTSapPrintTrace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + TBuf8<256> buf8; + buf8.AppendFormatList(aFmt, list); + + TBuf16<256> buf16(buf8.Length()); + buf16.Copy(buf8); + + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + } + +#endif // __CLOGGING__ + +inline void BTSapPrintHex(const TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + TDesC8* aValue = VA_ARG(list, TDesC8*); + VA_END(list); + + TBuf8<85> buf8; + for (TInt i = 0; i < aValue->Length(); i ++) + { + if (buf8.Length() > 80) break; + buf8.AppendNumFixedWidth((*aValue)[i], EHex, 2); + buf8.Append(0x20); + } + + BTSapPrintTrace(aFmt, &buf8); + } + +#define BTSAP_TRACE_OPT(a,p) { if((KBTSapDebugMask) & (a)) (p); } + +#else // NO DEBUG + +#define BTSAP_TRACE_OPT(a,p) + +#endif // _DEBUG + +#endif // BT_SAP_DEBUG_H + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/rom/BTSap.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/rom/BTSap.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef __BT_SAP_IBY__ +#define __BT_SAP_IBY__ + +REM Bluetooth SAP ECom Plugin + +#ifdef __BT_SAP +ECOM_PLUGIN(BTSap.dll, 101FFE46.rsc) +#endif + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/101FFE46.RSS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/101FFE46.RSS Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2002-2005 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: BT SAP Plugin resource +* +*/ + + +#include +#include + +RESOURCE REGISTRY_INFO theInfo +{ + resource_format_version = RESOURCE_FORMAT_VERSION_2; + dll_uid = 0x101FFE46; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x2000277B; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x101FFE46; + version_no = 1; + display_name = "BT SAP Plugin"; + default_data = "112D"; + opaque_data = ""; + rom_only = 1; + } + }; + } + }; +} + diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapHciExtensionMan.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapHciExtensionMan.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,427 @@ +/* +* Copyright (c) 2004 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: +* This class holds the HCI Extension Conduit singleton +* +*/ + + +// INCLUDE FILES +#include +#include "BTSapHciExtensionMan.h" +#include "debug.h" + +// CONSTANT + +/** +* A prefix patch in all commands for compatible reason with stack +*/ +const TUint8 KHciExtensionCmdPatch[] = {0xFC, 0x00, 0x00}; + +/** +* Common prerfix of additional functionality command +*/ +const TUint8 KHciExtensionCmdCommomPrefix[] = {0x00, 0xFC}; + +/** +* Command Channel ID (Type of command) +*/ +// Channel Id of additional functionality command +const TUint KHciExtensionFunctionalityChannelID = 0xF0; + +/** +* Command opcode and parameter total length +*/ +// ENCRYPTION_KEY_LENGTH_READ_CMD +const TUint8 KEncryptionKeyLengthReadOpcode = 0x07; + +const TInt KEncryptionKeyLengthReadCmdParamLen = 8; + +/** +* Event constants +*/ +const TInt KHciExtensionEventIndexOfOpcode = 2; + +const TInt KEncryptionKeyLengthReadEventLen = 6; + +// DATA TYPES + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTHciExtensionMan::NewL() +// --------------------------------------------------------- +// +CBTHciExtensionMan* CBTHciExtensionMan::NewL() + { + CBTHciExtensionMan* self = new (ELeave) CBTHciExtensionMan(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// Destructor. +CBTHciExtensionMan::~CBTHciExtensionMan() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::~CBTHciExtensionMan >>"))); + if (iConduit) + { + iConduit->StopWaitingForEvent(); + delete iConduit; + } + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::~CBTHciExtensionMan <<"))); + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::HandleReqeustL +// --------------------------------------------------------- +// +void CBTHciExtensionMan::GetEncryptionKeyLengthL(const TBTDevAddr& aBTDevAddr, TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::HandleRequestL >>"))); + + TInt err = KErrNone; + aStatus = KRequestPending; + iStatus = &aStatus; + + CBTHciExtensionCmd* cmd = NULL; + TBTDevAddrPckgBuf pckg; + pckg = aBTDevAddr; + + cmd = CBTHciExtensionCmd::NewLC(KEncryptionKeyLengthReadOpcode); + + cmd->SetParamL(pckg().Des()); + + if (err == KErrNone) + { + iRequestOpcode = cmd->Opcode(); + TPtrC8 ptr = cmd->DesC(); + TUint16 requestOpcode = ptr[0] << 8 | ptr[1]; + err = iConduit->IssueCommandL(requestOpcode, ptr.Mid(sizeof(KHciExtensionCmdPatch))); + if (err) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] iConduit->IssueCommandL err %d"), err)); + } + } + else + { + User::RequestComplete(iStatus, err); + } + if (cmd) + { + CleanupStack::PopAndDestroy(cmd); + } + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::HandleRequestL <<"))); + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::GetResultL +// --------------------------------------------------------- +// +TInt CBTHciExtensionMan::GetResultL(TUint8& aKeyLength) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::GetResultL: enc key length: %d"),iKeyLength )); + if ( iStatus && iStatus->Int() == KRequestPending ) + { + return KErrNotReady; + } + + aKeyLength = iKeyLength; + return KErrNone; + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::CancelRequest +// --------------------------------------------------------- +// +void CBTHciExtensionMan::CancelRequest() + { + iConduit->StopWaitingForEvent(); + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::CommandCompleted +// --------------------------------------------------------- +// +void CBTHciExtensionMan::CommandCompleted(TInt aError) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::CommandCompleted(%d)"), aError)); + if(aError == KErrNone) + { + aError = iConduit->WaitForEvent(); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::CommandCompleted, iConduit->WaitForEvent %d"), aError)); + } + if (aError != KErrNone) + { + User::RequestComplete(iStatus, aError); + } + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::ReceiveEvent +// --------------------------------------------------------- +// +TBool CBTHciExtensionMan::ReceiveEvent(TDesC8& aEvent, TInt aError) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::ReceiveEvent(aError %d) >>"), aError)); + if (aError != KErrNone) + { + User::RequestComplete(iStatus, aError); + return EFalse; + } + + CBTHciExtensionCmdEvent* event = NULL; + TInt err; + TRAP(err, event = CBTHciExtensionCmdEvent::NewL(aEvent)); + if (!event) + { + User::RequestComplete(iStatus, err); + return EFalse; + } + if (event->Opcode() != iRequestOpcode) + { + User::RequestComplete(iStatus, KErrArgument); + delete event; + return EFalse; + } + switch (iRequestOpcode) + { + case KEncryptionKeyLengthReadOpcode: + { + TPtrC8 desptr = event->DesC(); + iKeyLength = desptr[desptr.Length() - 1]; + err = KErrNone; + break; + } + default: + { + err = KErrNotSupported; + break; + } + } + delete event; + User::RequestComplete(iStatus, err); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::ReceiveEvent %d <<"), err)); + return EFalse; + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::ConstructL +// --------------------------------------------------------- +// +void CBTHciExtensionMan::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::ConstructL >>"))); + iConduit = CHciExtensionConduit::NewL(*this); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionMan::ConstructL, iConduit %d <<"), iConduit)); + } + +// --------------------------------------------------------- +// CBTHciExtensionMan::CBTHciExtensionMan +// --------------------------------------------------------- +// +CBTHciExtensionMan::CBTHciExtensionMan(): iKeyLength(0) + { + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::NewL +// --------------------------------------------------------- +// +CBTHciExtensionCmd* CBTHciExtensionCmd::NewL(TUint8 aOpcode) + { + CBTHciExtensionCmd* self = CBTHciExtensionCmd::NewLC(aOpcode); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::NewLC +// --------------------------------------------------------- +// +CBTHciExtensionCmd* CBTHciExtensionCmd::NewLC(TUint8 aOpcode) + { + CBTHciExtensionCmd* self = new (ELeave) CBTHciExtensionCmd(aOpcode); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// Destructor. +CBTHciExtensionCmd::~CBTHciExtensionCmd() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::~CBTHciExtensionCmd >>"))); + delete iCmdDes; + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::~CBTHciExtensionCmd <<"))); + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::Opcode +// --------------------------------------------------------- +// +TUint8 CBTHciExtensionCmd::Opcode() const + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::Opcode %d >>"), iOpcode)); + return iOpcode; + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::CmdDesC +// --------------------------------------------------------- +// +TPtrC8 CBTHciExtensionCmd::DesC() const + { + return iCmdDes->Des(); + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::SetParamL +// --------------------------------------------------------- +// +void CBTHciExtensionCmd::SetParamL(const TDesC8& aParam) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::SetParamL param len %d >>"), aParam.Length())); + TInt length = aParam.Length(); + if (length != iParamTotalLength - 2) + { + User::Leave(KErrArgument); + } + iCmdDes->Des().Replace(iCmdLength - length, length, aParam); + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::SetParamL <<"))); + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::CBTHciExtensionCmd +// --------------------------------------------------------- +// +CBTHciExtensionCmd::CBTHciExtensionCmd(TUint8 aOpcode) + : iOpcode(aOpcode) + { + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::ConstructL +// --------------------------------------------------------- +// +void CBTHciExtensionCmd::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::ConstructL >>"))); + switch (iOpcode) + { + case KEncryptionKeyLengthReadOpcode: + { + iChannelID = KHciExtensionFunctionalityChannelID; + iParamTotalLength = KEncryptionKeyLengthReadCmdParamLen; + iCmdLength = sizeof(KHciExtensionCmdPatch) + + sizeof(KHciExtensionCmdCommomPrefix) + iParamTotalLength + 1; + break; + } + default: + User::Leave(KErrArgument); + } + InitializeCmdDesL(); + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::ConstructL <<"))); + } + +// --------------------------------------------------------- +// CBTHciExtensionCmd::InitializeCmdDesL +// --------------------------------------------------------- +// +void CBTHciExtensionCmd::InitializeCmdDesL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::InitializeCmdDesL >>"))); + iCmdDes = HBufC8::NewL(iCmdLength); + TPtr8 cmdPtr = iCmdDes->Des(); + cmdPtr.Append(KHciExtensionCmdPatch, sizeof(KHciExtensionCmdPatch)); + cmdPtr.Append(KHciExtensionCmdCommomPrefix, sizeof(KHciExtensionCmdCommomPrefix)); + cmdPtr.Append(iParamTotalLength); + cmdPtr.Append(iChannelID); + cmdPtr.Append(iOpcode); + cmdPtr.AppendFill(0, iParamTotalLength - 2); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmd::InitializeCmdDesL, len %d <<"), cmdPtr.Length())); + } + +CBTHciExtensionCmdEvent* CBTHciExtensionCmdEvent::NewL(const TDesC8& aEvent) + { + CBTHciExtensionCmdEvent* self = CBTHciExtensionCmdEvent::NewLC(aEvent); + CleanupStack::Pop(); + return self; + } + +CBTHciExtensionCmdEvent* CBTHciExtensionCmdEvent::NewLC(const TDesC8& aEvent) + { + CBTHciExtensionCmdEvent* self = new (ELeave) CBTHciExtensionCmdEvent(); + CleanupStack::PushL(self); + self->ConstructL(aEvent); + return self; + } + +CBTHciExtensionCmdEvent::~CBTHciExtensionCmdEvent() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmdEvent::~CBTHciExtensionCmdEvent >>"))); + delete iEventDes; + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmdEvent::~CBTHciExtensionCmdEvent <<"))); + } + +TUint8 CBTHciExtensionCmdEvent::Opcode() const + { + return (*iEventDes)[KHciExtensionEventIndexOfOpcode]; + } + +TPtrC8 CBTHciExtensionCmdEvent::DesC() const + { + return iEventDes->Des(); + } + +CBTHciExtensionCmdEvent::CBTHciExtensionCmdEvent() + { + } + +void CBTHciExtensionCmdEvent::ConstructL(const TDesC8& aEvent) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmdEvent::ConstructL len %d >>"), aEvent.Length())); + if (aEvent.Length() > KHciExtensionEventIndexOfOpcode) + { + TInt desLength = 0; + // Get the opcode of this event + TUint8 opcode = aEvent[KHciExtensionEventIndexOfOpcode]; + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmdEvent::ConstructL opcode %d >>"), opcode)); + switch (opcode) + { + case KEncryptionKeyLengthReadOpcode: + { + if (aEvent.Length() != KEncryptionKeyLengthReadEventLen) + { + User::Leave(KErrArgument); + } + desLength = KEncryptionKeyLengthReadEventLen; + break; + } + default: + User::Leave(KErrNotSupported); + } + iEventDes = HBufC8::NewL(desLength); + TPtr8 ptr = iEventDes->Des(); + ptr.Append(aEvent); + } + else + { + User::Leave(KErrArgument); + } + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTHciExtensionCmdEvent::ConstructL <<"))); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapMessage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapMessage.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,389 @@ +/* +* Copyright (c) 2004 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: +* This class handles SAP message encoding/decoding +* +* +*/ + + +// INCLUDE FILES +#include "BTSapMessage.h" +#include "debug.h" + +TBTSapMessage::TBTSapMessage() + { + } + +// --------------------------------------------------------- +// SetMsgID +// --------------------------------------------------------- +void TBTSapMessage::SetMsgID(TMsgID aMsgID) + { + iData.Zero(); + // MsgID + iData.Append(aMsgID); + // para number + iData.Append(0); + // reserve + iData.AppendFill(0, 2); + } + +// --------------------------------------------------------- +// MsgID +// --------------------------------------------------------- +TMsgID TBTSapMessage::MsgID() + { + return TMsgID(iData[KMsgIDOffset]); + } + +void TBTSapMessage::AddParameter(TParaID aParaID, TInt aValue, TInt aLen) + { + if (aLen == 2) + { + TBuf8 value; + value.Append(aValue >> 8); + value.Append(aValue & 0xff); + AddParameter(aParaID, value); + } + else + { + TUint8 value = (TUint8)aValue; + AddParameter(aParaID, &value, 1); + } + } + +void TBTSapMessage::AddParameter(TParaID aParaID, const TDesC8& aValue) + { + AddParameter(aParaID, aValue.Ptr(), aValue.Length()); + } + +void TBTSapMessage::AddParameter(TParaID aParaID, const TUint8* aValue, TInt aLen) + { + // increase the number of parameters + iData[KParaNumOffset] ++; + //iData.Replace(1, 1, paraNum); + + // parameter ID + iData.Append(aParaID); + // reserve + iData.AppendFill(0, KParaResvLen); + // length + //TUint16 paraLen = (TUint16)aLen; + iData.Append(aLen >> 8); // high byte + iData.Append(aLen & 0xff); // low byte + + // value + iData.Append(aValue, aLen); + + //padding + TInt reminder = aLen % KParaLenModulo; + if (reminder > 0) + { + iData.AppendFill(0, KParaLenModulo - reminder); + } + } + +TInt TBTSapMessage::GetParameter(TParaID aParaID, TDes8& aValue) + { + TInt valuePos = 0; + TInt valueLen = 0; + TInt retVal = FindParameter(aParaID, valuePos, valueLen); + + if (retVal == KErrNone) + { + aValue.Copy(iData.Mid(valuePos, valueLen)); + } + + return retVal; + } + +TInt TBTSapMessage::GetParameter(TParaID aParaID, TInt& aValue) + { + TInt valuePos = 0; + TInt valueLen = 0; + TInt retVal = FindParameter(aParaID, valuePos, valueLen); + + if (retVal == KErrNone) + { + if (valueLen == 1) + { + aValue = iData[valuePos]; + } + else if (valueLen == 2) + { + aValue = (iData[valuePos] << 8) + iData[valuePos + 1]; + } + else + { + retVal = KErrArgument; + } + } + + return retVal; + } + +TInt TBTSapMessage::FindParameter(TParaID aParaID, TInt& aValuePos, TInt& aValueLen) + { + TInt retVal = KErrNotFound; + TInt pos = KPayloadOffset; + TInt valueLenPos = 0; + + while (pos < iData.Length()) + { + valueLenPos = pos + KParaIDLen + KParaResvLen; + aValueLen = iData[valueLenPos] * 0xff + iData[valueLenPos + 1]; + + if (iData[pos] == aParaID) + { + aValuePos = valueLenPos + KParaLenLen; + retVal = KErrNone; + break; + } + + TInt paddingLen = (KParaLenModulo - (aValueLen % KParaLenModulo)) % KParaLenModulo; + pos += KParaIDLen + KParaResvLen + KParaLenLen + aValueLen + paddingLen; + } + + return retVal; + } + +void TBTSapMessage::SetData(const TDes8& aData) + { + iData = aData; + } + +TInt TBTSapMessage::AppendData(const TDes8& aData) + { + if ( iData.Length() + aData.Length() <= iData.MaxLength() ) + { + iData.Append(aData); + } + else + { + return EInvalidSegmented; + } + + return KErrNone; + } + +void TBTSapMessage::Reset() + { + iData.Zero(); + } + +TBool TBTSapMessage::IsEmpty() + { + return (iData.Length() == 0); + } + +TDes8& TBTSapMessage::Data() + { + return iData; + } + +TValidationResult TBTSapMessage::Validate() + { + TValidationResult retVal = EInvalidUnknown; + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: IsValid: %d %d >>"), iData.Length(), iData[KMsgIDOffset])); + + if (iData.Length() < KParaLenModulo || (iData.Length() % KParaLenModulo) > 0) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: short or /4 ***"))); + retVal = EInvalidSegmented; + } + else if (!IsValidRequestID(TMsgID(iData[KMsgIDOffset]))) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: msgID wrong ***"))); + retVal = EInvalidMsgID; + } + else + { + TInt reserve = (iData[KParaNumOffset + 1] << 8) + iData[KParaNumOffset +2]; + + if (reserve != KHeaderResvValue) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: header rsvd not 0 ***"))); + retVal = EInvalidReservedBytes; + } + else + { + TInt paraNum = GetParaNum(); + TInt pos = KPayloadOffset; + TInt valueLenPos; + TInt valueLen = 0; + TInt i = 0; + + for (; i < paraNum; i ++) + { + if (pos >= iData.Length()) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: paraNum big ***"))); + retVal = EInvalidSegmented; + break; + } + else if (!IsValidParaID(TParaID(iData[pos]), TMsgID(iData[KMsgIDOffset]))) + { + // parameter ID is out of range + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: paraID wrong ***"))); + retVal = EInvalidParameterID; + break; + } + else if (iData[pos + KParaResvLen] != KParaResvValue) + { + // reserved field is not equal to 0 + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: para rsvd not 0 ***"))); + retVal = EInvalidReservedBytes; + break; + } + else + { + valueLenPos = pos + KParaIDLen + KParaResvLen; + valueLen = (iData[valueLenPos] << 8) + iData[valueLenPos + 1]; + pos = valueLenPos + KParaLenLen + valueLen; + + if (pos > iData.Length()) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: paraNum big ***"))); + retVal = EInvalidSegmented; + break; + } + + TInt paddingLen = (KParaLenModulo - (valueLen % KParaLenModulo)) % KParaLenModulo; + + for (TInt k = 0; k < paddingLen; k ++) + { + if (iData[pos++] != KParaResvValue) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: padding not 0 ***"))); + retVal = EInvalidPaddingBytes; + break; + } + } + } + } + + if (i == paraNum) + { + if (pos == iData.Length()) + { + // no problem so far + retVal = EValidFormat; + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TBTSapMessage: paraNum small ***"))); + retVal = EInvalidParaNumTooSmall; + } + } + + if(paraNum == 0) + { + // Check if the message needs a parameter + for(i = 0; i < sizeof(KMapParaID) / sizeof(KMapParaID[0]); i++) + { + if(KMapMsgID[i] == TMsgID(iData[KMsgIDOffset])) + { + retVal = EInvalidParaNumTooSmall; + break; + } + } + } + } + } + + return retVal; + } + +TResultCode TBTSapMessage::ToResultCode(TInt aErrCode) + { + TUint size = sizeof(KMapErrCode) / sizeof(KMapErrCode[0]); + TUint i = 0; + for (; i < size; i++) + { + if (KMapErrCode[i] == aErrCode) + { + break; + } + } + + return (i < size ? KMapResultCode[i] : EResultCodeDataNotAvailable); + } + +TBool TBTSapMessage::IsValidParaID(const TParaID aParaID, const TMsgID aMsgID) const + { + TUint size = sizeof(KMapParaID) / sizeof(KMapParaID[0]); + TUint i = 0; + + for (; i < size; i++) + { + if (KMapParaID[i] == aParaID) + { + break; + } + } + + return (i < size ? KMapMsgID[i] == aMsgID : EFalse); + } + +TBool TBTSapMessage::IsValidRequestID(const TMsgID aRequestID) const + { + TUint size = sizeof(KMapRequestID) / sizeof(KMapRequestID[0]); + TUint i = 0; + + for (; i < size; i++) + { + if (KMapRequestID[i] == aRequestID) + { + break; + } + } + + return (i < size); + } + +TUint8 TBTSapMessage::GetParaNum() + { + return iData[KParaNumOffset]; + } + +TInt TBTSapMessage::GetParaID(const TUint8 index, TParaID &aParaID) + { + TInt retVal = KErrNotFound; + TInt pos = KPayloadOffset; + TInt valueLenPos = 0; + TUint8 currentIndex = 0; + TUint8 valueLen; + + while (pos < iData.Length()) + { + valueLenPos = pos + KParaIDLen + KParaResvLen; + valueLen = iData[valueLenPos] * 0xff + iData[valueLenPos + 1]; + + if (currentIndex == index) + { + aParaID = (TParaID) iData[pos]; + retVal = KErrNone; + break; + } + + TInt paddingLen = (KParaLenModulo - (valueLen % KParaLenModulo)) % KParaLenModulo; + pos += KParaIDLen + KParaResvLen + KParaLenLen + valueLen + paddingLen; + currentIndex++; + } + + return retVal; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapPlugin.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,527 @@ +/* +* Copyright (c) 2004-2008 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: +* BT SAP Plugin header definition +* +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include "BTSapPlugin.h" +#include "BTSapServerState.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTSapStatusObserver::CBTSapStatusObserver() +//---------------------------------------------------------- +// +CBTSapAsyncHelper::CBTSapAsyncHelper(): CActive(CActive::EPriorityStandard) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------- +// CBTSapStatusObserver::NewL() +//---------------------------------------------------------- +// +CBTSapAsyncHelper* CBTSapAsyncHelper::NewL(CBTSapServerState* aServerState, MSapAsyncObserver* aObserver) + { + CBTSapAsyncHelper* self = new(ELeave) CBTSapAsyncHelper(); + CleanupStack::PushL( self ); + self->ConstructL(aServerState, aObserver); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTSapAsyncHelper::ConstructL() +//---------------------------------------------------------- +// +void CBTSapAsyncHelper::ConstructL(CBTSapServerState* aServerState, MSapAsyncObserver* aObserver) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapAsyncHelper::ConstructL"))); + + iServerState = aServerState; + iObserver = aObserver; + iOperation = MSapAsyncObserver::EConnect; + iDiscType = EDisconnectImmediate; + } + +// --------------------------------------------------------- +// CBTSapAsyncHelper::~CBTSapAsyncHelper +//---------------------------------------------------------- +// +CBTSapAsyncHelper::~CBTSapAsyncHelper() + { + Cancel(); + } + +// --------------------------------------------------------- +// CBTSapAsyncHelper::AsyncConnect() +//---------------------------------------------------------- +// +/* +void CBTSapAsyncHelper::AsyncConnect(const TBTDevAddr& aAddr) + { + // Not supported at the moment + } +*/ + +// --------------------------------------------------------- +// CBTSapAsyncHelper::AsyncCancelConnect() +//---------------------------------------------------------- +// +/* +void CBTSapAsyncHelper::AsyncCancelConnect(const TBTDevAddr& aAddr) + { + // Not supported at the moment + } +*/ + +// --------------------------------------------------------- +// CBTSapAsyncHelper::AsyncDissconnect() +//---------------------------------------------------------- +// +void CBTSapAsyncHelper::AsyncDisconnect(const TBTDevAddr& /*aAddr*/, TBTSapDisconnectType aDiscType) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapAsyncHelper::AsyncDisconnect"))); + + if (IsActive()) + { + return; + } + iOperation = MSapAsyncObserver::EDisconnect; + iDiscType = aDiscType; + TRequestStatus* ownStatus; + ownStatus = &iStatus; + *ownStatus = KRequestPending; + SetActive(); + User::RequestComplete(ownStatus, KErrNone);; + } + + +// --------------------------------------------------------- +// CBTSapAsyncHelper::DoCancel() +// --------------------------------------------------------- +// +void CBTSapAsyncHelper::DoCancel() + { + } + +// --------------------------------------------------------- +// CBTSapAsyncHelper::RunL() +// --------------------------------------------------------- +// +void CBTSapAsyncHelper::RunL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapAsyncHelper::RunL"))); + + TInt r = KErrNone; + + switch(iOperation) + { + case MSapAsyncObserver::EDisconnect: + { + r = iServerState->DisconnectSapConnection(iDiscType); + return; // Disconnect callback will happen after a socket is closed, not yet here + } + default: + { + // Nothing + } + } + iObserver->OperationCompletedL(iOperation, r); + } + +// --------------------------------------------------------- +// CBTSapPlugin::CBTSapPlugin() +// --------------------------------------------------------- +// +CBTSapPlugin::CBTSapPlugin() + : iServiceState(EServiceOff) + { + } + +// --------------------------------------------------------- +// CBTSapPlugin::~CBTSapPlugin() +// --------------------------------------------------------- +// +CBTSapPlugin::~CBTSapPlugin() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] ~CBTSapPlugin"))); + + if(iBTSapServerState) + { + iBTSapServerState->DisconnectSapConnection(EDisconnectImmediate); + } + + if(iAsyncHelper) + { + iAsyncHelper->Cancel(); + delete iAsyncHelper; + } + + delete iBTSapServerState; + iBTSapServerState = NULL; + } + +// --------------------------------------------------------- +// CBTSapPlugin::NewL +// --------------------------------------------------------- +// +CBTSapPlugin* CBTSapPlugin::NewL() + { + CBTSapPlugin* self=new(ELeave) CBTSapPlugin(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTSapPlugin::ConstructL +// --------------------------------------------------------- +// +void CBTSapPlugin::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::ConstructL"))); + iBTSapServerState = CBTSapServerState::NewL(*this); + iAsyncHelper = CBTSapAsyncHelper::NewL(iBTSapServerState, this); + StartBTSapServiceL(); // Creates iBTSapServerState + } + +// --------------------------------------------------------- +// CBTSapPlugin::SetObserver, from CBTEngPlugin +// --------------------------------------------------------- +// +void CBTSapPlugin::SetObserver( MBTEngPluginObserver* aObserver ) + { + iObserver = aObserver; + } + +// --------------------------------------------------------- +// CBTSapPlugin::GetSupportedProfiles, from CBTEngPlugin +// --------------------------------------------------------- +// +void CBTSapPlugin::GetSupportedProfiles( RProfileArray& aProfiles ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::GetSupportedProfiles"))); + + aProfiles.Append(EBTProfileSAP); + } + +// --------------------------------------------------------- +// CBTSapPlugin::IsProfileSupported, from CBTEngPlugin +// --------------------------------------------------------- +// +TBool CBTSapPlugin::IsProfileSupported( const TBTProfile aProfile ) const + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::IsProfileSupported"))); + + return (aProfile == EBTProfileSAP) ? ETrue : EFalse; + } + +// --------------------------------------------------------- +// CBTSapPlugin::Connect, from CBTEngPlugin +// --------------------------------------------------------- +// +TInt CBTSapPlugin::Connect( const TBTDevAddr& /*aAddr*/ ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::Connect"))); + + // A SAP connection can only be created by a remote device + return KErrNotSupported; + } + +// --------------------------------------------------------- +// CBTSapPlugin::CancelConnect, from CBTEngPlugin +// --------------------------------------------------------- +// +void CBTSapPlugin::CancelConnect( const TBTDevAddr& /*aAddr*/ ) + { + // A SAP connection can only be created by a remote device + } + +// --------------------------------------------------------- +// CBTSapPlugin::Disconnect, from CBTEngPlugin +// --------------------------------------------------------- +// +TInt CBTSapPlugin::Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::Disconnect"))); + + TInt r = KErrNotSupported; + TBTDevAddr btDevAddr; + iAddr = aAddr; + + r = GetRemoteBTAddress(btDevAddr); + + if (!r) + { + if (btDevAddr != aAddr) + { + return KErrNone; + } + } + else + { + return r; + } + + if (aDiscType == EBTDiscImmediate) + { + r = DisconnectSapConnection(EDisconnectImmediate); + } + else if (aDiscType == EBTDiscGraceful) + { + r = DisconnectSapConnection(EDisconnectGraceful); + } + return r; + } + +// --------------------------------------------------------- +// CBTSapPlugin::GetConnections, from CBTEngPlugin +// --------------------------------------------------------- +// +void CBTSapPlugin::GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile ) + { + TBTDevAddr btDevAddr; + + if(aConnectedProfile == EBTProfileSAP) + { + if (GetRemoteBTAddress(btDevAddr) == KErrNone) + { + aAddrArray.Append(btDevAddr); + } + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::IsConnected, from CBTEngPlugin +// --------------------------------------------------------- +// +TBTEngConnectionStatus CBTSapPlugin::IsConnected( const TBTDevAddr& aAddr ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::IsConnected"))); + + TBTDevAddr addr; + TInt r = KErrNotSupported; + + if(iServiceState) + { + // Only check connection state if the service is enabled + if (iBTSapServerState->IsSapConnected()) + { + r = GetRemoteBTAddress( addr ); + if( !r && addr == aAddr ) + { + return EBTEngConnected; + } + } + } + + // Otherwise there is no connection, for sure + return EBTEngNotConnected; + } + + +// --------------------------------------------------------- +// CBTSapPlugin::StartBTSapServiceL +// --------------------------------------------------------- +// +void CBTSapPlugin::StartBTSapServiceL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::StartBTSapServiceL"))); + + if(iServiceState == EServiceOff) + { + iBTSapServerState->StartL(); + iServiceState = EServiceOn; + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::AcceptSapConnection +// --------------------------------------------------------- +// +TInt CBTSapPlugin::AcceptSapConnection() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::AcceptSapConnection"))); + + if(iServiceState) + { + // Only accept connection if the service is enabled + return iBTSapServerState->AcceptSapConnection(); + } + else + { + // Otherwise the state-machine is not ready yet + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, + BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::AcceptSapConnection: Can't accept when service is disabled"))); + return KErrNotReady; + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::RejectSapConnection +// --------------------------------------------------------- +// +TInt CBTSapPlugin::RejectSapConnection(TBTSapRejectReason aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::RejectSapConnection"))); + + if(iServiceState) + { + // Only reject connection if the service is enabled + return iBTSapServerState->RejectSapConnection(aReason); + } + else + { + // Otherwise the state-machine is not ready yet + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, + BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::RejectSapConnection: Can't reject when service is disabled"))); + return KErrNotReady; + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::DisconnectSapConnection +// --------------------------------------------------------- +// +TInt CBTSapPlugin::DisconnectSapConnection(TBTSapDisconnectType aType) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::DisconnectSapConnection"))); + + if(iServiceState) + { + TBTDevAddr addr; + // Only disconnect SAP if the service is enabled + iAsyncHelper->AsyncDisconnect(addr, aType); + return KErrNone; + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, + BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::DisconnectSapConnection: Can't disconnect when service is disabled"))); + // Otherwise the state-machine is not ready yet + return KErrNotReady; + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::IsSapConnected +// --------------------------------------------------------- +// +TBool CBTSapPlugin::IsSapConnected() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::IsSapConnected"))); + + if(iServiceState) + { + // Only check connection state if the service is enabled + return iBTSapServerState->IsSapConnected(); + } + + // Otherwise there is no connection, for sure + return EFalse; + } + +// --------------------------------------------------------- +// CBTSapPlugin::GetRemoteBTAddress +// --------------------------------------------------------- +// +TInt CBTSapPlugin::GetRemoteBTAddress(TBTDevAddr& aBTDevAddr) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::GetRemoteBTAddress"))); + + if(iServiceState) + { + // Only get remote address if the service is enabled + return iBTSapServerState->GetRemoteBTAddress(aBTDevAddr); + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, + BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::GetRemoteBTAddress: Can't get remote address when service is disabled"))); + // Otherwise the state-machine is not ready yet + return KErrNotReady; + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::OperationCompletedL +// --------------------------------------------------------- +// +void CBTSapPlugin::OperationCompletedL(MSapAsyncObserver::TOperation aOperation, TInt aError) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapPlugin::OperationCompletedL"))); + + TBTProfile profile = EBTProfileSAP; + + switch (aOperation) + { + case MSapAsyncObserver::EDisconnect: + { + iObserver->DisconnectComplete(iAddr, profile, aError); + } + } + } + +// --------------------------------------------------------- +// CBTSapPlugin::ConnectComplete +// --------------------------------------------------------- +// +void CBTSapPlugin::ConnectComplete() + { + // Used just for incoming SAP connectios, outgoing SAP connections are not supported. + // And used only when connection is created successully. + if ( iObserver ) + { + TBTDevAddr addr; + if ( !GetRemoteBTAddress( addr ) ) + { + iObserver->ConnectComplete( addr, EBTProfileSAP, KErrNone ); + } + } + } + +// ----------------------------------------------------------------------------- +// Implementation table is required by ECom. Allows alternative +// New methods to be specified. +// ----------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x101FFE46,CBTSapPlugin::NewL) + }; + +// ----------------------------------------------------------------------------- +// ImplementationGroupProxy: Lookup method required by ECom +// Returns the ImplementationTable to the ECom framework +// ----------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapRequestHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapRequestHandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2004 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: +* This class handles data exchange between BTSap server and client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapRequestHandler.h" +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +const TInt KSegmentTimeout = 1000000; // 1s + +CBTSapRequestHandler::CBTSapRequestHandler(CBTSapServerState& aServerState) + : CActive(EPriorityNormal), + iServerState(aServerState), + iRequestMessage(aServerState.BTSapRequestMessage()) + { + CActiveScheduler::Add(this); + } + +CBTSapRequestHandler::~CBTSapRequestHandler() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] ~CBTSapRequestHandler"))); + + Cancel(); + delete iSegmentTimer; + } + +// --------------------------------------------------------- +// NewL() +// --------------------------------------------------------- +// +CBTSapRequestHandler* CBTSapRequestHandler::NewL(CBTSapServerState& aServerState) + { + CBTSapRequestHandler* self = new (ELeave) CBTSapRequestHandler(aServerState); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// ConstructL +// --------------------------------------------------------- +// +void CBTSapRequestHandler::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapRequestHandler: ConstructL"))); + + iSegmentTimer = CSegmentTimer::NewL(this); + + iStatus = KRequestPending; + SetActive(); + } + +// --------------------------------------------------------- +// DoCancel +// --------------------------------------------------------- +// +void CBTSapRequestHandler::DoCancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapRequestHandler: DoCancel"))); + + TRequestStatus* status = &iStatus; + User::RequestComplete(status, KErrCancel); + } + +// --------------------------------------------------------- +// RunL +// --------------------------------------------------------- +// +void CBTSapRequestHandler::RunL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapRequestHandler: RunL"))); + TInt status = iStatus.Int(); + + if ( status != KErrNone ) + { + HandleSapMessage(EInvalidSegmented); + } + else + { + while (!iRawMessage.IsEmpty()) + { + TValidationResult result = iRawMessage.Validate(); + + if (result == EInvalidSegmented) + { + // start timer if not started + iSegmentTimer->Cancel(); + iSegmentTimer->After(KSegmentTimeout); + break; + } + else + { + // complete message + HandleSapMessage(result); + } + } + } + iStatus = KRequestPending; + SetActive(); + } + +void CBTSapRequestHandler::HandleSapMessage(const TValidationResult aResult) + { + // stop timer + iSegmentTimer->Cancel(); + + iRequestMessage.SetData(iRawMessage.Data()); + //DEB(Hex(_L8("[BTSap] Request: %S"), &iRequestMessage.Data())); + + iRawMessage.Reset(); + + TBTSapServerState nextState = EStateIdle; + + if (aResult == EValidFormat) + { + nextState = KStateByRequest[(TInt)iRequestMessage.MsgID()]; + } + + if (iServerState.HandleStateChangeRequest(nextState) != KErrNone) + { + iServerState.SendErrorResponse(); + + if (nextState != iServerState.CurrentState()) + { + iServerState.ChangeState(nextState); + } + } + else + { + // always change state if request is acceptable + iServerState.ChangeState(nextState); + } + } + +void CBTSapRequestHandler::HandleSapData(const TDes8& aData) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapRequestHandler: HandleSapData"))); + + TInt result = iRawMessage.AppendData(aData); + + if (IsActive() && iStatus == KRequestPending) + { + TRequestStatus* status = &iStatus; + User::RequestComplete(status, result); + } + + } + +void CBTSapRequestHandler::HandleSegmentTimeout() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapRequestHandler: HandleIncompleteMessage"))); + + TValidationResult result = iRawMessage.Validate(); + HandleSapMessage(result); + } + +CBTSapRequestHandler::CSegmentTimer::CSegmentTimer(CBTSapRequestHandler* aRequestHandler) + : CTimer(EPriorityStandard), iRequestHandler(aRequestHandler) + { + CActiveScheduler::Add(this); + } + +CBTSapRequestHandler::CSegmentTimer* CBTSapRequestHandler::CSegmentTimer::NewL( + CBTSapRequestHandler* aRequestHandler) + { + CSegmentTimer* self = new (ELeave) CSegmentTimer(aRequestHandler); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CBTSapRequestHandler::CSegmentTimer::RunL() + { + iRequestHandler->HandleSegmentTimeout(); + } + +// End of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSecurityHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSecurityHandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2004-2008 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: +* This class is for security checking of key length of both encryption and pass keys +* +*/ + + + +// INCLUDE FILES +#include +#include // Needed to check the NOTIFIERS_SUPPORT_PASSKEY_MIN_LENGTH flag +#include +#include + +#include "BTSapSecurityHandler.h" +#include "BTSapHciExtensionMan.h" +#include "debug.h" + +const TInt KRequiredEncryptionKeyLen = 128; + +CBTSapSecurityHandler::CBTSapSecurityHandler() + : CActive(CActive::EPriorityStandard) + { + CActiveScheduler::Add(this); + } + +CBTSapSecurityHandler::~CBTSapSecurityHandler() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] ~CBTSapSecurityHandler"))); + Cancel(); + delete iBtHci; + if(iBtDeviceArray) + { + iBtDeviceArray->ResetAndDestroy(); + delete iBtDeviceArray; + } + delete iBtDevMan; + } + +// --------------------------------------------------------- +// CBTSapSecurityHandler::NewL() +// --------------------------------------------------------- +// +CBTSapSecurityHandler* CBTSapSecurityHandler::NewL() + { + CBTSapSecurityHandler* self = new (ELeave) CBTSapSecurityHandler(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTSapSecurityHandler::ConstructL +// --------------------------------------------------------- +// +void CBTSapSecurityHandler::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: ConstructL"))); + iBtDevMan = CBTEngDevMan::NewL(this); + iBtDeviceArray = new (ELeave) CBTDeviceArray(1); + iBtHci = CBTHciExtensionMan::NewL(); + } + +// --------------------------------------------------------- +// CBTSapSecurityHandler::DoCancel +// --------------------------------------------------------- +// +void CBTSapSecurityHandler::DoCancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: DoCancel"))); + if (iSecurityStatus && iSecurityStatus->Int() == KRequestPending) + { + User::RequestComplete(iSecurityStatus, KErrCancel); + } + } + +// --------------------------------------------------------- +// CBTSapSecurityHandler::RunL +// --------------------------------------------------------- +// +TInt CBTSapSecurityHandler::RunError(TInt aError) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: RunError: %d"), aError)); + + switch(iState) + { + case EEncryptionKeyLength: + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: RunError: Couldn't get EncryptionKeyLength: %d"), aError)); + User::RequestComplete(iSecurityStatus, static_cast (EGetEncryptionKeyFail)); + } + break; + case EPassKeyLength: + { + User::RequestComplete(iSecurityStatus, static_cast (EPassKeyTooShort)); + } + break; + default: + { + User::RequestComplete(iSecurityStatus, aError); + } + } + return KErrNone; + } + + +// --------------------------------------------------------- +// CBTSapSecurityHandler::RunL +// --------------------------------------------------------- +// +void CBTSapSecurityHandler::RunL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: RunL: %d"), iStatus.Int())); + TBTSapSecurityCheckResult result = ESecurityOK; + TBool complete = EFalse; + + User::LeaveIfError(iStatus.Int()); // handle errors in RunError + + switch(iState) + { + case EEncryptionKeyLength: + { + iBtHci->GetResultL(iEncryptionKeyLength); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: RunL: EncryptionKeyLength: %d"), iEncryptionKeyLength)); + + if (iEncryptionKeyLength < KRequiredEncryptionKeyLen) + { + result = EEncryptionKeyTooShort; + complete = ETrue; + } + else + { + ASSERT(iBtDeviceArray); + TBTSockAddr sockAddr; + iSocket->RemoteName(sockAddr); + TBTRegistrySearch criteria; + criteria.FindAddress(sockAddr.BTAddr()); + iBtDeviceArray->ResetAndDestroy(); + iBtDevMan->GetDevices(criteria, iBtDeviceArray); + iState = EPassKeyLength; + iStatus = KRequestPending; + SetActive(); + } + } + break; + case EPassKeyLength: + { + if (!iBtDeviceArray || !iBtDeviceArray->Count()) + { + User::Leave(KErrNotFound); + } + + CBTDevice* device = iBtDeviceArray->At( 0 ); + // When SSP is used, the link key needs to be authenticated, + // otherwise, the passkey needs to be 16 digits. + if( device->LinkKeyType() != ELinkKeyAuthenticated ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: unauthenticated link key"))); + if( !( device->LinkKeyType() == ELinkKeyCombination && + device->PassKeyLength() >= KRequiredPassKeyLen ) ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: unacceptable link key"))); + result = EPassKeyTooShort; + } + else if( device->LinkKeyType() == ELinkKeyDebug ) + { + // For SAP, we do an extra check for debug mode, to be really sure. + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: Debug link key, checking debug mode"))); + TBTSspDebugModeValue debugMode = EBTSspDebugModeOff; + TInt err = RProperty::Get( KPSUidBluetoothTestingMode, KBTSspDebugmode, (TInt&) debugMode ); + if( err || debugMode == EBTSspDebugModeOff ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler: debug key not allowed"))); + result = EPassKeyTooShort; + } + } + } + complete = ETrue; + } + break; + default: + { + User::Leave(KErrNotSupported); + } + } + if (complete) + { + User::RequestComplete(iSecurityStatus, static_cast (result)); + } + } + +// --------------------------------------------------------- +// CBTSapSecurityHandler::CheckSapSecurity +// --------------------------------------------------------- +void CBTSapSecurityHandler::CheckSapSecurity(RSocket& aSocket, TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler::CheckSapSecurity"))); + + iSocket = &aSocket; + iSecurityStatus = &aStatus; + aStatus = KRequestPending; + + TBTSockAddr sockAddr; + aSocket.RemoteName(sockAddr); + + TBTDevAddr btAddr = sockAddr.BTAddr(); + TRAPD(err, iBtHci->GetEncryptionKeyLengthL(btAddr, iStatus)); + if (err) + { + User::RequestComplete(iSecurityStatus, err); + } + else + { + iState = EEncryptionKeyLength; + SetActive(); + } + } + + +// --------------------------------------------------------- +// CBTSapSecurityHandler::HandleGetDevicesComplete, from MBTEngDevManObserver +// --------------------------------------------------------- +void CBTSapSecurityHandler::HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* /*aDeviceArray*/ ) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSecurityHandler::HandleGetDevicesComplete"))); + // Complete our own request -> RunL + TRequestStatus* ownStatus = &iStatus; + User::RequestComplete(ownStatus, aErr); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapServerState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapServerState.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,592 @@ +/* +* Copyright (c) 2004-2006 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: +* This class is a state machine of BTSap Server +* +*/ + + + +// INCLUDE FILES +#include +#include "BTSapDomainPSKeys.h" + +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "BTSapRequestHandler.h" +#include "BTSapSimCardStatusNotifier.h" +#include "debug.h" + +_LIT(KPhoneTsy, "PhoneTsy") ; +_LIT(KDefaultPhone, "DefaultPhone"); + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTSapStatusObserver::CBTSapStatusObserver() +//---------------------------------------------------------- +// +CBTSapStatusObserver::CBTSapStatusObserver(): CActive(CActive::EPriorityStandard) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------- +// CBTSapStatusObserver::NewL() +//---------------------------------------------------------- +// +CBTSapStatusObserver* CBTSapStatusObserver::NewL() + { + CBTSapStatusObserver* self = new(ELeave) CBTSapStatusObserver(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTSapStatusObserver::ConstructL() +//---------------------------------------------------------- +// +void CBTSapStatusObserver::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::ConstructL"))); + + User::LeaveIfError(iProperty.Attach( KPSUidBluetoothSapConnectionState, + KBTSapConnectionState)); + } + +// --------------------------------------------------------- +// CBTSapStatusObserver::~CBTSapStatusObserver +//---------------------------------------------------------- +// +CBTSapStatusObserver::~CBTSapStatusObserver() + { + Cancel(); + iProperty.Close(); + } + +// --------------------------------------------------------- +// CBTSapStatusObserver::StartObservingL() +//---------------------------------------------------------- +// +void CBTSapStatusObserver::SubscribeSapStatusL(MSapStatusObserver* aObserver) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::SubscribeSapStatusL"))); + + ASSERT(aObserver); + + iObserver = aObserver; + + iProperty.Subscribe(iStatus); + SetActive(); + } + + +// --------------------------------------------------------- +// CBTSapStatusObserver::DoCancel() +// --------------------------------------------------------- +// +void CBTSapStatusObserver::DoCancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::DoCancel"))); + + iProperty.Cancel(); + } + +// --------------------------------------------------------- +// CBTSapStatusObserver::RunL() +// --------------------------------------------------------- +// +void CBTSapStatusObserver::RunL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapStatusObserver::RunL"))); + + TInt btSapState; + TInt err = iStatus.Int(); + + iProperty.Subscribe(iStatus); + SetActive(); + + if (!err) + { + err = iProperty.Get(btSapState); + if (!err) + { + iObserver->SapStatusChangedL(btSapState); + } + } + } + +// --------------------------------------------------------- +// CBTSapServerState::CBTSapServerState() +// --------------------------------------------------------- +// +CBTSapServerState::CBTSapServerState(CBTSapPlugin& aBTSapPlugin) + : CActive(CActive::EPriorityStandard), + iBTSapPlugin(aBTSapPlugin), + iCurrentState(EStateInit), + iStatesCreated(EFalse) + { + CActiveScheduler::Add(this); + + _LIT_SECURITY_POLICY_C2(sapConnectionStateReadAndWritePolicy, ECapabilityLocalServices, ECapabilityReadDeviceData); + //_LIT_SECURITY_POLICY_S0(sapConnectionStateWritePolicy, 0x10005950); // BtEngServer SID + + RProperty::Define(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, RProperty::EInt, + sapConnectionStateReadAndWritePolicy, sapConnectionStateReadAndWritePolicy); + } + +// --------------------------------------------------------- +// CBTSapServerState::~CBTSapServerState() +// --------------------------------------------------------- +// +CBTSapServerState::~CBTSapServerState() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::~CBTSapServerState"))); + // Make sure we've cancelled. + Cancel(); + + if (IsSapConnected()) + { + iStateArray[iCurrentState]->NotifySapState(ESapNotConnected); + } + + iStateArray.ResetAndDestroy(); + + delete iSocketHandler; + delete iSimCardStatusNotifier; + delete iRequestHandler; + delete iStatusObserver; + + iSubscriptionModule.Close(); + iPhone.Close(); + iTelServer.UnloadPhoneModule(KPhoneTsy); + iTelServer.Close(); + + RProperty::Delete(KPSUidBluetoothSapConnectionState, KBTSapConnectionState); + } + +// --------------------------------------------------------- +// CBTSapServerState::NewL() +// --------------------------------------------------------- +// +CBTSapServerState* CBTSapServerState::NewL(CBTSapPlugin& aBTSapPlugin) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::NewL"))); + + CBTSapServerState* self = new (ELeave) CBTSapServerState(aBTSapPlugin); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTSapServerState::ConstructL() +// --------------------------------------------------------- +// +void CBTSapServerState::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::ConstructL"))); + + OpenSubscriptionModuleL(); + iRequestHandler = CBTSapRequestHandler::NewL(*this); + iSocketHandler = CBTSapSocketHandler::NewL(*this, *iRequestHandler); + iSimCardStatusNotifier = CBTSapSimCardStatusNotifier::NewL(*this); + iStatusObserver = CBTSapStatusObserver::NewL(); + + TState* state = new (ELeave) TStateInit(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + ChangeState(EStateInit); + } + +// --------------------------------------------------------- +// CBTSapServerState::StartL() +// --------------------------------------------------------- +// +void CBTSapServerState::StartL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::StartL"))); + + // the order matters + TState* state = new (ELeave) TStateNotConnected(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + // The SAP connection is accepted/rejected via a P&S key (KPSUidBluetoothSapConnectionState) + // iStatusObserver monitors P&S key changes and calls AcceptSapConnection or + // RejectSapConnection accordingly. + iStatusObserver->SubscribeSapStatusL(this); + + ChangeState(EStateNotConnected); + } + +// --------------------------------------------------------- +// CBTSapServerState::DoCancel() +// --------------------------------------------------------- +// +void CBTSapServerState::DoCancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::DoCancel"))); + + iStateArray[iCurrentState]->Cancel(); + } + +// --------------------------------------------------------- +// CBTSapServerState::ChangeState +// --------------------------------------------------------- +void CBTSapServerState:: ChangeState(const TBTSapServerState aNextState) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapServerState:: ChangeState: %d"), aNextState)); + + Cancel(); + iCurrentState = aNextState; + iStateArray[iCurrentState]->Enter(iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CBTSapServerState::RunL() +// --------------------------------------------------------- +// +void CBTSapServerState::RunL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::RunL: %d >>"), iStatus.Int())); + + TBTSapServerState nextState = iStateArray[iCurrentState]->Complete(iStatus.Int()); + + // Enter new state + ChangeState(nextState); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: RunL complete <<"))); + } + +// --------------------------------------------------------- +// CBTSapServerState::CurrentState() +// --------------------------------------------------------- +TBTSapServerState CBTSapServerState:: CurrentState() + { + return iCurrentState; + } + +// --------------------------------------------------------- +// CBTSapServerState::AcceptSapConnection() +// --------------------------------------------------------- +// +TInt CBTSapServerState::AcceptSapConnection() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::AcceptSapConnection"))); + + return iStateArray[iCurrentState]->AcceptSapConnection(); + } + +// --------------------------------------------------------- +// CBTSapServerState::RejectSapConnection() +// --------------------------------------------------------- +// +TInt CBTSapServerState:: RejectSapConnection(TBTSapRejectReason aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::RejectSapConnection"))); + + return iStateArray[iCurrentState]->RejectSapConnection(aReason); + } + +// --------------------------------------------------------- +// CBTSapServerState::DisconnectSapConnection() +// --------------------------------------------------------- +// +TInt CBTSapServerState::DisconnectSapConnection(TBTSapDisconnectType aType) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::DisconnectSapConnection: %d"), aType)); + TInt retVal = KErrNotReady; + + if (IsSapConnected()) + { + Cancel(); // Cancel current state + retVal = iStateArray[iCurrentState]->DisconnectSapConnection(aType); + ChangeState(aType == EDisconnectImmediate ? EStateNotConnected : EStateIdle); + } + + return retVal; + } + +// --------------------------------------------------------- +// CBTSapServerState::IsSapConnected() +// --------------------------------------------------------- +// +TBool CBTSapServerState::IsSapConnected() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::IsSapConnected"))); + TBool ret = EFalse; + if (iSocketHandler) + { + ret = iSocketHandler->IsSapConnected(); + } + return ret; + } + +// --------------------------------------------------------- +// CBTSapServerState::GetRemoteBTAddress() +// --------------------------------------------------------- +// +TInt CBTSapServerState::GetRemoteBTAddress(TBTDevAddr& aBTDevAddr) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::GetRemoteBTAddress"))); + + return (iSocketHandler != NULL) ? iSocketHandler->GetRemoteBTAddress(aBTDevAddr) : KErrDisconnected; + } + +// --------------------------------------------------------- +// CBTSapServerState::SimCardStatusChanged() +// --------------------------------------------------------- +// +void CBTSapServerState::SimCardStatusChanged(TCardStatus aCardStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] SapSimCardStatusChanged: %d"), aCardStatus)); + + if (iCurrentState == EStateConnect || + iCurrentState == EStatePowerOn || + iCurrentState == EStateReset) + { + iStateArray[iCurrentState]->SimCardStatusChanged(aCardStatus); + } + else + { + // real indication + Cancel(); + iStateArray[iCurrentState]->SimCardStatusChanged(aCardStatus); + ChangeState(EStateIdle); + } + } + +// --------------------------------------------------------- +// CBTSapServerState::CreateStatesL() +// --------------------------------------------------------- +// +TInt CBTSapServerState::CreateStatesL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::CreateStatesL"))); + + if (!iStatesCreated) + { + // Create SAP states. TStateInit and TStateNotConnected have already been created. + TState* state = new (ELeave) TStateConnect(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStateDisconnect(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStateIdle(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStateAPDU(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStateATR(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStatePowerOff(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStatePowerOn(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStateReset(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + + state = new (ELeave) TStateCardReaderStatus(*this); + CleanupStack::PushL(state); + User::LeaveIfError(iStateArray.Append(state)); + CleanupStack::Pop(state); + } + + iStatesCreated = ETrue; + return KErrNone; + } + +// --------------------------------------------------------- +// CBTSapServerState::ReleaseStatesL() +// --------------------------------------------------------- +// +TInt CBTSapServerState::ReleaseStatesL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::ReleaseStatesL"))); + // Delete SAP states, all except TStateInit and TStateNotConnected. + for(TInt i = iStateArray.Count() - 1; i >= 2; i--) + { + delete iStateArray[i]; + iStateArray[i] = NULL; + iStateArray.Remove(i); + } + + iStatesCreated = EFalse; + return KErrNone; + } + +// --------------------------------------------------------- +// CBTSapServerState::DisconnectCompleteL() +// --------------------------------------------------------- +// +TInt CBTSapServerState::DisconnectCompleteL(TInt aErr) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::DisconnectCompleteL"))); + iBTSapPlugin.OperationCompletedL(MSapAsyncObserver::EDisconnect, aErr); + return KErrNone; + } + +// --------------------------------------------------------- +// CBTSapServerState::HandleStateChangeRequest() +// --------------------------------------------------------- +// +TInt CBTSapServerState::HandleStateChangeRequest(TBTSapServerState& aNextState) + { + return iStateArray[iCurrentState]->ChangeState(aNextState); + } + +// --------------------------------------------------------- +// CBTSapServerState::SendErrorResponse() +// --------------------------------------------------------- +// +void CBTSapServerState::SendErrorResponse() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::SendErrorResponse"))); + + // set response: error_response + iResponseMessage.SetMsgID(EErrorResponse); + iSocketHandler->Send(iResponseMessage.Data()); + } + +// --------------------------------------------------------- +// CBTSapServerState::OpenSubscriptionModuleL() +// --------------------------------------------------------- +// +void CBTSapServerState::OpenSubscriptionModuleL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::OpenSubscriptionModuleL"))); + + User::LeaveIfError(iTelServer.Connect()); + User::LeaveIfError(iTelServer.LoadPhoneModule(KPhoneTsy)); // Load Custom API Extension + User::LeaveIfError(iPhone.Open( iTelServer, KDefaultPhone)); + User::LeaveIfError(iSubscriptionModule.Open(iPhone)); + } + +// --------------------------------------------------------- +// CBTSapServerState::BTSapSocketHandler() +// --------------------------------------------------------- +// +CBTSapSocketHandler& CBTSapServerState::BTSapSocketHandler() + { + return *iSocketHandler; + } + +// --------------------------------------------------------- +// CBTSapServerState::BTSapSimCardStatusNotifier() +// --------------------------------------------------------- +// +CBTSapSimCardStatusNotifier& CBTSapServerState::BTSapSimCardStatusNotifier() + { + return *iSimCardStatusNotifier; + } + +// --------------------------------------------------------- +// CBTSapServerState::SubscriptionModule() +// --------------------------------------------------------- +// +RMmCustomAPI& CBTSapServerState::SubscriptionModule() + { + return iSubscriptionModule; + } + +// --------------------------------------------------------- +// CBTSapServerState::BTSapRequestMessage() +// --------------------------------------------------------- +// +TBTSapMessage& CBTSapServerState::BTSapRequestMessage() + { + return iRequestMessage; + } + +// --------------------------------------------------------- +// CBTSapServerState::BTSapResponseMessage() +// --------------------------------------------------------- +// +TBTSapMessage& CBTSapServerState::BTSapResponseMessage() + { + return iResponseMessage; + } + +// --------------------------------------------------------- +// CBTSapServerState::SapStatusChangedL() +// --------------------------------------------------------- +// +void CBTSapServerState::SapStatusChangedL(TInt aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::SapStatusChangedL"))); + + switch (aStatus) + { + case EBTSapNotConnected: + case EBTSapConnecting: + { + // no actions + break; + } + case EBTSapConnected: + { + // Inform observers + iBTSapPlugin.ConnectComplete(); + break; + } + case EBTSapAccepted: + { + AcceptSapConnection(); + break; + } + case EBTSapRejected: + { + RejectSapConnection(ERejectGeneralError); + break; + } + default: + { + // An error or invalid state + RejectSapConnection(ERejectGeneralError); + break; + } + } + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSession.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 2004 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: +* SAP Server session definition. +* +*/ + +// INCLUDE FILES +#include +#include "BTSapSession.h" +#include "BTSapServer.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code that +// might leave. + +// constructor - must pass client to CSession +CBTSapSession::CBTSapSession() + { + } + +// destructor +CBTSapSession::~CBTSapSession() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSession::~CBTSapSession"))); + TRAPD(err, Server().SessionClosedL()); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, + BTSapPrintTrace(_L("[BTSap] CBTSapSession::~CBTSapSession: Error when closing the session! %d"), err)); + } + } + +// Two-phased constructor. +CBTSapSession* CBTSapSession::NewL() + { + return new (ELeave) CBTSapSession(); + } + +void CBTSapSession::CreateL() + { + Server().SessionOpened(); + } + +// --------------------------------------------------------- +// Server +// Return a reference to CBTSapServer +// --------------------------------------------------------- +CBTSapServer& CBTSapSession::Server() + { + return *STATIC_CAST(CBTSapServer*, CONST_CAST(CServer2*, CSession2::Server())); + } + +// --------------------------------------------------------- + +// --------------------------------------------------------- +// ServiceL +// Calls DispatchMessage under trap harness +// +// --------------------------------------------------------- +void CBTSapSession::ServiceL(const RMessage2& aMessage) + { + TRAPD(err, DispatchMessageL(aMessage)); + + if(err == KErrPermissionDenied) + { + // Fail if the client doesn't have the required capabilities + aMessage.Complete(err); + } + else if (err != KErrNone) + { + // A bad descriptor error implies a badly programmed client, so panic it; + PanicClient(aMessage, err); + } + } + +// --------------------------------------------------------- +// DispatchMessageL +// service a client request; test the opcode and then do +// appropriate servicing +// +// --------------------------------------------------------- +void CBTSapSession::DispatchMessageL(const RMessage2 &aMessage) + { + TInt retVal = KErrNone; + + // Leave with KErrPermissionDenied if the client doesn't have Local Services capability + aMessage.HasCapabilityL(ECapabilityLocalServices); + + switch (aMessage.Function()) + { + case EBTSapManageService: + { + retVal = Server().ManageService(aMessage.Int0()); + aMessage.Complete(retVal); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSession: ManageServiceL: %d"), retVal)); + break; + } + + case EBTSapAcceptSapConnection: + { + retVal = Server().AcceptSapConnection(); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSession: AcceptSapConnection: %d"), retVal)); + aMessage.Complete(retVal); + break; + } + + case EBTSapRejectSapConnection: + { + TBTSapRejectReason reason = STATIC_CAST(TBTSapRejectReason, aMessage.Int0()); + retVal = Server().RejectSapConnection(reason); + aMessage.Complete(retVal); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSession: RejectSapConnection: %d"), retVal)); + break; + } + + case EBTSapDisconnectSapConnection: + { + TBTSapDisconnectType type = STATIC_CAST(TBTSapDisconnectType, aMessage.Int0()); + retVal = Server().DisconnectSapConnection(type); + aMessage.Complete(retVal); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSession: DisconnectSapConnection: %d"), retVal)); + break; + } + + case EBTSapIsConnected: + { + retVal = Server().IsSapConnected(); + aMessage.Complete(retVal); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSession: IsSapConnected: %d"), retVal)); + break; + } + + case EBTSapGetRemoteBTAddress: + { + TBTDevAddr addr; + retVal = Server().GetRemoteBTAddress(addr); + + TBTDevAddrPckgBuf pckg(addr); + aMessage.WriteL(0, pckg); + aMessage.Complete(retVal); + + TBuf<12> buf; + addr.GetReadable(buf); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSession: GetRemoteBTAddress: %d, addr: %S"), retVal, &buf)); + break; + } + + default: + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSession: DispatchMessage: Bad request #"))); + User::Leave(KErrNotSupported); + break; + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSimCardStatusNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSimCardStatusNotifier.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2004 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: +* This class handles SIM card status change notification +* +* +*/ + + +// INCLUDE FILES +#include "BTSapSimCardStatusNotifier.h" +#include "BTSapServerState.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBTSapSimCardStatusNotifier::CBTSapSimCardStatusNotifier(CBTSapServerState& aBTSapServerState) + : CActive(EPriorityNormal), + iBTSapServerState(aBTSapServerState), + iSubscriptionModule(aBTSapServerState.SubscriptionModule()) + { + CActiveScheduler::Add(this); + } + +// Destructor. +CBTSapSimCardStatusNotifier::~CBTSapSimCardStatusNotifier() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] ~CBTSapSimCardStatusNotifier"))); + Cancel(); + } + +// --------------------------------------------------------- +// NewL() +// --------------------------------------------------------- +// +CBTSapSimCardStatusNotifier* CBTSapSimCardStatusNotifier::NewL(CBTSapServerState& aBTSapServerState) + { + CBTSapSimCardStatusNotifier* self = new (ELeave) CBTSapSimCardStatusNotifier(aBTSapServerState); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// ConstructL +// --------------------------------------------------------- +// +void CBTSapSimCardStatusNotifier::ConstructL() + { + } + +// --------------------------------------------------------- +// DoCancel +// --------------------------------------------------------- +// +void CBTSapSimCardStatusNotifier::DoCancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSimCardStatusNotifier: DoCancel"))); + iSubscriptionModule.CancelAsyncRequest(ECustomNotifySimCardStatusIPC); + } + +// --------------------------------------------------------- +// RunL +// --------------------------------------------------------- +// +void CBTSapSimCardStatusNotifier::RunL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSimCardStatusNotifier: RunL: %d, CardStatus: %d"), iStatus.Int(), iCardStatus)); + iBTSapServerState.SimCardStatusChanged(TCardStatus(iCardStatus)); + + iSubscriptionModule.NotifySimCardStatus(iStatus, iCardStatus); + SetActive(); + } + +// --------------------------------------------------------- +// Start +// --------------------------------------------------------- +void CBTSapSimCardStatusNotifier::Start() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSimCardStatusNotifier: Start"))); + + iSubscriptionModule.NotifySimCardStatus(iStatus, iCardStatus); + SetActive(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSniffHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSniffHandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,210 @@ +/* +* Copyright (c) 2004 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: +* This class implements a handler, which sets the physical link to +* sniff-mode when the SAP link is inactive for some time +* +*/ + + +// INCLUDE FILES +#include "BTSapSniffHandler.h" +#include "debug.h" + +// Sniff timer interval in microseconds +const TInt KSniffInterval = 3000000; // 3 seconds + +CBTSapSniffHandler::CBTSapSniffHandler(RSocket& aSocket, RSocketServ& aSocketServer) + : CTimer(EPriorityStandard), + iSocket(aSocket), + iSocketServer(aSocketServer), + iIsLinkAdapterOpen(EFalse) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler"))); + + CActiveScheduler::Add(this); + } + +CBTSapSniffHandler::~CBTSapSniffHandler() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] ~CBTSapSniffHandler"))); + + if(iIsLinkAdapterOpen) + { + // Now we can allow sniff-mode again + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] ~CBTSapSniffHandler Allowing LowPowerModes"))); + TInt err = iBTLinkAdapter.AllowLowPowerModes(ESniffMode); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] ~CBTSapSniffHandler: Couldn't allow sniff-mode %d"), err)); + } + iBTLinkAdapter.Close(); + } + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] ~CBTSapSniffHandler Stopping the sniff-timer"))); + Cancel(); + } + + +// --------------------------------------------------------- +// NewL() +// --------------------------------------------------------- +// +CBTSapSniffHandler* CBTSapSniffHandler::NewL(RSocket& aSocket, RSocketServ& aSocketServer) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::NewL"))); + + CBTSapSniffHandler* self = new (ELeave) CBTSapSniffHandler(aSocket, aSocketServer); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// Enable +// --------------------------------------------------------- +// +void CBTSapSniffHandler::Enable() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable"))); + TInt err; + + if(!iIsLinkAdapterOpen) + { + err = iBTLinkAdapter.Open(iSocketServer, iSocket); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: Couldn't open iBTLinkAdapter %d"))); + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: iBTLinkAdapter opened"))); + iIsLinkAdapterOpen = ETrue; + } + } + + if(iIsLinkAdapterOpen) + { + // Start the sniffer timer + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: Starting the sniff timer %d µsec"), KSniffInterval)); + Cancel(); + After(KSniffInterval); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: Cancelling LowPowerModeRequester"))); + err = iBTLinkAdapter.CancelLowPowerModeRequester(); + if(err == KErrNone) + { + // We don't want to go to sniff-mode while our timer is running, so we prevent low-power modes here + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: Preventing LowPowerModes"))); + err = iBTLinkAdapter.PreventLowPowerModes(EAnyLowPowerMode); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: Couldn't prevent low-power modes %d"), err)); + } + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Enable: Couldn't cancel sniff requester %d"), err)); + } + } + } + +// --------------------------------------------------------- +// Disable +// --------------------------------------------------------- +// +void CBTSapSniffHandler::Disable() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Disable"))); + + // Stop the timer + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Disable: Stopping the sniff-timer"))); + Cancel(); + + // If the adapter is not open, we don't need to do anything + if(iIsLinkAdapterOpen) + { + // When the sniffer is disabled, we should allow sniff-mode again + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Disable: Allowing LowPowerModes"))); + TInt err = iBTLinkAdapter.AllowLowPowerModes(ESniffMode); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Disable: Couldn't allow sniff-mode %d"), err)); + } + // And then close the physical link adapter + iBTLinkAdapter.Close(); + iIsLinkAdapterOpen = EFalse; + } + } + +// --------------------------------------------------------- +// Pause +// --------------------------------------------------------- +// +void CBTSapSniffHandler::Pause() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Pause"))); + TInt err; + + // Stop the timer + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Pause: Stopping the sniff-timer"))); + Cancel(); + + if(iIsLinkAdapterOpen) + { + // When the sniffer is paused, we are probably handling some requests, so we prevent sniff-mode + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Pause: Preventing LowPowerModes"))); + err = iBTLinkAdapter.PreventLowPowerModes(EAnyLowPowerMode); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::Pause: Couldn't prevent low-power modes %d"), err)); + } + } + } + +// --------------------------------------------------------- +// RunL +// --------------------------------------------------------- +// +void CBTSapSniffHandler::RunL() + { + TInt status = iStatus.Int(); + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler: RunL: %d"), status)); + + TInt err; + + if(iIsLinkAdapterOpen) + { + // Now we can allow sniff-mode again + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::RunL: Allowing LowPowerModes"))); + err = iBTLinkAdapter.AllowLowPowerModes(ESniffMode); + if(err == KErrNone) + { + // Start the sniff-mode requester + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::RunL: Activating SniffRequester"))); + err = iBTLinkAdapter.ActivateSniffRequester(); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::RunL: Couldn't activate the sniff requester %d"), err)); + } + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSniffHandler::RunL: Couldn't allow sniff-mode %d"), err)); + } + } + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSocketHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSocketHandler.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,336 @@ +/* +* Copyright (c) 2004-2008 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: +* This class handles data exchange between BTSap server and client +* +*/ + + +// INCLUDE FILES +#include +#include // Needed to check the NOTIFIERS_SUPPORT_PASSKEY_MIN_LENGTH flag +#include +#include +#include "BTSapSocketHandler.h" +#include "BTSapServerState.h" +#include "BTSapSecurityHandler.h" +#include "debug.h" + +// Old versions of RAN always try to connect to the same channel after pairing +// To solve this problem, we try to use always the same channel +const TUint KBTSapProposedChannel = 21; // 21 is big enough and my lucky number ;) +const TInt KListenQueSize = 1; + +CBTSapSocketHandler::CBTSapSocketHandler(CBTSapServerState& aServerState, CBTSapRequestHandler& aRequestHandler) + : CActive(CActive::EPriorityHigh), + iServerState(aServerState), + iChannel(0), + iStateListen(iSockServ, iSocket, iListener, iChannel), + iStateRecv(iSocket, aRequestHandler, &iSniffHandler), + iStateSend(iSocket), + iStateCheckSecurity(iSocket, iSecurityHandler), + iCurrentState(EBTSapSocketStateListen), + iNextState(EBTSapSocketStateRecv) + { + iStateArray.Append(&iStateListen); + iStateArray.Append(&iStateRecv); + iStateArray.Append(&iStateSend); + iStateArray.Append(&iStateCheckSecurity); + + CActiveScheduler::Add(this); + } + +// Destructor. +CBTSapSocketHandler::~CBTSapSocketHandler() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] ~CBTSapSocketHandler"))); + + Cancel(); + iStateArray.Close(); + + TRAPD(err, UnregisterBTSapServiceL()); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] ~CBTSapSocketHandler - Couldn't unregister SAP Service!!!"))); + } + + delete iSecurityHandler; + iSocket.Close(); + iListener.Close(); + iSockServ.Close(); + delete iBtDiscovery; + delete iSniffHandler; + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::NewL() +// --------------------------------------------------------- +// +CBTSapSocketHandler* CBTSapSocketHandler::NewL(CBTSapServerState& aServerState, CBTSapRequestHandler& aRequestHandler) + { + CBTSapSocketHandler* self = new (ELeave) CBTSapSocketHandler(aServerState, aRequestHandler); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::ConstructL +// --------------------------------------------------------- +// +void CBTSapSocketHandler::ConstructL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: ConstructL"))); + + RegisterBTSapServiceL(); + + iSecurityHandler = CBTSapSecurityHandler::NewL(); + // Now create the Sniff Handler + iSniffHandler = CBTSapSniffHandler::NewL(iSocket, iSockServ); + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::DoCancel +// --------------------------------------------------------- +// +void CBTSapSocketHandler::DoCancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: DoCancel"))); + iStateArray[iCurrentState]->Cancel(); + } + +// --------------------------------------------------------- +// RunL +// --------------------------------------------------------- +// +void CBTSapSocketHandler::RunL() + { + TInt status = iStatus.Int(); + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: RunL: %d"), status)); + TBool disconnecting = EFalse; + + if (iNextState == EBTSapSocketStateListen) + { + // In case we are here, we are disconnecting existing connection + disconnecting = ETrue; + } + + if (status >= KErrNone) + { + TBTSapSocketState nextState = iStateArray[iCurrentState]->Complete(status); + + if (iCurrentState == EBTSapSocketStateListen) + { + // The remote side has created SAP connection + // In order to save RAM, the SAP states are not created until here + iServerState.CreateStatesL(); + } + + if (iNextState == EBTSapSocketStateRecv) + { + iNextState = nextState; + } + + ChangeState(); + } + else + { + // BT link loss or other socket errors + iCurrentState = EBTSapSocketStateRecvWrong; + iServerState.ChangeState(EStateNotConnected); + } + + if (disconnecting) + { + // Disconnect has been completed, notify caller + iServerState.DisconnectCompleteL(status); + } + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::Listen +// --------------------------------------------------------- +void CBTSapSocketHandler::Listen() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: Listen"))); + + iNextState = EBTSapSocketStateListen; + + if (iCurrentState != EBTSapSocketStateSend) + { + Cancel(); + ChangeState(); + } + + // In order to save RAM, release the SAP states here and create + // them when the connection has been created. + TRAP_IGNORE( iServerState.ReleaseStatesL() ); + + // Make sure the sniffer is disabled when we're listening for an incoming connection + iSniffHandler->Disable(); + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::Send +// --------------------------------------------------------- +void CBTSapSocketHandler::Send(const TDes8& aResponseData) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: Send"))); + + if (iCurrentState == EBTSapSocketStateRecv || + iCurrentState == EBTSapSocketStateSend) + { + iStateSend.SetResponseData(aResponseData); + iNextState = EBTSapSocketStateSend; + + if (iCurrentState == EBTSapSocketStateRecv) + { + Cancel(); + ChangeState(); + } + } + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::GetRemoteBTAddress +// --------------------------------------------------------- +TInt CBTSapSocketHandler::GetRemoteBTAddress(TBTDevAddr& aBTDevAddr) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: GetRemoteBTAddress >>"))); + TInt retVal = KErrDisconnected; + + if (iCurrentState == EBTSapSocketStateRecv || + iCurrentState == EBTSapSocketStateSend) + { + TBTSockAddr addr; + iSocket.RemoteName(addr); + aBTDevAddr = addr.BTAddr(); + retVal = KErrNone; + } + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: GetRemoteBTAddress: %d"), retVal)); + return retVal; + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::IsSapConnected +// --------------------------------------------------------- +TBool CBTSapSocketHandler::IsSapConnected() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::IsSapConnected"))); + return (iCurrentState != EBTSapSocketStateListen); + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::ChangeState +// --------------------------------------------------------- +void CBTSapSocketHandler::ChangeState() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: ChangeState: %d"), iNextState)); + + iCurrentState = iNextState; + iNextState = EBTSapSocketStateRecv; + iStateArray[iCurrentState]->Enter(iStatus); + SetActive(); + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::RegisterBTSapServiceL +// --------------------------------------------------------- +void CBTSapSocketHandler::RegisterBTSapServiceL() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::RegisterBTSapServiceL"))); + + User::LeaveIfError(iSockServ.Connect()); + TProtocolDesc pInfo; + iBtDiscovery = CBTEngDiscovery::NewL(); + TInt err = KErrNone; + + // Old version of RAN always use the same channel, so try to get a fixed one + iChannel = KBTSapProposedChannel; + + User::LeaveIfError(iSockServ.FindProtocol(TProtocolName(KRFCOMMDesC), pInfo)); // Or other protocol + User::LeaveIfError(iListener.Open( iSockServ, pInfo.iAddrFamily, pInfo.iSockType, pInfo.iProtocol)); + + TRfcommSockAddr addr; + TBTServiceSecurity sec; + + sec.SetAuthentication( EMitmRequired ); + sec.SetAuthorisation(ETrue); + sec.SetEncryption(ETrue); + sec.SetPasskeyMinLength(KRequiredPassKeyLen); + addr.SetSecurity(sec); + addr.SetPort(iChannel); + + // On return, _should_ contain a free RFCOMM port + err = iListener.Bind(addr); + + if(err) + { + TInt freeChnl; + err = iListener.GetOpt(KRFCOMMGetAvailableServerChannel, KSolBtRFCOMM, freeChnl); + if (err == KErrNone) + { + err = iListener.SetLocalPort(freeChnl); + iChannel = freeChnl; + } + } + if(err) + { + // Try to bind using KRfcommPassiveAutoBind + iChannel = KRfcommPassiveAutoBind; + addr.SetPort(iChannel); + err = iListener.Bind(addr); + } + + if (!err) + { + // Update with the actual value + iChannel = iListener.LocalPort(); + + // Set the socket to listening + User::LeaveIfError(iListener.Listen(KListenQueSize)); + } + else + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler: RegisterBTSapServiceL: Couldn't register dynamic channel!!! (err = %d)"), err)); + User::Leave( err ); + } + + // register BTSap service profile + TUUID uuid(EBTProfileSAP); + User::LeaveIfError( iBtDiscovery->RegisterSdpRecord(uuid, iChannel, iSdpHandle) ); + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::UnregisterBTSapServiceL +// --------------------------------------------------------- +void CBTSapSocketHandler::UnregisterBTSapServiceL() + { + if(iSdpHandle) + { + User::LeaveIfError(iBtDiscovery->DeleteSdpRecord(iSdpHandle)); + } + } + +// --------------------------------------------------------- +// CBTSapSocketHandler::TState::TState +// --------------------------------------------------------- +CBTSapSocketHandler::TState::TState(RSocket& aSocket) + : iSocket(aSocket) + { + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSocketStateCheckSecurity.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSocketStateCheckSecurity.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapSocketHandler's state for security checking (length of +* encryption key and pass key) +* +* +*/ + + +// INCLUDE FILES +#include "BTSapSecurityHandler.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapSocketHandler::TStateCheckSecurity::TStateCheckSecurity(RSocket& aSocket, CBTSapSecurityHandler*& aSecurityHandler) + : TState(aSocket), iSecurityHandler(aSecurityHandler) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapSocketHandler::TStateCheckSecurity:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateCheckSecurity: Enter"))); + + iSecurityHandler->CheckSapSecurity(iSocket, aStatus); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// -------------------------------------------------------------------------------------------- +// +TBTSapSocketState CBTSapSocketHandler::TStateCheckSecurity::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateCheckSecurity: Complete"))); + + TBTSapSecurityCheckResult result = TBTSapSecurityCheckResult(aReason); + + switch (result) + { + case EEncryptionKeyTooShort: + // start notifer here + break; + + case EPassKeyTooShort: + // start notifier here + break; + + default: + break; + } + + return (result == ESecurityOK ? EBTSapSocketStateRecv : EBTSapSocketStateListen); + } + +void CBTSapSocketHandler::TStateCheckSecurity::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateCheckSecurity: Cancel"))); + + iSecurityHandler->Cancel(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSocketStateListen.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSocketStateListen.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapSocketHandler's state for Listenning incoming SAP connection +* +* +*/ + + +// INCLUDE FILES +#include +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapSocketHandler::TStateListen::TStateListen( + RSocketServ& aSockServ, RSocket& aSocket, RSocket& aListener, TUint aChannel) + : TState(aSocket), iSockServ(aSockServ), iListener(aListener), iChannel(aChannel) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapSocketHandler::TStateListen::Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateListen::Enter"))); + + iSocket.Close(); // make sure it won't be opened twice + // Open a blank socket (an incoming connection will be transferred to this socket) + TInt err = iSocket.Open(iSockServ); + if (err) + { + TRequestStatus* status = &aStatus; + User::RequestComplete(status, err); + return; + } + // Pass the blank socket to the listening socket + iListener.Accept(iSocket, aStatus); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// -------------------------------------------------------------------------------------------- +// +TBTSapSocketState CBTSapSocketHandler::TStateListen::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateListen: Complete"))); + +#ifdef _BTSAP_MT + // this is for easy module testing + TBuf<16> name; + _LIT(KSapModuleTestName, "Mu-Sap-MT"); + + CBTMCMSettings::GetLocalBTName(name); + DEB(Fmt(_L("[BTSap] CBTSapSocketHandler::TStateListen: local name: %S"), &name)); + + if (name == KSapModuleTestName) return EBTSapSocketStateRecv; +#endif + + return EBTSapSocketStateCheckSecurity; + } + +void CBTSapSocketHandler::TStateListen::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateListen: Cancel"))); + + iListener.CancelAccept(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSocketStateRecv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSocketStateRecv.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapSocketHandler's state for receiving incoming SAP connection +* +*/ + +// INCLUDE FILES + +#include "BTSapSocketHandler.h" +#include "BTSapRequestHandler.h" +#include "debug.h" + +CBTSapSocketHandler::TStateRecv::TStateRecv(RSocket& aSocket, + CBTSapRequestHandler& aRequestHandler, + CBTSapSniffHandler** aSniffHandler) + : TState(aSocket), + iRequestHandler(aRequestHandler), + iSniffHandler(aSniffHandler) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapSocketHandler::TStateRecv:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateRecv: Enter"))); + + // Start the sniffer, which will enter sniff-mode after time-out + (*iSniffHandler)->Enable(); + + iRequestData.SetLength(0); + iSocket.RecvOneOrMore(iRequestData, 0, aStatus, iSockXfrLength); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapSocketState CBTSapSocketHandler::TStateRecv::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateRecv: Complete"))); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] Recv: %S"), &iRequestData)); + + // We pause the sniffer, to allow time for the response to be sent + (*iSniffHandler)->Pause(); + + iRequestHandler.HandleSapData(iRequestData); + return EBTSapSocketStateRecv; + } + +void CBTSapSocketHandler::TStateRecv::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateRecv: Cancel"))); + + iSocket.CancelRecv(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapSocketStateSend.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapSocketStateSend.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapSocketHandler's state for sending incoming SAP connection +* +* +*/ + +// INCLUDE FILES +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapSocketHandler::TStateSend::TStateSend(RSocket& aSocket) + : TState(aSocket) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapSocketHandler::TStateSend:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateSend: Enter: msg size: %d"), iResponseData.Length())); + + iSocket.Write(iResponseData, aStatus); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] Send: %S"), &iResponseData)); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapSocketState CBTSapSocketHandler::TStateSend::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateSend: Complete"))); + + return EBTSapSocketStateRecv; + } + +void CBTSapSocketHandler::TStateSend::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] CBTSapSocketHandler::TStateSend: Cancel"))); + + iSocket.CancelSend(); + } + +void CBTSapSocketHandler::TStateSend::SetResponseData(const TDesC8& aResponseData) + { + iResponseData = aResponseData; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapState.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,178 @@ +/* +* Copyright (c) 2004-2006 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: +* This class is a base state class for all BTSap states +* +* +*/ + + + +// INCLUDE FILES +#include +#include +#include "BTSapDomainPSKeys.h" + +#include +#include "BTSapServerState.h" +#include "debug.h" + +CBTSapServerState::TState::TState(CBTSapServerState& aServerState) +: iSimStatus(0), + iServerState(aServerState), + iResponseMessage(aServerState.BTSapResponseMessage()), + iStatus(NULL) + { + } + +TInt CBTSapServerState::TState::AcceptSapConnection() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TState: AcceptSapConnection: Not Ready#"))); + return KErrNotReady; + } + +TInt CBTSapServerState::TState::RejectSapConnection(TBTSapRejectReason /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TState: RejectSapConnection: Not Ready#"))); + return KErrNotReady; + } + +TInt CBTSapServerState::TState::DisconnectSapConnection(TBTSapDisconnectType /*aType*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TState: DisconnectSapConnection: Not Ready#"))); + return KErrNotReady; + } + +void CBTSapServerState::TState::SimCardStatusChanged(TCardStatus /*aCardStatus*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TState: SimCardStatusChanged: Not Ready#"))); + } + +TInt CBTSapServerState::TState::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNone; + + if (aNextState != EStatePowerOff && + aNextState != EStateReset && + aNextState != EStateDisconnect) + { + aNextState = EStateIdle; + retVal = KErrNotSupported; + } + + return retVal; + } + +void CBTSapServerState::TState::NotifySapState(TSapConnectionState aState) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] NotifySapState: %d"), aState)); + + TBool simPresent = IsSimPresent(); + + switch(aState) + { + case ESapNotConnected: + { + // If the next state is ESapNotConnected, we need to verify the previous state + TInt previousState; + RProperty::Get(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, previousState); + + // Only show NotConnected if the previous state was connecting (ie. connection failed) + if(previousState == ESapConnecting) + { + if( simPresent ) + { + StartBTNotifier(EBTSapFailed); + } + else + { + // Notify the user of the specific reason that connection + // could not be completed: there is no SIM present + StartBTNotifier(EBTSapNoSim); + } + } + break; + } + + case ESapConnecting: + { + if( simPresent ) + { + // Don't show the note if no SIM is present + StartBTNotifier(EBTEnterSap); + } + break; + } + case ESapConnected: + StartBTNotifier(EBTSapOk); + break; + + default: + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] Invalid state!!! %d"), aState)); + break; + } + + RProperty::Set(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, aState); + } + +void CBTSapServerState::TState::StartBTNotifier(TInt note) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] StartBTNotifier: %d"), note)); + + RNotifier notifier; + TInt err = notifier.Connect(); + if(err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] NotifySapState: Couldn't connect to notifier: %d"), err)); + } + else + { + TBTGenericInfoNotiferParamsPckg type; + type().iMessageType = (TBTGenericInfoNoteType) note; + + err = notifier.StartNotifier(KBTGenericInfoNotifierUid, type); + + if (err != KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] NotifySapState: Couldn't start notifier: err = %d"), err)); + } + + notifier.Close(); + } + } + +TBool CBTSapServerState::TState::IsSimPresent() + { +#ifdef __WINS__ + + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::TStateConnect::IsSimPresent ON THE WINS SIDE"))); + return ETrue; + +#else //__WINS__ + + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::TStateConnect::IsSimPresent, SimStatus: %d"), iSimStatus)); + + TInt err = KErrNone; + if( iSimStatus == 0 ) + { + err = RProperty::Get(KPSUidStartup, KPSSimStatus, iSimStatus); + } + TBool retVal = !(err || iSimStatus == ESimNotPresent || iSimStatus == ESimNotSupported); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TStateConnect::IsSimPresent: err = %d, retVal = %d"), err, retVal)); + return retVal; + +#endif //__WINS__ + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateAPDU.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateAPDU.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2004-2005 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: +* This class is a BTSapServer's state for setting up connection with SAP client +* +*/ + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStateAPDU::TStateAPDU(CBTSapServerState& aServerState) + : TStateIdle(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateAPDU::Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateAPDU::Enter"))); + + iStatus = &aStatus; + TInt retValue = iServerState.BTSapRequestMessage().GetParameter(EParaCommandAPDU, iApduParameters.iCmdData); + if(retValue == KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] TStateAPDU:: iApduCmd %S"), &iApduParameters.iCmdData)); + } + else + { + iServerState.BTSapRequestMessage().GetParameter(EParaCommandAPDU7816, iApduParameters.iCmdData); + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] TStateAPDU:: iApduCmd (7816) %S"), &iApduParameters.iCmdData)); + } + + iServerState.SubscriptionModule().SendAPDUReq(aStatus, iApduParameters); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] TStateAPDU::Enter iApduRsp %S"), &iApduParameters.iRspData)); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateAPDU::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap] TStateAPDU::Complete iApduRsp %S"), &iApduParameters.iRspData)); + + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L8("[BTSap] TStateAPDU::Complete aReason %d"), aReason)); + + iResponseMessage.SetMsgID(ETransferAPDUResponse); + iResponseMessage.AddParameter(EParaResultCode, iResponseMessage.ToResultCode(aReason)); + + if(iResponseMessage.ToResultCode(aReason) == EResultCodeOK) + { + iResponseMessage.AddParameter(EParaResponseAPDU, iApduParameters.iRspData); + } + + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + return EStateIdle; + } + +void CBTSapServerState::TStateAPDU::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateAPDU: Cancel"))); + + iServerState.SubscriptionModule().CancelAsyncRequest(ECustomSendAPDUReqV2IPC); + TStateIdle::Cancel(); + } + +TInt CBTSapServerState::TStateAPDU::ChangeState(TBTSapServerState& aNextState) + { + return TState::ChangeState(aNextState); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateATR.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateATR.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapSocketHandler.h" +#include "BTSapServerState.h" +#include "debug.h" + +CBTSapServerState::TStateATR::TStateATR(CBTSapServerState& aServerState) + : TStateIdle(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateATR:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateATR: Enter"))); + + iStatus = &aStatus; + iATR.Zero(); + iServerState.SubscriptionModule().GetATR(aStatus, iATR); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateATR::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateATR: Complete"))); + + iResponseMessage.SetMsgID(ETransferATRResponse); + iResponseMessage.AddParameter(EParaResultCode, iResponseMessage.ToResultCode(aReason)); + + if (aReason == EResultCodeOK) + { + iResponseMessage.AddParameter(EParaATR, iATR); + } + + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + return EStateIdle; + } + +void CBTSapServerState::TStateATR::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateATR: Cancel"))); + + iServerState.SubscriptionModule().CancelAsyncRequest(ECustomGetATRIPC); + TStateIdle::Cancel(); + } + +TInt CBTSapServerState::TStateATR::ChangeState(TBTSapServerState& aNextState) + { + return TState::ChangeState(aNextState); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateCardReaderStatus.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateCardReaderStatus.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStateCardReaderStatus::TStateCardReaderStatus(CBTSapServerState& aServerState) + : TStateIdle(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateCardReaderStatus:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateCardReaderStatus: Enter"))); + + iStatus = &aStatus; + iServerState.SubscriptionModule().GetSimCardReaderStatus(aStatus, iCardReaderStatus); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateCardReaderStatus::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateCardReaderStatus: Complete"))); + + iResponseMessage.SetMsgID(ETransferCardReaderStatusResponse); + iResponseMessage.AddParameter(EParaResultCode, iResponseMessage.ToResultCode(aReason)); + iResponseMessage.AddParameter(EParaCardReaderStatus, iCardReaderStatus.GetStatus()); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + return EStateIdle; + } + +void CBTSapServerState::TStateCardReaderStatus::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateCardReaderStatus: Cancel"))); + + iServerState.SubscriptionModule().CancelAsyncRequest(ECustomGetSimCardReaderStatusIPC); + TStateIdle::Cancel(); + } + +TInt CBTSapServerState::TStateCardReaderStatus::ChangeState(TBTSapServerState& aNextState) + { + return TState::ChangeState(aNextState); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateConnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateConnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,267 @@ +/* +* Copyright (c) 2004-2006 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: +* This class is a BTSapServer's state for setting up connection with BTSap client + +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "BTSapSimCardStatusNotifier.h" +#include "debug.h" + + +CBTSapServerState::TStateConnect::TStateConnect(CBTSapServerState& aServerState) + : TStateIdle(aServerState), iConnectRequestOK(EFalse), iCardStatus(ECardStatusReserved) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateConnect:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Enter"))); + + iStatus = &aStatus; + TConnectionStatus connectionStatus = EConnectionErrReject; + if(!IsCallOngoing()) + { // SAP cannot be accepted if a call is ongoing or if no SIM is present + connectionStatus = EConnectionOK; + } + + if (connectionStatus == EConnectionOK) + { + CheckMaxMsgSize(connectionStatus); + } + + if (connectionStatus == EConnectionOK) + { + iConnectRequestOK = ETrue; + + // init value which is impossible to be received. + // by checking the value, BTSap knows if status_ind is received + iCardStatus = ECardStatusReserved; + // listen to status_ind (card_reset is expected) + iServerState.BTSapSimCardStatusNotifier().Start(); + + NotifySapState(ESapConnecting); + + // Waiting for Accept/RejectSapConnection() + aStatus = KRequestPending; + + if(!IsSimPresent()) + { + // If there is no SIM present, we bypass the accept/reject for the connection. + // Instead this will be signalled in the connection reply, followed by disconnection. + iCardStatus = ECardStatusRemoved; + User::RequestComplete(iStatus, EUserAccepted); + } +#ifdef __WINS__ + + //Doesn't wait for any confirmation (used in WINS) + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Enter Accept"))); + User::RequestComplete(iStatus, EUserAccepted); + +#endif //__WINS__ + + } + else + { + iConnectRequestOK = EFalse; + + iResponseMessage.SetMsgID(EConnectResponse); + iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); + + if (connectionStatus == EConnectionErrNotSupported) + { + iResponseMessage.AddParameter(EParaMaxMsgSize, KMaxMsgSize, 2); + } + + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + if (connectionStatus == EConnectionErrNotSupported) + { + // waiting for the client to send another conn_req with my KMaxMsgSize + aStatus = KRequestPending; + } + else + { + // too small or a phone call ongoing + User::RequestComplete(iStatus, EConnectionError); + } + } + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateConnect::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Complete"))); + + TBTSapServerState nextState = EStateNotConnected; + + if (aReason == EUserAccepted || aReason == EUserRejected) + { + TInt connectionStatus = (aReason == EUserAccepted) ? EConnectionOK : EConnectionErrReject; + + iResponseMessage.SetMsgID(EConnectResponse); + iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + if (connectionStatus == EConnectionOK) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Complete: iCardStatus: %d"), iCardStatus)); + + if (iCardStatus != ECardStatusReserved) + { + // send status_ind + TStateIdle::SimCardStatusChanged(iCardStatus); + } + + if(iCardStatus != ECardStatusRemoved) + { + // There is no SIM, so the connection will be disconnected by the client. + // We therefore do not signal a connection complete. + NotifySapState(ESapConnected); + } + nextState = EStateIdle; + } + } + + return nextState; + } + +void CBTSapServerState::TStateConnect::Cancel() + { + NotifySapState(ESapNotConnected); + User::RequestComplete(iStatus, KErrCancel); + } + +TBool CBTSapServerState::TStateConnect::IsCallOngoing() + { +#ifdef __WINS__ + + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::TStateConnect::IsCallOngoing ON THE WINS SIDE"))); + return EFalse; + +#else + + TBool retVal = EFalse; + + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] CBTSapServerState::TStateConnect::IsCallOngoing"))); + + TInt callState; + // Try to get the call state property + TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); + + // Check if retrieving the property value succeeded + if(err == KErrNone) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TStateConnect: callState: %d"), callState)); + + // If callState is EPSTelephonyCallStateNone or EPSTelephonyCallStateUninitialized, there's no ongoing call + retVal = (callState != EPSCTsyCallStateNone) && (callState != EPSCTsyCallStateUninitialized); + } + else + { + // Couldn't retrieve call state property + BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TStateConnect: Couldn't get callState!!! (err = %d)"), err)); + retVal = ETrue; // Assume there was an ongoing call to abort the SAP connection + } + + return retVal; +#endif // __WINS__ + } + +void CBTSapServerState::TStateConnect::CheckMaxMsgSize(TConnectionStatus& aMsgSizeStatus) + { + TInt msgSize; + iServerState.BTSapRequestMessage().GetParameter(EParaMaxMsgSize, msgSize); + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] TStateConnect: msg size: %d"), msgSize)); + + if (msgSize < KMinMsgSize) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: msg size too small ***"))); + aMsgSizeStatus = EConnectionErrTooSmall; + } + else if (msgSize > KMaxMsgSize) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: msg size too big ***"))); + aMsgSizeStatus = EConnectionErrNotSupported; + } + else + { + aMsgSizeStatus = EConnectionOK; + } + } + +TInt CBTSapServerState::TStateConnect::AcceptSapConnection() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: AcceptSapConnection"))); + + if (*iStatus == KRequestPending) + { + User::RequestComplete(iStatus, EUserAccepted); + } + + return KErrNone; + } + +TInt CBTSapServerState::TStateConnect::RejectSapConnection(TBTSapRejectReason /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: RejectSapConnection"))); + + if (*iStatus == KRequestPending) + { + User::RequestComplete(iStatus, EUserRejected); + } + + return KErrNone; + } + +TInt CBTSapServerState::TStateConnect::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNotSupported; + TBTSapServerState nextState = EStateNotConnected; + + if ((aNextState == EStateConnect && + *iStatus == KRequestPending && + !iConnectRequestOK) || + aNextState == EStateDisconnect) + { + retVal = KErrNone; + nextState = aNextState; + } + + aNextState = nextState; + return retVal; + } + +void CBTSapServerState::TStateConnect::SimCardStatusChanged(TCardStatus aCardStatus) + { + iCardStatus = aCardStatus; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateDisconnect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateDisconnect.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStateDisconnect::TStateDisconnect(CBTSapServerState& aServerState) + : TStateIdle(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateDisconnect:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateDisconnect: Enter"))); + + iStatus = &aStatus; + User::RequestComplete(iStatus, KErrNone); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateDisconnect::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateDisconnect: Complete"))); + + iResponseMessage.SetMsgID(EDisconnectResponse); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + return EStateNotConnected; + } + +void CBTSapServerState::TStateDisconnect::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateDisconnect: Cancel"))); + + TStateIdle::Cancel(); + } + +TInt CBTSapServerState::TStateDisconnect::ChangeState(TBTSapServerState& aNextState) + { + aNextState = EStateDisconnect; + return KErrNotSupported; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateIdle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateIdle.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStateIdle::TStateIdle(CBTSapServerState& aServerState) + : TState(aServerState) + { + } + +// --------------------------------------------------------------------- +// Enter +// calling NotifyCardStatus() of RMmCustomAPI +// ---------------------------------------------------------------------- +void CBTSapServerState::TStateIdle:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateIdle: Enter"))); + + iStatus = &aStatus; + aStatus = KRequestPending; + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateIdle::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateIdle: Complete"))); + + return EStateIdle; + } + +void CBTSapServerState::TStateIdle::Cancel() + { + if (*iStatus == KRequestPending) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] TStateIdle: Cancel"))); + User::RequestComplete(iStatus, KErrCancel); + } + } + +TInt CBTSapServerState::TStateIdle::DisconnectSapConnection(TBTSapDisconnectType aType) + { + // set iResponse: disconnect_ind + iResponseMessage.SetMsgID(EDisconnectIndication); + iResponseMessage.AddParameter(EParaDisconnectionType, aType); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + return KErrNone; + } + +void CBTSapServerState::TStateIdle::SimCardStatusChanged(TCardStatus aCardStatus) + { + // status_ind + iResponseMessage.SetMsgID(EStatusIndication); + iResponseMessage.AddParameter(EParaStatusChange, aCardStatus); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + } + +TInt CBTSapServerState::TStateIdle::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNone; + + if (aNextState == EStateIdle || aNextState == EStateConnect) + { + aNextState = EStateIdle; + retVal = KErrNotSupported; + } + + return retVal; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateInit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateInit.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for Init state +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "debug.h" + +CBTSapServerState::TStateInit::TStateInit(CBTSapServerState& aServerState) + : TState(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateInit:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateInit: Enter"))); + iStatus = &aStatus; + aStatus = KRequestPending; + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateInit::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateInit: Complete"))); + return EStateNotConnected; + } + +void CBTSapServerState::TStateInit::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateInit: Cancel"))); + + User::RequestComplete(iStatus, KErrCancel); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateNotConnected.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateNotConnected.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for NotConnected state +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "BTSapSimCardStatusNotifier.h" +#include "debug.h" + +CBTSapServerState::TStateNotConnected::TStateNotConnected(CBTSapServerState& aServerState) + : TState(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateNotConnected:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateNotConnected: Enter"))); + iStatus = &aStatus; + aStatus = KRequestPending; + + NotifySapState(ESapNotConnected); + + iServerState.BTSapSimCardStatusNotifier().Cancel(); + iServerState.BTSapSocketHandler().Listen(); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateNotConnected::Complete(TInt /*aReason*/) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateNotConnected: Complete"))); + return EStateConnect; + } + +void CBTSapServerState::TStateNotConnected::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateNotConnected: Cancel"))); + + //iServerState.BTSapSocketHandler().Cancel(); + User::RequestComplete(iStatus, KErrCancel); + } + +TInt CBTSapServerState::TStateNotConnected::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNone; + + if (aNextState != EStateConnect) + { + aNextState = EStateNotConnected; + retVal = KErrNotSupported; + } + + return retVal; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStatePowerOff.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStatePowerOff.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStatePowerOff::TStatePowerOff(CBTSapServerState& aServerState) + : TStateIdle(aServerState) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStatePowerOff:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOff: Enter"))); + + iStatus = &aStatus; + + iServerState.SubscriptionModule().PowerSimOff(aStatus); + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStatePowerOff::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOff: Complete: %d"), aReason)); + + iResponseMessage.SetMsgID(EPowerSimOffResponse); + TResultCode resultCode = iResponseMessage.ToResultCode(aReason); + + // SubscriptionModule always send the same error code: KErrAlreadyExists when powered on/off already + if (resultCode == EResultCodeAlreadyPowerOn) + { + resultCode = EResultCodePowerOff; + } + + iResponseMessage.AddParameter(EParaResultCode, resultCode); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + return EStateIdle; + } + +void CBTSapServerState::TStatePowerOff::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOff: Cancel"))); + + iServerState.SubscriptionModule().CancelAsyncRequest(ECustomPowerSimOffIPC); + + TStateIdle::Cancel(); + } + +TInt CBTSapServerState::TStatePowerOff::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNone; + + if (aNextState != EStateDisconnect) + { + aNextState = EStateIdle; + retVal = KErrNotSupported; + } + + return retVal; + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStatePowerOn.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStatePowerOn.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStatePowerOn::TStatePowerOn(CBTSapServerState& aServerState) + : TStateIdle(aServerState), iResultCode(EResultCodeReserved), iCardStatus(ECardStatusReserved) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStatePowerOn:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOn: Enter"))); + + if (iResultCode == EResultCodeReserved) + { + iStatus = &aStatus; + iServerState.SubscriptionModule().PowerSimOn(aStatus); + } + else + { + aStatus = KRequestPending; + } + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStatePowerOn::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOn: Complete: %d"), aReason)); + + TBTSapServerState state = EStatePowerOn; + + if (iResultCode == EResultCodeReserved) + { + iResultCode = iResponseMessage.ToResultCode(aReason); + } + + if (iCardStatus != ECardStatusReserved || + aReason != KErrNone) + { + iResponseMessage.SetMsgID(EPowerSimOnResponse); + iResponseMessage.AddParameter(EParaResultCode, iResultCode); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + iResultCode = EResultCodeReserved; + iCardStatus = ECardStatusReserved; + state = EStateIdle; + } + + return state; + } + +void CBTSapServerState::TStatePowerOn::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOn: Cancel"))); + + if (iResultCode == EResultCodeReserved) + { + iServerState.SubscriptionModule().CancelAsyncRequest(ECustomPowerSimOnIPC); + } + else + { + iResultCode = EResultCodeReserved; + iCardStatus = ECardStatusReserved; + TStateIdle::Cancel(); + } + } + +TInt CBTSapServerState::TStatePowerOn::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNone; + + if (aNextState != EStatePowerOff && + aNextState != EStateDisconnect) + { + aNextState = EStateIdle; + retVal = KErrNotSupported; + } + + return retVal; + } + +void CBTSapServerState::TStatePowerOn::SimCardStatusChanged(TCardStatus aCardStatus) + { + iCardStatus = aCardStatus; + User::RequestComplete(iStatus, KErrNone); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btsap/src/BTSapStateReset.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btsap/src/BTSapStateReset.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2004 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: +* This class is a BTSapServer's state for setting up connection with BTSap client +* +* +*/ + + +// INCLUDE FILES +#include "BTSapServerState.h" +#include "BTSapSocketHandler.h" +#include "debug.h" + +CBTSapServerState::TStateReset::TStateReset(CBTSapServerState& aServerState) + : TStateIdle(aServerState), iResultCode(EResultCodeReserved), iCardStatus(ECardStatusReserved) + { + } + +// --------------------------------------------------------- +// Enter +// --------------------------------------------------------- +void CBTSapServerState::TStateReset:: Enter(TRequestStatus& aStatus) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateReset: Enter"))); + + if (iResultCode == EResultCodeReserved) + { + iStatus = &aStatus; + iServerState.SubscriptionModule().SimWarmReset(aStatus); + } + else + { + aStatus = KRequestPending; + } + } + +// -------------------------------------------------------------------------------------------- +// Complete +// set next state +// -------------------------------------------------------------------------------------------- +// +TBTSapServerState CBTSapServerState::TStateReset::Complete(TInt aReason) + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateReset: Complete: %d"), aReason)); + + if (iResultCode == EResultCodeReserved) + { + iResultCode = iResponseMessage.ToResultCode(aReason); + } + + TBTSapServerState state; + + if (iCardStatus == ECardStatusReserved && + aReason == KErrNone) + { + iResultCode = iResponseMessage.ToResultCode(aReason); + state = EStateReset; + } + else + { + iResponseMessage.SetMsgID(EResetSimResponse); + iResponseMessage.AddParameter(EParaResultCode, iResultCode); + iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); + + iResultCode = EResultCodeReserved; + iCardStatus = ECardStatusReserved; + state = EStateIdle; + } + + return state; + } + +void CBTSapServerState::TStateReset::Cancel() + { + BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateReset: Cancel"))); + + if (iResultCode == EResultCodeReserved) + { + iServerState.SubscriptionModule().CancelAsyncRequest(ECustomSimWarmResetIPC); + } + else + { + iResultCode = EResultCodeReserved; + iCardStatus = ECardStatusReserved; + TStateIdle::Cancel(); + } + } + +TInt CBTSapServerState::TStateReset::ChangeState(TBTSapServerState& aNextState) + { + TInt retVal = KErrNone; + + if (aNextState != EStatePowerOff && + aNextState != EStateDisconnect) + { + aNextState = EStateIdle; + retVal = KErrNotSupported; + } + + return retVal; + } + +void CBTSapServerState::TStateReset::SimCardStatusChanged(TCardStatus aCardStatus) + { + iCardStatus = aCardStatus; + User::RequestComplete(iStatus, KErrNone); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/data/1020742B.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/data/1020742B.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2005 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: +* ECOM plugin resource file for BTUI plugin. +* +* +*/ + +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x1020742B; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10207236; // UID for CGSPluginInterface + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020742C; + version_no = 1; + display_name = "GS Btui Plugin"; // Plugin debug name + default_data = "0x10207250"; // Parent UID (BTUI is under "Connection" folder of General Setting Application) + opaque_data = "30"; // Order number + } + }; + }, + + INTERFACE_INFO + { + interface_uid = 0x1020745F; // UID for CBtuiPluginInterface + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020745C; // implementation UID + version_no = 1; + display_name = "Btui Application Plugin for MainView"; // Plugin debug name + }, + + IMPLEMENTATION_INFO + { + implementation_uid = 0x1020745D; // implementation UID + version_no = 1; + display_name = "Btui Application Plugin for PairedDevicesView"; // Plugin debug name + }, + + IMPLEMENTATION_INFO + { + implementation_uid = 0x20002780; // implementation UID + version_no = 1; + display_name = "Btui Application Plugin for BlockedDevicesView"; // Plugin debug name + } + + }; + + } + + }; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/data/BtuiViewResources.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/data/BtuiViewResources.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1440 @@ +/* +* Copyright (c) 2002 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: This file contains all the resources for the BTUI. +* +*/ + + +#include + +// RESOURCE IDENTIFIER + +NAME BVIE // 4 letter ID + +// INCLUDES +#include +#include "btui.hrh" // Enums for these resources +#include // Localisation file +#include // Icon indexes created by abld +#include "eikon.rsg" +#include +#include +#include +#include +#include + +// MACROS + +// RESOURCE DEFINITIONS + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf=""; } + +//---------------------------------------------------- +// +// Hotkeys for BTUI +// +//---------------------------------------------------- +// +RESOURCE HOTKEYS r_btui_hotkeys + { + control= + { + HOTKEY { command=EAknCmdExit; key='e'; } + }; + } + +// == MAIN VIEW ============================================================== + +RESOURCE CBA r_btui_softkeys_options_back__change + { + buttons = + { + CBA_BUTTON + { + id = EAknSoftkeyOptions; + txt = text_softkey_option; + }, + CBA_BUTTON + { + id = EAknSoftkeyBack; + txt = text_softkey_back; + }, + CBA_BUTTON + { + id = EBTUICmdMSK ; + txt = qtn_msk_change; + } + + }; + } + + + + +//---------------------------------------------------- +// +// The main view of the BTUI application +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_btui_main_view + { + hotkeys = r_btui_hotkeys; + menubar = r_btui_menubar_main_view; + cba = r_btui_softkeys_options_exit__change; + } + +//---------------------------------------------------- +// +// The main view's menu bar +// +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_btui_menubar_main_view + { + titles = + { + MENU_TITLE { menu_pane = r_btui_app_menu; txt=""; }, + MENU_TITLE { menu_pane = r_btui_main_view_menu; txt=""; } + }; + } + +//---------------------------------------------------- +// +// The main view options +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_btui_main_view_menu + { + items = + { + MENU_ITEM { command = EBTUICmdChangePowerStateMenu; txt = qtn_bt_change_value; }, + MENU_ITEM { command = EBTUICmdChangeVisibilityMenu; txt = qtn_bt_change_value; }, + MENU_ITEM { command = EBTUICmdChangeBTNameMenu; txt = qtn_bt_change_value; } + #ifdef __BT_SAP + , + MENU_ITEM { command = EBTUICmdChangeSapStateMenu; txt = qtn_bt_change_value; } + #endif + }; + } + +//---------------------------------------------------- +// +// Editor for entering all settings +// +//---------------------------------------------------- +// +RESOURCE LISTBOX r_bt_setting_editor + { + flags = EEikListBoxMultipleSelection; + } + +//---------------------------------------------------- +// +// The input dialog for entering power mode +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_bt_power_setting_page + { + label = qtn_bt_sett_module; + hint_text = " "; + softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + type = EAknSetListBox; + editor_resource_id = r_bt_setting_editor; + } + +//---------------------------------------------------- +// +// Bluetooth power modes +// +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_power_modes + { + items = + { + LBUF { txt = qtn_bt_sett_on; }, + LBUF { txt = qtn_bt_sett_off; } + }; + } + +//---------------------------------------------------- +// +// The input dialog for bluetooth visibility setting +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_bt_visibility_setting_page + { + label = qtn_bt_sett_phone_visibility; + hint_text = " "; + softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + type = EAknSetListBox; + editor_resource_id = r_bt_setting_editor; + } + +//---------------------------------------------------- +// +// Bluetooth visibility modes +// +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_visibility_modes + { + items = + { + LBUF { txt = qtn_bt_det_sett_general; }, + LBUF { txt = qtn_bt_set_visibility_time; }, + LBUF { txt = qtn_bt_hidden; } + }; + } + +//---------------------------------------------------- +// +// The input dialog for bluetooth local name setting +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_bt_name_setting_page + { + label = qtn_bt_sett_bt_name; + type = EEikCtEdwin; + softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + editor_resource_id = r_bt_name_setting_editor; + } + +//---------------------------------------------------- +// +// Editor for entering BT's local name +// +//---------------------------------------------------- +// +RESOURCE EDWIN r_bt_name_setting_editor + { + lines = 0; // Expanding to multiple rows + maxlength = KBTUIMaxNameLength; + flags = EEikEdwinNoLineOrParaBreaks; + } + + +// === PAIRED DEVICES VIEW =================================================== + +//---------------------------------------------------- +// +// This view shows all paired Bluetooth devices. +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_btui_other_devices_view + { + hotkeys = r_btui_hotkeys; + menubar = r_btui_menubar_other_devices_view; + cba = r_btui_softkeys_options_exit__conoptions; + } + + +RESOURCE CBA r_btui_softkeys_options_exit__conoptions + { + buttons = + { + CBA_BUTTON + { + id = EAknSoftkeyOptions; + txt = text_softkey_option; + }, + CBA_BUTTON + { + id = EAknSoftkeyExit; + txt = text_softkey_exit; + }, + CBA_BUTTON + { + id = EAknSoftkeyContextOptions;//EAknSoftkeyOptions; + txt = text_softkey_option; + } + + }; + } + +RESOURCE AVKON_VIEW r_btui_other_devices_view_gs + { + hotkeys = r_btui_hotkeys; + menubar = r_btui_menubar_other_devices_view; + cba = r_btui_softkeys_options_back__conoptions; + } +// menubar_context = r_btui_menubar_other_devices_view__context; +// this is defined in CBTUIOtherDevicesView::DoActivate, since I did not +// find a way to do this by resources + +RESOURCE CBA r_btui_softkeys_options_back__conoptions + { + buttons = + { + CBA_BUTTON + { + id = EAknSoftkeyOptions; + txt = text_softkey_option; + }, + CBA_BUTTON + { + id = EAknSoftkeyBack; + txt = text_softkey_back; + }, + CBA_BUTTON + { + id = EAknSoftkeyContextOptions;//EAknSoftkeyOptions; + txt = text_softkey_option; + } + + }; + } + +//---------------------------------------------------- +// +// The menubar for other paired devices view +// +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_btui_menubar_other_devices_view + { + titles = + { + MENU_TITLE { menu_pane = r_btui_app_menu; txt = ""; }, + MENU_TITLE { menu_pane = r_btui_other_devices_view_menu; txt = ""; } + }; + } + + +RESOURCE MENU_BAR r_btui_menubar_other_devices_view_context + { + titles = + { + MENU_TITLE { menu_pane = r_btui_other_devices_view_menu_context; txt = ""; } + }; + } + +//---------------------------------------------------- +// +// The other devices view options +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_btui_other_devices_view_menu + { + items = + { + MENU_ITEM { command = EBTUICmdNewPairedDevice; txt = qtn_bt_new_paired_device; }, + MENU_ITEM { command = EBTUICmdConnect; txt = qtn_bt_gen_connect; }, + MENU_ITEM { command = EBTUICmdConnectAudio; txt = qtn_bt_connect; }, + MENU_ITEM { command = EBTUICmdDisconnect; txt = qtn_bt_disconnect; }, + MENU_ITEM { command = EBTUICmdGiveNickname; txt = qtn_bt_give_nickname; }, + MENU_ITEM { command = EBTUICmdSetTrusted; txt = qtn_bt_set_as_trusted; }, + MENU_ITEM { command = EBTUICmdSetUnTrusted; txt = qtn_bt_set_as_untrusted; }, + MENU_ITEM { command = EBTUICmdSetBlocked; txt = qtn_bt_block; }, + MENU_ITEM { command = EBTUICmdDelete; txt = qtn_bt_delete; }, + MENU_ITEM { command = EBTUICmdSettings; txt = qtn_bt_settings; }, + MENU_ITEM { command = EBTUICmdDeleteAll; txt = qtn_bt_delete_all; } + }; + } + +RESOURCE MENU_PANE r_btui_other_devices_view_menu_context + { + items = + { + MENU_ITEM { command = EBTUICmdNewPairedDevice; txt = qtn_bt_new_paired_device; }, + MENU_ITEM { command = EBTUICmdConnect; txt = qtn_bt_gen_connect; }, + MENU_ITEM { command = EBTUICmdConnectAudio; txt = qtn_bt_connect; }, + MENU_ITEM { command = EBTUICmdDisconnect; txt = qtn_bt_disconnect; }, + MENU_ITEM { command = EBTUICmdGiveNickname; txt = qtn_bt_give_nickname; }, + MENU_ITEM { command = EBTUICmdSetTrusted; txt = qtn_bt_set_as_trusted; }, + MENU_ITEM { command = EBTUICmdSetUnTrusted; txt = qtn_bt_set_as_untrusted; }, + MENU_ITEM { command = EBTUICmdSetBlocked; txt = qtn_bt_block; }, + MENU_ITEM { command = EBTUICmdDelete; txt = qtn_bt_delete; }, + MENU_ITEM { command = EBTUICmdSettings; txt = qtn_bt_settings; } + }; + } + + +// == APPLICATION ============================================================ + +//---------------------------------------------------- +// +// The BTUI application level menu +// Common for all views +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_btui_app_menu + { + items = + { +#ifdef __SERIES60_HELP + MENU_ITEM { command = EAknCmdHelp; txt = qtn_options_help; }, +#endif + MENU_ITEM { command = EAknCmdExit; txt = qtn_options_exit; } + }; + } + + + +// === QUERIES =============================================================== + +//---------------------------------------------------- +// Data query "Enter Bluetooth name for your phone" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_enter_local_name_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + label = qtn_enter_bt_name; + control = EDWIN + { + flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable | EEikEdwinNoLineOrParaBreaks; + maxlength = KBTUIMaxNameLength; + }; + }; + } + }; + } + +//---------------------------------------------------- +// Confirmation query "You have active Bluetooth +// connections on. Switch off anyway?" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_switch_off_anyway_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + label = qtn_bt_switch_off_anyway; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Confirmation query "Bluetooth is currently off. +// Do you want to switch it on?" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_is_off_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + label = qtn_bt_is_off; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Confirmation query "Do you want to activate bluetooth in off-line mode?" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_activate_in_offline_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = qtn_bt_activate_in_offline; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Confirmation query "Cancel pairing with: %U" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_warn_erase_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_warn_erase { buf = qtn_bt_warn_erase; } +RESOURCE TBUF r_bt_warn_erase_connected { buf = qtn_bt_warn_erase_connected; } + +//---------------------------------------------------- +// Confirmation query "Cancel all pairings" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_warn_erase_all_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + label = qtn_bt_warn_erase_all; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Confirmation query "Delete all pairings? Some devices may be disconnected." +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_warn_erase_all_connected_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + label = qtn_bt_warn_erase_all_connected; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Data query "Enter alias" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_enter_nickname_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + label = qtn_bt_enter_nickname; + control = EDWIN + { + flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable; + maxlength = KBTUIMaxAliasLength; + }; + }; + } + }; + } + +//---------------------------------------------------- +// Confirmation query "Set this device as trusted" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_set_trusted_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + label = qtn_bt_conf_aut; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_set_as_trusted_prompt { buf = qtn_bt_conf_aut; } + +//---------------------------------------------------- +// Confirmation query "Disconnect from: %U" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_disconnect_from_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_disconnect_from { buf = qtn_bt_disconn_from; } + + +// === NOTES ================================================================= + +//---------------------------------------------------- +// Information note "Phone is visible to other +// Bluetooth devices." +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_phone_visib_to_oth_note + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIPhoneVisibleToOthers; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_phone_visib_to_oth; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Information note "Phone is hidden from others" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_hidden_from_others + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIHiddenFromOthersNote; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_hidden_from_others; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Error note "Alias exists in Paired devices list." +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_name_exists_note + { + flags = EAknErrorNoteFlags | EEikDialogFlagWait; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUINameAlreadyExists; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_name_exists; + animation = R_QGN_NOTE_ERROR_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Error note "Invalid name entered, try again." +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_invalid_local_name_note + { + //removed + //Leave the name here to keep binary compatibility + } + +//---------------------------------------------------- +// Confirmation note "Device set as untrusted." +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_device_untrusted_note + { + flags = EAknConfirmationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIDeviceSetAsUntrusted; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_dev_set_as_untrust; + animation = R_QGN_NOTE_OK_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Wait note "Waiting for response from %U" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_waiting + { + flags = EAknWaitNoteFlags; + buttons = R_AVKON_SOFTKEYS_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIWaitingForPairing; + control = AVKON_NOTE + { + layout = EWaitLayout; + singular_label = qtn_bt_waiting; + animation = R_QGN_GRAF_WAIT_BAR_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_waiting_prompt { buf = qtn_bt_waiting; } + +//---------------------------------------------------- +// Error note "Cannot execute Bluetooth operation +// successfully!" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_general_error_note + { + flags = EAknErrorNoteFlags | EEikDialogFlagWait; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIGeneralError; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_general_error; + animation = R_QGN_NOTE_ERROR_ANIM; + }; + } + }; + } + + +//---------------------------------------------------- +// Wait note "Connecting to %U" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_connecting_to_wait_note + { + flags = EAknWaitNoteFlags; + buttons = R_AVKON_SOFTKEYS_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIConnectingTo; + control = AVKON_NOTE + { + layout = EWaitLayout; + animation = R_QGN_GRAF_WAIT_BAR_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_connecting_to { buf = qtn_bt_wait_connecting_to;} + +//---------------------------------------------------- +// Information note "Disconnect wired accessory" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_disconnect_wired_note + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIDisconnectWired; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_disconnect_wired; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Information note "Cannot establish Bluetooth connection" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_not_incall_note + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUINotIncall; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_not_incall; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Information note "Disconnect %U first" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_disconnect_first_prompt { buf = qtn_bt_disconnect_first; } + +//---------------------------------------------------- +// Information note "Maximum amount of Bluetooth conn..." +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_busy + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIBtBusy; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_busy; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } + +//---------------------------------------------------- +// Information note "Bluetooth can't activated in off-line mode" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_offline_disabled { buf = qtn_bt_offline_disabled; } + +//---------------------------------------------------- +// Default value for "My Bluetooth name" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_default_local_name { buf = qtn_bt_default_local_name; } + + +// === GLOBAL QUERIES AND NOTES ============================================== + +//---------------------------------------------------- +// Global Information note "Audio routed to BT handsfree" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_audios_accessory_prompt { buf = qtn_bt_audio_accessory; } + +//---------------------------------------------------- +// Global Information note "Connected to %U" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_conf_connected_prompt { buf = qtn_bt_conf_connected; } + +//---------------------------------------------------- +// Global Information note "Disconnected from %U" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_conf_disconnected_prompt { buf = qtn_bt_conf_disconnected; } + +//---------------------------------------------------- +// Global Information note "Cannot establish Bluetooth connection" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_device_not_avail_note { buf = qtn_bt_device_not_avail; } + +//---------------------------------------------------- +// Global Information note "Hands-Free Profile not supported by %U" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_hfp_not_supported { buf = qtn_bt_hfp_not_supported; } + +//---------------------------------------------------- +// Global Information note "Unsupported device: %U" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_device_not_supported { buf = qtn_bt_device_not_supported; } + +// =========================================================================== + +//---------------------------------------------------- +// Titles for views +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_title_bluetooth { buf = qtn_bt_title_bluetooth; } +RESOURCE TBUF r_bt_title_paired_dev { buf = qtn_bt_title_paired_dev; } + +//---------------------------------------------------- +// Empty list text +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_no_paired_devices { buf = qtn_bt_no_paired_devices; } + +//---------------------------------------------------- +// Popup commands for paired devices view when +// there are no devices +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_no_paired_devices_popup_commands + { + items = { + LBUF { txt = qtn_bt_new_paired_device; } + }; + } + +//---------------------------------------------------- +// Standard popup commands for paired devices view +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_paired_devices_popup_commands + { + items = { + LBUF { txt = qtn_bt_give_nickname; }, + LBUF { txt = qtn_bt_delete; } + }; + } + +//---------------------------------------------------- +// Optional popup commands for paired devices view +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_set_untrusted_command { buf = qtn_bt_set_as_untrusted; } + +RESOURCE TBUF r_bt_set_trusted_command { buf = qtn_bt_set_as_trusted; } + +RESOURCE TBUF r_bt_connect_command { buf = qtn_bt_connect; } + +RESOURCE TBUF r_bt_disconnect_command { buf = qtn_bt_disconnect; } + + +//---------------------------------------------------- +// Format/label strings for main view +// There is also TBTUIMainViewSettingFormatStrings enum +// in the BTUI.hrh which must reflect EXACTLY this resource ! +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_label_strings + { + items = { + LBUF { txt=" \t"qtn_bt_sett_module"\t\t"qtn_bt_sett_on; }, + LBUF { txt=" \t"qtn_bt_sett_module"\t\t"qtn_bt_sett_off; }, + LBUF { txt=" \t"qtn_bt_sett_phone_visibility"\t\t"qtn_bt_det_sett_general; }, + LBUF { txt=" \t"qtn_bt_sett_phone_visibility"\t\t"qtn_bt_hidden; }, + + //temp visible mode + LBUF { txt=" \t"qtn_bt_sett_phone_visibility"\t\t" qtn_bt_temp_visible; }, + + LBUF { txt=" \t"qtn_bt_sett_bt_name"\t\t"; } + #ifdef __BT_SAP + , + LBUF { txt=" \t"qtn_bt_sap"\t\t"qtn_bt_sap_enabled; }, + LBUF { txt=" \t"qtn_bt_sap"\t\t"qtn_bt_sap_disabled; } + #endif + }; + } + + +#ifdef __BT_SAP +//---------------------------------------------------- +// +// The input dialog for SIM access profile setting +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_bt_sap_setting_page + { + label = qtn_bt_sap; + hint_text = " "; + softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + type = EAknSetListBox; + editor_resource_id = r_bt_setting_editor; + } + +//---------------------------------------------------- +// +// Bluetooth sap modes +// +//---------------------------------------------------- +// +RESOURCE ARRAY r_bt_sap_modes + { + items = + { + LBUF { txt = qtn_bt_sap_enabled; }, + LBUF { txt = qtn_bt_sap_disabled; } + }; + } + +//---------------------------------------------------- +// Information Note "Enabling SIM Access Profile +// connection Bluetooth must be ON" +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_sap_enable_note + { + flags = EAknInformationNoteFlags; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = EBTUIBtSapEnableNote; + control = AVKON_NOTE + { + layout = EGeneralLayout; + singular_label = qtn_bt_sap_enable_info; + animation = R_QGN_NOTE_INFO_ANIM; + }; + } + }; + } +#endif //__BT_SAP + +// Visibility TIMEOUT +//---------------------------------------------------- +// +// r_setting_visibility_time_slider +// visibility timeout setting slider +// +//---------------------------------------------------- +// +RESOURCE SLIDER r_setting_visibility_time_slider + { + layout = EAknSettingsItemSliderLayout; + minvalue = 1; + maxvalue = 60; + step = 1; + valuetype = EAknSliderValueBareFigure; + singular_valuelabel = qtn_bt_slider_singular; + + minlabel = qtn_bt_slider_min; + maxlabel = qtn_bt_slider_max; + valuelabel = qtn_bt_slider_plural; + } + +//---------------------------------------------------- +// +// r_visibility_time_setting_page +// visibility timeout setting page. +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_visibility_time_setting_page + { + number = EAknSettingPageNoOrdinalDisplayed; + label = qtn_bt_slider_visibility_time; + type = EAknCtSlider; + softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK; + editor_resource_id = r_setting_visibility_time_slider; + } + + +//---------------------------------------------------- +// r_gs_btui_view_caption +// +// Btui view caption for GS plugin +//---------------------------------------------------- +// +RESOURCE TBUF r_gs_btui_view_caption + { + buf = qtn_set_folder_bluetooth; + } + +//---------------------------------------------------- +// +// The main view of the BTUI as GS plugin +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_btui_main_view_gs_plugin + { + hotkeys = r_btui_hotkeys; + menubar = r_btui_menubar_main_view; + cba = r_btui_softkeys_options_back__change; + } + +RESOURCE CBA r_btui_softkeys_options_exit__change + { + buttons = + { + CBA_BUTTON + { + id = EAknSoftkeyOptions; + txt = text_softkey_option; + }, + CBA_BUTTON + { + id = EAknSoftkeyExit; + txt = text_softkey_exit; + }, + CBA_BUTTON + { + id = EBTUICmdMSK ; + txt = qtn_msk_change; + } + + }; + } + +//---------------------------------------------------- +// Audio connection confirmation query +//---------------------------------------------------- +// +RESOURCE DIALOG r_bt_connect_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +// === BLOCKED DEVICES VIEW =================================================== + +//---------------------------------------------------- +// +// This view shows all blocked Bluetooth devices.(for GS) +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_btui_block_devices_view_gs + { + hotkeys = r_btui_hotkeys; + menubar = r_btui_menubar_block_devices_view; + cba = r_btui_softkeys_options_back__unblock ; + } + +//---------------------------------------------------- +// +// The menubar buttons for blocked devices view +// MSK is dimmed when needed. +// +//---------------------------------------------------- +// + + +RESOURCE CBA r_btui_softkeys_options_back__unblock + { + buttons = + { + CBA_BUTTON + { + id = EAknSoftkeyOptions; + txt = text_softkey_option; + }, + CBA_BUTTON + { + id = EAknSoftkeyBack; + txt = text_softkey_back; + }, + CBA_BUTTON + { + id = EBTUICmdUnblock ; + txt = qtn_msk_delete ; + } + + }; + } + +//---------------------------------------------------- +// +// This view shows all blocked Bluetooth devices.(bt application) +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_btui_block_devices_view + { + hotkeys = r_btui_hotkeys; + menubar = r_btui_menubar_block_devices_view; + cba = r_btui_softkeys_options_exit__unblock ; + } + +//---------------------------------------------------- +// +// The menubar buttons for blocked devices view +// MSK is dimmed when needed. +// +//---------------------------------------------------- +// + + +RESOURCE CBA r_btui_softkeys_options_exit__unblock + { + buttons = + { + CBA_BUTTON + { + id = EAknSoftkeyOptions; + txt = text_softkey_option; + }, + CBA_BUTTON + { + id = EAknSoftkeyExit; + txt = text_softkey_exit; + }, + CBA_BUTTON + { + id = EBTUICmdUnblock ; + txt = qtn_msk_delete ; + } + + }; + } + +//---------------------------------------------------- +// +// The menubar for other blocked devices view +// +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_btui_menubar_block_devices_view + { + titles = + { + MENU_TITLE { menu_pane = r_btui_app_menu; txt = ""; }, + MENU_TITLE { menu_pane = r_btui_block_devices_view_menu; txt = ""; } + }; + } + + +//---------------------------------------------------- +// +// The blocked devices view options +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_btui_block_devices_view_menu + { + items = + { + MENU_ITEM { command = EBTUICmdUnblock; txt = qtn_bt_delete;}, + MENU_ITEM { command = EBTUICmdUnblockAll; txt = qtn_bt_delete_all; } + }; + } + +//----------------------------------------------- +//Title for blocked device view +//------------------------------------------------ +// +RESOURCE TBUF r_bt_title_blocked_dev { buf = qtn_bt_title_blocked_devices; } +// empty listy +RESOURCE TBUF r_bt_no_blocked_devices { buf = qtn_bt_no_blocked_devices; } +// Information note "Disconnect %0U device and %1U device first" +//---------------------------------------------------- +// +RESOURCE TBUF r_bt_disconnect_first_stereo_prompt { buf = qtn_bt_disconnect_first_stereo; } + + +RESOURCE TBUF r_bt_warn_erase_blocked +{ + buf=qtn_bt_warn_erase_blocked; +} +RESOURCE TBUF r_bt_warn_erase_all_blocked +{ + buf=qtn_bt_warn_erase_all_blocked; +} + +RESOURCE DIALOG r_bt_generic_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + animation = R_QGN_NOTE_QUERY_ANIM; + }; + } + }; + } + +RESOURCE TBUF r_bt_option_block_device_header +{ + buf=qtn_bt_block_device_header ; +} +RESOURCE TBUF r_bt_option_block_paired_device_help +{ + buf= qtn_bt_block_paired_device "\n\n" qtn_bt_block_device_link; +} + +RESOURCE TBUF r_bt_option_block_paired_device_nohelp +{ + buf=qtn_bt_block_paired_device; +} + +RESOURCE TBUF r_bt_option_block_connected_paired_devices_help +{ + buf= qtn_bt_block_connected_paired_devices "\n\n" qtn_bt_block_device_link; +} + +RESOURCE TBUF r_bt_option_block_connected_paired_devices_nohelp +{ + buf= qtn_bt_block_connected_paired_devices ; +} +RESOURCE TBUF r_bt_block_device_link + { + buf=qtn_bt_block_device_link; + } + +RESOURCE DIALOG r_bt_message_query + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_YES_NO__YES; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + label = header_not_defined; + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + }; + } + }; + } + +RESOURCE TBUF r_cp_detail_bt_off { buf= qtn_cp_detail_bt_off; } +RESOURCE TBUF r_cp_detail_bt_on_shown { buf= qtn_cp_detail_bt_on_shown; } +RESOURCE TBUF r_cp_detail_bt_on_hidden { buf= qtn_cp_detail_bt_on_hidden; } +RESOURCE TBUF r_cp_detail_bt_conn_shown { buf= qtn_cp_detail_bt_conn_shown; } +RESOURCE TBUF r_cp_detail_bt_conn_hidden { buf= qtn_cp_detail_bt_conn_hidden; } + +RESOURCE TBUF r_bt_ssp_incorrect_passcode { buf = qtn_bt_simple_incorrect_passcode;} +RESOURCE TBUF r_bt_ssp_passcode_retry { buf = qtn_bt_simple_passcode_retry; } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/group/BtuiPlugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/group/BtuiPlugin.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2002-2007 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: This module contains the views of BTUI. +* +*/ + + +#include +#include +#include + + +CAPABILITY CAP_ECOM_PLUGIN NetworkControl +TARGET BtuiPlugin.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x1020742B // UPDATE THIS +VENDORID VID_DEFAULT + +//********* UIDs ************* +//0x1020742B //DLL UID +//0x1020742C //Impl1. UID +//0x1020745C //impl2. UID +//0x1020745D //impl3. UID +//**************************** + +SOURCEPATH ../src +SOURCE BTUIMainContainer.cpp +SOURCE BTUIMainView.cpp +SOURCE BTUIViewsCommonUtils.cpp +SOURCE BTUIKeyWatcher.cpp +SOURCE BTUIActive.cpp + +#ifdef __BT_SAP +SOURCE BTUISap.cpp +#else +SOURCE BTUINonSap.cpp +#endif + +SOURCE BTUIBlockedDevicesView.cpp +SOURCE BTUIPairedDevicesView.cpp +SOURCE BTUIDeviceContainer.cpp +SOURCE BtuiPluginImplementationTable.cpp +SOURCE btuipluginman.cpp + +//BTUI plugin resource definition +START RESOURCE ../data/BtuiViewResources.rss +HEADER +TARGETPATH RESOURCE_FILES_DIR +LANGUAGE_IDS +END + + +//***********ECOM resource definition****************** +//--Ecom resource TARGET name must be same as DLL name, +//--otherwise Ecom won't recognise it. +//***************************************************** +START RESOURCE ../data/1020742B.rss +TARGET BtuiPlugin.rsc +END + + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../data //for documents + + +SYSTEMINCLUDE ../../inc //for private API headers (BluetoothEngine subsystem) +SYSTEMINCLUDE ../../../inc //for internal API headers (localconnectivity) +APP_LAYER_SYSTEMINCLUDE + +SYSTEMINCLUDE /epoc32/include/ecom + +#ifdef __SERIES60_HELP +SYSTEMINCLUDE /epoc32/include/cshelp +#endif +LIBRARY btdevmodel.lib // Model of BTUI +LIBRARY btengdiscovery.lib // device search +LIBRARY btengsettings.lib // main settings view +LIBRARY btengdevman.lib // sap name,PairedDevicesView,Blocked devices view +LIBRARY btengconnman.lib // sap address, connect/disconnect device +LIBRARY btmanclient.lib // TBTRegistrySearch for sap address +LIBRARY euser.lib apparc.lib cone.lib // Symbian OS framework libraries +LIBRARY eikcore.lib eikcoctl.lib eikctl.lib // UIKON libraries +LIBRARY avkon.lib // Series 60 UI library +LIBRARY bafl.lib // Basic Application Framework Library +LIBRARY btdevice.lib // Bluetooth device handling routines +LIBRARY bluetooth.lib // Bluetooth device address handling routines +LIBRARY commonengine.lib // Series 60 common components library publish & subsribe and string loader +LIBRARY aknnotify.lib // Avkon global notes +LIBRARY AknSkins.lib // Skinned icons +LIBRARY aknicon.lib +LIBRARY centralrepository.lib // Central Repository +LIBRARY FeatMgr.lib +LIBRARY ecom.lib +LIBRARY charconv.lib +LIBRARY esock.lib + +LIBRARY GSEcomPlugin.lib +LIBRARY GSFramework.lib + +// For cover display support: +LIBRARY eikdlg.lib +LIBRARY estor.lib + + +#ifdef __BT_SAP +//LIBRARY BTSap.lib +#endif + +DEBUGLIBRARY flogger.lib // File logging services + +#ifdef __SERIES60_HELP +LIBRARY hlplch.lib // Help library +#endif + +LIBRARY egul.lib +LIBRARY btfeatures.lib + +// This is optional - used only by Codewarrior IDE for .RSS file editing. +//DOCUMENT ../data/1020742B.rss +//DOCUMENT ../data/BtuiViewResources.rss + +//**** End of .mmp ***** diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2005 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: This file provides project information required for BTUI/ECOM. +* +*/ + + +#include + +PRJ_PLATFORMS + + +PRJ_EXPORTS + + +PRJ_MMPFILES +./BtuiPlugin.mmp + + +//---End of File--- diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIActive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIActive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2007 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: Active object helper class. +* +*/ + + + +#ifndef BTUIACTIVE_H +#define BTUIACTIVE_H + + +#include + +class CBTUIActive; + +/** + * Class MBTUIActiveObserver + * + * Callback class for receiving a completed active object event. + * Users of CBTUIActive need to derive from this class. + * + * @since S60 v5.0 + */ +class MBTUIActiveObserver + { + +public: + + /** + * Callback to notify that an outstanding request has completed. + * + * @since S60 v5.0 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTUIActive* aActive, TInt aId, + TInt aStatus ) = 0; + + /** + * Callback to notify that an error has occurred in RunL. + * + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTUIActive* aActive, TInt aId, + TInt aError ) = 0; + + }; + + +/** + * Class CBTUIActive + * + * Base clase for active objects used in BTUI + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CBTUIActive ) : public CActive + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v5.0 + * @param aObserver Pointer to callback interface that receives notification + * that the request has been completed. + * @param aId The request ID + * @param aPriority Active Object Priority + * @return Pointer to the constructed CBTUIActive object. + */ + static CBTUIActive* NewL( MBTUIActiveObserver* aObserver, + TInt aId, TInt aPriority ); + + /** + * Destructor + */ + virtual ~CBTUIActive(); + + /** + * Get the request ID of this active object. + * + * @since S60 v5.0 + * @return The request ID of this active object. + */ + TInt RequestId(); + + /** + * Set a new request ID for this active object. + * + * @since S60 v5.0 + * @param The new request ID of this active object. + */ + void SetRequestId( TInt aId ); + + /** + * Activate the active object. + * + * @since S60 v5.0 + */ + void GoActive(); + + /** + * Cancel an outstanding request. + * + * @since S60 v5.0 + */ + void CancelRequest(); + + /** + * Get a reference to the active object request status. + * + * @since S60 v5.0 + * @return Reference to the active object request status. + */ + TRequestStatus& RequestStatus(); + +// from base class CActive + + /** + * From CActive. + * Called by the active scheduler when the request has been cancelled. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * From CActive. + * Called by the active scheduler when the request has been completed. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * From CActive. + * Called by the active scheduler when an error in RunL has occurred. + * Error handling is really done by callback in HandleError(). + * + * @since S60 v5.0 + * @param aError Error occured in Active Object's RunL(). + * @return KErrNone. + */ + TInt RunError( TInt aError ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aObserver Pointer to callback interface that receives notification + * that the request has been completed. + * @param aId ID of the request (for the client to keep track of multiple + * active objects). + * @param aPriority Priority of + */ + CBTUIActive( MBTUIActiveObserver* aObserver, TInt aId, TInt aPriority ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: // data + + /** + * ID of the request (used only by our client). + */ + TInt iRequestId; + + /** + * Our observer. + * Not own. + */ + MBTUIActiveObserver* iObserver; + + }; + + +#endif // BTUIACTIVE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIBlockedDevicesView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIBlockedDevicesView.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 2006-2007 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: The view that handles paired devices. +* +*/ + +#ifndef BTUIBLOCKEDDEVICESVIEW_H +#define BTUIBLOCKEDDEVICESVIEW_H + +#include +#include // Menu pane definitions +#include +#include "BtuiPluginInterface.h" +#include "BTUIListedDevicesView.h" +#include + + +class CGSTabHelper; +class CBTUIMainView; //base view +class CBTUiDeviceContainer; +class CBTDevModel; + +/** +* Blocked devicew view of the pluetooth application. +* +* This view handles lists of blocked devices and the abolity to unblock them. +* +*@lib BTUIPlugin.dll +*@since S60 v3.2 +*/ +class CBTUIBlockedDevicesView : public CBTUIListedDevicesView, + public MGSTabbedView + + { + public: // New functions + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL( ); + + /** + * Symbian 2nd phase constructor when serve as GS plugin. + * @param aBaseView, GS base view pointer. + * @param aTabViewArray, the array which contains all the tabed views' pointer. + * @return None. + */ + void ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray ); + + /* + * ECOM implementation instantiation factory function of + * interface "CBtuiPluginInterface", to be used by BTUI Application. + */ + static CBTUIBlockedDevicesView* NewL(MBtuiPluginViewActivationObserver* aObserver = NULL); + + /** + * Symbian 2 phase constructor used by base view when serve as GS plugin. + * @param aBaseView, GS base view pointer. + * @param aTabViewArray, the array which contains all the tabed views' pointer. + * @return None. + */ + static CBTUIBlockedDevicesView* NewLC(CBTUIMainView* aBaseView, + CArrayPtrFlat* aTabViewArray); + + /** + * Destructor. + */ + virtual ~CBTUIBlockedDevicesView(); + + + /** + * From MGSTabbedView: + * Creates new icon for tab. Ownership is transferred to client. + * @since 3.1 + */ + CGulIcon* CreateTabIconL(); + + public: // Functions from base classes + + /** + * From CAknView Returns view id. + * @param None. + * @return View id. + */ + TUid Id() const; + + /** + * From CAknView Handles user commands. + * @param aCommand A command id. + * @return None. + */ + void HandleCommandL(TInt aCommand); + + /** Dim/unDim middleSoftkey. + * This function is called by CBTUiDeviceContainer + * durings screen refreshes based on if there are devices or not. + * + * @param aDimmed. If this is true the middleSoftKey is invisible. + */ + void DimMskL(TBool aDimmed); + + /** + * From CAknView Dynamically initialises options menu. + * @param aResourceId Id identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + * @return None. + */ + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + + public: + /** + * Informs the observer that adevice has been changes or a new device added. + * @param aErr Symbian error code + * @param aDevice the device which is changed. If iAddr == 0, it's for notifiying "GetAllDevices()", + * @param aEnable True: pair/authorize/block/connect; False: unpair/unauthorize/unblock/disconnect + * @param aDevNameArray hold conflicting devices' short names if "AlreadyExist" error happened during "connect" + * @return None. + */ + void NotifyChangeDeviceComplete(const TInt aErr, const TBTDevice& aDevice, + const RBTDevNameArray* aDevNameArray = NULL); + + /** Updates the shown device list. This module will send this list forward + * to container that takes care of the actual display of those devices + * + *@param aDevices all the devices to be shown + *@param aSelectedItemIndex currently selected item after refresh. + */ + void RefreshDeviceList(const RDeviceArray* aDevices,TInt aSelectedItemIndex); + + protected: + /** + * C++ default constructor. + */ + CBTUIBlockedDevicesView (MBtuiPluginViewActivationObserver* aObserver= NULL); + + private: // Functions from base classes + + /** + * From CAknView Activates view. + * @param aPrevViewId Id of previous view. + * @param aCustomMessageId Custom message id. + * @param aCustomMessage Custom message. + * @return None. + */ + void DoActivateL( const TVwsViewId& aPrevViewId, + TUid aCustomMessageId, + const TDesC8& aCustomMessage ); + + /** + * From CAknView Deactivates view. + * @param None. + * @return None. + */ + void DoDeactivate(); + + private: // Data + + CGSTabHelper* iTabHelper; + CBTUIMainView* iBaseView; + TBool iConstructAsGsPlugin; // Flag that indicate this obj is served as GS plugin not BTUI app's plugin. + MBtuiPluginViewActivationObserver* iActivationObserver; // view activation observer + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIDeviceContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIDeviceContainer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,206 @@ +/* +* Copyright (c) 2006-2007 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: The view that handles paired devices. +* +*/ +#ifndef BTUIDEVICECONTAINER_H +#define BTUIDEVICECONTAINER_H + +#include // AVKON components +#include +#include // Commands popup window +#include // For column listbox access +#include + +#include "btdevmodel.h" +#include "btui.hrh" + +class CBTEngConnMan; +class CAknView; +class CBTDevModel; +class CBTUIListedDevicesView; + +/** +* This class displays lists of bluetooth devices. +* +* This class is used by blocked devices view and paired devices view to show +* lists of blocked or paired devices. +* +*@lib BTUIPlugin.dll +*@since S60 v3.2 +*/ +NONSHARABLE_CLASS(CBTUiDeviceContainer) : public CCoeControl, + public MCoeControlObserver, + public MEikListBoxObserver + { + public: // Constructors and destructor + + /** Create new instance + * @param aView PairedDevicesView or BlockedDevicesView. + * @param aStorage The handler of + * @param aContainerMode are we serving as blocked or paired device list + * @param aParent used by SetMopParent + */ + static CBTUiDeviceContainer* NewL(const TRect& aRect, + CBTUIListedDevicesView* aView, TBTDeviceGroup aGroup, MObjectProvider* aParent); + + /** + * Destructor. + */ + virtual ~CBTUiDeviceContainer(); + + public: // Methods ralated devicelist upkeep. + + /** Refreshes this container to show these devices. + * Note: This container will not refresh screen if the listed + * devices have not changed. + *@param aDeviceArray The items to be displayed + *@param aSelectedItem which one of the items is selected after the refresh. + *Must be between 0 and aDeviceArray.Count()-1 or -1 if the list is empty. + */ + void RefreshDeviceListL(const RDeviceArray* aDeviceArray,TInt aSelectedItem); + + /** Counts how many devices this container displays. + * @return the amount of items in this container + */ + TInt CountItems(); + + /** + * Return the currently selected item index. KErrNotFound found if + * this container has no items and therefore no selected item. + * + * @return index of currently selected item, or KErrNotFund if none. + */ + TInt CurrentItemIndex() ; + + private: + /** 2nd phase constructor + * @param aView PairedDevicesView or BlockedDevicesView. + * @param aStorage The handler of + * @param aContainerMode are we serving as blocked or paired device list + * @param aParent used by SetMopParent + */ + void ConstructL(const TRect& aRect, CBTUIListedDevicesView* aView, TBTDeviceGroup aGroup); + + /** + * From CoeControl Responds to size changes. + * Sets the size and position of the contents of this control. + * @param None. + * @return None. + */ + void SizeChanged(); + + /** + * From CoeControl Gets the number of controls contained + * in a compound control. + * @param None. + * @return The number of component controls contained by this control. + */ + TInt CountComponentControls() const; + + /** + * From CoeControl Gets the specified component of a compound control. + * @param aIndex The index of the control to get. + * @return Reference to the component control. + */ + CCoeControl* ComponentControl(TInt aIndex) const; + + /** + * From CoeControl Draws the control. + * @param aRect The region of the control to be redrawn. + * @return None. + */ + void Draw(const TRect& aRect) const; + + /** + * From CoeControl Handles key events. + * @param aKeyEvent The key event that occurred. + * @param aType The event type. + * @return Response to the key event. + */ + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + + /** + * From MCoeControlObserver Handles an event from an observed control. + * @param aControl The control that sent the event. + * @param aEventType The event type. + * @return None. + */ + void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); + + /** returns help context or empty context, if help is not supported + */ + void GetHelpContext(TCoeHelpContext& aContext) const; + + /** + * From CCoeControl + * + * Handles a change to the control's resources. + */ + void HandleResourceChange( TInt aType ); + + /** + * From CCoeControl + * + * Responds to a change in focus. + */ + void FocusChanged(TDrawNow aDrawNow); + + /** + * From MEikListBoxObserver Handles list box events. + * + * This is used to handle touch screen double click. + * + * @param aListBox The originating list box. + * @param aEventType The event type. + * @return None. + */ + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); + + + /** Create descriptor representation of given device + * @param aDevice The device to be represented + * @param aListItem where the representation will be written. + */ + void CreateListItemL(const TBTDevice& aDevice, TBTDeviceName& alistItem); + + /** + * Creates and adds local bitmap to icon array. + * @param aID Item ID of the masked bitmap to be created. + * @param aFilename Filename to be used to construct the item. + * @param aBitmapId The ID if bitmap + * @param aMaskId The ID of bitmap's mask + * @param aIconList The icon list for BT devices listbox. + */ + void CreateAndAppendIconL( const TAknsItemID& aID, + const TDesC& aFileName, + const TInt aBitmapId, + const TInt aMaskId, + CAknIconArray* aIconList); + /** + * Internal leave function called by HandleResourceChange() + * @param aType Type of resource change + */ + void HandleResourceChangeL( TInt aType ); + + private: + CAknSingleGraphicStyleListBox* iDeviceList; // Other paired BT-devices list + CBTUIListedDevicesView* iView; // The reference to PairedDevicesView or BlockedDevicesView + TBTDeviceGroup iGroup; // are we operating blocked or paired devices container + + }; + +#endif + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIKeyWatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIKeyWatcher.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2006-2007 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: Watcher for PubSub and CenRep keys. +* +*/ + + +#ifndef CBTUIKEYWATCHER_H +#define CBTUIKEYWATCHER_H + +#include +#include +#include "BTUIActive.h" + +// Identification for key and active object to be watched +const TInt KBTUIPHYCountWatcher = 0x01; + +/** + * Class CBTUIKeyWatcher + * + * Notify and handle the key values' change. + * + * @since S60 v5.0 + */ +class CBTUIKeyWatcher : public CBase, public MBTUIActiveObserver + { + +public: + + /** + * Two-phase constructor + * + * @param aCaller The one calls this class. + * @param aServiceID Identify which key to be listened to. + * It can be a logical AND value when listening to multiple keys. + */ + static CBTUIKeyWatcher* NewL( TAny* aCaller, TInt aServiceID); + + /** + * Destructor + */ + virtual ~CBTUIKeyWatcher(); + + /** + * From MBTUIActiveObserver. + * Notification that a key value has changed. + * + * @since S60 v5.0 + * @param aActive Active object for the key which value changed. + * @param aId Identification for key, defined in this file. + * @param aStatus Request status + */ + void RequestCompletedL( CBTUIActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTUIActiveObserver. + * Notification that a key value has changed. + * + * @since S60 v5.0 + * @param aActive Active object for the key which value changed. + * @param aId Identification for key, defined in this file. + * @param aError Error occured in Active Object's RunL(). + */ + void HandleError( CBTUIActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor + * @param aCaller The one calls this class. + */ + CBTUIKeyWatcher( TAny* aCaller ); + + /** + * Symbian 2nd-phase constructor + * @param aServiceID Identify which key to be listened to. It can + * be a logical AND value when listening to multiple keys. + */ + void ConstructL( TInt aServiceID ); + +private: // data + + /** + * Property containing count of physical BT connections. + * When physical connections exists, specific BT UI indicator is shown. + */ + RProperty iPHYCountKey; + + /** + * Active object for listening to above keys' change. + * Own. + */ + CBTUIActive* iPHYCountWatcher; + + /** + * Our caller view. + * Not own. + */ + TAny* iCaller; + + }; + +#endif // CBTUIKEYWATCHER_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIListedDevicesView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIListedDevicesView.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006-2007 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: The view that handles paired devices. +* +*/ + +#ifndef BTUILISTEDDEVICESVIEW_H +#define BTUILISTEDDEVICESVIEW_H + +#include "BtuiPluginInterface.h" +#include "BTUIDeviceContainer.h" +#include "btdevmodel.h" +#include "BTUIViewsCommonUtils.h" + +/** +* SuperClass of PairedDevicesView and BlockedDevicesview. +* +* This defines functionality common to PairedDevicesView and BlockedDevicesview. +* +*@lib BTUIPlugin.dll +*@since S60 v3.2 +*/ +class CBTUIListedDevicesView : public CBtuiPluginInterface, + public MBTDeviceObserver, + public TBTUIViewsCommonUtils + + { + public: + + /** Checks if there a device change operation + * ongoing. + * @return ETrue if there is. EFalse otherwise + */ + TBool DeviceChangeInProgress() + { + return iModel && iModel->DeviceChangeInProgress(); + } + + /** The index of currently selected item. + * This function delegates the question to BTUIDevicesContainer. + * @return the index, or KErrNotFound in the list is empty + * or if iContainer is not yet initialized; + */ + TInt CurrentItemIndex() + { + if(iContainer) + return iContainer->CurrentItemIndex(); + else + return KErrNotFound; + } + protected: + CBTUiDeviceContainer* iContainer; + CBTDevModel* iModel; + TBool iCoverDisplayEnabled; + MBtuiPluginViewActivationObserver* iActivationObserver; + }; + +#endif + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIMainContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIMainContainer.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2006-2007 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: Declares container control for application. +* +*/ + +#ifndef BTUIMAINCONTAINER_H +#define BTUIMAINCONTAINER_H + +#include // AVKON components +#include +#include "btui.hrh" +#include "BTUIMainView.h" +#include "btengsettings.h" + +/** +* This class handles main view dependent requests from user and +* contains listbox for main view items. +* +*@lib BTUIPlugin.dll +*@since S60 v3.0 +*/ +class CBTUIMainContainer : public CCoeControl, + public MCoeControlObserver, + public MEikListBoxObserver + { + public: // Constructors and destructor + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL( const TRect& aRect, CBTUIMainView* aMainView ); + + /** + * Destructor. + */ + virtual ~CBTUIMainContainer(); + + + public: // New functions + + /** + * Returns the current item index (highlight position) + * for main setting list. + * @param None. + * @return Current item index. + */ + TInt CurrentItemIndex(); + + /** + * From MBTUISettingsObserver Handles setting changes. + * @param aListItem The changed setting item. + * @return None. + */ + void SettingChanged( TBTMainListItemIndexes aListItem ); + + private: // Functions from base classes + + /** + * From CoeControl Responds to size changes. + * Sets the size and position of the contents of this control. + * @param None. + * @return None. + */ + void SizeChanged(); + + /** + * From CoeControl Gets the number of controls contained + * in a compound control. + * @param None. + * @return The number of component controls contained by this control. + */ + TInt CountComponentControls() const; + + /** + * From CoeControl Gets the specified component of a compound control. + * @param aIndex The index of the control to get. + * @return Reference to the component control. + */ + CCoeControl* ComponentControl(TInt aIndex) const; + + /** + * From CoeControl Draws the control. + * @param aRect The region of the control to be redrawn. + * @return None. + */ + void Draw(const TRect& aRect) const; + + /** + * From CoeControl Handles key events. + * @param aKeyEvent The key event that occurred. + * @param aType The event type. + * @return Response to the key event. + */ + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + + /** + * From MEikListBoxObserver Handles list box events. + * @param aListBox The originating list box. + * @param aEventType The event type. + * @return None. + */ + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); + + /** + * From MCoeControlObserver Handles an event from an observed control. + * @param aControl The control that sent the event. + * @param aEventType The event type. + * @return None. + */ + void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType); + + + /** + * From CoeControl Gets the control's help context. + * @param aContext The control's help context + * @return None. + */ + void GetHelpContext(TCoeHelpContext& aContext) const; + + /** + * From CCoeControl + */ + void HandleResourceChange( TInt aType ); + + /** + * From CCoeControl + */ + void FocusChanged(TDrawNow /*aDrawNow*/); + + + private: // Data + + /** + * Friend class for generating format string for main list. + */ + class TMainListItemArray : public MDesCArray + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + TMainListItemArray( CDesCArray* aBtAllItemsArray, CBTUIMainView* aMainView, + CBTEngSettings* aBtEngSettings ); + + public: // New functions + + /** + * Returns number of items in array / main list. + * @param None. + * @return Number of items. + */ + TInt MdcaCount() const; + + /** + * Returns the current format string for the given item. + * @param aIndex Index of the item. + * @return Pointer to the format string. + */ + TPtrC MdcaPoint(TInt aIndex) const; + private: + static void GetSapStatusL( TInt& aStatus ); + + private: // Data + + // Local BT name format string + __MUTABLE TBuf iItemText; + + // No ownership (reference) + CDesCArray& iArray; + CBTUIMainView* iMainView; + CBTEngSettings* iBtEngSettingsRef; + + }; + + CAknSettingStyleListBox* iBtMainListBox; // The setting items list (scrollable) + CDesCArray* iBtAllItemsArray; // All format string combinations (ownership) + TMainListItemArray* iBtListItemArray; // Format strings for list items + TInt iCurrentItemIndex; // Current highlighted main list item + CBTUIMainView* iMainView; + CBTEngSettings* iBtEngSettingsRef; + + + + private: // Friend classes + + friend class TMainListItemArray; + + + +}; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIMainView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIMainView.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,427 @@ +/* +* Copyright (c) 2006-2007 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: Declares the settings view for BTUI application. +* +*/ + + +#ifndef BTUIMAINVIEW_H +#define BTUIMAINVIEW_H + +#include "BtuiPluginInterface.h" +#include "BTUIViewsCommonUtils.h" +#include "btui.hrh" + +#include // AVKON components +#include // for disconnect type and connection observer +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class CBTUIMainContainer; +class CBTDevModel; +class TBTUIViewsCommonUtils; +class CGSTabHelper; +class CBTUIKeyWatcher; +class CAknViewAppUi; +class MGSTabbedView; + +/** +* Main view of the application. +* +* This view handles option activation, +* deactivation, commands and dynamic options menus. +* +*@lib BTUIPlugin.dll +*@since S60 v3.0 +*/ +class CBTUIMainView : public CBtuiPluginInterface, + public MBTEngSettingsObserver, + public TBTUIViewsCommonUtils, + public MGSTabbedView + { + public: // Constructors and destructor + + + /** + * ECOM implementation instantiation function of + * interface "CBtuiPluginInterface", to be used by BTUI Application. + */ + static CBTUIMainView* NewL(MBtuiPluginViewActivationObserver* aObserver= NULL); + /** + * ECOM implementation instantiation function of + * interface "CGSPluginInterface", to be used by GS application. + */ + static CBTUIMainView* NewGsPluginL(); + + /** + * Destructor. + */ + virtual ~CBTUIMainView(); + + /** + * From MGSTabbedView: + * Creates new icon for tab. Ownership is transferred to client. + * @since 3.1 + */ + CGulIcon* CreateTabIconL(); + + /** + * From MBTEngSettingsObserver - Called when powerstate is changed + * @param TBTPowerStateValue power state + * @return None + */ + void PowerStateChanged( TBTPowerStateValue aState ); + + /** + * From MBTEngSettingsObserver - Called when visibility is changed + * @param TBTPowerStateValue state of visibility mode + * @return None + */ + void VisibilityModeChanged( TBTVisibilityMode aState ); + + protected: + + /** + * C++ default constructor. + */ + CBTUIMainView (MBtuiPluginViewActivationObserver* aObserver= NULL); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + + public: // Functions from base classes + + /** + * From CAknView Returns view id. + * @param None. + * @return View id. + */ + TUid Id() const; + + /** + * Calls possibly leaving HandleCommandL function + * @param aCommand A command id. + * @return None. + */ + void HandleCommand(TInt aCommand); + + /** + * From CAknView Handles user commands. + * @param aCommand A command id. + * @return None. + */ + void HandleCommandL(TInt aCommand); + + /** + * Used by BTUIAppUI to Redraw BT name + * field. + * @param aListItem The changed setting item. + * @return None. + */ + void SettingChangedL( TBTMainListItemIndexes aListItem ); + + private: // Functions from base classes + + /** + * From CAknView Activates view. + * @param aPrevViewId Id of previous view. + * @param aCustomMessageId Custom message id. + * @param aCustomMessage Custom message. + * @return None. + */ + void DoActivateL( const TVwsViewId& aPrevViewId, + TUid aCustomMessageId, + const TDesC8& aCustomMessage ); + + /** + * From CAknView Deactivates view. + * @param None. + * @return None. + */ + void DoDeactivate(); + + /** + * From CAknView Dynamically initialises options menu. + * @param aResourceId Id identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + * @return None. + */ + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + + /** + * From MProgressDialogCallback Get's called when a dialog is dismissed. + * @param aButtonId Id of the pressed button. + * @return None. + */ + void DialogDismissedL( TInt aButtonId ); + + public: // New functions + + /** + * Set the power status of Bluetooth. + * + * @param aValue The new power status. + * @return Symbian OS error code. + */ + TInt SetPowerStatusL( TBool aValue ); + + /** + * Set the visibility mode of Bluetooth. + * + * @param aMode The new visibility mode. + * @return None. + */ + void SetVisibilityStatusL( TBTVisibilityMode aMode ); + + + /** + * Returns the local name of BT Device. + * + * @param None. + * @return The local name. + */ + TDesC* GetBTLocalName(); + + /** + * Returns a reference to class CBTEngSettings. + * + * @param None. + * @return A reference to class CBTEngSettings. + */ + CBTEngSettings* GetBtSettingsReference(); + + /** + * Set the SIM Access Profile status . + * + * @param aValue The new SAP status. + */ + void SetSapStatusL( TBTSapMode aValue ); + + /** + * Update its parent's view + * @param None. + * @return None. + */ + void UpdateParentView(); + + private: + /** takes care of middle softkey press. + */ + void HandleMiddleSoftkey(); + + /** + * Asks new power mode from user via selection buttons. + * + * @param None. + * @return None. + */ + void AskPowerModeDlgL(); + + /** + * Asks new visibility mode from user via selection buttons. + * + * @param None. + * @return None. + */ + void AskVisibilityDlgL(); + + /** + * Asks new local BT Device name from user. + * + * @param None. + * @return None. + */ + void AskNewBtNameDlgL(); + + /** + * A callback for launching local BT Device name query. + * + * @param aAppUi A reference to self. + * @return Symbian OS error code. + */ + static TInt LaunchBTLocalNameQueryL(TAny* aAppUi); + + /** + * Asks local BT Device name from user at startup. + * + * @param None. + * @return Symbian OS error code. + */ + TInt AskBTLocalNameQueryL(); + + /** + * Initiates BT local name query after Symbian OS has entered idle state. + * + * @param None. + * @return None. + */ + void InitiateBTLocalNameQueryL(); + + /** + * blaa blaa + * + * @param aNum count of connectionsions. + * @return None. + */ + TInt GetConnectionNumber(TInt& aNum); + + /** + * Asks new SAP mode from user via selection buttons. + * + * @param None. + * @return None. + */ + void AskSapModeDlgL(); + + /** + * Connected sap name + * + * @param aName + * @return TInt. + */ + TInt GetConnectedSapNameL( TDes& aName ); + + /** + * Get settings' values including power state, discovery mode and connection state + * Then set member varient iBtState. + */ + void RefreshSettingsStatusL(); + + /** + * Internal leave function used by GetValue(). + */ + void GetValueL( const TGSPluginValueKeys aKey, TDes& aValue ); + + /** + * Checks from central repository whether the Bluetooth friendly name + * has been modified . + * @param aStatus + * @return error code + */ + + TInt IsLocalNameModifiedL( TBool& aStatus ); + + public: // Enumerations + + enum TBTStateSummary + { + EBTOff = 0, + EBTOnShown, + EBTOnHidden, + EBTConnectedShown, + EBTConnectedHidden + }; + + private: // from CGSBaseView + + /** + * Handles OK key press. + * @since 3.1 + */ + void HandleListBoxSelectionL(); + + /** + * Creates new container. + * @since 3.1 + */ + void NewContainerL(); + + + public: //Functions from CGSPluginInterface + + /** + * Method for checking plugin's Uid. Uid identifies this GS plugin. Use + * same Uid as the ECOM plugin implementation Uid. + * + * @return PluginUid + */ + TUid PluginUid() const; + + /** + * Method for getting caption of this plugin. This should be the + * localized name of the settings view to be shown in parent view. + * + * @param aCaption pointer to Caption variable + */ + void GetCaptionL( TDes& aCaption ) const; + + + /** + * Creates a new icon of desired type. + * @param aIconType UID Icon type UID of the icon to be created. + * @return Pointer of the icon. NOTE: Ownership of this icon is + * transferred to the caller. + */ + CGulIcon* CreateIconL( const TUid aIconType ); + + /** + * Function for getting plugin's value for a certain key. + * Override to provide own functionality. + * + * @param aKey Key for the value to be retrieved. + * @parem aValue Value for the given gey in TDes format. + */ + void GetValue( const TGSPluginValueKeys aKey, TDes& aValue ); + + /** + * Returns sap status + * + * @param None + * @return TInt. + */ + TInt GetSapStatusL(); + + TVwsViewId GetParentView(); + + /** + * From MGSTabbedView + * @return Reference to owned tabbed views which should be included in + * the sub-view's tab group. + * @since 3.1 + */ + CArrayPtrFlat* TabbedViews(); + + private: // Data + CBTUIMainContainer* iContainer; // Main container + CBTEngSettings* iBtEngSettings; // Settings class + CIdle* iIdle; // Idle time class (for doing operation delayed) + TBTDeviceName iTempNameBuffer; // Temporary storage for BT name + CEikonEnv* iEikEnv; // Local eikonenv + TInt iResourceFileFlag; // Flag for eikon env. + TBool iConstructAsGsPlugin; // Flag that indicate who constrct this obj + TBool iCoverDisplayEnabled; // Flag that indicate cover UI feature + + CGSTabHelper* iTabHelper; + TBool iParentViewNotSetYet; + CArrayPtrFlat* iViewArray; + TVwsViewId iParentView; + TBTStateSummary iBtState; + CBTUIKeyWatcher* iKeyWatcher; + MBtuiPluginViewActivationObserver* iActivationObserver; // view activation observer + }; + +#endif + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,490 @@ +/* +* Copyright (c) 2006-2007 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: The view that handles paired devices. +* +*/ + +#ifndef BTUIPAIREDDEVICESVIEW_H +#define BTUIPAIREDDEVICESVIEW_H + +#include +#include // Menu pane definitions +#include +#include +#include +#include +#include "BtuiPluginInterface.h" +#include "btdevmodel.h" +#include "BTUIListedDevicesView.h" +#include "btuipluginman.h" +#include "BTUIActive.h" +#include +#include + +class CAknNavigationControlContainer; +class CBTUiDeviceContainer; +class CGSTabHelper; +class CBTEngSettings; +class CBTUIMainView; + +// if there are more connection that this, it is disallowed to +// connect to any device +const TInt KBtUiMaxConnections = 6; + +/** +* Paired devicew view of the pluetooth application. +* +* This view handles lists of paired device and pairing new devices, unpairing devices +* and setting previously paired devices as blocked. Also connecting and disconnecting +* are done by using this view. +* +*@lib BTUIPlugin.dll +*@since S60 v3.0 +*/ +class CBTUIPairedDevicesView : public CBTUIListedDevicesView, + public MBTEngSettingsObserver, + public MProgressDialogCallback, + public MBTEngSdpResultReceiver, // for bt discovery. SDP is not used + public MGSTabbedView, + public MBTUIActiveObserver +{ + public: + + /** + * ECOM implementation instantiation function of + * interface "CBtuiPluginInterface", to be used by BTUI Application. + */ + static CBTUIPairedDevicesView* NewL(MBtuiPluginViewActivationObserver* aObserver = NULL); + + static CBTUIPairedDevicesView* NewLC(CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + void ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray ); + + /** + * Destructor. + */ + virtual ~CBTUIPairedDevicesView(); + + /** + * From MGSTabbedView: + * Creates new icon for tab. Ownership is transferred to client. + * @since 3.1 + */ + CGulIcon* CreateTabIconL(); + + public: // Functions from base classes + + /** + * From CAknView Returns view id. + * @param None. + * @return View id. + */ + TUid Id() const; + + /** + * From CAknView Handles user commands. + * @param aCommand A command id. + * @return None. + */ + void HandleCommandL(TInt aCommand); + + protected: + /** + * C++ default constructor. + */ + CBTUIPairedDevicesView (MBtuiPluginViewActivationObserver* aObserver= NULL); + + private: // Functions from base classes + + /** + * From CAknView Activates view. + * @param aPrevViewId Id of previous view. + * @param aCustomMessageId Custom message id. + * @param aCustomMessage Custom message. + * @return None. + */ + void DoActivateL( const TVwsViewId& aPrevViewId, + TUid aCustomMessageId, + const TDesC8& aCustomMessage ); + + /** + * From CAknView Deactivates view. + * @param None. + * @return None. + */ + void DoDeactivate(); + + /** + * From CAknView Dynamically initialises options menu. + * @param aResourceId Id identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + * @return None. + */ + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + + // implemented from MProgressDialogCallback + /** This is used to cancel connecting and pairing, if user presses the Cancel-button. + * From MProgressDialogCallback Get's called when a dialog is dismissed. + * @param aButtonId Id of the pressed button. + * @return None. + */ + void DialogDismissedL( TInt aButtonId ); + + public: // from MBTDeviceObserver + /** + * Informs the observer that an error happened in changing device status or a new device added. + * @param aErr Symbian error code + * @param aDevice the device which is changed. + * @param aDevNameArray hold conflicting devices' short names if "AlreadyExist" error happened during "connect" + * @return None. + */ + void NotifyChangeDeviceComplete(const TInt aErr, const TBTDevice& aDevice, + const RBTDevNameArray* /*aDevNameArray*/ ) ; + /** + * Leaving version of NotifyChangeDeviceComplete + * @param aErr Symbian error code + * @param aDevice the device which is changed. + * @param aDevNameArray hold conflicting devices' short names if "AlreadyExist" error happened during "connect" + * @return None. + */ + void NotifyChangeDeviceCompleteL(const TInt aErr, const TBTDevice& aDevice, + const RBTDevNameArray* /*aDevNameArray*/ ) ; + + /** Updates the shown device list. This module will send this list forward + * to container that takes care of the actual display of those devices + * + *@param aDevices all the devices to be shown + *@param aSelectedItemIndex currently selected item after refresh. + */ + void RefreshDeviceList(const RDeviceArray* aDevices,TInt aSelectedItemIndex); + + private: // From MBTUIActiveObserver + + /** + * Callback to notify that an outstanding request has completed. + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + void RequestCompletedL( CBTUIActive* aActive, TInt aId, + TInt aStatus ); + + /** + * Callback to notify that an error has occurred in RunL. + * + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + void HandleError( CBTUIActive* aActive, TInt aId, + TInt aError ); + + public: // Operations to devices not containing confirmation queries + /** + * Sets the current security setting of the device. + * Does not ask user about it. + * + * @param aTrusted ETrue when trusted, EFalse if untrusted. + * @return None. + */ + void ChangeDeviceSecurityL( TBool aTrusted ); + + /** + * Issues prompts to connects to specified accessory. + * Connects to it if user andswers yes. + * + * @param TBTDevice connect to this device + * @return None. + */ + void ConnectL( const TBTDevice& aDevice, TBool aNewWaitNote ); + + /** + * Disconnects from the selected BT Accessory. + * + * @param None. + * @return None. + */ + void DisconnectL(); + + /** + * Removes iDisconnectQueryDlg created in DisconnectL + * + * @param None. + * @return None. + */ + void CancelDisconnectQueryDlgL(); + + /** + * Disconnects from the selected BT Accessory without query. + * + * @param None. + * @return None. + */ + void DisconnectWithoutQuery(); + + /** Checks if there is an active phonecall. + *@return ETrue if there is, EFalse otherwise + */ + TBool CallOnGoing(); + + + /** This is used to create TCallBack to help. This is static, since TCallBack does not + * allow instance methods. This is used by BlockDeviceDlgL to add help callback to the query. + * + * @param aTCoeHelpContext. Must be instance TCoeHelpContext, or NULL. + * If this is not specified this will open help about blocked devices. + * This is not an instance of TCoeHelpContext, since TCallback does not allow + * parameters of other type that TAny*. + * @return allways KErrNone. TCallBack does not allow void functions + */ + static TInt LaunchHelp(TAny *aTCoeHelpContext=NULL); + + private: //These handle command given by user + /** + * Asks new nick name for the BT Device from user and + * attempt to rename the device. Failures are handled by NotifyChangeDeviceComplete. + * + * @param None. + * @return None. + */ + void RenameDeviceDlgL(); + + /** + * Asks confirmation for deleting a BT Device from user. + * Delete the current device if yes replied yes. + * + * @param None. + * @return None. + */ + void DeleteDeviceDlgL(); + + /** + * Asks confirmation for deleting all BT devices from user. + * Delete the devices if yes replied yes. + * + * @param None. + * @return None. + */ + void DeleteAllDevicesDlgL(); + + /** + * Initiates the pairing procedure to get a new paired device. + * DeviceSearchComplete is called after the dialog is done. + * + * @param None. + * @return None. + */ + void NewPairedDeviceDlgL(); + + /** + * Asks confirmation for Blocking the selected BT Device. + * Blocks the current device if yes replied yes. + * + * @param None. + * @return None. + */ + void BlockDeviceDlgL(); + + /**Opens a wait note. + * + *@param dialog. The dialog object to be used for displaying this note. + *@param aNoteResource The resource of the note, not including the text. + *@param aNoteTextResource The text resource. The %U if this note is filled up with aDevName. + *@param aSec SecondaryDisplaycommand + *@param aDevName The dev name filled in aNoteTextResource + */ + void OpenWaitNoteL(CAknWaitDialog *&dialog,TUint aNoteResource,TUint aNoteTextResource, + TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName); + + /** Open Setting view for peripheral devices + * + * @param None. + * @return None. + */ + void LaunchSettingViewL(); + + public: // Inherited from MBTEngSdpResultReceiver + + + /** Inherited from MBTEngSdpResultReceiver and implemented as empty, + * since this class will not do service searches, only device searches. + */ + void ServiceSearchComplete( const RSdpRecHandleArray& aResult, + TUint aTotalRecordsCount, TInt aErr ) ; + /** Inherited from MBTEngSdpResultReceiver and implemented as empty, + * since this class will not do attributes seaches, only device searches. + */ + void AttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr,TInt aErr ) ; + /** Inherited from MBTEngSdpResultReceiver and implemented as empty, + * since this class will not do service attribute seaches, only device searches. + */ + void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr,TInt aErr ); + + /** + * Provides notification of the result of the discovery of nearby + * Bluetooth devices. If a device is selected this class will try to pair it. + * + * @param aDevice The data structure encapsulates all information + * about the selected device. Ownership of the data + * structure has not been transfered and is still with + * the API client. + * This is not TBTDevice that is normally used inside the UI. + * @param aErr Error code of the device search operation; KErrNone if + * sucessful, KErrCancel if the user cancelled the + * dialog, KErrAbort if CBTEngDiscovery::CancelSearchRemoteDevice + * was called; otherwise one of the system-wide error codes. + */ + void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ); + + /** + * Provides notification of the result of the discovery of nearby + * Bluetooth devices and EIR data. If a device is selected this class will try to pair it. + * + * @since S60 v5.1 + * @param aDevice The data structure encapsulates information + * about the selected device. + * Ownership of the data structure has not been transfered and + * is still with the API client. + * @param aEirWrapper Contains the EIR data of the remote device. + * Ownership of the data structure has not been transfered and + * is still with the API client. + * @param aErr Error code of the device search operation; KErrNone if + * sucessful, KErrCancel if the user cancelled the + * dialog, KErrAbort if CBTEngDiscovery::CancelSearchRemoteDevice + * was called; otherwise one of the system-wide error codes. + */ + void DeviceSearchComplete( CBTDevice* aDevice, + TNameEntry* aNameEntry, + TInt aErr ); + +private: + /** Leaving version of DeviceSearchComplete. + * + * @param aDevice The data structure encapsulates all information + * about the selected device. Ownership of the data + * structure has not been transfered and is still with + * the API client. + * This is not TBTDevice that is normally used inside the UI. + * @param aEirWrapper Contains the EIR data of the remote device. + * Ownership of the data structure has not been transfered and + * is still with the API client. + * @param aErr Error code of the device search operation; KErrNone if + * sucessful, KErrCancel if the user cancelled the + * dialog, KErrAbort if CBTEngDiscovery::CancelSearchRemoteDevice + * was called; otherwise one of the system-wide error codes. + */ + + void DeviceSearchCompleteL( CBTDevice* aDevice, + TNameEntry* aNameEntry, TInt aErr ); + + /** Shows 'Disonnect first' note + * + * @param aDevice + */ + void ShowDisconnecNoteL(TBTDevice *aDevice); + + /** + * Auto connect to headset after pairing succeeded. + * @param aCount the counter of connecting request issuing staring from 0. + */ + void ConnectIfNeededAfterPairL( TInt aCount ); + + public: // internal methods for informing operation completes + /** + * Informs that pairing attempt of a device has been completed. + * Dismisses wait note and displays questions about authorizing and + * connecting, if the device is connectable. + * + * This method is called by ModifyDeviceChangeL. This method will not inform + * iContainer about the pairing since that is done by ModifyDeviceChangeL. + * + * @param aError Status code of the operation. + * @param aDeviceIndex the new place of the device in UI + * @return None. + */ + void BondingCompleteL( TInt aError,const TBTDevice& aDevice); + + /** Informs that attempt to connect to a device is completed. Closes wait + * note and if there was an error shows the error notice. + * + * This method is called by ModifyDeviceChangeL. This method will not inform + * iContainer about the pairing since that is done by ModifyDeviceChangeL. + * + * @param aError KErrNone or system wide error code + * @param aDeviceIndex The index of the new device + * @param aConflictingDeviceName this is filled only when + */ + void ConnectCompleteL(TInt aError,const TBTDevice& aDevice, + const RBTDevNameArray* aConflictingDeviceNames=NULL); + + + /** + * From MBTEngSettingsObserver - Called when powerstate is changed + * @param TBTPowerStateValue power state + * @return None + */ + void PowerStateChanged( TBTPowerStateValue aState ); + + /** + * From MBTEngSettingsObserver - Called when visibility is changed + * @param TBTPowerStateValue state of visibility mode + * @return None + */ + void VisibilityModeChanged( TBTVisibilityMode aState ); + + + private: // Data + + CAknWaitDialog* iWaitForPairingDlg; // Wait note for pairing + CAknWaitDialog* iWaitForConnectDlg; // Wait note for connecting to BT Accessory + CAknQueryDialog* iDisconnectQueryDlg; // Question dialog for disconnecting BT Accessory + TBool iHelpEnabled; // Flag for the Help feature + + // these are needed so these are owened by someone + // and can be cleaned up, in case the operations are interrupted by the user. + CBTDevice* iPairingDevice; + TNameEntry iPairingDevNameEntry; + TBTDevice* iConnectDevice; //device we are trying to connect to + TBTDevice iDisconnectQueryDevice; //device we are trying to disconnect + + CBTEngDiscovery* iDeviceSearcher; // used only for searching devices, not for device discovery + CBTEngSettings* iBtEngSettings; // used only for turning on bluetooth, + CBTUIPluginMan* iBTPluginMan; + CGSTabHelper* iTabHelper; + CBTUIMainView* iBaseView; + TBool iConstructAsGsPlugin; // Flag that indicate this obj is served as GS plugin not BTUI app's plugin. + TInt iExpectedCallBack; // In case of DeleteAll, counter for expected callback NotifyChangeDeviceCompleteL() + TBool iSearchOngoing; + TBool iIsConnectDevice; + MBtuiPluginViewActivationObserver* iActivationObserver; // view activation observer + TBool iIsAlreadyConnected; // used only for showing "Connected to" note once for Stereo device + TBTDevice iMenuDevice; + CEikMenuPane* iActiveMenuPane; + CBTUIActive* iActive; // used for subscribing notifier lock status + TBTDevAddr iPairConnectAddr; // the address of the just paired device + // with which a connection establishment is pending + TBool iIsPairConnect; // if we are doing auto-connecting after pairing or not + +}; + +#endif + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIRegistryWatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIRegistryWatcher.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2002 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: Declares Registry watcher class for BTUI. +* +*/ + + +#ifndef CBTUIREGISTRYWATCHERAO_H +#define CBTUIREGISTRYWATCHERAO_H + +// INCLUDES + +#include + +// CLASS DECLARATION + +/** +* A callback interface for informing content change of BT Registry. +*/ +class MBTUIRegistryObserver + { + public: // New functions + + /** + * Informs the observer that contents of Registry has been changed. + * @param None. + * @return None. + */ + virtual void RegistryContentChangedL()=0; + }; + + +// CLASS DECLARATION + +/** +* An active object based class which can used to listen +* Registry changes +*/ +class CBTUIRegistryWatcherAO : public CActive + { + public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CBTUIRegistryWatcherAO( MBTUIRegistryObserver* aParent ); + + /** + * Destructor. + */ + virtual ~CBTUIRegistryWatcherAO(); + + public: // New functions + + /** + * Starts / continues Registry watching + * + * @param None. + * @return None. + */ + void WatchL(); + + /** + * Starts / continues Registry watching + * + * @param None. + * @return None. + */ + void StopWatching(); + + private: // Functions from base classes + + /** + * From CActive Gets called when CActive::Cancel is called, + * cancels Registry watching. + * + * @param None. + * @return None. + */ + void DoCancel(); + + /** + * From CActive Gets called when content of Registry is changed, + * calls MBTUIRegistryObserver::RegistryContentChangedL. + * + * @param None. + * @return None. + */ + void RunL(); + + /** + * From CActive Handles a leave occurring in the request completion event. + * + * @param aError The leave code. + * @return Symbian OS error code. + */ + TInt RunError(TInt aError); + + private: // Data + + // Reference to observer + MBTUIRegistryObserver* iParent; + // Database handle + RProperty iProperty; + }; + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/BTUIViewsCommonUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/BTUIViewsCommonUtils.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2002-2007 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: +* +*/ + +#ifndef BTUIVIEWSCOMMONUTILS_H +#define BTUIVIEWSCOMMONUTILS_H + +#include + +class CBTEngSettings; +/** +* Utils class which offer common functions that were used by all BTUI views +*/ +class TBTUIViewsCommonUtils + { + public: + + /** + * Displays a general error note. + * + * @param None. + * @return None. + */ + static void ShowGeneralErrorNoteL(); // Display general error note + + /** Check if there are any bluetooth connections. + *@param None + *@return ETrue if there is one or more connections. + */ + static TBool IsAnyDeviceConnectedL(); + + /** Asks user to turn on bluetooth is it it not on. + * @param aBtEngSettings settings object used to turn on the bt. + * @param aCoverDisplayEnabled. True if cover display is enabled. + * @return KErrNone, if bluetooth is on, or has turned on. KErrCancel if user said no. System wide errorcode otherwise. + */ + static TInt TurnBTOnIfNeededL(CBTEngSettings* aBtEngSettings,TBool aCoverDisplayEnabled ); + }; + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/inc/btuipluginman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/btuipluginman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2007 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: Plugin loader +* +*/ + + + +#ifndef BTUIPLUGINMAN_H +#define BTUIPLUGINMAN_H + +#include +#include +#include "BtuiPluginInterface.h" +#include "btdevmodel.h" + +typedef RPointerArray RImplInfoPtrArray; +typedef RPointerArray RPluginPtrArray; + +/** + * Class CBTUIPluginMan + * + * Load plugins of CBtuiPluginInterface + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CBTUIPluginMan ) + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v5.0 + */ + static CBTUIPluginMan* NewL( CAknViewAppUi* aAppUi ); + + /** + * Destructor + */ + virtual ~CBTUIPluginMan(); + + /** + * Get the setting view. + * @param TBTDevice Get this device's view + * @return CAknView the view of the specified plugin + */ + CAknView* GetSettingViewL(TBTDevice& aDevice); + + /** + * Check if the plug-in for specified HID device exists. + * @param TBTDeviceClass Use ClassOfDevice as the property to search + * @return ETrue if exist, otherwise EFalse. + */ + TBool IsPluginAvaiable(TBTDeviceClass aDeviceClassInfo); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + */ + CBTUIPluginMan( CAknViewAppUi* aAppUi ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v5.0 + */ + void ConstructL(); + + /** + * Load plugins which are for HID devices. + * @param None + * @return None + */ + void LoadPluginsL(); + +private: // data + + /** + * Array of pointers to ECom plug-in information objects. + */ + RImplInfoPtrArray iPluginInfoArray; + + /** + * Array of pointers to the BtuiPluginInterface ECom plug-ins loaded by PairedView. + */ + RPluginPtrArray iPluginArray; + + /** + * Current Application process + */ + CAknViewAppUi* iAppUi; + }; + + +#endif // BTUIPLUGINMAN_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIActive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIActive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2007 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: Active object helper class. +* +*/ + + +#include "BTUIActive.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTUIActive::CBTUIActive( MBTUIActiveObserver* aObserver, TInt aId, + TInt aPriority ) +: CActive( aPriority ), + iRequestId( aId ), + iObserver( aObserver ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTUIActive::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTUIActive* CBTUIActive::NewL( MBTUIActiveObserver* aObserver, + TInt aId, TInt aPriority ) + { + CBTUIActive* self = new( ELeave ) CBTUIActive( aObserver, aId, aPriority ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTUIActive::~CBTUIActive() + { + Cancel(); + } + +// --------------------------------------------------------------------------- +// RequestId() +// Return the request ID of this active object. +// --------------------------------------------------------------------------- +// +TInt CBTUIActive::RequestId() + { + return iRequestId; + } + +// --------------------------------------------------------------------------- +// SetRequestId() +// Set a new request ID for this active object. +// --------------------------------------------------------------------------- +// +void CBTUIActive::SetRequestId( TInt aId ) + { + iRequestId = aId; + } + +// --------------------------------------------------------------------------- +// GoActive() +// Set active. +// --------------------------------------------------------------------------- +// +void CBTUIActive::GoActive() + { + SetActive(); + } + +// --------------------------------------------------------------------------- +// CancelRequest() +// Cancel an outstanding request. +// --------------------------------------------------------------------------- +// +void CBTUIActive::CancelRequest() + { + Cancel(); + } + +// --------------------------------------------------------------------------- +// RequestStatus() +// Get a reference to the active object request status. +// --------------------------------------------------------------------------- +// +TRequestStatus& CBTUIActive::RequestStatus() + { + return iStatus; + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been cancelled. +// --------------------------------------------------------------------------- +// +void CBTUIActive::DoCancel() + { + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been completed. +// --------------------------------------------------------------------------- +// +void CBTUIActive::RunL() + { + iObserver->RequestCompletedL( this, iRequestId, iStatus.Int() ); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when an error in RunL has occurred. +// --------------------------------------------------------------------------- +// +TInt CBTUIActive::RunError( TInt aError ) + { + iObserver->HandleError( this, iRequestId, aError ); + return KErrNone; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,431 @@ +/* +* Copyright (c) 2007 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: This is view that handles listing and +* unblocking blocked devices view. +* +*/ + +#include // AVKON components +#include +#include +#include // Compiled resource ids +#include // Feature Manager +#include +#include +#include +#include // Series 60 localisation stringloader +#include +#include // Help launcher +#include + +#include "BTUIBlockedDevicesView.h" +#include "BTUIDeviceContainer.h" +#include "debug.h" +#include "btui.h" + +#include +#include // Tab icon for General Setting +#include "BTUIMainView.h" // base View. +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::ConstructL +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::ConstructL() + { + TRACE_FUNC_ENTRY + + BaseConstructL(R_BTUI_BLOCK_DEVICES_VIEW); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::ConstructL +// Symbian 2nd phase constructor when served as GS plugin. +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray ) + { + iBaseView = aBaseView, + iTabHelper = CGSTabHelper::NewL(); + aTabViewArray->AppendL(this); + + BaseConstructL(R_BTUI_BLOCK_DEVICES_VIEW_GS); + + TRACE_INFO(_L("CBtuiGSPlugin* aBaseView, CArrayPtrFlat* aTabViewArray")) + } + +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::NewL +// Two phased constructor +// --------------------------------------------------------- +// +CBTUIBlockedDevicesView* CBTUIBlockedDevicesView::NewL(MBtuiPluginViewActivationObserver* aObserver) + { + //TRACE_FUNC_ENTRY + CBTUIBlockedDevicesView* self = new (ELeave) CBTUIBlockedDevicesView(aObserver); + CleanupStack::PushL(self); + self->iConstructAsGsPlugin = EFalse; + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::NewL +// Two phased constructor +// --------------------------------------------------------- +// +CBTUIBlockedDevicesView* CBTUIBlockedDevicesView::NewLC(CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray) + { + CBTUIBlockedDevicesView* self = new (ELeave) CBTUIBlockedDevicesView(); + CleanupStack::PushL( self ); + + self->iConstructAsGsPlugin = ETrue; + self->ConstructL( aBaseView, aTabViewArray ); + + return self; + } + +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::CBTUIBlockedDevicesView +// --------------------------------------------------------- + +CBTUIBlockedDevicesView::CBTUIBlockedDevicesView(MBtuiPluginViewActivationObserver* aObserver ) + :iActivationObserver(aObserver) + { + } + +// --------------------------------------------------------- +// Destructor +// --------------------------------------------------------- +// +CBTUIBlockedDevicesView::~CBTUIBlockedDevicesView() + { + TRACE_FUNC_ENTRY + if (iContainer) + { + AppUi()->RemoveFromViewStack(*this, iContainer); + } + + delete iContainer; + delete iModel; + + if(iConstructAsGsPlugin) + delete iTabHelper; + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIBlockedDevicesView::Id +// --------------------------------------------------------- +// +TUid CBTUIBlockedDevicesView::Id() const + { + TRACE_FUNC_ENTRY + return KBtuiPluginUidBlockedDevicesView;//KBTBlockDevicesViewId; + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIBlockedDevicesView::HandleCommandL +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::HandleCommandL(TInt aCommand) + { + TRACE_FUNC_ENTRY + TInt bItemIndex; + switch (aCommand) + { + case EAknSoftkeyBack: + // do not exit if devicechange is in progress. + if(iModel->DeviceChangeInProgress() ) + return; + AppUi()->ActivateLocalViewL(iBaseView->GetParentView().iViewUid ); + break; + + case EAknSoftkeyExit: + // do not exit if devicechange is in progress. + if(iModel->DeviceChangeInProgress() ) + return; + AppUi()->ProcessCommandL(EEikCmdExit); + break; + + case EBTUICmdDelete: + case EBTUICmdUnblock: + { + + bItemIndex = iContainer->CurrentItemIndex(); + if(bItemIndex < 0) + break; + + TBTDevice device; + device.iIndex = bItemIndex; + iModel->GetDevice(device); + + CAknQueryDialog* dialog = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone); + HBufC* s = StringLoader::LoadLC(R_BT_WARN_ERASE_BLOCKED,device.iName); + TInt keypress = dialog->ExecuteLD(R_BT_GENERIC_QUERY, *s); + + CleanupStack::PopAndDestroy(s); + + if(keypress) // User has accepted the dialog + { + device.iOperation = EOpUnblock; + iModel->ChangeDevice(device); + } + + break; + + } + case EBTUICmdDeleteAll: + case EBTUICmdUnblockAll: + { + CAknQueryDialog* dialog = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone); + HBufC* s=iCoeEnv->AllocReadResourceLC(R_BT_WARN_ERASE_ALL_BLOCKED); + TInt keypress=dialog->ExecuteLD(R_BT_GENERIC_QUERY, *s); + CleanupStack::PopAndDestroy(s); + + if(keypress) + { + iModel->ChangeAllDevices(EOpUnblock); + } + + break; + } + + case EAknCmdHelp: + { + #ifdef __SERIES60_HELP + HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), AppUi()->AppHelpContextL()); + #endif + break; + } + + default: + { + AppUi()->HandleCommandL(aCommand); + break; + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------- +// From CAknView +// CBTUIBlockedDevicesView::DoActivateL +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + TRACE_FUNC_ENTRY + // Setup title + // + iModel = CBTDevModel::NewL(EGroupBlocked, this); + iContainer = CBTUiDeviceContainer::NewL(ClientRect(), this, EGroupBlocked, this); + + HBufC* btBlockDevices = iCoeEnv->AllocReadResourceLC(R_BT_TITLE_BLOCKED_DEV); + CEikStatusPane* statusPane = StatusPane(); + CAknTitlePane* titlePane; + titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); + titlePane->SetTextL(*btBlockDevices); + CleanupStack::PopAndDestroy(btBlockDevices); + AppUi()->AddToStackL(*this, iContainer); + DimMskL(ETrue ); + // the MSK will be undimmed, if there are blocked devices when + // the deviceList will be refreshed + + if( iBaseView && iConstructAsGsPlugin) + { + iTabHelper->CreateTabGroupL( Id(), + static_cast*> + (iBaseView->TabbedViews()) ); + } + + // notify observer + if( iActivationObserver && iConstructAsGsPlugin == EFalse) + { + iActivationObserver->PluginViewActivated(EBlockedDevicesViewId); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIBlockedDevicesView::DoDeactivate +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::DoDeactivate() + { + TRACE_FUNC_ENTRY + if (iContainer) + { + AppUi()->RemoveFromStack(iContainer); + delete iContainer; + iContainer = NULL; + } + + delete iModel; + iModel=NULL; + if(iConstructAsGsPlugin) + iTabHelper->RemoveTabGroup(); + + TRACE_FUNC_EXIT + } +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::DimMskL +// This will dim/Undim MSK. +// However the command is sent when the key is pressed +// regardless wether the MSK command is visible and +// the view must be able to receive it anyway. +// --------------------------------------------------------- +void CBTUIBlockedDevicesView::DimMskL(TBool aDimmed) + { + TRACE_FUNC_ENTRY + if(aDimmed) + { + Cba()->SetCommandL (EBTUICmdUnblock,KNullDesC); + } + else + { + if(iConstructAsGsPlugin) + { + Cba()->SetCommandSetL(R_BTUI_SOFTKEYS_OPTIONS_BACK__UNBLOCK); + } + else + { + Cba()->SetCommandSetL(R_BTUI_SOFTKEYS_OPTIONS_EXIT__UNBLOCK); + } + } + + Cba()->DrawDeferred(); + + // NOTE: these will only hide the MSK label. + // The command is still being sent if button is pressed. + // HandleCommanL will take care + // of the situation that there may be no devices to unblock + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIBlockedDevicesView::DynInitMenuPaneL +// Shows selected item's context sensitive options menu. +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::DynInitMenuPaneL(TInt aResId, CEikMenuPane* aMenu) + { + TRACE_FUNC_ENTRY + // dim help if it exists and is not supported + TInt tmp; + if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) + { + aMenu->SetItemDimmed(EAknCmdHelp, + !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); + } + + // do not show "unblock" and "unblock all" commands + // if there is nothing to unblock + if (aResId == R_BTUI_BLOCK_DEVICES_VIEW_MENU) + { + if( iContainer->CountItems() == 0) + { + aMenu->SetItemDimmed(EBTUICmdUnblock, ETrue); + aMenu->SetItemDimmed(EBTUICmdUnblockAll, ETrue); + } + else + { + aMenu->SetItemDimmed(EBTUICmdUnblockAll, EFalse); + aMenu->SetItemDimmed(EBTUICmdUnblock, ETrue); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From MBTDeviceObserver +// CBTUIBlockedDevicesView::NotifyChangeDeviceComplete +// --------------------------------------------------------- +// +void CBTUIBlockedDevicesView::NotifyChangeDeviceComplete(const TInt aErr, + const TBTDevice&, const RBTDevNameArray* ) + { + TRACE_FUNC_ENTRY + // we do not show any note, when blocked devices are unblocked, + // and that is the only command available. + + if(aErr!= KErrNone) + { + TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL();); + } + TRACE_FUNC_EXIT + } + + +// ----------------------------------------------- +// From MBTDeviceObserver +// CBTUIBlockedDevicesView::RefreshDeviceList +// ----------------------------------------------- +void CBTUIBlockedDevicesView::RefreshDeviceList(const RDeviceArray* aDevices, + TInt aSelectedItemIndex) + { + TRACE_FUNC_ENTRY + + TRAPD(err, + if(iContainer) + { + iContainer->RefreshDeviceListL(aDevices,aSelectedItemIndex ); + } + // dim the MSK if there are no devices to unblock + DimMskL(aDevices->Count()==0); + + ); + if(err!= KErrNone) + { + TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CBTUIBlockedDevicesView::CreateTabIconL() +// Creates icon for tab. +// --------------------------------------------------------------------------- +// +CGulIcon* CBTUIBlockedDevicesView::CreateTabIconL() + { + TFileName bmpFilename; + bmpFilename += KBitmapFileDrive; + bmpFilename += KDC_APP_BITMAP_DIR; + bmpFilename += KBtuiBmpFileName; + + CGulIcon* icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropBtBlockedTab3, + bmpFilename, + EMbmBtuiQgn_prop_bt_blocked_tab3, + EMbmBtuiQgn_prop_bt_blocked_tab3_mask ); + + return icon; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIDeviceContainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIDeviceContainer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,669 @@ +/* +* Copyright (c) 2007 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: This is the implementation of device list container. It contains +* all necessary AVKON components and handles user inputs +* for paired and blocked devices view. +* +*/ + + +#include // Compiled resource ids +#include +#include // For Extended skinning icons +#include +#include // For char filter +#include +#include // AVKON icons +#include // Help IDs + +#include "BTUIDeviceContainer.h" +#include "BTUIListedDevicesView.h" +#include "debug.h" +#include "btui.h" // Global declarations + +const TInt KBTNumberOfIcons = 13; // Number of class of device icons + +_LIT( DEV_TYPE_COMPUTER,"0\t"); +_LIT( DEV_TYPE_PHONE,"1\t"); +_LIT( DEV_TYPE_AUDIO,"2\t"); +_LIT( DEV_TYPE_DEFAULT,"3\t"); +_LIT( DEV_TYPE_KEYBOARD,"4\t"); +_LIT( DEV_TYPE_MOUSE,"5\t"); +_LIT( DEV_TYPE_PRINTER,"6\t"); +_LIT( DEV_TYPE_CARKIT,"7\t"); +_LIT( DEV_TYPE_AUDIO_CONNECT,"8\t"); +_LIT( DEV_TYPE_COMPUTER_CONNECT,"9\t"); +_LIT( DEV_TYPE_KEYBOARD_CONNECT,"10\t"); +_LIT( DEV_TYPE_CARKIT_CONNECT,"11\t"); +_LIT( DEV_TYPE_MOUSE_CONNECT,"12\t"); + +_LIT(DEV_STATUS_NORMAL, "\t" ); // blocked in blocked devices view, paired in pairred devices view +_LIT(DEV_STATUS_AUTHORIZED, "\t13" ); // autorized in paired devices view + + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTUiDeviceContainer::ConstructL +// --------------------------------------------------------- +void CBTUiDeviceContainer::ConstructL(const TRect& aRect, + CBTUIListedDevicesView* aView, TBTDeviceGroup aGroup) + { + TRACE_FUNC_ENTRY + + CreateWindowL(); + + iView = aView; + iGroup = aGroup; + // Create new list for other paired bt-devices + // + iDeviceList = new (ELeave) CAknSingleGraphicStyleListBox; + iDeviceList->SetContainerWindowL(*this); + iDeviceList->ConstructL(this, EAknListBoxSelectionList); + + iDeviceList->SetListBoxObserver( this ); + + // Set the empty text at basis of the list + HBufC* devEmptyText = NULL ; + if(iGroup ==EGroupPaired) + { + devEmptyText=iCoeEnv->AllocReadResourceLC( R_BT_NO_PAIRED_DEVICES); + } + else + { + devEmptyText=iCoeEnv->AllocReadResourceLC( R_BT_NO_BLOCKED_DEVICES); + } + iDeviceList->View()->SetListEmptyTextL(*devEmptyText ); + CleanupStack::PopAndDestroy(devEmptyText); + + // Set up filenames for Btui and Avkon bitmaps + TFileName bmpFilename; + bmpFilename += KBitmapFileDrive; + bmpFilename += KDC_APP_BITMAP_DIR; + bmpFilename += KBtuiBmpFileName; + + // The avkon bitmap we will get from AknIconUtils::AvkonIconFileName() + TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName(); + + // Setup graphic items list for BT devices listbox + CAknIconArray* iconList = new(ELeave) CAknIconArray(KBTNumberOfIcons); + CleanupStack::PushL( iconList ); + + + CreateAndAppendIconL( KAknsIIDQgnPropBtComputer, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_computer, + EMbmAvkonQgn_prop_bt_computer_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtPhone, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_phone, + EMbmAvkonQgn_prop_bt_phone_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtAudio, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_audio, + EMbmAvkonQgn_prop_bt_audio_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtMisc, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_misc, + EMbmAvkonQgn_prop_bt_misc_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtKeyboard, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_keyboard, + EMbmAvkonQgn_prop_bt_keyboard_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtMouse, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_mouse, + EMbmAvkonQgn_prop_bt_mouse_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtPrinter, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_printer, + EMbmAvkonQgn_prop_bt_printer_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtCarKit, + avkonbmpFilename, + EMbmAvkonQgn_prop_bt_carkit, + EMbmAvkonQgn_prop_bt_carkit_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtAudioConnect, + bmpFilename, + EMbmBtuiQgn_prop_bt_audio_connect, + EMbmBtuiQgn_prop_bt_audio_connect_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtComputerConnect, + bmpFilename, + EMbmBtuiQgn_prop_bt_computer_connect, + EMbmBtuiQgn_prop_bt_computer_connect_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtKeyboardConnect, + bmpFilename, + EMbmBtuiQgn_prop_bt_keyboard_connect, + EMbmBtuiQgn_prop_bt_keyboard_connect_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtCarKitConnect, + bmpFilename, + EMbmBtuiQgn_prop_bt_car_kit_connect, + EMbmBtuiQgn_prop_bt_car_kit_connect_mask, + iconList); + + CreateAndAppendIconL( KAknsIIDQgnPropBtMouseConnect, + bmpFilename, + EMbmBtuiQgn_prop_bt_mouse_connect, + EMbmBtuiQgn_prop_bt_mouse_connect_mask, + iconList); + + CFbsBitmap* bitmap = NULL; + CFbsBitmap* mask = NULL; + AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), + KAknsIIDQgnIndiBtTrustedAdd, + KAknsIIDQsnIconColors, + EAknsCIQsnIconColorsCG13, + bitmap, mask, + avkonbmpFilename, + EMbmAvkonQgn_indi_bt_trusted_add, + EMbmAvkonQgn_indi_bt_trusted_add_mask, + KRgbBlack); + CGulIcon* icon = CGulIcon::NewL(bitmap, mask); + + CleanupStack::Pop(mask); + CleanupStack::Pop(bitmap); + + CleanupStack::PushL(icon); + iconList->AppendL( icon ); + CleanupStack::Pop(icon); + + + // Transfer iconlist ownership to the listbox + iDeviceList->ItemDrawer()->ColumnData()->SetIconArray(iconList); + CleanupStack::Pop(iconList); + + // Create scrollbars + iDeviceList->CreateScrollBarFrameL(ETrue); + iDeviceList->ScrollBarFrame()->SetScrollBarVisibilityL( + CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto); + + SetRect(aRect); + ActivateL(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUiDeviceContainer::NewL +// --------------------------------------------------------- +CBTUiDeviceContainer* CBTUiDeviceContainer::NewL(const TRect& aRect, + CBTUIListedDevicesView* aView, TBTDeviceGroup aGroup, MObjectProvider* aParent) + { + CBTUiDeviceContainer* self = new (ELeave) CBTUiDeviceContainer(); + self->SetMopParent(aParent); + CleanupStack::PushL(self); + self->ConstructL(aRect, aView, aGroup); + CleanupStack::Pop(self); + return self; + } +// --------------------------------------------------------- +// destructor +// --------------------------------------------------------- + +CBTUiDeviceContainer::~CBTUiDeviceContainer() + { + TRACE_FUNC_ENTRY + delete iDeviceList; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUiDeviceContainer::RefreshDeviceListL +// This function will refresh only the changed parts of the +// screen, if any. +// --------------------------------------------------------- +void CBTUiDeviceContainer::RefreshDeviceListL(const RDeviceArray* aDeviceArray,TInt selectedItem) + { + TRACE_FUNC_ENTRY + + MDesCArray* itemTextArray = iDeviceList->Model()->ItemTextArray(); + CDesCArray* itemArray = (CDesCArray*) itemTextArray; + TBool removal=EFalse; + TBool addition=EFalse; + TInt previouslySelected=CurrentItemIndex(); + TBTDeviceName listItem; + TInt deviceCount = aDeviceArray->Count(); + TInt i = 0; + for( ; i < deviceCount; i++) + { + TBTDevice device = *(*aDeviceArray)[i]; + CreateListItemL(device, listItem); + if(itemArray->Count()<=i) + { + itemArray->AppendL(listItem); + addition=ETrue; + } + else + if(listItem != (*itemArray)[i] ) + { + itemArray->Delete(i); + itemArray->InsertL(i,listItem); + + removal=ETrue; + addition=ETrue; + } + + } + if(itemArray->Count()-i>=0) + { + itemArray->Delete(i,itemArray->Count()-i); + removal=ETrue; + } + + + if(removal) + iDeviceList->HandleItemRemovalL(); + if(addition) + iDeviceList->HandleItemAdditionL(); + + if(deviceCount >0 ) + iDeviceList->SetCurrentItemIndex( Max(selectedItem,0 )) ; + + if(addition | removal | previouslySelected!=selectedItem) + iDeviceList->DrawDeferred(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUiDeviceContainer::CountItems +// --------------------------------------------------------- +TInt CBTUiDeviceContainer::CountItems() + { + return iDeviceList->Model()->ItemTextArray()->MdcaCount(); + } + +// --------------------------------------------------------- +// CBTUiDeviceContainer::CreateListItemL +// --------------------------------------------------------- +void CBTUiDeviceContainer::CreateListItemL(const TBTDevice& aDevice, TBTDeviceName& aListItem) + { + TRACE_FUNC_ENTRY + aListItem.Zero(); // may not needed + + TInt iconIndex = (TInt)(aDevice.iType); + + switch( iconIndex) + { + case EDeviceComputer: + if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + aListItem.Append(DEV_TYPE_COMPUTER_CONNECT); + } + else + { + aListItem.Append(DEV_TYPE_COMPUTER); + } + break; + + case EDevicePhone: + aListItem.Append(DEV_TYPE_PHONE); + break; + + case EDeviceAudio: + if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + aListItem.Append(DEV_TYPE_AUDIO_CONNECT); + } + else + { + aListItem.Append(DEV_TYPE_AUDIO); + } + break ; + case EDeviceCarkit: + if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + aListItem.Append(DEV_TYPE_CARKIT_CONNECT); + } + else + { + aListItem.Append(DEV_TYPE_CARKIT); + } + break ; + + case EDevicePrinter: + aListItem.Append(DEV_TYPE_PRINTER); + break; + + case EDeviceKeyboard: + + if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + aListItem.Append(DEV_TYPE_KEYBOARD_CONNECT); + } + else + { + aListItem.Append(DEV_TYPE_KEYBOARD); + } + break ; + + case EDeviceMice: + + if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + aListItem.Append(DEV_TYPE_MOUSE_CONNECT); + } + else + { + aListItem.Append(DEV_TYPE_MOUSE); + } + break; + + case EDeviceDefault: + aListItem.Append(DEV_TYPE_DEFAULT); + break; + + default: + aListItem.Append('\t'); + break; + } + + aListItem.Append(aDevice.iName); + + if((aDevice.iStatus & EStatusTrusted) == EStatusTrusted && iGroup ==EGroupPaired ) + { + aListItem.Append(DEV_STATUS_AUTHORIZED); + } + else + { + aListItem.Append( DEV_STATUS_NORMAL ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::OfferKeyEventL +// --------------------------------------------------------- +TKeyResponse CBTUiDeviceContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, + TEventCode aType) + { + TRACE_FUNC_ENTRY + // Inform model where we are now + TInt bItemIndex = CurrentItemIndex(); + + // Shortcut for deleting a device + if ((aKeyEvent.iCode == EKeyBackspace) && (bItemIndex >= 0)) + { + iView->HandleCommandL( EBTUICmdDelete ); + return EKeyWasConsumed; + } + + // Show popup commands window if selection or enter key is pressed. + // It should not go to here, unless | EAknEnableMSK is not set + if ((aKeyEvent.iCode == EKeyDevice3) || (aKeyEvent.iCode == EKeyEnter)) + { + iView->ProcessCommandL(EAknSoftkeyContextOptions); + return EKeyWasConsumed; + } + + if ((aKeyEvent.iCode != EKeyLeftArrow) && + (aKeyEvent.iCode != EKeyRightArrow)) + { + TRACE_FUNC_EXIT + return iDeviceList->OfferKeyEventL(aKeyEvent, aType); + } + else + { + // BTRegistry operations are not done in atomic way + // so we cannot allow them to be interrupted + if(iView->DeviceChangeInProgress()) + return EKeyWasConsumed; + + TRACE_FUNC_EXIT + return EKeyWasNotConsumed; + } + } + +// ---------------------------------------------------- +// CBTUiDeviceContainer::CreateAndAppendIconL +// ---------------------------------------------------- +void CBTUiDeviceContainer::CreateAndAppendIconL( + const TAknsItemID& aID, + const TDesC& aFileName, + const TInt aBitmapId, + const TInt aMaskId, + CAknIconArray* aIconList) + { + TRACE_FUNC_ENTRY + + CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), + aID, aFileName, aBitmapId, aMaskId); + + CleanupStack::PushL(icon); + aIconList->AppendL(icon); + CleanupStack::Pop(icon); + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::GetHelpContext +// --------------------------------------------------------- +void CBTUiDeviceContainer::GetHelpContext(TCoeHelpContext& aContext) const + { + TRACE_FUNC_ENTRY +#ifdef __SERIES60_HELP + + aContext.iMajor = KBtuiUid3; + if( iGroup ==EGroupPaired) + aContext.iContext = KBT_HLP_PAIRED; + else + aContext.iContext = KBT_HLP_BLOCKED ; +#else +#endif + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::SizeChanged +// Called by framework when the view size is changed +// --------------------------------------------------------- +void CBTUiDeviceContainer::SizeChanged() + { + TRACE_FUNC_ENTRY + iDeviceList->SetRect(Rect()); // Mandatory, otherwise not drawn + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::CountComponentControls +// --------------------------------------------------------- +TInt CBTUiDeviceContainer::CountComponentControls() const + { + TRACE_FUNC_ENTRY + // return number of controls inside this container + return 1; + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::ComponentControl +// --------------------------------------------------------- +CCoeControl* CBTUiDeviceContainer::ComponentControl(TInt aIndex) const + { + TRACE_FUNC_ENTRY + if(aIndex == 0) + { + return iDeviceList ; + } + else + { + return NULL; + } + } + +// ---------------------------------------------------- +// CBTUiDeviceContainer::CurrentItemIndex +// ---------------------------------------------------- +TInt CBTUiDeviceContainer::CurrentItemIndex() + { + TRACE_FUNC_ENTRY + + return iDeviceList->CurrentItemIndex(); + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::Draw +// --------------------------------------------------------- +void CBTUiDeviceContainer::Draw( const TRect& /* aRect */ ) const + { + } + +// --------------------------------------------------------- +// From MCoeControlObserver +// CBTUiDeviceContainer::HandleControlEventL +// --------------------------------------------------------- +void CBTUiDeviceContainer::HandleControlEventL( CCoeControl* /* aControl */, TCoeEvent /* aEventType */ ) + { + TRACE_FUNC_ENTRY + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::HandleResourceChange +// --------------------------------------------------------- +void CBTUiDeviceContainer::HandleResourceChange( TInt aType ) + { + TRACE_FUNC_ENTRY + CCoeControl::HandleResourceChange(aType); + TRAP_IGNORE(HandleResourceChangeL(aType)); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// Internal Leave function +// CBTUiDeviceContainer::HandleResourceChangeL +// --------------------------------------------------------- +void CBTUiDeviceContainer::HandleResourceChangeL( TInt aType ) + { + TRACE_FUNC_ENTRY + + //Handle change in layout orientation + if (aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange ) + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); + + // Because the trailing icons are not changed properly after theme is changed. + // we refresh those icons in the iconlist from iDeviceList manually. + + // Get iconlist from listbox + CAknIconArray* iconList = static_cast(iDeviceList->ItemDrawer()->ColumnData()->IconArray()); + + CleanupStack::PushL( iconList ); + // remove the last two icons which will not be updated properly by theme changing. + iconList->Delete(KBTNumberOfIcons-1); + + // The avkon bitmap we will get from AknIconUtils::AvkonIconFileName() + TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName(); + + + + CFbsBitmap* bitmap = NULL; + CFbsBitmap* mask = NULL; + AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), + KAknsIIDQgnIndiBtTrustedAdd, + KAknsIIDQsnIconColors, + EAknsCIQsnIconColorsCG13, + bitmap, mask, + avkonbmpFilename, + EMbmAvkonQgn_indi_bt_trusted_add, + EMbmAvkonQgn_indi_bt_trusted_add_mask, + KRgbBlack); + + + CGulIcon* icon = CGulIcon::NewL(bitmap, mask); + + CleanupStack::Pop(2); // bitmap, mask; + + CleanupStack::PushL(icon); + + iconList->AppendL( icon ); + CleanupStack::Pop(icon); + + + // Transfer iconlist ownership back to the listbox + iDeviceList->ItemDrawer()->ColumnData()->SetIconArray(iconList); + CleanupStack::Pop(iconList); + + SetRect(mainPaneRect); + DrawDeferred(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::FocusChanged +// --------------------------------------------------------- +void CBTUiDeviceContainer::FocusChanged(TDrawNow /*aDrawNow*/) + { + TRACE_FUNC_ENTRY + iDeviceList->SetFocus(IsFocused()); + TRACE_FUNC_EXIT + } +// --------------------------------------------------------- +// From CCoeControl +// CBTUiDeviceContainer::HandleListBoxEventL +// +// Handle touch screen singleclick as MSK devent to paired view or +// as delete key event to blocked devices view. +// --------------------------------------------------------- +// +void CBTUiDeviceContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) + { + TRACE_FUNC_ENTRY + // this is no longer called, unless MSK is disabled. + // if msk is not disabled, then + // BTMainView::HandleCommand(EBTUICmdMSK) is called instead + if( aEventType == EEventEnterKeyPressed + || aEventType == EEventItemSingleClicked) // Selection key pressed, or item clicked + { + // msk open context options in paired devices view. + // it will unblock the selected blocked device in blocked devices view. + if(iGroup==EGroupPaired) + { + iView->ProcessCommandL( EAknSoftkeyContextOptions); + } + else + { + iView->ProcessCommandL( EBTUICmdUnblock); + } + + } + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIKeyWatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIKeyWatcher.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2007 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: Listen to CenRep and PubSub Keys +* +*/ + + +#include +#include +#include +#include +#include "BTUIKeyWatcher.h" +#include "BTUIMainView.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTUIKeyWatcher* CBTUIKeyWatcher::NewL( TAny* aCaller, TInt aServiceID ) + { + CBTUIKeyWatcher* self = new( ELeave ) CBTUIKeyWatcher( aCaller ); + CleanupStack::PushL( self ); + self->ConstructL( aServiceID ); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTUIKeyWatcher::CBTUIKeyWatcher( TAny* aCaller ) +: iCaller( aCaller ) + { + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTUIKeyWatcher::ConstructL( TInt aServiceID ) + { + TRACE_FUNC_ENTRY + + if( aServiceID & KBTUIPHYCountWatcher ) + { + TInt err = iPHYCountKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount ); + if( !err ) + { + iPHYCountWatcher = CBTUIActive::NewL( this, KBTUIPHYCountWatcher, CActive::EPriorityStandard ); + if( iPHYCountWatcher != NULL ) + { + iPHYCountKey.Subscribe( iPHYCountWatcher->RequestStatus() ); + iPHYCountWatcher->GoActive(); + } + else + { + TRACE_INFO(_L("new iPHYCountWatcher failed")); + } + } + else + { + TRACE_INFO((_L("Attach failed %d"), err)) + } + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTUIKeyWatcher::~CBTUIKeyWatcher() + { + TRACE_FUNC_ENTRY + + if( iPHYCountKey.Handle() ) + { + iPHYCountKey.Cancel(); + } + if( iPHYCountWatcher ) + { + delete iPHYCountWatcher; + iPHYCountWatcher = NULL; + } + iPHYCountKey.Close(); + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Processes a changed key value. +// --------------------------------------------------------------------------- +// +void CBTUIKeyWatcher::RequestCompletedL( CBTUIActive* aActive, TInt aId, TInt /*aStatus*/ ) + { + switch( aId ) + { + case KBTUIPHYCountWatcher: + iPHYCountKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + static_cast(iCaller)->UpdateParentView(); + break; + default: + TRACE_INFO((_L("wrong key notification! id=%d"), aId)) + break; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Handles a leave in RunL/RequestCompletedL by checking that all +// the subscriptions are active. +// --------------------------------------------------------------------------- +// +void CBTUIKeyWatcher::HandleError( CBTUIActive* aActive, TInt aId, TInt aError ) + { + TRACE_INFO((_L("status = %d"), aError)) + (void) aError; + if( !aActive->IsActive() ) + { + switch( aId ) + { + case KBTUIPHYCountWatcher: + iPHYCountKey.Subscribe( aActive->RequestStatus() ); + aActive->GoActive(); + break; + default: + TRACE_INFO((_L("wrong key notification! id=%d"), aId)) + break; + } + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIMainContainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIMainContainer.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,466 @@ +/* +* Copyright (c) 2006-2007 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: This is the implementation of main container. It contains +* all necessary AVKON components and handles user inputs. +* +*/ + +#include +#include +#include // Resource reader +#include // Compiled resource ids +#include // For EnterpriseEnablementL() +#include "BTUIMainContainer.h" +#include "debug.h" // Global declarations +#include "btui.h" +#ifdef __SERIES60_HELP +#include // Help ids +#endif + +// --------------------------------------------------------- +// CBTUIMainContainer::ConstructL +// Symbian OS 2nd phase constructor can leave +// --------------------------------------------------------- +// +void CBTUIMainContainer::ConstructL(const TRect& aRect, CBTUIMainView* aMainView ) + { + TRACE_FUNC_ENTRY + + CreateWindowL(); + + iMainView = aMainView; + + // Check if listbox is empty + __ASSERT_DEBUG(iBtMainListBox==0, PANIC( EBTMainListNotEmpty )); + __ASSERT_DEBUG(iBtAllItemsArray==0, PANIC( EBTAllFormatStingsArrayNotEmpty )); + __ASSERT_DEBUG(iBtListItemArray==0, PANIC( EBTFormatStingsArrayNotEmpty )); + + // Create main itemlist + iBtMainListBox = new (ELeave) CAknSettingStyleListBox; + iBtMainListBox->SetContainerWindowL( *this ); + iBtMainListBox->ConstructL( this, EAknListBoxMarkableList ); + + + // Update settings from original sources via model + iBtEngSettingsRef = iMainView->GetBtSettingsReference(); + + __ASSERT_DEBUG(iBtEngSettingsRef!=0, PANIC(EBTPanicIllegalValue)); + + // Read all format strings from resources and create array for them + iBtAllItemsArray = iCoeEnv->ReadDesCArrayResourceL( R_BT_LABEL_STRINGS ); + iBtListItemArray = new (ELeave) TMainListItemArray( + iBtAllItemsArray, aMainView, iBtEngSettingsRef ); + + // Set up/down arrows at bottom of the screen (scrollbar) + iBtMainListBox->CreateScrollBarFrameL( ETrue ); + iBtMainListBox->ScrollBarFrame()->SetScrollBarVisibilityL( + CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); + + // Set text labels for list items again (overwriting resource definitions) + iBtMainListBox->Model()->SetItemTextArray( iBtListItemArray ); + iBtMainListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); // Does not delete items array + + // Set up the observer (events listener) + iBtMainListBox->SetListBoxObserver( this ); + + + + SetRect(aRect); + ActivateL(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// Destructor +// --------------------------------------------------------- +// +CBTUIMainContainer::~CBTUIMainContainer() + { + TRACE_FUNC_ENTRY + delete iBtMainListBox; + delete iBtAllItemsArray; + delete iBtListItemArray; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIMainContainer::SizeChanged() +// From CCoeControl +// Called by framework when the view size is changed +// --------------------------------------------------------- +// +void CBTUIMainContainer::SizeChanged() + { + TRACE_FUNC_ENTRY + iBtMainListBox->SetRect(Rect()); // Mandatory, otherwise not drawn + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::CountComponentControls() const +// --------------------------------------------------------- +// +TInt CBTUIMainContainer::CountComponentControls() const + { + TRACE_FUNC_ENTRY + if(iBtMainListBox ) + return 1; + else + return 0; // return nbr of controls inside this container + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::ComponentControl(TInt aIndex) const +// --------------------------------------------------------- +// +CCoeControl* CBTUIMainContainer::ComponentControl(TInt aIndex) const + { + TRACE_FUNC_ENTRY + if( aIndex ==0 ) + { + return iBtMainListBox; + } + return NULL; + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::Draw +// --------------------------------------------------------- +// +void CBTUIMainContainer::Draw(const TRect& /* aRect */) const + { + } + +// --------------------------------------------------------- +// From CoeControl +// CBTUIMainContainer::HandleControlEventL +// --------------------------------------------------------- +// +void CBTUIMainContainer::HandleControlEventL( CCoeControl* /* aControl */, TCoeEvent /* aEventType */) + { + } + +// --------------------------------------------------------- +// From CoeControl +// CBTUIMainContainer::OfferKeyEventL +// Redirect keypresses to the listbox +// --------------------------------------------------------- +// +TKeyResponse CBTUIMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) + { + TRACE_FUNC_ENTRY + if(( iBtMainListBox ) && ( aKeyEvent.iCode != EKeyLeftArrow ) + && (aKeyEvent.iCode != EKeyRightArrow )) + { + TKeyResponse res = iBtMainListBox->OfferKeyEventL( aKeyEvent, aType ); + + // Store current item index for options list usage later + // + iCurrentItemIndex = iBtMainListBox->CurrentItemIndex(); + return res; + } + return EKeyWasNotConsumed; + } + +// --------------------------------------------------------- +// From MEikListBoxObserver +// CBTUIMainContainer::HandleListBoxEventL +// --------------------------------------------------------- +// +void CBTUIMainContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) + { + TRACE_FUNC_ENTRY + + __ASSERT_DEBUG(iMainView!=0, PANIC(EBTPanicIllegalValue)); + + // this is no longer called, unless MSK is disabled. + // if msk is not disabled, then + // BTMainView::HandleCommand(EBTUICmdMSK) is called instead + if( aEventType == EEventEnterKeyPressed + || aEventType == EEventItemSingleClicked ) // Selection key pressed, or item clicked + { + TInt currentHighLightPosition = aListBox->CurrentItemIndex(); + switch(currentHighLightPosition) + { + case EBTMainListItemPowerMode: + iMainView->HandleCommandL( EBTUICmdChangePowerStateSelect ); + break; + case EBTMainListItemVisibilityMode: + iMainView->HandleCommandL( EBTUICmdChangeVisibilitySelect ); + break; + case EBTMainListItemNameSetting: + iMainView->HandleCommandL( EBTUICmdChangeBTNameSelect ); + break; + + // For Bluetooth SIM Access Profile feature + // + case EBTMainListItemSapMode: + iMainView->HandleCommandL( EBTUICmdChangeSapStateSelect ); + break; + default: + break; + } + aListBox->DrawItem(currentHighLightPosition); // Redraw item only to the screen + } + } + +// ---------------------------------------------------- +// From CEikListBox +// CBTUIMainContainer::CurrentItemIndex +// ---------------------------------------------------- +// +TInt CBTUIMainContainer::CurrentItemIndex() + { + TRACE_FUNC_ENTRY + + return iBtMainListBox->CurrentItemIndex(); + } + +// ---------------------------------------------------- +// CBTUIMainContainer::SettingChangedL +// ---------------------------------------------------- +// +void CBTUIMainContainer::SettingChanged( TBTMainListItemIndexes /* aListItem */ ) + { + TRACE_FUNC_ENTRY + + iBtMainListBox->DrawDeferred(); + } + +#ifdef __SERIES60_HELP + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::GetHelpContext +// --------------------------------------------------------- +// +void CBTUIMainContainer::GetHelpContext(TCoeHelpContext& aContext) const + { + TRACE_FUNC_ENTRY + + aContext.iMajor = KBtuiUid3; + aContext.iContext = KBT_HLP_MAIN; + } + +#else + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::GetHelpContext +// --------------------------------------------------------- +// +void CBTUIMainContainer::GetHelpContext(TCoeHelpContext& /*aContext*/) const + { + TRACE_FUNC_ENTRY + } + +#endif + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::HandleResourceChange +// --------------------------------------------------------- +// +void CBTUIMainContainer::HandleResourceChange( TInt aType ) + { + TRACE_FUNC_ENTRY + //Pass the event to base class, so whenever resource changing happened, + //this control will be considered to be re-drawed by base class, therefore + //no specific DrawNow() function call is needed here. + CCoeControl::HandleResourceChange(aType); + + //Handle change in layout orientation + //aType == KAknsMessageSkinChange is handled by base class. + if (aType == KEikDynamicLayoutVariantSwitch) + { + //"TRect rect = iAvkonAppUi->ClientRect();" + // The line above provides to big rectangle in the bottom causing cba's overdrawn by by blank area. + // Correct way to do this is below. + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); + SetRect(mainPaneRect); + } + } + +// --------------------------------------------------------- +// From CCoeControl +// CBTUIMainContainer::FocusChanged +// --------------------------------------------------------- +// +void CBTUIMainContainer::FocusChanged(TDrawNow /*aDrawNow*/) + { + TRACE_FUNC_ENTRY + if( iBtMainListBox) + { + iBtMainListBox->SetFocus( IsFocused() ); + } + } + + +// ******************************************* +// Nested class function implemenations: +// ******************************************* + +// ---------------------------------------------------- +// CBTUIMainContainer::TMainListItemArray::TMainListItemArray +// Initialize friend class +// ---------------------------------------------------- +CBTUIMainContainer::TMainListItemArray::TMainListItemArray( CDesCArray* aBtAllItemsArray, + CBTUIMainView* aMainView, CBTEngSettings* aBtEngSettings) + + : iArray( *aBtAllItemsArray ), // Store references + iMainView( aMainView ), + iBtEngSettingsRef( aBtEngSettings ) + + { + TRACE_FUNC_ENTRY + } + +// ---------------------------------------------------- +// CBTUIMainContainer::TMainListItemArray::MdcaCount() +// ---------------------------------------------------- +// +TInt CBTUIMainContainer::TMainListItemArray::MdcaCount() const + { + TRACE_FUNC_ENTRY + return KNumberOfMainViewItems; + } + +// ---------------------------------------------------- +// CBTUIMainContainer::TMainListItemArray::MdcaPointL +// Main view listbox item formatter: +// Returns the current format string depending value +// of the item concerned. +// ---------------------------------------------------- +// +TPtrC CBTUIMainContainer::TMainListItemArray::MdcaPoint( TInt aIndex ) const + { + TRACE_FUNC_ENTRY + _LIT(KBTUIEmptyFormatString, " \t \t\t "); // Empty format string if illegal indexing + TPtrC chosen; + + switch ( aIndex ) + { + case EBTMainListItemPowerMode: + { + TBTPowerStateValue powerState; + iBtEngSettingsRef->GetPowerState(powerState); + if( powerState==EBTPowerOn ) + chosen.Set( iArray.MdcaPoint( EBTUISettModulePowerOn )); + else + chosen.Set( iArray.MdcaPoint( EBTUISettModulePowerOff )); + break; + } + + case EBTMainListItemVisibilityMode: + { + TBTVisibilityMode mode; + iBtEngSettingsRef->GetVisibilityMode(mode); + + switch(mode) + { + case EBTVisibilityModeGeneral: + chosen.Set( iArray.MdcaPoint( EBTUISettVisibilityModeGeneral )); + break; + + case EBTVisibilityModeHidden: + chosen.Set( iArray.MdcaPoint( EBTUISettVisibilityModeHidden )); + break; + + case EBTVisibilityModeTemporary: + chosen.Set( iArray.MdcaPoint( EBTUISettVisibilityModeTemp )); + break; + + default: + break; + } + break; + } + + case EBTMainListItemNameSetting: + { + TDes &buf = MUTABLE_CAST(TBuf&,iItemText); + buf.Zero(); + buf.Append( iArray.MdcaPoint( EBTUISettBTNameHeader ) ); + buf.Append( *iMainView->GetBTLocalName() ); + chosen.Set( iItemText ); + break; + } + + // For Bluetooth SIM Access Profile feature + case EBTMainListItemSapMode: + { + BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EEnabled; + TRAPD(err, mode = BluetoothFeatures::EnterpriseEnablementL()); + if ( err == KErrNone ) + { + if ( mode == BluetoothFeatures::EDataProfilesDisabled ) + { + chosen.Set( iArray.MdcaPoint( EBTUISettSapDisabled )); + break; + } + } + + TInt sapStatus; + TRAP_IGNORE(GetSapStatusL(sapStatus);); + + if(sapStatus==EBTSapEnabled) + { + chosen.Set( iArray.MdcaPoint( EBTUISettSapEnabled )); + } + else + { + chosen.Set( iArray.MdcaPoint( EBTUISettSapDisabled )); + } + + TInt sapMode = KErrNone; + TRAP_IGNORE(sapMode = iMainView->GetSapStatusL()); + + + if(sapMode==EBTSapEnabled) + { + if ( sapMode ) + { + chosen.Set( iArray.MdcaPoint( EBTUISettSapEnabled )); + } + else + { + chosen.Set( iArray.MdcaPoint( EBTUISettSapDisabled )); + } + } + + break; + } + default: + chosen.Set( KBTUIEmptyFormatString ); + break; + } + + return chosen; + } + +// ---------------------------------------------------------------------- +// CBTUIMainContainer::TMainListItemArray::GetSapStatusL(TInt& aStatus) +// ---------------------------------------------------------------------- +// +void CBTUIMainContainer::TMainListItemArray::GetSapStatusL( TInt& aStatus ) +{ + CRepository* repository = CRepository::NewL(KCRUidBTEngPrivateSettings); + CleanupStack::PushL(repository); + repository->Get(KBTSapEnabled, aStatus); + CleanupStack::PopAndDestroy(repository); +} diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIMainView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIMainView.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1402 @@ +/* +* Copyright (c) 2002-2007 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: This is the settings view of btui. +* +*/ + +#include // AVKON components +#include +#include +#include // Feature Manager API + +#include "btui.hrh" // Menu commands +#include "btui.h" +#include "BTUIMainView.h" +#include "BTUIMainContainer.h" +#include "debug.h" +#include "BTUIKeyWatcher.h" +#include "BTUIPairedDevicesView.h" +#include "BTUIBlockedDevicesView.h" + +#include // Compiled resource ids +#include +#include +#include +#include +#include // Series 60 localisation stringloader +#include //visibility time setting page +#include +#include // BAFL utils (for language file) +#include // application icon for General Setting +#include +#include // For char filter +#include +#include // Help launcher +#include +#include +#include +#include +#include +#include // CnvUtfConverter +#include // For EnterpriseEnablementL() +#include + +// --------------------------------------------------------- +// CBTUIMainView::NewL +// Two phased constructor +// --------------------------------------------------------- +// +CBTUIMainView* CBTUIMainView::NewL(MBtuiPluginViewActivationObserver* aObserver) + { + //TRACE_FUNC_ENTRY + + CBTUIMainView* self = new (ELeave) CBTUIMainView(aObserver); + + // Set construction type, before ConstructL(). + self->iConstructAsGsPlugin = EFalse; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + //TRACE_FUNC_EXIT + return self; + } + + +// --------------------------------------------------------- +// CBTUIMainView::NewL +// Two phased constructor +// --------------------------------------------------------- +// +CBTUIMainView* CBTUIMainView::NewGsPluginL() + { + //TRACE_FUNC_ENTRY + + CBTUIMainView* self = new (ELeave) CBTUIMainView(NULL); + + // Set construction type, before ConstructL(). + self->iConstructAsGsPlugin = ETrue; + + CleanupStack::PushL( self ); + self->ConstructL(); + + CleanupStack::Pop( self ); + + //TRACE_FUNC_EXIT + return self; + } + + +// --------------------------------------------------------- +// CBTUIMainView::CBTUIMainView +// --------------------------------------------------------- + +CBTUIMainView::CBTUIMainView(MBtuiPluginViewActivationObserver* aObserver ) + :iConstructAsGsPlugin(EFalse), iActivationObserver(aObserver) + { + } +// --------------------------------------------------------- +// CBTUIMainView::ConstructL +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------- +// +void CBTUIMainView::ConstructL() + { + TRACE_FUNC_ENTRY + + // Plugin load resource manually. + // These resources are needed by BaseConstructL + + iEikEnv = CEikonEnv::Static(); + + TFileName filename; + filename += KFileDrive; + filename += KDC_RESOURCE_FILES_DIR; + filename += KResourceFileName; + + BaflUtils::NearestLanguageFile(iEikEnv->FsSession(),filename); + iResourceFileFlag=iEikEnv->AddResourceFileL(filename); + + // According to Construction type, different softkey resource will be used. + // + if(iConstructAsGsPlugin) + { + iViewArray = new CArrayPtrFlat( 3 ); + iTabHelper = CGSTabHelper::NewL(); + iViewArray->AppendL(this); + iParentViewNotSetYet = ETrue; + + iKeyWatcher = CBTUIKeyWatcher::NewL(this, KBTUIPHYCountWatcher); + + // Construct OtherDeviceView + // + CAknView* pairedDeviceView = CBTUIPairedDevicesView::NewLC( this, iViewArray ); + iAppUi->AddViewL( pairedDeviceView ); // Transfer ownership to CAknViewAppUi + CleanupStack::Pop(pairedDeviceView ); + + // Construct BlockDeviceView + // + CAknView* blockedDeviceView = CBTUIBlockedDevicesView::NewLC( this, iViewArray ); + iAppUi->AddViewL( blockedDeviceView ); // Transfer ownership to CAknViewAppUi + CleanupStack::Pop(blockedDeviceView ); + + BaseConstructL( R_BTUI_MAIN_VIEW_GS_PLUGIN ); + } + else + { + BaseConstructL( R_BTUI_MAIN_VIEW ); + } + + iBtEngSettings = CBTEngSettings::NewL(this); + + // Sets up TLS, must be done before FeatureManager is used. + FeatureManager::InitializeLibL(); + iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); + + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// --------------------------------------------------------- +// Destructor. +// --------------------------------------------------------- +// +CBTUIMainView::~CBTUIMainView() + { + TRACE_FUNC_ENTRY + + iEikEnv->DeleteResourceFile(iResourceFileFlag); + + if ( iContainer ) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + } + + delete iBtEngSettings; + delete iContainer; + delete iIdle; + + if(iConstructAsGsPlugin) + { + if ( iViewArray ) + { + iViewArray->Reset(); + delete iViewArray; + } + + delete iTabHelper; + delete iKeyWatcher; + } + + // Frees the TLS. Must be done after FeatureManager is used. + FeatureManager::UnInitializeLib(); + + + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------- +// CBTUIMainView::PowerStateChanged +// ---------------------------------------------------- +// +void CBTUIMainView::PowerStateChanged( TBTPowerStateValue ) + { + TRACE_FUNC_ENTRY + if(iContainer) + { + iContainer->SettingChanged(EBTMainListItemPowerMode); + } + + if( iConstructAsGsPlugin ) + { + UpdateParentView(); + } + TRACE_FUNC_EXIT + } +// ---------------------------------------------------- +// CBTUIMainView::VisibilityModeChanged +// ---------------------------------------------------- +// +void CBTUIMainView::VisibilityModeChanged( TBTVisibilityMode ) + { + TRACE_FUNC_ENTRY + if(iContainer) + { + iContainer->SettingChanged(EBTMainListItemVisibilityMode); + } + + if( iConstructAsGsPlugin ) + { + UpdateParentView(); + } + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIMainView::Id +// --------------------------------------------------------- +// +TUid CBTUIMainView::Id() const + { + TRACE_FUNC_ENTRY + if(iConstructAsGsPlugin) + { + return KGsBtuiPluginUid; //same as ecom impl UID, required by GS interface. + } + else + { + return KBtuiPluginUidMainView; //view id + } + } +// --------------------------------------------------------- +// CBTUIMainView::HandleMiddleSoftkey +// Handles middle soft key +// --------------------------------------------------------- +// +void CBTUIMainView::HandleMiddleSoftkey() + { + TRACE_FUNC_ENTRY + if( iContainer == NULL ) return; + + TInt currentHighLightPosition= iContainer->CurrentItemIndex(); + switch(currentHighLightPosition) + { + case EBTMainListItemPowerMode: + HandleCommand( EBTUICmdChangePowerStateSelect ); + break; + case EBTMainListItemVisibilityMode: + HandleCommand( EBTUICmdChangeVisibilitySelect ); + break; + case EBTMainListItemNameSetting: + HandleCommand( EBTUICmdChangeBTNameSelect ); + break; + + // For Bluetooth SIM Access Profile feature + // + case EBTMainListItemSapMode: + HandleCommand( EBTUICmdChangeSapStateSelect ); + break; + default: + break; + } + TRACE_FUNC_EXIT + } +// --------------------------------------------------------- +// TUid CBTUIMainView::HandleCommand +// --------------------------------------------------------- +// +void CBTUIMainView::HandleCommand(TInt aCommand) +{ + TRAP_IGNORE(HandleCommandL(aCommand)); +} +// --------------------------------------------------------- +// CBTUIMainView::HandleCommandL +// Redirects commands to the appui class. +// --------------------------------------------------------- +// +void CBTUIMainView::HandleCommandL(TInt aCommand) + { + TRACE_INFO((_L(">> CBTUIMainView::HandleCommandL: %d"), aCommand)) + switch ( aCommand ) + { + //middle soft key is handled here + case EBTUICmdMSK: + HandleMiddleSoftkey(); + break; + case EAknSoftkeyBack: + AppUi()->ActivateLocalViewL(iParentView.iViewUid); + break; + + case EAknSoftkeyExit: + { + AppUi()->ProcessCommandL(EEikCmdExit); + break; + } + +#ifdef __SERIES60_HELP + case EAknCmdHelp: + { + HlpLauncher::LaunchHelpApplicationL( + iEikonEnv->WsSession(), AppUi()->AppHelpContextL()); + break; + } +#endif + case EBTUICmdChangePowerStateMenu: + { + AskPowerModeDlgL(); + break; + } + + case EBTUICmdChangePowerStateSelect: + { + TBTPowerStateValue powerState; + iBtEngSettings->GetPowerState(powerState); + if(powerState==EBTPowerOn) + { + SetPowerStatusL( EFalse ); + } + else + { + SetPowerStatusL( ETrue ); + } + break; + } + + case EBTUICmdChangeVisibilitySelect: // now both select key and menu command will triger the setting page. + case EBTUICmdChangeVisibilityMenu: + { + AskVisibilityDlgL(); + break; + } + + case EBTUICmdChangeBTNameMenu: + case EBTUICmdChangeBTNameSelect: + { + AskNewBtNameDlgL(); + iContainer->SettingChanged(TBTMainListItemIndexes(iContainer->CurrentItemIndex())); + break; + } + + // For Bluetooth SIM Access Profile feature + case EBTUICmdChangeSapStateSelect: + { + + if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDataProfilesDisabled ) + { + RNotifier notifier; + User::LeaveIfError(notifier.Connect()); + CleanupClosePushL(notifier); + User::LeaveIfError(notifier.StartNotifier(KBTEnterpriseItSecurityInfoNotifierUid, KNullDesC8 )); + CleanupStack::PopAndDestroy(¬ifier); + } + else + { + TInt sapStatus; + CRepository* repository = CRepository::NewL(KCRUidBTEngPrivateSettings); + CleanupStack::PushL(repository); + repository->Get(KBTSapEnabled, sapStatus); + CleanupStack::PopAndDestroy(repository); + + if(sapStatus==EBTSapEnabled) + { + SetSapStatusL( EBTSapDisabled ); + } + else + { + SetSapStatusL( EBTSapEnabled ); + } + iContainer->SettingChanged( + TBTMainListItemIndexes(iContainer->CurrentItemIndex())); + } + break; + } + + // For Bluetooth SIM Access Profile feature + case EBTUICmdChangeSapStateMenu: + { + AskSapModeDlgL(); + iContainer->SettingChanged( + TBTMainListItemIndexes(iContainer->CurrentItemIndex())); + break; + } + + default: + { + AppUi()->HandleCommandL( aCommand ); + iContainer->SettingChanged( + TBTMainListItemIndexes(iContainer->CurrentItemIndex())); + break; + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------- +// From CAknView +// CBTUIMainView::DoActivateL +// --------------------------------------------------------- +// +void CBTUIMainView::DoActivateL( const TVwsViewId& aPrevViewId, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + TRACE_FUNC_ENTRY + + + if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDisabled ) + { + RNotifier notifier; + User::LeaveIfError(notifier.Connect()); + CleanupClosePushL(notifier); + User::LeaveIfError(notifier.StartNotifier(KBTEnterpriseItSecurityInfoNotifierUid, KNullDesC8 )); + CleanupStack::PopAndDestroy(¬ifier); + + AppUi()->ActivateLocalViewL(aPrevViewId.iViewUid); //go back straight away + return; + } + + + if( iConstructAsGsPlugin ) + { + // Only set parent view when entering BT GS setting. + // since tab change chould make aPrevViewId assign to non-parent views. e.g. paired or blocked view. + if(iParentViewNotSetYet) + { + iParentView = aPrevViewId; + iParentViewNotSetYet = EFalse; + } + + // Setup tab group + iTabHelper->CreateTabGroupL( Id(), iViewArray ); + } + + iContainer = new (ELeave) CBTUIMainContainer; + iContainer->SetMopParent(this); // MObjectProvider + iContainer->ConstructL( ClientRect(), this ); + + // Setup the title + // + HBufC* btTitleMain = iCoeEnv->AllocReadResourceLC(R_BT_TITLE_BLUETOOTH); + CEikStatusPane* statusPane = StatusPane(); + CAknTitlePane* titlePane; + titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); + titlePane->SetTextL(btTitleMain->Des()); + CleanupStack::PopAndDestroy(btTitleMain); // btTitleMain + btTitleMain = NULL; + + AppUi()->AddToStackL( *this, iContainer ); + + //Check if the local name has been set. If not ask user to set name + + TBool nameStatus = EFalse; + TInt err = IsLocalNameModifiedL( nameStatus ); + + if( err || nameStatus == EBTLocalNameDefault ) + { + InitiateBTLocalNameQueryL(); // Ask local Bluetooth name if not given yet. + } + + // notify observer + if( iActivationObserver && iConstructAsGsPlugin == EFalse) + { + iActivationObserver->PluginViewActivated(EMainViewId); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIMainView::DoDeactivate +// --------------------------------------------------------- +// +void CBTUIMainView::DoDeactivate() + { + TRACE_FUNC_ENTRY + + if ( iContainer ) + { + AppUi()->RemoveFromStack( iContainer ); + } + + delete iContainer; + iContainer = NULL; + + if(iConstructAsGsPlugin) + { + iTabHelper->RemoveTabGroup(); + CGSBaseView::DoDeactivate(); + } + TRACE_FUNC_EXIT + + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIMainView::DynInitMenuPaneL +// Shows selected item's context sensitive options menu. +// --------------------------------------------------------- +// +void CBTUIMainView::DynInitMenuPaneL( TInt aResId, CEikMenuPane* aMenu ) + { + TRACE_FUNC_ENTRY + + // dim help if it exists and is not supported + TInt tmp; + if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) + { + aMenu->SetItemDimmed(EAknCmdHelp, + !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); + } + + if ( aResId == R_BTUI_MAIN_VIEW_MENU ) + { + // Set all menus dimmed at first(hide them all) + // + aMenu->SetItemDimmed(EBTUICmdChangePowerStateMenu, ETrue); + aMenu->SetItemDimmed(EBTUICmdChangeVisibilityMenu, ETrue); + aMenu->SetItemDimmed(EBTUICmdChangeBTNameMenu, ETrue); + if ( FeatureManager::FeatureSupported( KFeatureIdBtSap ) ) + aMenu->SetItemDimmed(EBTUICmdChangeSapStateMenu, ETrue); + + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIMainView::SettingChangedL +// Redraws the BT Name field. +// --------------------------------------------------------- +// +void CBTUIMainView::SettingChangedL( TBTMainListItemIndexes aListItem ) + { + TRACE_FUNC_ENTRY + if(iContainer) + { + iContainer->SettingChanged(aListItem); + } + + } + +// ---------------------------------------------------- +// CBTUIMainView::SetPowerStatusL +// ---------------------------------------------------- +// +TInt CBTUIMainView::SetPowerStatusL( TBool aValue ) + { + TRACE_FUNC_ENTRY + + TInt errorCode = KErrNone; + TBTPowerStateValue previousPowerMode; + errorCode=iBtEngSettings->GetPowerState(previousPowerMode); + if(errorCode) + return errorCode; + + TBool legalToChange = ETrue; + + if ( ( previousPowerMode==EBTPowerOn ) && ( !aValue )) // power ON -> OFF + { + TRACE_INFO(_L("power ON -> OFF")) + + // Check active connections before query + if( TBTUIViewsCommonUtils::IsAnyDeviceConnectedL()) + { + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtSwitchOffAnywayQuery, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + TInt keypress = dlg->ExecuteLD( R_BT_SWITCH_OFF_ANYWAY_QUERY ); + if( !keypress ) // User has not accepted the dialog + { + legalToChange = EFalse; + } + } + TRACE_INFO((_L("power ON -> OFF, legalToChange = %d"), legalToChange)) + + } + else if ( ( !previousPowerMode ) && ( aValue ) ) // power OFF -> ON + { + TRACE_INFO(_L("power OFF -> ON")) + + TInt offlineModeOff = 0; // possible values are 0 and 1 + TInt activationEnabled = 0; // possible values are 0 and 1 + + CRepository* repository = CRepository::NewL(KCRUidCoreApplicationUIs); + CleanupStack::PushL(repository); + repository->Get(KCoreAppUIsNetworkConnectionAllowed, offlineModeOff); + // Closing connection: + CleanupStack::PopAndDestroy(repository); + repository =NULL; + repository = CRepository::NewL(KCRUidBluetoothEngine); + // Check activation enabled + CleanupStack::PushL(repository); + repository->Get(KBTEnabledInOffline, activationEnabled); + // Closing connection: + CleanupStack::PopAndDestroy(repository); + + + TRACE_INFO((_L("power OFF -> ON, offlineModeOff = %d"), offlineModeOff )) + TRACE_INFO((_L("power OFF -> ON, activationEnabled = %d"), activationEnabled )) + + // Is offline mode on + // + if ( !offlineModeOff ) + { + // Choose user interaction + // + if ( activationEnabled ) + { + // Create and show query + // + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtActivateInOfflineQuery, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + TInt keypress = dlg->ExecuteLD( R_BT_ACTIVATE_IN_OFFLINE_QUERY ); + if( !keypress ) // User has not accepted the dialog + { + legalToChange = EFalse; + } + } + else + { + legalToChange = EFalse; + + // Load a string, create and show a note + // + HBufC* stringHolder = StringLoader::LoadLC( R_BT_OFFLINE_DISABLED ); + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(note); + note->PublishDialogL(ECmdShowBtOfflineDisabledNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(note); + } + + note->ExecuteLD( *stringHolder ); + CleanupStack::PopAndDestroy(stringHolder); //stringHolder + } + } + } + + TRACE_INFO((_L("legalToChange = %d"), legalToChange)) + + // Switch powermode + // + if ( legalToChange ) + { + + TInt errorCode = KErrNone; + TBTPowerStateValue powerMode; + if(aValue) + { + powerMode=EBTPowerOn; + } + else + { + powerMode=EBTPowerOff; + } + + errorCode=iBtEngSettings->SetPowerState(powerMode); + + if( (errorCode == KErrNone ) && (aValue)) + + { + //Check the visibility mode + TBTVisibilityMode visiMode; + errorCode=iBtEngSettings->GetVisibilityMode(visiMode); + if(errorCode==KErrNone) + { + if (visiMode == EBTVisibilityModeHidden) + { + //Show note + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, + CAknNoteDialog::ELongTimeout ); + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdBtuiShowBtHiddenFromOthersNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + dlg->ExecuteLD( R_BT_HIDDEN_FROM_OTHERS ); + } + } + } + if ( errorCode != KErrNone && errorCode != KErrAlreadyExists ) + { + TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL()); + } + + } + + TRACE_INFO((_L("SetPowerStatusL() complete. errorCode = %d"), errorCode)) + return errorCode; + } + +// ---------------------------------------------------------- +// CBTUIMainView::SetVisibilityStatusL +// ---------------------------------------------------------- +// +void CBTUIMainView::SetVisibilityStatusL( TBTVisibilityMode aMode ) + { + TRACE_FUNC_ENTRY + + TInt errorCode = KErrNone; + + switch( aMode ) + { + case EBTVisibilityModeGeneral: + { + errorCode = iBtEngSettings->SetVisibilityMode(aMode); + + if(errorCode == KErrNone) + { + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, + CAknNoteDialog::ELongTimeout ); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtPhoneVisibToAllNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + dlg->ExecuteLD( R_BT_PHONE_VISIB_TO_OTH_NOTE ); + } + } + break; + + case EBTVisibilityModeHidden: + { + errorCode = iBtEngSettings->SetVisibilityMode(aMode); + + if(errorCode == KErrNone) + { + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, + CAknNoteDialog::ELongTimeout ); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdBtuiShowBtHiddenFromOthersNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + dlg->ExecuteLD( R_BT_HIDDEN_FROM_OTHERS ); + } + } + break; + + case EBTVisibilityModeTemporary: + { + // Asks user to turn on Bluetooth, if temporary visibility is chosen. + if( TBTUIViewsCommonUtils::TurnBTOnIfNeededL(iBtEngSettings,iCoverDisplayEnabled) != KErrNone) + { + return; + } + TInt sliderValue = 1; + CAknSettingPage* dlg = + new(ELeave) CAknSliderSettingPage(R_VISIBILITY_TIME_SETTING_PAGE, + sliderValue); + + if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) + { + errorCode = iBtEngSettings->SetVisibilityMode( aMode, sliderValue ); + } + } + break; + + default: + break; + } + + if((errorCode != KErrNone) && (errorCode != KErrAlreadyExists)) + { + TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL()); + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIMainView::GetBTLocalName +// ---------------------------------------------------------- +// +TDesC* CBTUIMainView::GetBTLocalName() + { + TRACE_FUNC_ENTRY + + iTempNameBuffer.Zero(); // Empty Local BT device name + TInt err=iBtEngSettings->GetLocalName( iTempNameBuffer );// Store name into member variable + if(err!=KErrNone) + TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL()); + + // Cut the excess part of the name away. The query can handle only + // KBTUIMaxNameLength characters. + // + if( iTempNameBuffer.Length() > KBTUIMaxNameLength ) + { + iTempNameBuffer.SetLength( KBTUIMaxNameLength ); + } + TRACE_FUNC_EXIT + return &iTempNameBuffer; // And return reference for it + } + +// ---------------------------------------------------------- +// CBTUIMainView::AskNewBtNameDlgL +// ---------------------------------------------------------- +// +void CBTUIMainView::AskNewBtNameDlgL() + { + TRACE_FUNC_ENTRY + + // Cut the excess part of the name away. The query can handle only + // KBTUIMaxNameLength characters. + // + if( iTempNameBuffer.Length() > KBTUIMaxNameLength ) + { + iTempNameBuffer.SetLength( KBTUIMaxNameLength ); + } + + FOREVER + { + CAknTextSettingPage* dlg = new( ELeave )CAknTextSettingPage( R_BT_NAME_SETTING_PAGE, + iTempNameBuffer ); + if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) + { + // Remove trouble making control chars + AknTextUtils::StripCharacters(iTempNameBuffer, KAknStripListControlChars); + + iTempNameBuffer.TrimAll(); // Remove spaces and check what is left.. + if( iTempNameBuffer.Length() > 0 ) + { + + if(iBtEngSettings->SetLocalName(iTempNameBuffer) != KErrNone) + { + TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); + } + TRACE_FUNC_EXIT + return; + } + } + else + { + TRACE_FUNC_EXIT + return; // User has cancelled this operation + } + } + + } + +// ---------------------------------------------------------- +// CBTUIMainView::AskPowerModeDlgL +// ---------------------------------------------------------- +// +void CBTUIMainView::AskPowerModeDlgL() + { + TRACE_FUNC_ENTRY + + CDesCArrayFlat* items = iCoeEnv->ReadDesCArrayResourceL( R_BT_POWER_MODES ); + CleanupStack::PushL(items); + TBTPowerStateValue powerState; + iBtEngSettings->GetPowerState(powerState); + TInt currentItem = !powerState; // Implicit cast from Not-TBool to int (inverted) + + CAknRadioButtonSettingPage* dlg = new ( ELeave )CAknRadioButtonSettingPage( + R_BT_POWER_SETTING_PAGE, currentItem, items ); + if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) + { + SetPowerStatusL( static_cast( !currentItem )); // Cast it back (invert again) + } + CleanupStack::PopAndDestroy(items); // items + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIMainView::AskVisibilityDlgL +// ---------------------------------------------------------- +// +void CBTUIMainView::AskVisibilityDlgL() + { + TRACE_FUNC_ENTRY + + CDesCArrayFlat* items = iCoeEnv->ReadDesCArrayResourceL( R_BT_VISIBILITY_MODES ); + CleanupStack::PushL(items); + + TInt currentItem = 0; // Current position at radio button setting page + TBTVisibilityMode currentMode; + TInt errorCode(iBtEngSettings->GetVisibilityMode(currentMode)); + if(errorCode==KErrNone) + { + + switch( currentMode ) // Map from mode to radio button position at setting page + { + case EBTVisibilityModeGeneral: + currentItem = 0; + break; + case EBTVisibilityModeTemporary: // temp visible + currentItem = 1; + break; + case EBTVisibilityModeHidden: + currentItem = 1+1; + break; + default: + break; + } + + // Ask new mode from user + + CAknRadioButtonSettingPage* dlg = new ( ELeave )CAknRadioButtonSettingPage( + R_BT_VISIBILITY_SETTING_PAGE, currentItem, items ); + if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) + { + switch( currentItem ) // Map it back from radio button position to mode at setting page + { + case 0: + SetVisibilityStatusL( EBTVisibilityModeGeneral ); + break; + + case 1: + SetVisibilityStatusL( EBTVisibilityModeTemporary ); + break; + + case 1+1: + SetVisibilityStatusL( EBTVisibilityModeHidden ); + break; + + default: + break; + } + } + } + else + TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); + + + CleanupStack::PopAndDestroy(items); // items + } + + +// ---------------------------------------------------- +// CBTUIMainView::GetBtSettingsReference +// +// This method returns the reference to the settings class +// ---------------------------------------------------- +// +CBTEngSettings* CBTUIMainView::GetBtSettingsReference() + { + TRACE_FUNC + return iBtEngSettings; + } + +// ---------------------------------------------------- +// CBTUIMainView::InitiateBTLocalNameQueryL +// +// Initiate BT local name query after Symbian OS has entered +// idle state. +// ---------------------------------------------------- +// +void CBTUIMainView::InitiateBTLocalNameQueryL() + { + TRACE_FUNC + + + __ASSERT_DEBUG( !iIdle, PANIC(EBTPanicClassMemberVariableNotNull) ); + + // Launch idle time regognition and execute local BT name query when ready + iIdle = CIdle::NewL(CActive::EPriorityIdle); + iIdle->Start(TCallBack(LaunchBTLocalNameQueryL, this)); + } + +// ---------------------------------------------------- +// CBTUIMainView::LaunchBTLocalNameQueryL +// +// Execute BT local name query. Symbian OS has entered +// idle state now. +// ---------------------------------------------------- +// +TInt CBTUIMainView::LaunchBTLocalNameQueryL(TAny* aMainView) + { + //TRACE_FUNC + + TInt errorCode = static_cast(aMainView)->AskBTLocalNameQueryL(); + if( errorCode != KErrNone ) + { + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EErrorTone, + CAknNoteDialog::ELongTimeout ); + if(static_cast(aMainView)->iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtGeneralErrorNote, KUidCoverUiCategoryBtui); // initializes cover support} + CleanupStack::Pop(dlg); + } + dlg->ExecuteLD( R_BT_GENERAL_ERROR_NOTE ); + } + return KErrNone; + } + +// ---------------------------------------------------- +// CBTUIMainView::AskBTLocalNameQueryL +// ---------------------------------------------------- +// +TInt CBTUIMainView::AskBTLocalNameQueryL() + { + TRACE_FUNC_ENTRY + + TInt errorCode = KErrNone; + iTempNameBuffer.Zero(); // Empty Local BT device name + + //Get default name if given by e.g. phone product + errorCode = RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothSetDeviceName, iTempNameBuffer ); + + if( errorCode || !iTempNameBuffer.Length() ) + { + errorCode = RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetDeviceName, iTempNameBuffer ); + + if( errorCode || !iTempNameBuffer.Length() ) + { + RBTRegServ btRegServ; + RBTLocalDevice btReg; + TBTLocalDevice localDev; + + errorCode = btRegServ.Connect(); + + if( !errorCode ) + { + errorCode = btReg.Open( btRegServ ); + + if( !errorCode ) + { + // Read the BT local name from BT Registry. + errorCode = btReg.Get( localDev ); + + if( !errorCode ) + { + // The error can be > 0 if there are unconverted characters. + errorCode = CnvUtfConverter::ConvertToUnicodeFromUtf8( iTempNameBuffer, localDev.DeviceName() ); + } + } + } + + btReg.Close(); + btRegServ.Close(); + } + } + + if(errorCode==KErrNone) + { + + // Cut the excess part of the name away. The query can handle only + // KBTUIMaxNameLength characters. + // + if( iTempNameBuffer.Length() > KBTUIMaxNameLength ) + { + iTempNameBuffer.SetLength( KBTUIMaxNameLength ); + } + + CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( iTempNameBuffer ); + TInt keypress = dlg->ExecuteLD( R_BT_ENTER_LOCAL_NAME_QUERY ); + + if( keypress ) // User has accepted the dialog + { + // Remove trouble making control chars + AknTextUtils::StripCharacters(iTempNameBuffer, KAknStripListControlChars); + + iTempNameBuffer.TrimAll(); // Remove extra spaces + errorCode = iBtEngSettings->SetLocalName(iTempNameBuffer); + + this->SettingChangedL(EBTMainListItemNameSetting); // Redraw BT name + } + } + + delete iIdle; iIdle = NULL; + TRACE_FUNC_EXIT + return errorCode; + } + +//--------------------------------------------------------------------- +// CBTUIMainView::GetCaption +//---------------------------------------------------------------------- +// +void CBTUIMainView::GetCaptionL( TDes& aCaption ) const + { + TRACE_FUNC + + // the resource file is already opened. + HBufC* result = StringLoader::LoadL( R_GS_BTUI_VIEW_CAPTION ); + aCaption.Copy( *result ); + delete result; + } + + +//--------------------------------------------------------------------- +// CBTUIMainView::CreateIconL +//---------------------------------------------------------------------- +// +CGulIcon* CBTUIMainView::CreateIconL( const TUid aIconType ) + { + TRACE_FUNC_ENTRY + + RefreshSettingsStatusL(); + CGulIcon* icon = NULL; + TFileName bmpFilename; + bmpFilename += KBitmapFileDrive; + bmpFilename += KDC_APP_BITMAP_DIR; + bmpFilename += KBtuiBmpFileName; + + if(aIconType == KGSIconTypeLbxItem) + { + + switch(iBtState) + { + case EBTOff: + icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropSetAppsBtOff, + bmpFilename, + EMbmBtuiQgn_prop_set_apps_bt_off, + EMbmBtuiQgn_prop_set_apps_bt_off_mask ); + break; + case EBTOnShown: + icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropSetAppsBtOnShown, + bmpFilename, + EMbmBtuiQgn_prop_set_apps_bt_on_shown, + EMbmBtuiQgn_prop_set_apps_bt_on_shown_mask ); + break; + case EBTOnHidden: + icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropSetAppsBtOnHidden, + bmpFilename, + EMbmBtuiQgn_prop_set_apps_bt_on_hidden, + EMbmBtuiQgn_prop_set_apps_bt_on_hidden_mask ); + break; + case EBTConnectedShown: + icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropSetAppsBtConnShown, + bmpFilename, + EMbmBtuiQgn_prop_set_apps_bt_conn_shown, + EMbmBtuiQgn_prop_set_apps_bt_conn_shown_mask ); + break; + case EBTConnectedHidden: + icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropSetAppsBtConnHidden, + bmpFilename, + EMbmBtuiQgn_prop_set_apps_bt_conn_hidden, + EMbmBtuiQgn_prop_set_apps_bt_conn_hidden_mask ); + break; + } + } + else + { + icon = CGSPluginInterface::CreateIconL( aIconType ); + } + + return icon; + } + + +// --------------------------------------------------------------------------- +// CBTUIMainView::GetValue() +// Get 2nd row text for parent Connectivity View. +// --------------------------------------------------------------------------- +// +void CBTUIMainView::GetValue( const TGSPluginValueKeys aKey, TDes& aValue ) + { + TRACE_FUNC_ENTRY + + TRAP_IGNORE( GetValueL(aKey, aValue) ); + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::GetValueL() +// --------------------------------------------------------------------------- +// +void CBTUIMainView::GetValueL( const TGSPluginValueKeys aKey, TDes& aValue ) + { + if(aKey == EGSPluginKeySettingsItemValueString) + { + HBufC* secondary = NULL; + RefreshSettingsStatusL(); + switch(iBtState) + { + case EBTOff: + secondary = StringLoader::LoadL( R_CP_DETAIL_BT_OFF ); + break; + case EBTOnShown: + secondary = StringLoader::LoadL( R_CP_DETAIL_BT_ON_SHOWN ); + break; + case EBTOnHidden: + secondary = StringLoader::LoadL( R_CP_DETAIL_BT_ON_HIDDEN ); + break; + case EBTConnectedShown: + secondary = StringLoader::LoadL( R_CP_DETAIL_BT_CONN_SHOWN ); + break; + case EBTConnectedHidden: + secondary = StringLoader::LoadL( R_CP_DETAIL_BT_CONN_HIDDEN ); + break; + } + aValue.Copy( *secondary ); + delete secondary; + } + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::CreateTabIconL() +// Creates icon for tab. +// --------------------------------------------------------------------------- +// +CGulIcon* CBTUIMainView::CreateTabIconL() + { + TFileName bmpFilename; + bmpFilename += KBitmapFileDrive; + bmpFilename += KDC_APP_BITMAP_DIR; + bmpFilename += KBtuiBmpFileName; + + CGulIcon* icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropBtSetTab3, + bmpFilename, + EMbmBtuiQgn_prop_bt_set_tab3, + EMbmBtuiQgn_prop_bt_set_tab3_mask ); + + return icon; + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::RefreshSettingsStatusL() +// Get the current BT settings: power, visibility and connection. +// --------------------------------------------------------------------------- +// +void CBTUIMainView::RefreshSettingsStatusL() + { + + if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDisabled ) + { + iBtState = EBTOff; + } + else + { + TBTPowerStateValue powerState; + iBtEngSettings->GetPowerState(powerState); + + TBTVisibilityMode currentMode; + iBtEngSettings->GetVisibilityMode(currentMode); + + TBool connected = TBTUIViewsCommonUtils::IsAnyDeviceConnectedL(); + + if(powerState == EBTPowerOff) + iBtState = EBTOff; + else + { + if( !connected && (currentMode == EBTVisibilityModeGeneral || + currentMode == EBTVisibilityModeTemporary)) + iBtState = EBTOnShown; + + else if(!connected && currentMode == EBTVisibilityModeHidden) + iBtState = EBTOnHidden; + + else if(connected && (currentMode == EBTVisibilityModeGeneral || + currentMode == EBTVisibilityModeTemporary)) + iBtState = EBTConnectedShown; + + else if(connected && currentMode == EBTVisibilityModeHidden) + iBtState = EBTConnectedHidden; + } + } + } + +// ---------------------------------------------------- +// CBTUIMainView::UpdateParentView +// +// Update Connectivity View when it's the current +// active view and the key watched is changed. +// ---------------------------------------------------- +void CBTUIMainView::UpdateParentView() + { + if(iConstructAsGsPlugin) + { + CGSParentPlugin* parent = static_cast(AppUi()->View( KGSConPluginUid )); + if( parent ) + { + parent->UpdateView(); + } + } + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::NewContainerL +// Creates new iContainer. +// --------------------------------------------------------------------------- +// +void CBTUIMainView::NewContainerL() + { + //As a transparent view, do nothing here. + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::HandleListBoxSelectionL +// Handle any user actions while in the list view. +// --------------------------------------------------------------------------- +// +void CBTUIMainView::HandleListBoxSelectionL() + { + //As a base-view, it's transparent, so do nothing here. + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::GetParentView +// --------------------------------------------------------------------------- +// +TVwsViewId CBTUIMainView::GetParentView() + { + return iParentView; + } + +// --------------------------------------------------------------------------- +// CBTUIMainView::TabbedViews() +// Returns pointer to tabbed views of application. +// --------------------------------------------------------------------------- +// +CArrayPtrFlat* CBTUIMainView::TabbedViews() + { + return iViewArray; + } + + +// --------------------------------------------------------------------------- +// CBTUIMainView::IsLocalNameModified +// Checks from central repository whether the Bluetooth friendly name +// has been modified . +// --------------------------------------------------------------------------- +// +TInt CBTUIMainView::IsLocalNameModifiedL( TBool& aStatus ) + { + TRACE_FUNC_ENTRY + + aStatus = (TBool) EBTLocalNameDefault; + + TInt val = 0; + CRepository* cenRep = NULL; + TInt err = KErrNone; + TRAP_IGNORE(cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings )); + + err = cenRep->Get( KBTLocalNameChanged, val ); + + if ( val != 0 ) + { + aStatus = (TBool) EBTLocalNameSet; + } + delete cenRep; + cenRep = NULL; + TRACE_FUNC_EXIT + return err; + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUINonSap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUINonSap.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2002 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: This module is created for variant that doesn't support +* Bluetooth SIM Access Profile. +* +*/ + + +#include "BTUIMainView.h" +//#include "BTUIModel.h" + +// ---------------------------------------------------- +// CBTUIMainView::SetSapStatusL +// ---------------------------------------------------- +// +void CBTUIMainView::SetSapStatusL( TBTSapMode /*aValue*/ ) + { + + } + +// ---------------------------------------------------------- +// CBTUIMainView::AskSapModeDlgL +// ---------------------------------------------------------- +// +void CBTUIMainView::AskSapModeDlgL() + { + + } +// ---------------------------------------------------------- +// CBTUIMainView::GetSapStatusL +// ---------------------------------------------------------- + +TInt CBTUIMainView::GetSapStatusL() + { + return EBTSapDisabled; + } + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,1914 @@ +/* +* Copyright (c) 2002,2007 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: This is view that handles listing and + * unblocking blocked devices view. + * +*/ + +#include // AVKON components +#include +#include +#include // Compiled resource ids +#include // Feature Manager + +#include +#include +#include // Series 60 localisation stringloader +#include +#include +#include +#include +#include // Help launcher +#include // for device search + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "btui.h" // Global declarations +#include "BTUIPairedDevicesView.h" +#include "BTUIDeviceContainer.h" +#include +#include // Help IDs + +#include +#include // Tab icon for General Setting +#include "BTUIMainView.h" // base View. + +const TInt KAutoConnect2ndTry = 1; +const TUint32 SetExcludePairedDeviceMask = 0x800000; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTUIPairedDevicesView::NewL +// Two phased constructor called by BT AppUI when serve as part of btui.exe +// --------------------------------------------------------- +// +CBTUIPairedDevicesView* CBTUIPairedDevicesView::NewL(MBtuiPluginViewActivationObserver* aObserver) + { + CBTUIPairedDevicesView* self = new (ELeave) CBTUIPairedDevicesView(aObserver); + CleanupStack::PushL(self); + + self->iConstructAsGsPlugin = EFalse; + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------- +// CBTUIPairedDevicesView::NewLC +// Two phased constructor called by mainView when serve as GS Plugin. +// --------------------------------------------------------- +// +CBTUIPairedDevicesView* CBTUIPairedDevicesView::NewLC(CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray) + { + CBTUIPairedDevicesView* self = new (ELeave) CBTUIPairedDevicesView(); + CleanupStack::PushL( self ); + + self->iConstructAsGsPlugin = ETrue; + self->ConstructL( aBaseView, aTabViewArray ); + + return self; + } + + +// --------------------------------------------------------- +// CBTUIPairedDevicesView::ConstructL +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------- +// +void CBTUIPairedDevicesView::ConstructL() + { + TRACE_FUNC_ENTRY + + BaseConstructL(R_BTUI_OTHER_DEVICES_VIEW); + + iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); + iHelpEnabled = FeatureManager::FeatureSupported(KFeatureIdHelp); + + iDeviceSearcher = CBTEngDiscovery::NewL(this); + iBtEngSettings = CBTEngSettings::NewL(this); + iBTPluginMan = CBTUIPluginMan::NewL( AppUi() ); + iIsAlreadyConnected = EFalse; + iExpectedCallBack = 0; + TRACE_INFO(_L("Initial iIsAlreadyConnected -> False")) + TRACE_FUNC_EXIT + } + +void CBTUIPairedDevicesView::ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat* aTabViewArray ) + { + TRACE_FUNC_ENTRY + + iBaseView = aBaseView, + iTabHelper = CGSTabHelper::NewL(); + aTabViewArray->AppendL(this); + + BaseConstructL(R_BTUI_OTHER_DEVICES_VIEW_GS); + iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); + iHelpEnabled = FeatureManager::FeatureSupported(KFeatureIdHelp); + + iDeviceSearcher = CBTEngDiscovery::NewL(this); + iBtEngSettings=CBTEngSettings::NewL(this); + iBTPluginMan = CBTUIPluginMan::NewL( AppUi() ); + iIsAlreadyConnected = EFalse; + TRACE_INFO(_L("Initial iIsAlreadyConnected = False")) + iExpectedCallBack = 0; + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIBlockedDevicesView::CBTUIBlockedDevicesView +// --------------------------------------------------------- + +CBTUIPairedDevicesView::CBTUIPairedDevicesView( MBtuiPluginViewActivationObserver* aObserver ) + : iActivationObserver(aObserver) + { + } + +// --------------------------------------------------------- +// Destructor +// --------------------------------------------------------- +// +CBTUIPairedDevicesView::~CBTUIPairedDevicesView() + { + TRACE_FUNC_ENTRY + + //close dialogs if any + TRAP_IGNORE( + DialogDismissedL(EAknSoftkeyCancel); + ); + + delete iActive; + + if (iContainer) + { + AppUi()->RemoveFromViewStack(*this, iContainer); + delete iContainer; + iContainer = NULL; + } + + if(iDeviceSearcher) + { + // Canceling devicesearches is done by DialogDismissedL(), + // so it is not done here + delete iDeviceSearcher; + iDeviceSearcher = NULL ; + } + delete iConnectDevice; + iConnectDevice=NULL; + + delete iPairingDevice; + delete iBtEngSettings; + delete iBTPluginMan; + + if(iConstructAsGsPlugin) + delete iTabHelper; + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIPairedDevicesView::Id +// --------------------------------------------------------- +// +TUid CBTUIPairedDevicesView::Id() const + { + TRACE_FUNC_ENTRY + return KBtuiPluginUidPairedDevicesView;//KBTOtherDevicesViewId; + } + + + + +// --------------------------------------------------------- +// From CAknView +// CBTUIPairedDevicesView::HandleCommandL +// Redirects commands to the appui class. +// --------------------------------------------------------- +// +void CBTUIPairedDevicesView::HandleCommandL(TInt aCommand) + { + TRACE_FUNC_ENTRY + + switch (aCommand) + { + + case EAknSoftkeyBack: + // do not exit if devicechange is in progress. + if(iModel->DeviceChangeInProgress() ) + return; + AppUi()->ActivateLocalViewL(iBaseView->GetParentView().iViewUid ); + break; + + case EAknSoftkeyExit: + { + TRACE_INFO(_L("EAknSoftkeyExit")) + // do not exit if devicechange or bt discovery is in progress. + if(iModel->DeviceChangeInProgress() + || iSearchOngoing ) + { + TRACE_INFO(_L("exit denied, due to operation")) + return; + } + + TRACE_INFO(_L("exit in progress")) + AppUi()->ProcessCommandL(EEikCmdExit); + break; + } + + case EAknCmdHelp: + { + #ifdef __SERIES60_HELP + HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(),AppUi()->AppHelpContextL()); + #endif + break; + } + + case EBTUICmdNewPairedDevice: + { + iSearchOngoing=ETrue; + NewPairedDeviceDlgL(); + break; + } + + case EBTUICmdDelete: + { + DeleteDeviceDlgL(); + break; + } + + case EBTUICmdDeleteAll: + { + DeleteAllDevicesDlgL(); + break; + } + + case EBTUICmdGiveNickname: + { + RenameDeviceDlgL(); + break; + } + + case EBTUICmdSetTrusted: + { + ChangeDeviceSecurityL(ETrue); + break; + } + + case EBTUICmdSetUnTrusted: + { + ChangeDeviceSecurityL(EFalse); + break; + } + + case EBTUICmdConnect: + case EBTUICmdConnectAudio: + { + TBTDevice device; + device.iIndex = iContainer->CurrentItemIndex(); + iModel->GetDevice(device); + device.iOperation = EOpConnect; + ConnectL( device, ETrue ); + break; + } + + case EBTUICmdDisconnect: + { + DisconnectL(); + break; + } + + case EBTUICmdSetBlocked: + { + BlockDeviceDlgL(); + break; + } + + case EBTUICmdSettings: + { + LaunchSettingViewL(); + break; + } + + default: + { + AppUi()->HandleCommandL(aCommand); + break; + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------- +// From CAknView +// CBTUIPairedDevicesView::DoActivateL +// --------------------------------------------------------- +// +void CBTUIPairedDevicesView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + TRACE_FUNC_ENTRY + + iModel = CBTDevModel::NewL(EGroupPaired, this); + iContainer = CBTUiDeviceContainer::NewL(ClientRect(), this, EGroupPaired, this); + iContainer->SetMopParent(this); // MObjectProvider + + // Setup title + HBufC* btTitlePairedDevices = + iCoeEnv->AllocReadResourceLC(R_BT_TITLE_PAIRED_DEV); + CEikStatusPane* statusPane = StatusPane(); + CAknTitlePane* titlePane; + titlePane = (CAknTitlePane*) statusPane->ControlL( + TUid::Uid(EEikStatusPaneUidTitle)); + titlePane->SetTextL(btTitlePairedDevices->Des()); + CleanupStack::PopAndDestroy(btTitlePairedDevices); // btTitlePairedDevices + btTitlePairedDevices = NULL; + + AppUi()->AddToStackL(*this, iContainer); + + if( iBaseView && iConstructAsGsPlugin) + { + iTabHelper->CreateTabGroupL( Id(), + static_cast*> + (iBaseView->TabbedViews()) ); + } + + // MSK menu is added here. + // the left key menu is added by resources. + MenuBar()->SetContextMenuTitleResourceId( + R_BTUI_MENUBAR_OTHER_DEVICES_VIEW_CONTEXT); + // notify observer + if( iActivationObserver && iConstructAsGsPlugin == EFalse) + { + iActivationObserver->PluginViewActivated(EPairedDevicesViewId); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIPairedDevicesView::DoDeactivate +// --------------------------------------------------------- +// +void CBTUIPairedDevicesView::DoDeactivate() + { + TRACE_FUNC_ENTRY + + if (iContainer) + { + AppUi()->RemoveFromStack(iContainer); + delete iContainer; + iContainer = NULL; + } + if ( iDeviceSearcher ) + { + iDeviceSearcher->CancelSearchRemoteDevice(); + } + delete iModel; + iModel=NULL; + if(iConstructAsGsPlugin) + iTabHelper->RemoveTabGroup(); + delete iActive; + iActive = NULL; + iIsPairConnect = EFalse; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// From CAknView +// CBTUIPairedDevicesView::DynInitMenuPaneL +// Shows only options supported for selected device, if any. +// If not show only options supported regardless of selected +// device +// --------------------------------------------------------- +// +void CBTUIPairedDevicesView::DynInitMenuPaneL(TInt aResId, CEikMenuPane* aMenu) + { + TRACE_FUNC_ENTRY + iActiveMenuPane = aMenu; + // dim help if it exists and is not supported + TInt tmp; + if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) + { + aMenu->SetItemDimmed(EAknCmdHelp, + !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); + } + + if ( aResId == R_BTUI_OTHER_DEVICES_VIEW_MENU ) + { + TInt index = iContainer->CurrentItemIndex(); + + // we only show "new pair device", "help" , "Exit" and "Delete All" if view contains device(s). + aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); + aMenu->SetItemDimmed(EBTUICmdDelete,ETrue); + aMenu->SetItemDimmed(EBTUICmdSetTrusted,ETrue); + aMenu->SetItemDimmed(EBTUICmdSetUnTrusted,ETrue); + aMenu->SetItemDimmed(EBTUICmdConnect,ETrue); + aMenu->SetItemDimmed(EBTUICmdConnectAudio,ETrue); + aMenu->SetItemDimmed(EBTUICmdDisconnect,ETrue); + aMenu->SetItemDimmed(EBTUICmdSetBlocked,ETrue); + aMenu->SetItemDimmed(EBTUICmdSettings,ETrue); + aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); + + if ( index < 0 ) // No devices at list. Hide all device related commands. + { + aMenu->SetItemDimmed(EBTUICmdDeleteAll, ETrue); + } + + } + + if ( aResId == R_BTUI_OTHER_DEVICES_VIEW_MENU_CONTEXT ) + { + TInt index = iContainer->CurrentItemIndex(); + + // If user is fast enough to click the RSK option between + // bt discovery view and device found view, bt ui will crash. + // Therefore, we disable commands if bt discovery is onging. + // + if(iSearchOngoing) + { + aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); + aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); + aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, ETrue); + aMenu->SetItemDimmed(EBTUICmdSetBlocked, ETrue); + aMenu->SetItemDimmed(EBTUICmdDelete, ETrue); + aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); + aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); + aMenu->SetItemDimmed(EBTUICmdDisconnect, ETrue); + aMenu->SetItemDimmed(EBTUICmdNewPairedDevice, ETrue); + return; + } + + if(index < 0) // No devices at list. Hide all device related commands. + { + TRACE_INFO(_L("no devices in list")) + + aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); + aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); + aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, ETrue); + aMenu->SetItemDimmed(EBTUICmdSetBlocked, ETrue); + aMenu->SetItemDimmed(EBTUICmdDelete, ETrue); + aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); + aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); + aMenu->SetItemDimmed(EBTUICmdDisconnect, ETrue); + aMenu->SetItemDimmed(EBTUICmdSettings, ETrue); + } + else // There are devices at list + { + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + iMenuDevice = device; + + TRACE_INFO(_L("there are device in list")) + + TBool dim = (device.iStatus & EStatusTrusted) == EStatusTrusted; + + aMenu->SetItemDimmed(EBTUICmdSetTrusted, dim); + aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, !dim); + + // Check if device can be connected or disconnected + dim = (! (device.iStatus & EStatusConnectable) + || device.iStatus & EStatusBtuiConnected); + + if (dim) + { + aMenu->SetItemDimmed(EBTUICmdConnect, dim); + aMenu->SetItemDimmed(EBTUICmdConnectAudio, dim); + } + else + { + if ( device.iDeviceClass.MajorDeviceClass() == EMajorDeviceComputer) + { + aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); + } + else + { + aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); + } + } + dim = (device.iStatus & EStatusBtuiConnected) != EStatusBtuiConnected; + aMenu->SetItemDimmed(EBTUICmdDisconnect, dim); + + if ( !iBTPluginMan->IsPluginAvaiable(device.iDeviceClass) ) + { + aMenu->SetItemDimmed(EBTUICmdSettings, ETrue); + } + else + { + dim = (device.iStatus & EStatusBtuiConnected) != EStatusBtuiConnected; + aMenu->SetItemDimmed(EBTUICmdSettings, dim); + } + //Hide New pair device + aMenu->SetItemDimmed(EBTUICmdNewPairedDevice, ETrue); + } + } + TRACE_FUNC_EXIT + } + + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::RenameDeviceDlgL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::RenameDeviceDlgL() + { + TRACE_FUNC_ENTRY + + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + TBTDeviceName name = device.iName; + + CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(device.iName); + TInt keypress = dlg->ExecuteLD(R_BT_ENTER_NICKNAME_QUERY); + + if(keypress) // User has accepted the dialog + { + if(device.iName != name) // Check if the user really changed the name + { + device.iOperation = EOpChangeName; + // Remove trouble making control chars + AknTextUtils::StripCharacters(device.iName, KAknStripListControlChars); + device.iName.TrimAll(); // Remove extra spaces + iModel->ChangeDevice(device); + } + } + TRACE_FUNC_EXIT + } + + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::NewPairedDeviceDlgL +// +// Initiate bonding (pairing) by opening the search dialog. +// DeviceSearchComplete is called after that. +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::NewPairedDeviceDlgL() + { + TRACE_FUNC_ENTRY + // we must not have other pairing in progress. + // we maight issue an error, but none is defined by + // ui spec. Anyhow this should be possible + // only by pressing everything roo rapidly. + if(iPairingDevice!=NULL) + return; + iPairingDevice = CBTDevice::NewL(); + + // Here we use last bit in device class to inform bt inquiry notifier + // not to display the device which is already paired and in the paired + // device list. + + // We use DeviceClass to tell btnotif not to show paired device in + // bt discovery notifier through bteng. + // Set bit 24 to 1 ( bit 24 is not used for any other purpose currently ) + iPairingDevice->SetDeviceClass(iPairingDevice->DeviceClass().DeviceClass() | SetExcludePairedDeviceMask ); + TInt err = iDeviceSearcher->SearchRemoteDevice(iPairingDevice, + &iPairingDevNameEntry, + iPairingDevice->DeviceClass().DeviceClass()); + + + if(err != KErrNone) + { + delete iPairingDevice; + iPairingDevice=NULL; + TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::DeleteDeviceDlgL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::DeleteDeviceDlgL() + { + TRACE_FUNC_ENTRY + + iExpectedCallBack = 0; + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + + HBufC* stringholder = NULL; + + TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; + // Choose confirmation phrase + // + if ( device.iStatus & tmp ) + { + stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE_CONNECTED, + device.iName); + } + else + { + stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE, device.iName ); + } + + // Create confirmation query + // + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtWarnEraseNote, KUidCoverUiCategoryBtui); + // initializes cover support + CleanupStack::Pop(dlg); + + CAknMediatorFacade* covercl = AknMediatorFacade(dlg); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName) ;// takes copy so consts are ok too + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, *stringholder); + + CleanupStack::PopAndDestroy(stringholder); // stringholder + + if(keypress) // User has accepted the dialog + { + // If device is connected we need to first to disconnect + // then unpair, otherwise unpairing does not succeed. + if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + iExpectedCallBack++; + DisconnectWithoutQuery(); + return; + } + device.iOperation = EOpUnpair; + iModel->ChangeDevice(device); + } + + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::DeleteAllDevicesDlgL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::DeleteAllDevicesDlgL() + { + TRACE_FUNC_ENTRY + + iExpectedCallBack = 0; + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + TInt keypress = KErrNone; + + CleanupStack::PushL(dlg); + + // Choose and execute confirmation query + // + if (iModel->IsAnyDeviceConnected()) + { + if(iCoverDisplayEnabled) + { + dlg->PublishDialogL(ECmdShowBtWarnEraseAllConnectedQuery, KUidCoverUiCategoryBtui); // initializes cover support + } + + keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_ALL_CONNECTED_QUERY); + } + else + { + if(iCoverDisplayEnabled) + { + dlg->PublishDialogL(ECmdShowBtWarnEraseAllQuery, KUidCoverUiCategoryBtui); // initializes cover support + } + + keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_ALL_QUERY); + } + CleanupStack::Pop(dlg); + + if(keypress) // User has accepted the dialog + { + TInt count = iContainer->CountItems(); + for (TInt i = 0; i < count; i++) + { + // If device is connected we need to first to disconnect + // then unpair, otherwise unpairing does not succeed. + TBTDevice device; + device.iIndex = i; + iModel->GetDevice(device); + if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + iExpectedCallBack++; + } + } + TRACE_INFO((_L("iExpectedCallBack %d"), iExpectedCallBack )) + + for (TInt i = 0; i < count; i++) + { + // If device is connected we need to first to disconnect + // then unpair, otherwise unpairing does not succeed. + TBTDevice device; + device.iIndex = i; + iModel->GetDevice(device); + + if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) + { + //disconnect it first, removal will be done in + //callback NotifyChangeDeviceCompleteL for ChangeDevice() below + TRACE_INFO((_L("EOpDisconnect issued for %d"), i )) + device.iOperation = EOpDisconnect; + iModel->ChangeDevice(device); + } + else + { + //otherwise, just remove it from the paired view + device.iOperation = EOpUnpair; + iModel->ChangeDevice(device); + } + } + } + + TRACE_FUNC_EXIT + } +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::BlockDeviceDlgL +// ---------------------------------------------------------- +void CBTUIPairedDevicesView::BlockDeviceDlgL() + { + TRACE_FUNC_ENTRY + + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + + //check if this is connected device + + HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); + + HBufC* stringHolder = NULL; + if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) + stringHolder = StringLoader::LoadLC( + (iHelpEnabled? R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_HELP: + R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_NOHELP ), + device.iName); + else + stringHolder = StringLoader::LoadLC( + (iHelpEnabled?R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP:R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP), + device.iName); + + + CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (*stringHolder, + CAknQueryDialog::EConfirmationTone); + queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); + + (queryDialog)->Heading()->SetTextL(*header); + queryDialog->SetFocus(ETrue); + + TInt keypress=EFalse; +#ifdef __SERIES60_HELP + if (iHelpEnabled) + { + HBufC* queryLink = StringLoader::LoadL(R_BT_BLOCK_DEVICE_LINK); + TCoeHelpContext hc(KBtuiUid3,KBT_HLP_BLOCKED); + TCallBack helpCallBack(CBTUIPairedDevicesView::LaunchHelp , &hc); + + TRAPD(err, + static_cast(queryDialog)->SetLinkTextL(*queryLink); + static_cast(queryDialog)->SetLink(helpCallBack);); + if(err==KErrNone) + { + keypress = queryDialog->RunLD(); + } + + delete queryLink; + queryLink = NULL; + } + else +#endif + { + keypress = queryDialog->RunLD(); + } + + CleanupStack::PopAndDestroy(stringHolder); + CleanupStack::PopAndDestroy(header); + + if(keypress) + { + device.iOperation = EOpBlock; + iModel->ChangeDevice(device); + } + TRACE_FUNC_EXIT + } +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::ChangeDeviceSecurityL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::ChangeDeviceSecurityL(TBool aTrusted) + { + TRACE_FUNC_ENTRY + + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + + if(aTrusted) + { + // set to trusted + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtAuthConfirmQuery, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + TInt keypress = dlg->ExecuteLD(R_BT_SET_TRUSTED_QUERY); + + if(keypress) // User has accepted the dialog + { + device.iOperation = EOpTrust; + iModel->ChangeDevice(device); + } + } + else + { + device.iOperation = EOpUntrust; + iModel->ChangeDevice(device); + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------- +// CBTUIMainView::VisibilityModeChanged +// ---------------------------------------------------- +// +void CBTUIPairedDevicesView::VisibilityModeChanged( TBTVisibilityMode ) + { + TRACE_FUNC_ENTRY + + + TRACE_FUNC_EXIT + } + + +// ---------------------------------------------------- +// CBTUIMainView::PowerStateChanged +// ---------------------------------------------------- +// +void CBTUIPairedDevicesView::PowerStateChanged( TBTPowerStateValue ) + { + TRACE_FUNC_ENTRY + + if ( iIsConnectDevice ) + { + iModel->ChangeDevice(*iConnectDevice); + iIsConnectDevice = EFalse; // reset flag + } + + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::ConnectL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::ConnectL( + const TBTDevice& aDevice, TBool aNewWaitNote ) + { + TRACE_FUNC_ENTRY + + iIsAlreadyConnected = EFalse; + TRACE_INFO(_L("Set iIsAlreadyConnected -> False")) + //Check that there is not more than max amount of connections allready. + TInt connNum = 0; + RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, connNum); + if(connNum > KBtUiMaxConnections) + { + ConnectCompleteL(KErrServerBusy, aDevice); + } + else if(CallOnGoing()&& connNum > 1) + { + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::ENoTone, + CAknNoteDialog::ELongTimeout); + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtImpossibleIncallNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + dlg->ExecuteLD(R_BT_NOT_INCALL_NOTE); + } + else + { + if(TBTUIViewsCommonUtils::TurnBTOnIfNeededL(iBtEngSettings,iCoverDisplayEnabled)!= KErrNone) + return; + + TInt errorCode = KErrNone; + TBTPowerStateValue currentPowerMode; + errorCode=iBtEngSettings->GetPowerState(currentPowerMode); + + if(errorCode) + { + // handle the error code + return; + } + if ( aNewWaitNote ) + { + // Launch wait note + OpenWaitNoteL(iWaitForConnectDlg,R_BT_CONNECTING_TO_WAIT_NOTE,R_BT_CONNECTING_TO , + ECmdShowBtWaitConnectingToNote,aDevice.iName); + } + iConnectDevice=new(ELeave) TBTDevice(aDevice); + iConnectDevice->iOperation=EOpConnect; + + if( currentPowerMode == EBTPowerOff ) + { + // turn on the flag IsConnectDevice + // + iIsConnectDevice = ETrue; + } + else + { + // connect device + // + iModel->ChangeDevice(*iConnectDevice); + + // reset IsConnectDevice flag + iIsConnectDevice = EFalse; + } + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::OpenWaitNoteL +// ---------------------------------------------------------- +void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, + TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) + { + TRAPD(err, + HBufC* stringholder = StringLoader::LoadLC(aNoteTextResource , aDevName ); + aWaitDialog = new (ELeave) CAknWaitDialog( + reinterpret_cast(&aWaitDialog), ETrue); + aWaitDialog->PrepareLC(aNoteResource); + aWaitDialog->SetTextL(*stringholder); + + if(iCoverDisplayEnabled) + { + aWaitDialog->PublishDialogL( + aSec, KUidCoverUiCategoryBtui); // initializes cover support + CAknMediatorFacade* covercl = AknMediatorFacade(aWaitDialog); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevName);// takes copy so consts are ok too + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + aWaitDialog->SetCallback(this); // for capturing Cancel keypress + aWaitDialog->RunLD(); + + CleanupStack::PopAndDestroy(stringholder); // stringholder + ); + // if the above functions leaves the iWaitNote is deleted, but + // not set to NULL. This will cause a problem, when + // the items may be deleted again, since it has to + // be a member variable, in order to be closed + // programmatically. + if(err!=KErrNone) + { + // that is why we set it to NULL here and + // continue leaving further. + aWaitDialog=NULL; + User::Leave(err); + } + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::LaunchSettingViewL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::LaunchSettingViewL() + { + TRACE_FUNC_ENTRY + + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + + CAknView* settingView = iBTPluginMan->GetSettingViewL(device); + if(settingView != NULL) + { + TUid viewId = settingView->Id(); + if(( device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected ) + { + TBuf8 DeviceName; + DeviceName.Copy(device.iName); + AppUi()->ActivateLocalViewL( viewId, KNullUid, DeviceName); + } + else + { + AppUi()->ActivateLocalViewL( viewId ); + } + } + else + { + User::Leave(KErrNotFound); + } + + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::DisconnectL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::DisconnectL() + { + TRACE_FUNC_ENTRY + + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + iDisconnectQueryDevice = device;//remember device related with query dialog + + // Create confirmation query + HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName); + iDisconnectQueryDlg = CAknQueryDialog::NewL(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(iDisconnectQueryDlg); + iDisconnectQueryDlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(iDisconnectQueryDlg); + + CAknMediatorFacade* covercl = AknMediatorFacade(iDisconnectQueryDlg); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName);// takes copy so consts are ok too + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + + TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, *stringholder); + + CleanupStack::PopAndDestroy(stringholder); // stringholder + + iDisconnectQueryDlg = NULL; + if(keypress) // User has accepted the dialog + { + device.iOperation = EOpDisconnect; + iModel->ChangeDevice(device); + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::CancelDisconnectQueryDlgL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::CancelDisconnectQueryDlgL() +{ + TRACE_FUNC_ENTRY + + if(iDisconnectQueryDlg) + { + delete iDisconnectQueryDlg; + iDisconnectQueryDlg = NULL; + } + + TRACE_FUNC_EXIT +} + +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::DisconnectWithoutQuery +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::DisconnectWithoutQuery() +{ + TRACE_FUNC_ENTRY + + TInt index = iContainer->CurrentItemIndex(); + if(index == KErrNotFound) return; + + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + device.iOperation = EOpDisconnect; + iModel->ChangeDevice(device); +} +// ---------------------------------------------------------- +// CBTUIPairedDevicesView::ConnectCompleteL +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::ConnectCompleteL(TInt aError,const TBTDevice& aDevice, + const RBTDevNameArray* aConflictingDeviceNames) + { + TRACE_FUNC_ENTRY + + // Dismiss wait note + // + if(iConnectDevice) + { + delete iConnectDevice; + iConnectDevice=NULL; + } + + if ( iIsPairConnect ) + { + iIsPairConnect = EFalse; + if ( aError != KErrNone && + aError != KErrCancel && + aError != KErrNotSupported && + aError != KErrAlreadyExists && + aError != KErrServerBusy ) + { + // It is possible that we started connecting too soon before the + // device moves to conntable mode from pairing mode. Let's try + // once more: + if ( !iActive ) + { + iActive = CBTUIActive::NewL( + this, KAutoConnect2ndTry, CActive::EPriorityStandard ); + } + iActive->RequestStatus() = KRequestPending; + iActive->GoActive(); + TRequestStatus* stptr = &( iActive->RequestStatus() ); + User::RequestComplete( stptr, KErrNone ); + TRACE_INFO( _L("CBTUIPairedDevicesView, sceadule auto connect 2nd try") ) + return; + } + } + + if(iWaitForConnectDlg) + { + TRACE_INFO(_L("waiting dialog is active, dismiss it")) + iWaitForConnectDlg->ProcessFinishedL(); + } + + switch (aError) + { + case KErrCancel: + TRACE_INFO(_L("aError = KErrCancel")) + break; + case KErrAlreadyExists: // connection exists allready + { + HBufC* stringholder = NULL; + if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) + { + if(aConflictingDeviceNames->Count() == 1) + { + stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_PROMPT, + *(*aConflictingDeviceNames)[0],iCoeEnv ); + } + else + { + CPtrC16Array* aa=new(ELeave) CPtrC16Array(1+1); + aa->InsertL(0, *(*aConflictingDeviceNames)[0] ); + aa->InsertL(1, *(*aConflictingDeviceNames)[1] ); + stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_STEREO_PROMPT , + *aa,iCoeEnv); + delete(aa); + } + TRACE_INFO(_L("KErrAllreadyExists")) + } + else + { + // Showing a note in this case would always show a note with "%U" in it + // so the note is not shown at all + TRACE_INFO(_L("KErrAlreadyExists, but no device given, not showing a notification")) + break; + } + + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(note); + note->PublishDialogL(ECmdShowBtDisconnectFirstNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(note); + + CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(*(*aConflictingDeviceNames)[0]); + } + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + + note->ExecuteLD(*stringholder); + CleanupStack::PopAndDestroy(stringholder); + } + break; + case KErrServerBusy: + { + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( + CAknNoteDialog::ENoTone,CAknNoteDialog::ELongTimeout); + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdBtuiShowBtBusyNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + dlg->ExecuteLD(R_BT_BUSY); + } + break; + case KErrNone: + { + + TRACE_INFO(_L("aError = KErrNone")) + // Create note + // + CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); + + HBufC* stringHolder = NULL; + + if (!FeatureManager::FeatureSupported(KFeatureIdAccessoryFw)) + { + if (CallOnGoing()) + { + stringHolder = StringLoader::LoadLC(R_BT_AUDIOS_ACCESSORY_PROMPT); // qtn_bt_audio_accessory "Audio routed to BT handsfree" + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(notePtr); + notePtr->PublishDialogL(ECmdBtuiShowBtAudioAccessory, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(notePtr); + } + + notePtr->ExecuteLD(*stringHolder); + } + else + { + TRACE_INFO(_L("No call ongoing. Connected to")) + stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); // "Connected to %U" + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(notePtr); + notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(notePtr); + + CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + + notePtr->ExecuteLD(*stringHolder); + } + } + else + { + TRACE_INFO(_L("AccFW Supported. Connected to")) + stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(notePtr); + notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(notePtr); + + CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + + notePtr->ExecuteLD(*stringHolder); + } + + CleanupStack::PopAndDestroy(stringHolder); + } + + TRAP_IGNORE(LaunchSettingViewL();) + break; + + case KErrNotSupported: + { + TRACE_INFO(_L("error = KErrNotSupported")) + + + // create note + // + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + HBufC* stringHolder = StringLoader::LoadLC(R_BT_DEVICE_NOT_SUPPORTED,aDevice.iName); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(note); + note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(note); + + CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + note->ExecuteLD(*stringHolder); + CleanupStack::PopAndDestroy(stringHolder); + } + break; + + default: + { + // Create note + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + HBufC* stringHolder=StringLoader::LoadLC(R_BT_DEVICE_NOT_AVAIL_NOTE ); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(note); + note->PublishDialogL(ECmdBtuiShowBtDeviceNotAvail, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(note); + + } + + note->ExecuteLD(*stringHolder); + CleanupStack::PopAndDestroy(stringHolder); + TRACE_INFO(_L("default error note BT-not-available")) + } + break; + } + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------ +// CBTUIPairedDevicesView::LaunchHelp +// static help launching function for TCallback +// ------------------------------------------------------ +TInt CBTUIPairedDevicesView::LaunchHelp(TAny* aCoeHelpContext) + { +#ifdef __SERIES60_HELP + //TRACE_FUNC_ENTRY + TCoeHelpContext hc; + + if(aCoeHelpContext==NULL) + hc = TCoeHelpContext(KBtuiUid3,KBT_HLP_BLOCKED); + else + hc = *static_cast(aCoeHelpContext); + TRAPD(err, + CArrayFix< TCoeHelpContext >* array=new (ELeave) CArrayFixFlat< TCoeHelpContext >(1); + array->AppendL(hc); + CleanupStack::PushL(array); + // codescan will complain about CCoeEnv::Static(), however it is not reasonable + // avoidable, since this is static funtion. + HlpLauncher::LaunchHelpApplicationL(CCoeEnv::Static()->WsSession() , array); + CleanupStack::Pop(array); + ); + + // the array is not deleted, since deleting it will result + // to E32User-CBase 3. It is assumed that HlpLancher is taking care of it. + // however this has not been documented. + //TRACE_FUNC_EXIT + return err; +#else + return KErrNone; +#endif + } + +// ------------------------------------------------------ +// CBTUIPairedDevicesView::CallOnGoing +// ------------------------------------------------------ +TBool CBTUIPairedDevicesView::CallOnGoing() + { + TRACE_FUNC_ENTRY + TInt callState; + // Try to get the call state property + + TInt err = RProperty::Get(KPSUidCtsyCallInformation, + KCTsyCallState, callState); //KPSUidTelephonyCallInformation should be used // Check also,if retrieving the property value succeeded + return (err == KErrNone) ? + (callState != EPSCTsyCallStateNone && + callState != EPSCTsyCallStateUninitialized) : + EFalse; + } +// ---------------------------------------------------------- +// From MProgressDialogCallback +// CBTUIPairedDevicesView::DialogDismissedL +// +// Cancels pairing/connection operation if user has pressed Cancel softkey. +// Does nothing if the dialog has been dismissed by this program. +// ---------------------------------------------------------- +// +void CBTUIPairedDevicesView::DialogDismissedL(TInt aButtonId ) + { + TRACE_FUNC_ENTRY + + // it was not canceled, but dialog was closed + // because it ended normally, so there is nothing to clean up. + if( aButtonId != EAknSoftkeyCancel ) + return; + + // Cancel ongoing operations if any + // + if ( iWaitForConnectDlg) + { + if( iConnectDevice ) + { + iModel->CancelChange(*iConnectDevice); + delete iConnectDevice; + iConnectDevice=NULL; + iIsPairConnect = EFalse; + } + iWaitForConnectDlg = NULL; + } + if ( iWaitForPairingDlg ) + { + if( iPairingDevice ) + { + TBTDevice device; + device.iAddr = iPairingDevice->BDAddr(); + device.iOperation = EOpPair; + + iDeviceSearcher->CancelSearchRemoteDevice(); + + iModel->CancelChange(device); + + delete iPairingDevice; + iPairingDevice=NULL; + } + // The dialog has already been deleted by UI framework and + // must not be deleted manually. + iWaitForPairingDlg = NULL; + } + + TRACE_FUNC_EXIT + } +// ------------------------------------------------------ +// From MBTEngSdpResultReceiver +// CBTUIPairedDevicesView::ServiceSearchComplete +// not used and implemented as empty +// ------------------------------------------------------ +void CBTUIPairedDevicesView::ServiceSearchComplete(const RSdpRecHandleArray& , TUint , TInt) + { + TRACE_FUNC_ENTRY + } +// ------------------------------------------------------ +// From MBTEngSdpResultReceiver +// CBTUIPairedDevicesView::AttributeSearchComplete +// not used and implemented as empty +// ------------------------------------------------------ +void CBTUIPairedDevicesView::AttributeSearchComplete(TSdpServRecordHandle, + const RSdpResultArray& ,TInt) + { + TRACE_FUNC_ENTRY + } +// ------------------------------------------------------ +// From MBTEngSdpResultReceiver +// CBTUIPairedDevicesView::AttributeSearchComplete +// not used and implemented as empty +// ------------------------------------------------------ +void CBTUIPairedDevicesView::ServiceAttributeSearchComplete(TSdpServRecordHandle , + const RSdpResultArray& ,TInt ) + { + TRACE_FUNC_ENTRY + } +// ------------------------------------------------------ +// From MBTEngSdpResultReceiver +// CBTUIPairedDevicesView::DeviceSearchComplete +// ------------------------------------------------------ +void CBTUIPairedDevicesView::DeviceSearchComplete(CBTDevice* aDevice, TInt aErr) + { + TRACE_FUNC_ENTRY + + TRAPD(err, DeviceSearchCompleteL(aDevice, NULL, aErr); + ); + // something went wrong. + if(err != KErrNone) + { + TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); + } + iSearchOngoing=EFalse; + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------ +// From MBTEngSdpResultReceiver +// CBTUIPairedDevicesView::DeviceSearchComplete +// ------------------------------------------------------ +void CBTUIPairedDevicesView::DeviceSearchComplete( CBTDevice* aDevice, + TNameEntry* aNameEntry, TInt aErr ) + { + TRACE_FUNC_ENTRY + + TRAPD(err, DeviceSearchCompleteL(aDevice, aNameEntry, aErr); + ); + // something went wrong. + if(err != KErrNone) + { + TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); + } + iSearchOngoing=EFalse; + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------ +// CBTUIPairedDevicesView::DeviceSearchCompleteL +// Leaving version of DeviceSearchComplete +// ------------------------------------------------------ + +void CBTUIPairedDevicesView::DeviceSearchCompleteL(CBTDevice* aDevice, + TNameEntry* aNameEntry, TInt aErr) + { + TRACE_FUNC_ENTRY + iSearchOngoing=EFalse; + if ( !iPairingDevice ) + { + delete iModel; + iModel = NULL; + return; + } + // we must not have multiple pairings at the same time + __ASSERT_DEBUG(aDevice->BDAddr() == iPairingDevice->BDAddr(), + PANIC(EBTPanicTwoPairingAttemptsAtTheSameTime) ); + + // other error condition, most likely dialog cancel. + if(aErr != KErrNone && (aErr != KErrAlreadyExists)) + { + delete iPairingDevice; + iPairingDevice=NULL; + return; + } + + // In case user switches the view fast enough before searching starts, + // It crashes the whole btui by iModel is null value. + // We add an extra check here + // + if ( !iModel ) + { + delete iPairingDevice; + iPairingDevice=NULL; + return; + } + + TBTDevice *tmpDevice=iModel->CreateDeviceL(aDevice, aNameEntry); + CleanupStack::PushL(tmpDevice); + if(tmpDevice->iStatus & (EStatusPhysicallyConnected|EStatusBtuiConnected|EStatusPaired)) + { + ShowDisconnecNoteL(tmpDevice); + CleanupStack::PopAndDestroy(tmpDevice); + delete iPairingDevice; + iPairingDevice=NULL; + return; + } + else + { + // Launch wait note + OpenWaitNoteL(iWaitForPairingDlg,R_BT_WAITING,R_BT_WAITING_PROMPT, + ECmdShowBtWaitingNote,tmpDevice->iName); + + CleanupStack::PopAndDestroy(tmpDevice); + tmpDevice=NULL; + // and start the pairing + iModel->ChangeDevice(aDevice, aNameEntry, EOpPair); + // aDevice is not deleted, since it points to iPairingDevice and it is still used + // after this + } + TRACE_FUNC_EXIT + } +// ------------------------------------------------------ +// CBTUIPairedDevicesView::ShowDisconnecNote +// ------------------------------------------------------ +void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) + { + HBufC* stringholder = StringLoader::LoadLC( + R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName); + + // Launch a waiting confirmation note + // + CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(note); + note->PublishDialogL(ECmdShowBtSuccesfullyPairedNote, + KUidCoverUiCategoryBtui); // initializes cover support + CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice->iName);// takes copy so consts are ok too + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + CleanupStack::Pop(note); + } + + note->ExecuteLD(*stringholder); + + CleanupStack::PopAndDestroy(stringholder); // stringholder + + } + +void CBTUIPairedDevicesView::ConnectIfNeededAfterPairL( TInt aCount ) + { + TRACE_FUNC_ENTRY + TBTDevice device; + device.iAddr = iPairConnectAddr; + iModel->GetDevice(device); + device.iOperation = EOpConnect; + ConnectL( device, ( aCount ) ? EFalse : ETrue ); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------ +// CBTUIPairedDevicesView::BondingCompleted +// called by NotifyChangeDeviceComplete +// ------------------------------------------------------ +void CBTUIPairedDevicesView::BondingCompleteL(TInt aError, const TBTDevice& aDevice) + { + TRACE_INFO((_L("aError=%d"), aError)) + // We need to make a copy of the device, since it may be cleaned up + // by device refresh. + TBTDevice bDevice= aDevice; + + // this may look useless, however if the device has a given shortName it is listed with it + // all the time. If you omnit this line it will be shown with its original deviceName, + // dispite it will be listed with the given name + iModel->GetDevice(bDevice); + + delete iPairingDevice; + iPairingDevice=NULL; + + // Dismiss wait note + if(iWaitForPairingDlg) + { + iWaitForPairingDlg->ProcessFinishedL(); + iWaitForPairingDlg = NULL; + } + + // Error handling + switch(aError) + { + case KErrCancel: + break; + case KErrAlreadyExists: // This is a legal return value + case KErrNone: + case KHCIErrorBase: + { + if( (bDevice.iStatus & EStatusConnectable) + && (bDevice.iDeviceClass.MajorDeviceClass() != EMajorDeviceComputer)) + // Only automatically query for a connectable device but not a computer + { + iPairConnectAddr = aDevice.iAddr; + iIsPairConnect = ETrue; + ConnectIfNeededAfterPairL( 0 ); + } + break; + } + default: + { + break; + } + } + TRACE_FUNC_EXIT + } + +// ----------------------------------------------- +// From MBTDeviceObserver +// CBTUIPairedDevicesView::RefreshDeviceList +// calls the container to refresh the deviceList +// ----------------------------------------------- +void CBTUIPairedDevicesView::RefreshDeviceList(const RDeviceArray* aDevices, + TInt aSelectedItemIndex) + { + TRACE_FUNC_ENTRY + TRAPD(err, + if(iContainer) + { + iContainer->RefreshDeviceListL(aDevices,aSelectedItemIndex); + } + ); + if (iActiveMenuPane && iActiveMenuPane->NumberOfItemsInPane()>0 ) + { + TInt index = iContainer->CurrentItemIndex(); + if ( index >=0 ) + { + TBTDevice device; + device.iIndex = index; + iModel->GetDevice(device); + if ( iMenuDevice.iAddr == device.iAddr && + ( ( iMenuDevice.iStatus & EStatusBtuiConnected ) != ( device.iStatus & EStatusBtuiConnected ) ) ) + { + TRACE_INFO(_L("Device status changed, update menupane")); + iMenuDevice = device; + iActiveMenuPane->Close(); + TRAP_IGNORE( this->ProcessCommandL(EAknSoftkeyOptions) ); + } + } + } + if(err!= KErrNone) + { + TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); + } + TRACE_FUNC_EXIT + } + + +// ----------------------------------------------- +// +// ----------------------------------------------- +void CBTUIPairedDevicesView::RequestCompletedL( CBTUIActive* aActive, TInt aId, + TInt aStatus ) + { + TRACE_INFO( ( _L("CBTUIPairedDevicesView::RequestCompletedL err %d"), aStatus ) ) + (void) aActive; + (void) aId; + (void) aStatus; + TRACE_INFO( _L("CBTUIPairedDevicesView, auto connect 2nd try ... ") ) + ConnectIfNeededAfterPairL( 1 ); + } + +// ----------------------------------------------- +// +// ----------------------------------------------- +void CBTUIPairedDevicesView::HandleError( CBTUIActive* aActive, TInt aId, + TInt aError ) + { + (void) aActive; + (void) aId; + (void) aError; + iIsPairConnect = EFalse; + } + +// --------------------------------------------------------- +// From MBTDeviceObserver +// CBTUIPairedDevicesView::NotifyChangeDeviceComplete +// This function implement the functionality of command complete. +// The lists of shown devices are refreshed by RefreshDeviceList, +// not by this function +// --------------------------------------------------------- +// +void CBTUIPairedDevicesView::NotifyChangeDeviceComplete(const TInt aErr, + const TBTDevice& aDevice, const RBTDevNameArray* aDevNameArray) + { + TRACE_FUNC_ENTRY + TBTDevice tmpDevice=aDevice; + TRAPD(err,NotifyChangeDeviceCompleteL(aErr,tmpDevice,aDevNameArray + );); + if(err!= KErrNone) + { + TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); + } + TRACE_FUNC_EXIT + } +// --------------------------------------------------------- +// CBTUIPairedDevicesView::NotifyChangeDeviceCompleteL +// Leaving version of notifyChangeDevice +// --------------------------------------------------------- + +void CBTUIPairedDevicesView::NotifyChangeDeviceCompleteL(const TInt aErr, + const TBTDevice& aDevice, const RBTDevNameArray* aDevNameArray) + { + TRACE_FUNC_ENTRY + if(iContainer == NULL) return; + + TRACE_INFO((_L("aErr=%d"), aErr)) + TRACE_INFO((_L("aDevice.iOperation=%d"), aDevice.iOperation)) + TRACE_INFO((_L("aDevice.iStatus=%d"), aDevice.iStatus)) + TRACE_INFO((_L("iIsAlreadyConnected=%d"), iIsAlreadyConnected)) + + if (aDevice.iOperation == EOpDisconnect && iExpectedCallBack>0 ) + { + TBTDevice device; + device.iIndex = aDevice.iIndex; + iModel->GetDevice(device); + device.iOperation = EOpUnpair; + iModel->ChangeDevice(device); + iExpectedCallBack--; + } + + if( aDevice.iOperation == EOpConnect ) + { + if( aErr == KErrNone && iIsAlreadyConnected ) + { + TRACE_INFO(_L("Don't show notes several times for the same device with different profile connections")) + return; + } + ConnectCompleteL(aErr, aDevice, aDevNameArray ); + iIsAlreadyConnected = ETrue; + TRACE_INFO(_L("iIsAlreadyConnected False -> True")) + return; + } + if(aDevice.iOperation == EOpPair) + { + BondingCompleteL(aErr, aDevice); + } + if(aErr != KErrNone) + { + // The user tried to rename to a name that allready exists. + if(aDevice.iOperation == EOpChangeName && aErr == KErrAlreadyExists) + { + CAknNoteDialog* dlg2 = new (ELeave) CAknNoteDialog(CAknNoteDialog::EErrorTone, + CAknNoteDialog::ELongTimeout); + dlg2->ExecuteLD(R_BT_NAME_EXISTS_NOTE); + + RenameDeviceDlgL(); + return; + } + // Need to properly handle situation when "Disconnect from xxx" query + // has been shown and paired device has been turned off simultaneously. + // CancelDisconnectQuery dialog need to be closed. + if(aErr == KErrDisconnected) + { + if(iDisconnectQueryDlg && aDevice.iAddr == iDisconnectQueryDevice.iAddr) + CancelDisconnectQueryDlgL(); + + TRACE_FUNC_EXIT + return; + } + // show general error if any of these failed + if( aDevice.iOperation== EOpTrust || + aDevice.iOperation== EOpUntrust || + aDevice.iOperation== EOpBlock || + aDevice.iOperation== EOpChangeName) + { + TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); + } + return; + } + + if(aDevice.iOperation == EOpUntrust) + { + // Unauthorise ok note, + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::EConfirmationTone, + CAknNoteDialog::ELongTimeout); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtDevSetAsUntrustNote, KUidCoverUiCategoryBtui); + // initializes cover support + CleanupStack::Pop(dlg); + } + dlg->ExecuteLD( R_BT_DEVICE_UNTRUSTED_NOTE ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CBTUIPairedDevicesView::CreateTabIconL() +// Creates icon for tab. +// --------------------------------------------------------------------------- +// +CGulIcon* CBTUIPairedDevicesView::CreateTabIconL() + { + TFileName bmpFilename; + bmpFilename += KBitmapFileDrive; + bmpFilename += KDC_APP_BITMAP_DIR; + bmpFilename += KBtuiBmpFileName; + + CGulIcon* icon = AknsUtils::CreateGulIconL( + AknsUtils::SkinInstance(), + KAknsIIDQgnPropBtDevicesTab3, + bmpFilename, + EMbmBtuiQgn_prop_bt_devices_tab3, + EMbmBtuiQgn_prop_bt_devices_tab3_mask ); + + return icon; + } + +// End of File + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIRegistryWatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIRegistryWatcher.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2002 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: Declares Registry watcher class for BTUI. +* +*/ + + +// INCLUDE FILES + +#include "BTUI.h" +#include "BTUIRegistryWatcher.h" +#include + +#include "BTDevModel.h" //for Log printing Macro + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CBTUIRegistryWatcherAO::CBTUIRegistryWatcherAO +// C++ default constructor can NOT contain any code, that +// might leave. +// --------------------------------------------------------- +// +CBTUIRegistryWatcherAO::CBTUIRegistryWatcherAO( MBTUIRegistryObserver* aParent ) + : CActive(EPriorityNormal), iParent ( aParent ) + { + TRACE_FUNC_ENTRY + + CActiveScheduler::Add(this); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// Destructor. +// --------------------------------------------------------- +// +CBTUIRegistryWatcherAO::~CBTUIRegistryWatcherAO() + { + TRACE_FUNC_ENTRY + + Cancel(); + iProperty.Close(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIRegistryWatcherAO::WatchL +// --------------------------------------------------------- +// +void CBTUIRegistryWatcherAO::WatchL() + { + TRACE_FUNC_ENTRY + + if( !iProperty.Handle() ) + { + User::LeaveIfError( iProperty.Attach( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothRegistryTableChange ) ); + } + + if( !IsActive() ) + { + iProperty.Subscribe(iStatus); + SetActive(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIRegistryWatcherAO::DoCancel +// --------------------------------------------------------- +// +void CBTUIRegistryWatcherAO::DoCancel() + { + TRACE_FUNC + + iProperty.Cancel(); + } + +// --------------------------------------------------------- +// CBTUIRegistryWatcherAO::RunL +// --------------------------------------------------------- +// +void CBTUIRegistryWatcherAO::RunL() + { + TRACE_FUNC_ENTRY + + if( iStatus.Int()==KErrNone ) + { + __ASSERT_DEBUG(iParent, PANIC(EBTPanicClassMemberVariableIsNull)); + + // Inform observer + // + iParent->RegistryContentChangedL(); + + // Continue watching + // + WatchL(); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CBTUIRegistryWatcherAO::RunError +// --------------------------------------------------------- +// +TInt CBTUIRegistryWatcherAO::RunError( TInt aError ) + { + TRACE_INFO((_L("RunError: %d"), aError)) + + return aError; + } + +// --------------------------------------------------------- +// CBTUIRegistryWatcherAO::StopWatching +// --------------------------------------------------------- +// +void CBTUIRegistryWatcherAO::StopWatching() + { + TRACE_FUNC + + Cancel(); + } + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUISap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUISap.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,248 @@ +/* +* Copyright (c) 2002-2007 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: This module is created for Bluetooth SIM Access Profile +* feature variant. +* +*/ + +#include +#include +#include // localisation stringloader +#include // Compiled resource ids +#include +#include +#include +#include // for disconnect type and connection observer +#include +#include +#include +#include // For EnterpriseEnablementL() +#include + +#include "btdevmodel.h" + +#include "debug.h" +#include "BTUIMainView.h" + +#include +// ---------------------------------------------------- +// CBTUIMainView::SetSapStatusL +// ---------------------------------------------------- +// +void CBTUIMainView::SetSapStatusL( TBTSapMode aValue ) + { + TRACE_FUNC_ENTRY + + TInt previousSapMode = GetSapStatusL(); + + if(previousSapMode==EBTSapEnabled) + previousSapMode=ETrue; + + TBool legalToChange = ETrue; + + if ( ( previousSapMode ) && ( !aValue ) ) // SAP Enabled -> Disabled + { + // Check active SAP connections before query + TInt connStatus = EBTSapNotConnected; + RProperty::Get(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, connStatus); + + if(connStatus == EBTSapConnected) + { + //Get name of the currently connected SAP device + + TBTDeviceName connectedSap; + TInt error = GetConnectedSapNameL( connectedSap ); + + if ( error ) + { + TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); + } + else + { + + // Create confirmation query + HBufC* stringholder = StringLoader::LoadLC( R_BT_DISCONNECT_FROM, connectedSap ); + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + + CAknMediatorFacade* covercl = AknMediatorFacade(dlg); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(connectedSap);// takes copy so consts are ok too + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } + + TInt keypress = dlg->ExecuteLD( R_BT_DISCONNECT_FROM_QUERY, *stringholder ); + + CleanupStack::PopAndDestroy(stringholder); // stringholder + + if( keypress ) // User has accepted the dialog + { + legalToChange = ETrue; + } + else + { + legalToChange = EFalse; + } + } + } + } + + else if ( ( !previousSapMode ) && ( aValue ) ) // SAP Disabled -> Enabled + { + + //if Bluetooth is off + TBTPowerStateValue powerState; + iBtEngSettings->GetPowerState(powerState); + if(powerState!=EBTPowerOn) + { + CAknNoteDialog* dlg2 = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, + CAknNoteDialog::ENoTimeout/*ELongTimeout*/ ); + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(dlg2); + dlg2->PublishDialogL(ECmdShowBtSapEnableNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg2); + } + + dlg2->ExecuteLD( R_BT_SAP_ENABLE_NOTE ); + } + + } + + // Switch sapmode + // + if ( legalToChange ) + { + CRepository* cenRep = NULL; + cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + CleanupStack::PushL(cenRep); + TInt err = cenRep->Set( KBTSapEnabled, aValue ); + CleanupStack::PopAndDestroy(cenRep); + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIMainView::AskSapModeDlgL +// ---------------------------------------------------------- +// +void CBTUIMainView::AskSapModeDlgL() + { + TRACE_FUNC_ENTRY + + if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDataProfilesDisabled ) + { + RNotifier notifier; + User::LeaveIfError(notifier.Connect()); + CleanupClosePushL(notifier); + User::LeaveIfError(notifier.StartNotifier(KBTEnterpriseItSecurityInfoNotifierUid, KNullDesC8 )); + CleanupStack::PopAndDestroy(¬ifier); + } + else + { + CDesCArrayFlat* items = iCoeEnv->ReadDesCArrayResourceL( R_BT_SAP_MODES ); + CleanupStack::PushL(items); + + TInt currentItem = KErrNotFound; + if(GetSapStatusL() == EBTSapEnabled ) + { + currentItem=0; + } + else + { + currentItem=1; + + } + CAknRadioButtonSettingPage* dlg = new ( ELeave )CAknRadioButtonSettingPage( + R_BT_SAP_SETTING_PAGE, currentItem, items ); + if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) + { + if(currentItem == 1) + { + SetSapStatusL( static_cast( EBTSapDisabled ) ); + // Cast it back (invert again) + } + else + { + SetSapStatusL( static_cast( EBTSapEnabled ) ); + // Cast it back (invert again) + } + } + CleanupStack::PopAndDestroy(items); + } + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// CBTUIMainView::GetSapStatusL +// ---------------------------------------------------------- +// +TInt CBTUIMainView::GetSapStatusL() + { + TRACE_FUNC_ENTRY + TInt sapStatus; + CRepository* repository = CRepository::NewL(KCRUidBTEngPrivateSettings); + CleanupStack::PushL(repository); + repository->Get(KBTSapEnabled, sapStatus); + CleanupStack::PopAndDestroy(repository); + TRACE_FUNC_EXIT + return sapStatus; + } + +// ---------------------------------------------------------- +// CBTUIModel::GetConnectedSapNameL +// ---------------------------------------------------------- +// + +TInt CBTUIMainView::GetConnectedSapNameL( TDes& aName ) + { + TRACE_FUNC_ENTRY + + + CBTEngConnMan* cm = CBTEngConnMan::NewL(NULL); + CleanupStack::PushL(cm); + + RBTDevAddrArray devAddrArray; + cm->GetConnectedAddresses(devAddrArray, EBTProfileSAP); + if(devAddrArray.Count()>0) + { + CBTEngDevMan* devMan = CBTEngDevMan::NewL(NULL); + + TBTRegistrySearch search; + search.FindAddress(devAddrArray[0]); + + CBTDeviceArray* deviceArray= new (ELeave) CBTDeviceArray(devAddrArray.Count()); + //the name is in first CBTDevice in returned CBTDeviceArray. + devMan->GetDevices(search, deviceArray); + + aName = *(CnvUtfConverter::ConvertToUnicodeFromUtf8L(deviceArray->At(0)->DeviceName())); + + deviceArray->ResetAndDestroy(); + delete deviceArray; + + delete devMan; + } + + devAddrArray.Close(); + CleanupStack::PopAndDestroy(cm); + TRACE_FUNC_EXIT + return KErrNone; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BTUIViewsCommonUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BTUIViewsCommonUtils.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2007 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: Utility function for the views. +* +*/ + +#include // Compiled resource ids +#include +#include // Series 60 localisation stringloader +#include +#include +#include // Feature Manager API +#include +#include +#include +#include +#include + +#include "BTUIViewsCommonUtils.h" +#include "debug.h" + + +// ---------------------------------------------------------- +// TBTUIViewsCommonUtils::ShowGeneralErrorNoteL +// ---------------------------------------------------------- +// +void TBTUIViewsCommonUtils::ShowGeneralErrorNoteL() + { + //TRACE_FUNC_ENTRY + + CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EErrorTone, + CAknNoteDialog::ELongTimeout ); + if(FeatureManager::FeatureSupported( KFeatureIdCoverDisplay )) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(ECmdShowBtGeneralErrorNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + TRACE_INFO(_L("ShowGeneralErrorNoteL ")) + dlg->ExecuteLD( R_BT_GENERAL_ERROR_NOTE ); + + //TRACE_FUNC_EXIT + } + +// ---------------------------------------------------------- +// TBTUIViewsCommonUtils::IsAnyDeviceConnectedL() +// ---------------------------------------------------------- +TBool TBTUIViewsCommonUtils::IsAnyDeviceConnectedL() + { + //TRACE_FUNC_ENTRY + + TInt connNum = 0; + TInt retVal = RProperty::Get(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount, connNum); + TRACE_INFO((_L("GetConnectionNumber(): %d"), connNum)) + //TRACE_FUNC_EXIT + return (connNum > 0); + } + +// ----------------------------------------------- +// CBTUIPairedDevicesView::TurnBTOnIfNeededL +// ----------------------------------------------- +TInt TBTUIViewsCommonUtils::TurnBTOnIfNeededL(CBTEngSettings* aBtEngSettings,TBool aCoverDisplayEnabled ) + { + //TRACE_FUNC + + TInt errorCode = KErrNone; + TBTPowerStateValue previousPowerMode; + + errorCode=aBtEngSettings->GetPowerState(previousPowerMode); + if(errorCode) + return errorCode; + + if( previousPowerMode==EBTPowerOn ) + return KErrNone; + + if ( previousPowerMode==EBTPowerOff ) // power OFF -> ON + { + TRACE_INFO(_L("[BTUI]\t power OFF -> ON")) + + TInt offlineModeOff = 0; // possible values are 0 and 1 + TInt activationEnabled = 0; // possible values are 0 and 1 + + CRepository* repository = CRepository::NewL(KCRUidCoreApplicationUIs); + CleanupStack::PushL(repository); + repository->Get(KCoreAppUIsNetworkConnectionAllowed, offlineModeOff); + // Closing connection: + CleanupStack::PopAndDestroy(repository); + repository=NULL; + + repository = CRepository::NewL(KCRUidBluetoothEngine); + // Check activation enabled + CleanupStack::PushL(repository); + repository->Get(KBTEnabledInOffline, activationEnabled); + // Closing connection: + CleanupStack::PopAndDestroy(repository); + + + TRACE_INFO((_L("power OFF -> ON, offlineModeOff = %d"), offlineModeOff)) + TRACE_INFO((_L("power OFF -> ON, activationEnabled = %d"), activationEnabled)) + + // Choose user interaction + // + if ( !offlineModeOff && !activationEnabled ) + { + // Load a string, create and show a note + // + HBufC* stringHolder = StringLoader::LoadLC( R_BT_OFFLINE_DISABLED ); + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + + if(aCoverDisplayEnabled) + { + CleanupStack::PushL(note); + note->PublishDialogL(ECmdBtuiShowBtOfflineDisableNote, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(note); + } + + note->ExecuteLD( *stringHolder ); + CleanupStack::PopAndDestroy(stringHolder); //stringHolder + } + else + { + // Choose query + // + TInt resource = 0; + + TInt coverUiDlgId = 0; + + if ( offlineModeOff ) + { + resource = R_BT_IS_OFF_QUERY; + if(aCoverDisplayEnabled) + { + coverUiDlgId = ECmdBtuiShowBtIsOffDlg; + } + } + else + { + resource = R_BT_ACTIVATE_IN_OFFLINE_QUERY; + if(aCoverDisplayEnabled) + { + coverUiDlgId = ECmdBtuiShowBtActivateInOfflineDlg; + } + } + + // Create and show query + // + CAknQueryDialog* dlg = CAknQueryDialog::NewL(); + + if(aCoverDisplayEnabled) + { + CleanupStack::PushL(dlg); + dlg->PublishDialogL(coverUiDlgId, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(dlg); + } + + TInt keypress = dlg->ExecuteLD( resource ); + + if( keypress ) + { + // Switch BT ON + // + errorCode=aBtEngSettings->SetPowerState(EBTPowerOn ) ; + if (errorCode) + { + ShowGeneralErrorNoteL(); + } + } else + { + errorCode=KErrCancel; + } + + + } + + } + + return errorCode; + } + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/BtuiPluginImplementationTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/BtuiPluginImplementationTable.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2002-2007 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: ECOM proxy table for this plugin +* +*/ + +#include +#include + +#include "BTUIMainView.h" +#include "BTUIPairedDevicesView.h" +#include "BTUIBlockedDevicesView.h" + + +const TImplementationProxy KBtuiPluginImplementationTable[] = + { + // UPDATE THIS - Uid for plugin implementation: + //This impl is for GS FW, in this case mainView will construct BTUI Model. + IMPLEMENTATION_PROXY_ENTRY( 0x1020742C, CBTUIMainView::NewGsPluginL ), + + //Following two are for BTUI App, in this case mainView won't construct BTUI Model, + //BTUI's AppUi will do it and pass the pointer of Model to both views. + IMPLEMENTATION_PROXY_ENTRY( 0x1020745C, CBTUIMainView::NewL ), + IMPLEMENTATION_PROXY_ENTRY( 0x1020745D, CBTUIPairedDevicesView::NewL ), + IMPLEMENTATION_PROXY_ENTRY( 0x20002780, CBTUIBlockedDevicesView::NewL ) + }; + +// --------------------------------------------------------------------------- +// ImplementationGroupProxy +// Gate/factory function +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KBtuiPluginImplementationTable) + / sizeof(TImplementationProxy); + return KBtuiPluginImplementationTable; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/Ecom/src/btuipluginman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/src/btuipluginman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2007 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: Find and load plugin +* +*/ + + +#include +#include "btuipluginman.h" +#include "debug.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTUIPluginMan* CBTUIPluginMan::NewL( CAknViewAppUi* aAppUi ) + { + CBTUIPluginMan* self = new( ELeave ) CBTUIPluginMan( aAppUi ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTUIPluginMan::~CBTUIPluginMan() + { + TRACE_FUNC_ENTRY + + iPluginInfoArray.ResetAndDestroy(); + iPluginInfoArray.Close(); + iPluginArray.Reset();//Do not destroy - Plugins are owned by iAppUi + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Check if availability of some plug-in +// --------------------------------------------------------------------------- +// +TBool CBTUIPluginMan::IsPluginAvaiable(TBTDeviceClass aDeviceClassInfo) + { + for( TInt i=0; iGetCOD(); + if( devClass.MajorDeviceClass() == aDeviceClassInfo.MajorDeviceClass() && + devClass.MinorDeviceClass() == aDeviceClassInfo.MinorDeviceClass() ) + return ETrue; + } + return EFalse; + } + +// --------------------------------------------------------------------------- +// Get the setting view from PluginArrary based on the COD +// --------------------------------------------------------------------------- +// +CAknView* CBTUIPluginMan::GetSettingViewL(TBTDevice& aDevice) + { + for (TInt ii = 0; ii < iPluginArray.Count(); ii++ ) + { + TBTDeviceClass tmpCOD = iPluginArray[ii]->GetCOD(); + //Currently one device - one view - one plugin, + //in future maybe other device properties will decide on getting the view. + if(aDevice.iDeviceClass.MajorDeviceClass() == tmpCOD.MajorDeviceClass() && + aDevice.iDeviceClass.MinorDeviceClass() == tmpCOD.MinorDeviceClass()) + { + return (CAknView*)iPluginArray[ii]; + } + } + + return NULL; + } + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTUIPluginMan::CBTUIPluginMan( CAknViewAppUi* aAppUi ) + : iAppUi(aAppUi) + { + + } + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +void CBTUIPluginMan::ConstructL() + { + LoadPluginsL(); + } + +// --------------------------------------------------------------------------- +// Load ECom plug-ins +// --------------------------------------------------------------------------- +// +void CBTUIPluginMan::LoadPluginsL() + { + TRACE_FUNC_ENTRY + + REComSession::ListImplementationsL( KCBtuiPluginInterfaceUid, iPluginInfoArray ); + TInt count = iPluginInfoArray.Count(); + TRACE_INFO( ( _L( "[BTUI]\t CBTUIPluginMan::LoadSettingPluginL() PluginArray count=%d" ), count) ) + + iPluginArray.Reset(); + for ( TUint ii = 0 ; ii < count; ++ii ) + { + CImplementationInformation* impl = iPluginInfoArray[ii]; + //Only append the plugins which datatype() is for HID devices. + if(impl->DataType().Length()) + { + TLex8 lex( impl->DataType() ); + TUint major = 0, minor = 0; + TInt err1 = lex.Val(major, EHex); + lex.SkipSpace(); + TInt err2 = lex.Val(minor, EHex); + if( !err1 && !err2) + { + TRACE_INFO( ( _L( "[BTUI]\t CBTUIPluginMan::LoadSettingPluginL() MajorCOD=%d MinorCOD=%d" ), major, minor) ) + TBTDeviceClass cod(0x00, major, minor); + + CBtuiPluginInterface* plugin = NULL; + TRAPD( ret, plugin = CBtuiPluginInterface::NewL( impl->ImplementationUid() ) ); + if( !ret ) + { + CleanupStack::PushL(plugin); + + // Transfer the ownership to AppUi + iAppUi->AddViewL( (CAknView*)plugin ); + plugin->SetCOD(cod); + iPluginArray.AppendL(plugin); + CleanupStack::Pop(plugin); + } + } + } + } + + TRACE_FUNC_EXIT + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/aif/BTUI_caption.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/aif/BTUI_caption.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2002 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: Caption RSS file for creating the aif file for BTUI. +* +*/ + + +#include "btui.loc" +#include + +RESOURCE CAPTION_DATA + { + caption = qtn_apps_bluetooth_list; + shortcaption = qtn_apps_bluetooth_grid; + } + + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/aif/BTUIaif.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/aif/BTUIaif.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2002 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: +* RSS for creating the aif file for BTUI. +* +*/ + + +#include + +RESOURCE AIF_DATA +{ + app_uid=0x10005951; // Application UID + num_icons=2; // Grid and list icons with masks +} + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/data/BTUI.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/data/BTUI.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2002 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: This file contains all the resources for the BTUI. +* +*/ + + +#include + +// RESOURCE IDENTIFIER + +NAME BTUI // 4 letter ID + +// INCLUDES +#include +#include "btui.hrh" // Enums for these resources +#include // Localisation file +#include // Icon indexes created by abld +#include "eikon.rsg" +#include +#include +#include + +// MACROS + +// RESOURCE DEFINITIONS + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf="BTUI"; } + +RESOURCE EIK_APP_INFO + { + status_pane = r_btui_status_pane; + } + +//---------------------------------------------------- +// +// Hotkeys for BTUI +// +//---------------------------------------------------- +// +RESOURCE HOTKEYS r_btui_hotkeys + { + control= + { + HOTKEY { command=EAknCmdExit; key='e'; } + }; + } + +//---------------------------------------------------- +// +// The status pane for BTUI application +// +//---------------------------------------------------- +// +RESOURCE STATUS_PANE_APP_MODEL r_btui_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidNavi; + type = EAknCtNaviPane; + resource = r_btui_navi_decorator; + } + }; + } + +//---------------------------------------------------- +// +// The navi decorator for BTUI application +// Defines application views tabs +// +//---------------------------------------------------- +// +RESOURCE NAVI_DECORATOR r_btui_navi_decorator + { + type = ENaviDecoratorControlTabGroup; + control = TAB_GROUP + { + tab_width = EAknTabWidthWithThreeTabs; + active = 0; // Initial tab to be active + tabs = + { + TAB + { + id = EBTUIMainViewTab; + bmpfile = btui_bitmap_file_data_caging; + bmpid = EMbmBtuiQgn_prop_bt_set_tab3; + bmpmask = EMbmBtuiQgn_prop_bt_set_tab3_mask; + }, + TAB + { + id = EBTUIPairedDevicesViewTab; + bmpfile = btui_bitmap_file_data_caging; + bmpid = EMbmBtuiQgn_prop_bt_devices_tab3; + bmpmask = EMbmBtuiQgn_prop_bt_devices_tab3_mask; + }, + + TAB + { + id = EBTUIBlockedDevicesViewTab; + bmpfile = btui_bitmap_file_data_caging; + bmpid = EMbmBtuiQgn_prop_bt_blocked_tab3; + bmpmask = EMbmBtuiQgn_prop_bt_blocked_tab3_mask; + } + }; + }; + } + + + +//---------------------------------------------------- +// +// LOCALISABLE_APP_INFO +// +//---------------------------------------------------- + + +RESOURCE LOCALISABLE_APP_INFO r_btui_localisable_app_info + { + short_caption = qtn_apps_bluetooth_grid; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = qtn_apps_bluetooth_list; + #ifdef __SCALABLE_ICONS + number_of_icons = 1; + icon_file = APP_BITMAP_DIR"\\Btui_aif.mif"; + #else + number_of_icons = 2; + icon_file = APP_BITMAP_DIR"\\Btui_aif.mbm"; + #endif + }; + } + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/data/Btui_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/data/Btui_reg.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2004 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 + +UID2 KUidAppRegistrationResourceFile +UID3 0x10005951 + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "Btui"; + localisable_resource_file = APP_RESOURCE_DIR"\\btui"; + localisable_resource_id = R_BTUI_LOCALISABLE_APP_INFO; + } + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/BWINS/btdevmodelU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/BWINS/btdevmodelU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,16 @@ +EXPORTS + ??0TBTDevice@@QAE@XZ @ 1 NONAME ; TBTDevice::TBTDevice(void) + ?IsAnyDeviceConnected@CBTDevModel@@QAEHXZ @ 2 NONAME ; int CBTDevModel::IsAnyDeviceConnected(void) + ?CancelChange@CBTDevModel@@QAEXABVTBTDevice@@@Z @ 3 NONAME ; void CBTDevModel::CancelChange(class TBTDevice const &) + ?ReverseCompareAphabetically@TBTDeviceComparison@@SAHABVTBTDevice@@0@Z @ 4 NONAME ; int TBTDeviceComparison::ReverseCompareAphabetically(class TBTDevice const &, class TBTDevice const &) + ?ChangeDevice@CBTDevModel@@QAEXPBVCBTDevice@@PAV?$TPckgBuf@VTNameRecord@@@@W4TBTDeviceOp@@@Z @ 5 NONAME ; void CBTDevModel::ChangeDevice(class CBTDevice const *, class TPckgBuf *, enum TBTDeviceOp) + ?DeviceChangeInProgress@CBTDevModel@@QAEHXZ @ 6 NONAME ; int CBTDevModel::DeviceChangeInProgress(void) + ??0TBTDevice@@QAE@ABV0@@Z @ 7 NONAME ; TBTDevice::TBTDevice(class TBTDevice const &) + ?CreateDeviceL@CBTDevModel@@QAEPAVTBTDevice@@PBVCBTDevice@@PAV?$TPckgBuf@VTNameRecord@@@@@Z @ 8 NONAME ; class TBTDevice * CBTDevModel::CreateDeviceL(class CBTDevice const *, class TPckgBuf *) + ?ChangeDevice@CBTDevModel@@QAEXABVTBTDevice@@@Z @ 9 NONAME ; void CBTDevModel::ChangeDevice(class TBTDevice const &) + ??4TBTDevice@@QAEAAV0@ABV0@@Z @ 10 NONAME ; class TBTDevice & TBTDevice::operator=(class TBTDevice const &) + ?ChangeAllDevices@CBTDevModel@@QAEXW4TBTDeviceOp@@@Z @ 11 NONAME ; void CBTDevModel::ChangeAllDevices(enum TBTDeviceOp) + ?GetDevice@CBTDevModel@@QAEHAAVTBTDevice@@@Z @ 12 NONAME ; int CBTDevModel::GetDevice(class TBTDevice &) + ?NewL@CBTDevModel@@SAPAV1@W4TBTDeviceGroup@@PAVMBTDeviceObserver@@PAV?$TLinearOrder@VTBTDevice@@@@@Z @ 13 NONAME ; class CBTDevModel * CBTDevModel::NewL(enum TBTDeviceGroup, class MBTDeviceObserver *, class TLinearOrder *) + ?CompareAphabetically@TBTDeviceComparison@@SAHABVTBTDevice@@0@Z @ 14 NONAME ; int TBTDeviceComparison::CompareAphabetically(class TBTDevice const &, class TBTDevice const &) + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/eabi/btdevmodelu.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/eabi/btdevmodelu.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,18 @@ +EXPORTS + _ZN11CBTDevModel12CancelChangeERK9TBTDevice @ 1 NONAME + _ZN11CBTDevModel12ChangeDeviceEPK9CBTDeviceP8TPckgBufI11TNameRecordE11TBTDeviceOp @ 2 NONAME + _ZN11CBTDevModel12ChangeDeviceERK9TBTDevice @ 3 NONAME + _ZN11CBTDevModel13CreateDeviceLEPK9CBTDeviceP8TPckgBufI11TNameRecordE @ 4 NONAME + _ZN11CBTDevModel16ChangeAllDevicesE11TBTDeviceOp @ 5 NONAME + _ZN11CBTDevModel20IsAnyDeviceConnectedEv @ 6 NONAME + _ZN11CBTDevModel22DeviceChangeInProgressEv @ 7 NONAME + _ZN11CBTDevModel4NewLE14TBTDeviceGroupP17MBTDeviceObserverP12TLinearOrderI9TBTDeviceE @ 8 NONAME + _ZN11CBTDevModel9GetDeviceER9TBTDevice @ 9 NONAME + _ZN19TBTDeviceComparison20CompareAphabeticallyERK9TBTDeviceS2_ @ 10 NONAME + _ZN19TBTDeviceComparison27ReverseCompareAphabeticallyERK9TBTDeviceS2_ @ 11 NONAME + _ZN9TBTDeviceC1ERKS_ @ 12 NONAME + _ZN9TBTDeviceC1Ev @ 13 NONAME + _ZN9TBTDeviceC2ERKS_ @ 14 NONAME + _ZN9TBTDeviceC2Ev @ 15 NONAME + _ZN9TBTDeviceaSERKS_ @ 16 NONAME + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2006 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: Build information file for project btdevmodel +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/btdevmodel.h |../../../inc/btdevmodel.h +PRJ_MMPFILES +btdevmodel.mmp + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/group/btdevmodel.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/group/btdevmodel.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 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: Project definition file for project btdevmodel +* +*/ + + + +#include +#include + +TARGET btdevmodel.dll +TARGETTYPE DLL +UID 0x10009D8D 0x1020745E + +CAPABILITY CAP_GENERAL_DLL NetworkControl +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE btdevmodel.cpp +SOURCE btdevmodelbase.cpp +SOURCE btpairedmodel.cpp +SOURCE btblockedmodel.cpp +SOURCE btregistryobserver.cpp +SOURCE btdevice.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +SYSTEMINCLUDE ../../../inc +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib //CActive, TDes +LIBRARY btengsettings.lib +LIBRARY btengdevman.lib +LIBRARY btengconnman.lib +LIBRARY btmanclient.lib //TBTRegistrySearch,CBluetoothPhysicalLinks +LIBRARY bluetooth.lib //TBTDevAddr +LIBRARY btdevice.lib +LIBRARY centralrepository.lib +LIBRARY esock.lib //btpairedmodel +DEBUGLIBRARY flogger.lib diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/inc/btblockedmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/inc/btblockedmodel.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2006-2007 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: Maintains a Bluetooth devices data model for blocked devices view. +* +*/ + +#ifndef BTBLOCKEDMODEL_H +#define BTBLOCKEDMODEL_H + +#include "btdevmodelbase.h" +/** +* This is a adds funtionality to show only blocked devices to BTDevModelBase. +* +* It act as a mediator between UI applications and Bluetooth Engine Device Management API. +* +*@lib btdevmodel.dll +*@since S60 V3.2 +*/ +NONSHARABLE_CLASS(CBTBlockedModel) : public CBTDevModelBase + { +public: // Constructors and destructor + /** NewL function + * @param aObserver The observer will receive information about command completes and + * changes in the devices. + * @param aOrder The order the devices are sorted. Default order is added by CBTDevMan, so + * this class can assume this parameter to be used. This class is responsible for deleting this parameter on + * its destructor. + */ + static CBTBlockedModel* NewL(MBTDeviceObserver* aObserver , + TBTDeviceSortOrder* aOrder ); + /** Destructor + */ + virtual ~CBTBlockedModel(); + + /** Add new device to the list, but only if the device is blocked. + * This function will filter out those devices that are not blocked. + *@param aRegdevice the device to be added to the list + */ + void HandleNewDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry); + +private: + /** Constructor + * @param aObserver The observer will receive information about command completes and + * changes in the devices. + * @param aOrder The order the devices are sorted. Default order is added by CBTDevMan, so + * this class can assume this parameter to be used. This class is responsible for deleting this parameter on + * its destructor. + */ + CBTBlockedModel(MBTDeviceObserver* aObserver , + TBTDeviceSortOrder* aOrder ); + /** Symbian 2nd phase constuctor that may leave. + *@param None. + * @return None. + */ + void ConstructL(); + + + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/inc/btdevmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/inc/btdevmodel.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,304 @@ +/* +* Copyright (c) 2006-2007 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: Maintain a Bluetooth devices data model for UI components. +* +*/ + +#ifndef BTDEVMODEL_H +#define BTDEVMODEL_H + +#include +#include +#include +#include + +// used to support different device list of UI +enum TBTDeviceGroup + { + EGroupPaired, // for paired device list + EGroupBlocked // for blocked device list + }; + +// for showing left side icon of a device in device list. Based on CoD major device +enum TBTDeviceType + { + EDeviceComputer = 0,// computer + EDevicePhone, // mobile phone + EDeviceAudio, // headset or loudspeakers + EDeviceCarkit, // audio-caraudio + EDevicePrinter, // imaging-printer + EDeviceKeyboard, // peripheral-keyboard + EDeviceMice, // peripheral-pointer + EDeviceGPS, // major service positioning + EDeviceDefault, // device of other type than define above. + }; + +// for showing right side icon of a device on a device list +enum TBTDeviceStatus + { + EStatusTrusted = 0x0001, // show authorised icon on both paired and blocked lists + EStatusBtuiConnected = 0x0002, // show connected icon on paired list + EStatusBlocked = 0x0004, // show device on blocked list + EStatusPaired = 0x0008, // show the device in paired devices list + EStatusConnectable = 0x0010, // The device can be connected to. + // NOTE: connected devices are also connectable, + // despite they cannot be connected before disconnect. + EStatusPhysicallyConnected = 0x0020 // Physical bluetooth connection. + }; + +enum TBTDeviceOp + { + EOpPair, + EOpUnpair, + EOpBlock, + EOpUnblock, + EOpConnect, + EOpDisconnect, + EOpTrust, + EOpUntrust, + EOpChangeName, + EOpNone, + EOPInternalUntust // used by CBTDevModel internally + }; + +/* TBTDevAddr that is not address of any device +*/ +#define KNullAddress TBTDevAddr(TInt64(0)) + +// contain all device info needed for shown on a device list +NONSHARABLE_CLASS( TBTDevice ) + { +public: + /** Constructor, that initialized this as empty*/ + IMPORT_C TBTDevice(); + /** Copy constructor */ + IMPORT_C TBTDevice(const TBTDevice& aDevice); + /** Copy */ + IMPORT_C TBTDevice& operator=(const TBTDevice& aDevice); + + TBTDeviceType iType; // left side icon + TBTDeviceClass iDeviceClass; // this is needed by connect + TBTDeviceName iName; // a formated friendly/device name in corresponding CBTDevice + TBTDeviceName iFriendlyName; // still need to remember if friendly name has been set + TUint iStatus; // mask of TDeviceStatus + TBTDeviceOp iOperation; // last operation on the device + TBTDevAddr iAddr; // bt device address + TInt iIndex; // new position of the device in the device list. + // Default value means iAddr should be used instead. + TBTLinkKeyType iLinkKeyType; + TNameEntry iNameEntry; // the device's EIR data + }; +/** Static methods for TBTDeviceComparison. These are meant to be given to TBTDeviceSortOrder and +* to be used for defining sort orders. +*/ +class TBTDeviceComparison + { +public: + /** + * Compare function for alphabetic sorting order. + * @param aFirstDevice to be compared + * @param aSecondDevice sencond device to be compared + * @return 1 if aFirstDevice is before aSecondDevice -1 otherwise. May not return 0, + * on devices that are not the same. + */ + + IMPORT_C static TInt CompareAphabetically( + const TBTDevice& aFirstDevice, const TBTDevice& aSecondDevice) ; + + /** + * Compare function for reverse alphabetic sorting order. + * @param aFirstDevice to be compared + * @param aSecondDevice sencond device to be compared + * @return 1 if aFirstDevice is before aSecondDevice -1 otherwise. May not return 0, + * on devices that are not the same. + */ + IMPORT_C static TInt ReverseCompareAphabetically( + const TBTDevice& aFirstDevice, const TBTDevice& aSecondDevice) ; + }; + +typedef RPointerArray RDeviceArray; +typedef RPointerArray RBTDevNameArray; +typedef TLinearOrder TBTDeviceSortOrder ; + +class CBTDevModelBase; + +/** +* Callback interface for informing about the changes in the devices shown by the listening view. +* Also a callback interface that informs the listener when the issued commands have been completed. +*/ +class MBTDeviceObserver + { +public: + /** + * Informs the observer that ChangeDevice command has been completed. + * + * The listener must not change the displaid devices, since RefreshDeviceList is used for that purpose. + * Also this will not be called, if changes happen from outside such as pairing initiated by 3rd party + * of blocking from notifier. + * + * @param aErr Symbian error code, KErrNone if no error. + * @param aDevice the device which is changed. This has allways given to the listener by RefreshDeviceList + * prior this call, if that device is visible at the listening view. This not passed by refrence, + * since this device could change, if registry is changed + * @param aDevNameArray hold conflicting devices' short names if "AlreadyExist" error happened during "connect" + * @return None. + */ + virtual void NotifyChangeDeviceComplete(const TInt aErr, const TBTDevice& aDevice, + const RBTDevNameArray* aDevNameArray = NULL) = 0; + + /** + * This is used to notify the listening graphic component that the deviceList is changed. + * After receiving this call the graphic component has to redraw its screen to match this list. + * @param aDevices The devices to be displaid. + * @param aSelectedItemIndex The index of the item to be selected in the given devices. + */ + virtual void RefreshDeviceList(const RDeviceArray* aDevices,TInt aSelectedItemIndex) =0; + + /** + * This is used before calling RefreshDeviceList to save the currently selected index, + * so that the same device could be selected after the refresh, if that device still exists. + * @param None. + * @return the selected device. KErrNotFound if the view has no devices. + */ + virtual TInt CurrentItemIndex() =0; + }; + +/** +* This is a abstract class providing basic common fucntions for derived classes. +* It act as a facade between UI applications and Bluetooth Engine Device Management API. +*/ +NONSHARABLE_CLASS( CBTDevModel ) : public CBase + { +public: // Constructors and destructor + /** + * Constructs devmodel. + * @param aGroup. do you wish to list other or blocked devices. + * @param MBTDeviceObserver The object that will receive the notifications for command completes, + * @param the order the devices are sorted in the list. If you do not give this the devices + * will be sorted in ascending alphabetic order. Devices with same name are sorted according to + * bluetooth addreses. DevModel will take the ownership of this object. + */ + IMPORT_C static CBTDevModel* NewL(const TBTDeviceGroup aGroup, + MBTDeviceObserver* aObserver=NULL, + TBTDeviceSortOrder* aOrder=NULL); + /** Destructor */ + virtual ~CBTDevModel(); + +public: // New functions + + /** + * Get device based on addr or index. + * @param aDevice the TBTDevice holder. The device address is passed in + * @return KErrNone if ok. + * KErrArgument, if neither index not address is filled. + * KErrOverFlow if index is out of range. + * KErrNotFound if the given address does not exists, in the internal array. + */ + IMPORT_C TInt GetDevice(TBTDevice& aDevice); + + /** + * Checks if any of the devices shown in view have active bluetooth connection. + * @return ETrue, if one or more devices are connected. EFalse if no devices are connected. + * This also return EFalse, in case of blocked devices. + */ + IMPORT_C TBool IsAnyDeviceConnected(); + + /** + * Creates and allocates TBTDevice representation of this device. + * The caller is responsibe for the garbage connection of the created device. + * @param aRegDevice the device to be converted + * @return the TBTDevice representation of the same device + */ + IMPORT_C TBTDevice* CreateDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry); + + /** + * Change status of all devices on the list, e.g. used by unpair all and unblock all commands. + * @param aOperation unpair/unblock + * @return None. + */ + IMPORT_C void ChangeAllDevices(const TBTDeviceOp aOperation); + + /** + * Change device status, add device, e.g. pair/block, or delete device,e.g. unpair/unblcok + * You must not pair device without properly filling deviceName. + * @param aDevice the TBTDevice holder. The device address is passed in + * @return None + */ + IMPORT_C void ChangeDevice(const TBTDevice& aDevice); + + /** + * Change device status, add device, e.g. pair/block, or delete device,e.g. unpair/unblcok + * @param aDevice the CBTDevice holder. + * @return None. + */ + IMPORT_C void ChangeDevice(const CBTDevice* aDevice, + TNameEntry* aNameEntry, + TBTDeviceOp aOp) ; + + /** + * Cancel ongoing operation, such as connecting or pairing. + * At the moment btui does not support other Other operations than pairing and connecting cannot be canceled. + * + * @param aDevice the device, whose command is to be canceled. + * @return None. + */ + IMPORT_C void CancelChange(const TBTDevice& aDevice); + + /** + *Checks if there are ChangeDeviceCommands that are not finnished. + */ + IMPORT_C TBool DeviceChangeInProgress(); + + +private: + /** constructor */ + CBTDevModel(); + + /** Symbian 2nd phase constuctor that may leave. + * @param aGroup EGroupPaired and EGroupBlocked are supported. + * @param aObserver the observer of the device list. This is not mandatory + * @param aOrder The order the devices are sorted + */ + void ConstructL(const TBTDeviceGroup aGroup, + MBTDeviceObserver* aObserver, + TBTDeviceSortOrder* aOrder ); +private: + + CBTDevModelBase* iDevModel; // CBTDevModelPaired or CBTDevModel Blocked + TBTDeviceGroup iGroup; + }; + + +/** Adds flags to iStatus of TBTDevice. + *@param aStatus the status of the device + *@param aFlags the flags to be set + */ +inline TUint SetStatusFlags(TUint& aStatus,TBTDeviceStatus aFlags) + { + aStatus |=aFlags; + return aStatus; + } +/** Clear status flags to iStatus of TBTDevice. + *@param aStatus the status of the device + *@param aFlags the flags to be set + */ +inline TUint UnsetStatusFlags(TUint& aStatus,TBTDeviceStatus aFlags) + { + aStatus &= ~aFlags; + return aStatus; + } + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/inc/btdevmodelbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/inc/btdevmodelbase.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2006-2007 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: Abstract base class for concete models. +* +*/ + + +#ifndef BTDEVMODELBASE_H +#define BTDEVMODELBASE_H + +#include // for MBTEngDevManObserver + +#include "btdevmodel.h" +#include "btregistryobserver.h" // for MBTRegistryObserver + +/** +* This is a abstract class providing basic common fucntions for derived classes. +* It act as a mediator between UI applications and Bluetooth Engine Device Management API. +* +*@lib btdevmodel.dll +*@since S60 V3.2 +*/ +NONSHARABLE_CLASS( CBTDevModelBase ): public CBase, public MBTEngDevManObserver, public MBTRegistryObserver + { +public: // Constructors and destructor + /** destructor + *@param none. + *@return none. + */ + virtual ~CBTDevModelBase(); +public: + + /** Checks if any of the devices shown in view have active bluetooth connection. + * This baseclass does not support connections, so the answer is allways EFalse. + * + * NOTE: TBTUIViewsCommonUtils::IsAnyDeviceConnectedL will report also those devices + * that are not part of particular view, such as paired devices. + * CBTPairedModel::IsAnyDeviceConnected reports only connection from paired devices. + * + *@return ETrue, if one or more devices are connected. EFalse if no devices are connected. + */ + TBool virtual IsAnyDeviceConnected(); + /** + * Get device based on addr or index. + * @param aDevice the TBTDevice holder. You have to set either the deviceAddress or the + * or the device index. If you specify both the device address and the index then the address is used, + * this includes those cases when there is no device corresponding the address. + * @return KErrNone if ok. + * KErrArgument, if neither index not address is filled. + * KErrOverFlow if index is out of range. which means it is negative or the internal array does not have that + * many items. + * KErrNotFound if the given address does not exists, in the internal array. + */ + TInt virtual GetDevice(TBTDevice& aDevice); + + /** + * Change status of all devices on the list. This is used by Delete All operations in paired devices view + * (EOpPair) and Blocked devices view(EOpUnblock) + * + * This creates multiple operations in the intergal queue that are all executed on by one. + * + * @param aOperation unpair/unblock + * @return None. + */ + void ChangeAllDevices(const TBTDeviceOp aOperation); + + /** + * Change device status, add device, e.g. block, unpair,unblock etc. + * + * The operation is put to queue and executed when the prior operations + * of the queue are finnished. Immeadiately if the queue is empty. + * + * @param aDevice. The device and the type of the change. If the address is empty, then the + * device index means what device is to be used. + * @return none + */ + virtual void ChangeDeviceL(const TBTDevice& aDevice); + + /** + * Change device status, add device, e.g. block, unpair,unblock etc. + * This will check for leaves and make a callback, if leave occurs. + * + * The operation is put to queue and executed when the prior operations + * of the queue are finnished. Immeadiately if the queue is empty. + * + * @param aDevice. The device and the type of the change. If the address is empty, then the + * device index means what device is to be used. + * @return none + */ + + virtual void ChangeDevice(const TBTDevice& aDevice); + + /** + * Cancel connecting, pairing, modifying device in BTRegistry + * + * Cancels ongoing operation or operation from queue, if it has not been started yet. + * Cancels it, if it is being executed. Used by Canceling Connecting and pairing operations. + * + * @param aDevice. The device and the type of the change that will be canceled. + * If the address is empty, then the + * device index means what device is to be used. + * @return None. + */ + virtual void CancelChange(const TBTDevice& aDevice); + + /** Creates and allocates TBTDevice representation of this device + *@param aRegDevice the device to be converted, + *@param aNameEntry contains the EIR data of the device if its data is valid + *@return the TBTDevice representation of the same device. (Note the caller is responsible for deleting + * the returned item.) + */ + virtual TBTDevice* CreateDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry); + + /** Checks if there are any ChangeDeviceCommands that are not finnished. + *@return ETrue if the are one or more commands being executed or are in the execution queue. + */ + virtual TBool DeviceChangeInProgress(); + + /** This is used to make callback to iObserver, when a leave has been detected. + *It will also clean up the partial operation. + * + *@param aErr the leave error code + *@param aDevice The device and operation that cause the leave. + * If this is inserted in the queue, it is deleted from there. + * If the leave occurred before inserting it to execution queue + * (not common), then it will not deleted from there. + *@return none. + */ + virtual void HandleLeave(TInt aErr,const TBTDevice* aDevice ); + +protected: + /** + * Change device status, add device, e.g. block, unpair,unblock etc. + * + * This is the operation that is used to to execute the operation queued by ChangeDevice. + * + * @param aDevice. The device and the type of the change. If the address is empty, then the + * device index means what device is to be used. + * @return KerrNone or system wide error code. + */ + virtual TInt DoChangeDeviceL(const TBTDevice& aDevice); + + /** + * Cancel ongoing connecting, pairing, modifying device in BTRegistry + * + * This is the operation that is used to cancel ongoing operation. + * + * @param aDevice. The device and the type of the change that will be canceled. + * If the address is empty, then the + * device index means what device is to be used. + * @return None. + */ + virtual void DoCancelChangeL(const TBTDevice& aDevice); + + /** This function recounts the indexes of iDeviceArray. + *@return none. + */ + void RenumberDeviceArray(); + + /** Constructor + * @param aObserver The observer will receive information about command completes and + * changes in the devices. + * @param aOrder The order the devices are sorted. Default order is added by CBTDevMan, so + * this class can assume this parameter to be used. This class is responsible for deleting this parameter on + * its destructor. + */ + CBTDevModelBase(MBTDeviceObserver* aObserver, + TBTDeviceSortOrder* aOrder ); + + /** Get the index for a device specified by bluetooth device address. + * + *@param aAddr the address of the searched device or KNullAddres. + *@param aIndexIfNullAddress, if this parameter is defined this function + *returns this index instead of KErrNotFound, it the device has nullAddress. + *@return index of the address. If the given address is KNullAddress then returns aIndexIfNullAddress or KErrNotFound if one is not specified by called. + *This will allways return KErrNone if the given address is not a KNullAddress and is not found. + */ + TInt GetIndexByAddress(const TBTDevAddr aAddr,TInt aIndexIfNullAddress=KErrNotFound); + + /** Adds the TBTDevice representation of this device to iDeviceArray, if + * this device is of that type (paired/blocked) that this model supports. + * If the device is not that type, it will not be added. + * + * NOTE: This function is not guaranteed againt duplicates, so multiple + * additions of the same device will lead to multiple copies of it. + * + * Subclasses can also implement their version of this function to add information + * to the device objects, such as connection information. + * + * @param aRegDevice the device to be added (if not filtered). + * @param aNameEntry contains the EIR data of the device if its data is valid + * @aOperation the operation that this device will contain when added. + */ + void AddDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry, + const TBTDeviceOp aOperation=EOpNone); + + /** Replaces iDeviceArray contents with the given devices + *@param aDeviceArray the devices that will be added to internal structures. + */ + virtual void CreateDevicesL(const CBTDeviceArray* aDeviceArray); + + /** Adds the given device to internal structures of this class + * using AddDeviceL, if the device is such that it should not be listed by this + * class, then it is not added. + * + * Implementing is used to filter out devices that are not handled by particular view. + * + * @param aNameEntry contains the EIR data of the device if its data is valid + */ + virtual void HandleNewDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry) = 0; + + /** Sends refresh of list of shown devices to listener. + * + * @param aErr If this is not KErrNone, then this function + * will send refresh to the listener. Allways send, if not specified. + * If this funtion is not KEerrNone, then the funtion does nothing. + * @param aSelectedItem. If this is specified, then select this item. + * if not specified uses the same item that the listener used to have active. + */ + virtual void SendRefreshIfNoError(TInt aErr=KErrNone,TInt aSelectedItem = KErrNotSupported ); + +protected: + + /** This callback is used to to notify this call from completed changed from iDevMan. + * Inherited from MBTEngDevManObserver. + * + * This funtion will trap any leave if they may occur and report them as errors in the + * corresponfing device change operarion. + */ + void HandleDevManComplete(TInt aErr); + + /** Inherited from BTEng's MBTEngDevManObserver, and implemented as empty, + * because we do ask devicelists directly from iDevman, but trough iRegistryObserver->Refresh() + */ + void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray); + + /** This callback is used by iRegistryObserver to notify device changes, that + * originate both from changes of the BTRegistry as well as refreshes requested + * by this class. + * @aDeviceArray the devices that the registry observer gets. + */ + void RegistryChangedL(const CBTDeviceArray* aDeviceArray); + + /** Check if there is allready one or more devices with this name. + *@return ETrue if there is. + */ + TBool IsNameExisting(const TDesC& aName); + + /** Executes the next one in the queue, if any. + * Leaves are trapped by this class and send as failed commands to iObserver + * using HandleLeave. + *@param none. + *@return none. + */ + void HandleQueue(); + +protected: // Data + MBTDeviceObserver* iObserver; // the listener of the completed commands and registry changes. + CBTEngDevMan* iDevMan; // This is used to change the devices. + TBTDeviceSortOrder* iSortOrder; // The order the devices are sorted to. + RDeviceArray iDeviceArray; // The list of current devices. + CBTRegistryObserver* iRegistryObserver; // This takes care of sending the devicelist to us each time + // something may have been changes. + TBTRegistrySearch iSearchPattern; // the pattern iRegistrySearch uses in retrieving devicelist. + // NOTE: HandleDeviceL is used to filter the results. + TBool iIsChangeAll; + TBTDevice* iDevice; // the currently changed device, if any + RDeviceArray iQueue; // The queue of commands to be executed + }; + +#endif // BT_DEV_MODEL_BASE_H + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/inc/btpairedmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/inc/btpairedmodel.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,282 @@ +/* +* Copyright (c) 2006-2007 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: The model that is used to list and handle all paired devices. +* +*/ + + +#ifndef BTPAIREDMODEL_H +#define BTPAIREDMODEL_H + +#include "btdevmodelbase.h" +#include +#include // for TBTDevAddr +#include //for TBTPowerStateValue +#include +#include + +enum TPairedModelState + { + EIdleState=0, + EDeleteDeviceState, + EAddDeviceState, + EPairDeviceState, + EDisconnectBeforeOperationState, + }; +class CBTEngSettings; + +/** +* This is a adds pairing and connecting functionality to BTDevModelBase. +* +* It act as a mediator between UI applications and Bluetooth Engine Device Management API. +* +*@lib btdevmodel.dll +*@since S60 V3.2 +*/ +NONSHARABLE_CLASS(CBTPairedModel) : + public CBTDevModelBase, public MBTEngConnObserver, + public MBluetoothPhysicalLinksNotifier, + public MBTEngSettingsObserver + { + +public: // Constructors and destructor + + /** + * C++ default constructor. + */ + CBTPairedModel(MBTDeviceObserver* aObserver, + TBTDeviceSortOrder* aOrder ); + + /** Symbian 2nd phase constuctor that may leave. + *@param None. + *@return None. + */ + void ConstructL(); + + /** + * NewL function + * @param aObserver The observer will receive information about command completes and + * changes in the devices. + * @param aOrder The order the devices are sorted. Default order is added by CBTDevMan, so + * this class can assume this parameter to be used. This class is responsible for deleting this parameter on + * its destructor. + */ + static CBTPairedModel* NewL(MBTDeviceObserver* aObserver, + TBTDeviceSortOrder* aOrder ); + + /** + * Destructor + * @param None. + */ + virtual ~CBTPairedModel(); + + /** + * Checks if any of the devices shown in paired devices view have active bluetooth connection. + * + * NOTE: TBTUIViewsCommonUtils::IsAnyDeviceConnectedL will also check + * those devices that are not paired. + * + *@return ETrue, if one or more devices are connected. EFalse if no devices are connected. + */ + TBool virtual IsAnyDeviceConnected(); + + /** + * Start new device pairing. This is handled by Queue, like + * all other device changes. + * + * This is used by CBTDevice::ChangeDevice(CBTDevice* ,EOpPair) + * + * @param aPairingDevice the device to be paired. + * @return KErrInUse, if another operation has be queued and not finnished. KErrNone otherwise. + */ + TInt PairDeviceL(const CBTDevice* aPairingDevice, + TNameEntry* aNameEntry); + +protected: + + /** + * Change device status, add device, e.g. block, unpair,unblock etc. + * + * This is the operation that is used to to execute the operation queued by ChangeDevice. + * + * This class will add connection releted operations to CBTDevModelBase::DoChangeDevice. + * + * @param aDevice. The device and the type of the change. If the address is empty, then the + * device index means what device is to be used. + * @return KerrNone or system wide error code. + */ + TInt DoChangeDeviceL(const TBTDevice& aDevice); + + /** + * Cancel ongoing connecting, pairing, modifying device in BTRegistry + * + * This is the operation that is used to cancel ongoing operation. + * + * @param aDevice. The device and the type of the change that will be canceled. + * If the address is empty, then the + * device index means what device is to be used. + * @return None. + */ + void DoCancelChangeL(const TBTDevice& aDevice); + + /** + * These two methods set the EStatusPhysicallyConnected attribute to + * the devices that have active connection. + */ + void FlagPhysicallyConnectedDevices(RDeviceArray &aDevices); + void FlagPhysicallyConnectedDevices(TBTDevice& aDevice, RBTDevAddrArray& aBTDeviceArray); + + +private: + + /** + * Start the actual pairing of iPairingDevice + * This is called by DoChangeDevice, if the operation is pairing. + *@param none. + *@return none. + */ + void DoPairDeviceL(); + + /** + * BTEngConnMan will call this when the connecting is finnished. + * This is called as callback not only for connections initiated by this class, + * but also for all BT Engines supported porofile connections, including those + * initiated by remote devices. + * @param aAddr The address of the device whose connection attempt has been finnished. + * @param aErr KErrNone if connection is succesfull, Otherwise system wide error code. + * @param aConflicts The conflicting devices in case of unsuccesfull connection attempt if any. + * @return none. + */ + void ConnectComplete(TBTDevAddr& aAddr, TInt aErr, RBTDevAddrArray* aConflicts = NULL); + + /** + * BTEngConnMan will call this when the disconnecting is finnished. + * This is called as callback not only for disconnections initiated by this class, + * but also for disconnection of BT Engines supported porofile connections, including those + * initiated by remote devices. + * @param aAddr The address of the device whose connection attempt has been finnished. + * @param aErr KErrNone if disconnection is succesfull, Otherwise system wide error code. + * @return none. + */ + void DisconnectComplete(TBTDevAddr& aAddr, TInt aErr); + + /** + * from BTEng's MBTEngConnObserver + */ + void PairingComplete(TBTDevAddr& aAddr, TInt aErr); + + /** + * The leaving version of PairingComplete. Internally called by PairingComplete + */ + void PairingCompleteL(TBTDevAddr& aAddr, TInt aErr); + + /** + * Creates and allocates TBTDevice representation of this device + * + * This class will add the connection status information to + * to CBTDevModelBase::CreateDevice. + * + * @param aRegDevice the device to be converted + * @return the TBTDevice representation of the same device. (Note the caller is responsible for deleting + * the returned item.) + */ + TBTDevice* CreateDeviceL(const CBTDevice* aRegDevice, TNameEntry* aNameEntry); + + /** + * Adds the given device to internal structures of this class + * using AddDeviceL, if it is paired and not blocked. + * + * @param aRegDevice + */ + void HandleNewDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry); + + /** + * This callback is used to to notify this call from completed changed from iDevMan. + * Inherited from MBTEngDevManObserver. + * + * This funtion will trap any leave if they may occur and report them as errors in the + * corresponfing device change operarion. + * + * @param aErr KErrNone or system wide error code. + */ + void HandleDevManComplete(TInt aErr); + +public: + + /** + * From MBTEngSettingsObserver - Called when powerstate is changed + * @param TBTPowerStateValue power state + * @return None + */ + void PowerStateChanged( TBTPowerStateValue aState ); + + /** + * From MBTEngSettingsObserver - Called when visibility is changed + * @param TBTPowerStateValue state of visibility mode + * @return None + */ + void VisibilityModeChanged( TBTVisibilityMode aState ); + + +public: //from MBluetoothPhysicalLinksNotifier + + /** + * Inherited from MBluetoothPhysicalLinksNotifier and implemented empty + */ + void HandleCreateConnectionCompleteL(TInt ) {}; + + /** + * Disconnect from non BTEng device by iLinks is complete. + *@param aErr KErrNone or system wide errorcode. + */ + void HandleDisconnectCompleteL(TInt aErr) ; + + /** Inherited from MBluetoothPhysicalLinksNotifier and not used. + */ + void HandleDisconnectAllCompleteL(TInt aErr) {HandleDisconnectCompleteL(aErr); } + + /** + * Get device based on addr or index. + * @param aDevice the TBTDevice holder. The device address is passed in + * @return KErrNone if ok. + * KErrArgument, if neither index not address is filled. + * KErrOverFlow if index is out of range. + * KErrNotFound if the given address does not exists, in the internal array. + */ + TInt virtual GetDevice(TBTDevice& aDevice); + + /** + * This is used to make callback to iObserver, when a leave has been detected. + * + *@param aErr the leave error code + *@param aDevice The device and operation that cause the leave. + */ + virtual void HandleLeave(TInt aErr,const TBTDevice* aDevice ); + +private: + + CBTEngConnMan* iConnMan; + CBTDevice* iPairingDevice; + + TBTDevice* iDisconnectDevice; + TPairedModelState iState; // The device is deleted and written back to bt registry before pairing + // this is used to control those operations + //used for disconnecting connections not managed by BTEngine + CBluetoothPhysicalLinks *iLinks; + RSocketServ iSocketServ; + CBTEngSettings *iBtEngSettings; // used for turning on BT, if not enabled + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/inc/btregistryobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/inc/btregistryobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2006-2007 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: Registry observer is listening to registry changes and +* and reporting the changed devices to the listener. +* +*/ + +#ifndef BTREGISTRYOBSERVER_H +#define BTREGISTRYOBSERVER_H + +#include +#include +#include +#include + +/** This class will inform the listener about the new BTregistry status +*after registry change events. +* +* This class will listen to events about registry changes and inform +* the listener about the latest registry status. The listener can +* also ask the status using refresh. This is usefull for for +* for example retrieval of initial lists of devices. +* +*@lib btdevmodel.dll +*@since S60 V3.2 +*/ +NONSHARABLE_CLASS(MBTRegistryObserver) + { +public: + /** The aDeviceArray constents are deleted after this + * call returns. If storage is wanted the array and its contents + * must be copied by implementor. + */ + virtual void RegistryChangedL(const CBTDeviceArray* aDeviceArray) = 0; + }; + +NONSHARABLE_CLASS(CBTRegistryObserver) : public CActive, public MBTEngDevManObserver + { +public: + /** NewL + *@param aObserver The class that is listening to registry changes + *@param aPattern The pattern to be used to retrieve the changed objects. + */ + static CBTRegistryObserver* NewL(MBTRegistryObserver* aObserver, + const TBTRegistrySearch aPattern); + + /** Destructor*/ + virtual ~CBTRegistryObserver(); + + /** Start listening to registry changes. + * + *Calling this while registry observer is running is silently ignored. + */ + void StartIfNotRunning(); + + /* Registry observer will retrieve list of devices in the backround + * and send it to the listener, when one is retrieved. + */ + void Refresh(); + + /** Check if this is running. + *@return ETrue if not listening to registry changes. + */ + inline TBool IsStopped() {return iIsStopped;} + + /** This will stop listening and cancel any retrieval of devicelists, + * if any. + * @param none. + * @return none. + */ + void Cancel(); +private: + /* Constructor that may not leave. + *@param aObserver The class that is listening to registry changes + *@param aPattern The pattern to be used to retrieve the changed objects. + */ + CBTRegistryObserver(MBTRegistryObserver* aObserver, const TBTRegistrySearch aPattern); + /** 2nd phase constructor. Called by NewL only. + * @param none. + * @return none. + */ + void ConstructL(); + + /** This is called when registry changes occur, but not when deviceLists are + * retrieved, since HandleGetDevicesComplete is called then. + * + * If one or more registry events occur during devicelist retrieval, there + * will be one new devicelist retrieval after the current retrieval is done. + * + * @param none. + * @return none. + */ + void RunL(); + + /** This will clear iRegDeviceArray and delete its contents. + * @param none. + * @return none. + */ + void DeleteAllocatedDevices(); + + + /** This will cancel listening. To be called by Cancel only. + * @param none. + * @return none. + */ + void DoCancel(); + + /** This is called when devicelist have been read from BtDevMan + * @param aErr KErrNone or the accurred error. + * @param aDeviceArray the devices that have been retrieved. + * @return none. + */ + void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray); + +private: + MBTRegistryObserver* iObserver; // the class listening to this class + CBTDeviceArray* iRegDeviceArray; // this is used for retrieving devices + TBTRegistrySearch iSearchPattern; // the search used to retrieve devices + // NOTE: this class does not filter the results, + // but the one listening to this (if filtering is done). + RProperty iProperty; + CBTEngDevMan* iDevMan; // the object that is used to retrieve the device lists. + TBool iIsStopped; // is this runining. + TBool iAnotherEventPending; // Has there been one or more changes during this retrieval. + // if this is true then HandleGetDevices will start a new search. + }; + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/src/btblockedmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/src/btblockedmodel.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2006-2007 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: Maintain a Bluetooth devices data model for Blocked devices view. +* +*/ + + +// INCLUDE FILES +#include "btblockedmodel.h" +#include "debug.h" + +// --------------------------------------------------------------------- +// constructor +// ---------------------------------------------------------------------- +CBTBlockedModel::CBTBlockedModel(MBTDeviceObserver* aObserver,TBTDeviceSortOrder* aOrder ) + : CBTDevModelBase(aObserver, aOrder) + { + TRACE_FUNC + } +// --------------------------------------------------------------------- +// CBTBlockedModel::NewL +// ---------------------------------------------------------------------- +CBTBlockedModel* CBTBlockedModel::NewL(MBTDeviceObserver* aObserver, TBTDeviceSortOrder* aOrder ) + { + CBTBlockedModel* self = new (ELeave) CBTBlockedModel(aObserver, aOrder); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } +// --------------------------------------------------------------------- +// destructor +// ---------------------------------------------------------------------- +CBTBlockedModel::~CBTBlockedModel() + { + TRACE_FUNC + } +// --------------------------------------------------------------------- +// CBTBlockedModel::ConstructL +// ---------------------------------------------------------------------- +void CBTBlockedModel::ConstructL() + { + TRACE_FUNC_ENTRY + // get all devices from btregistry to iDeviceArray - a TBTDevice array + iDevMan = CBTEngDevMan::NewL(this); + iSearchPattern.FindAll(); + iRegistryObserver = CBTRegistryObserver::NewL(this, iSearchPattern); + iRegistryObserver->Refresh(); + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTBlockedModel::HandleNewDeviceL +// from CBTDevModel +// ---------------------------------------------------------------------- +void CBTBlockedModel::HandleNewDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry) + { + TRACE_FUNC_ENTRY + TBTDeviceSecurity security = aRegDevice->GlobalSecurity(); + if (security.Banned()) + { + AddDeviceL(aRegDevice, aNameEntry, EOpBlock); + } + TRACE_FUNC_EXIT + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/src/btdevice.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/src/btdevice.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2006-2007 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: This is used by BTUI to contain the information on a displaid device. +* +*/ + +#include "btdevmodel.h" +// --------------------------------------------------------------------- +// Default Constructor +// --------------------------------------------------------------------- +EXPORT_C TBTDevice::TBTDevice() + { + iType = EDeviceDefault; + iName = KNullDesC; + iFriendlyName = KNullDesC; + iStatus = 0; + iOperation = EOpNone; + iAddr = KNullAddress; + iIndex = KErrNotFound; + iDeviceClass=TBTDeviceClass(0); + iLinkKeyType = ELinkKeyCombination; + iNameEntry() = TNameRecord(); + } +// --------------------------------------------------------------------- +// Copy Constructor +// --------------------------------------------------------------------- +EXPORT_C TBTDevice::TBTDevice(const TBTDevice& aDevice) + { + iType = aDevice.iType; + iName = aDevice.iName; + iFriendlyName = aDevice.iFriendlyName; + iStatus = aDevice.iStatus; + iOperation = aDevice.iOperation; + iAddr = aDevice.iAddr; + iIndex = aDevice.iIndex; + iDeviceClass= aDevice.iDeviceClass; + iLinkKeyType = aDevice.iLinkKeyType; + iNameEntry() = TNameRecord(); + } +// --------------------------------------------------------------------- +// operator= +// --------------------------------------------------------------------- +EXPORT_C TBTDevice& TBTDevice::operator=(const TBTDevice& aDevice) + { + iType = aDevice.iType; + iName = aDevice.iName; + iFriendlyName = aDevice.iFriendlyName; + iStatus = aDevice.iStatus; + iOperation = aDevice.iOperation; + iAddr = aDevice.iAddr; + iIndex = aDevice.iIndex; + iDeviceClass= aDevice.iDeviceClass; + iLinkKeyType = aDevice.iLinkKeyType; + iNameEntry = aDevice.iNameEntry; + return *this; + } +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/src/btdevmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/src/btdevmodel.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,230 @@ +/* +* Copyright (c) 2007 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: Maintain a Bluetooth devices data model for UI components. +* +*/ + +// INCLUDE FILES +#include +#include "btdevmodel.h" +#include "btpairedmodel.h" +#include "btblockedmodel.h" +#include "debug.h" + +// -------------------------------------------------------------------------------------------- +// CBTDevModel::CBTDevModel +// -------------------------------------------------------------------------------------------- +CBTDevModel::CBTDevModel() + { + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::NewL +// -------------------------------------------------------------------------------------------- +EXPORT_C CBTDevModel* CBTDevModel::NewL(const TBTDeviceGroup aGroup, + MBTDeviceObserver* aObserver, + TBTDeviceSortOrder* aOrder + ) + { + CBTDevModel* self = new (ELeave) CBTDevModel(); + CleanupStack::PushL(self); + + TBTDeviceSortOrder *order=NULL; + if(aOrder == NULL) + { + order=new(ELeave) TBTDeviceSortOrder(TBTDeviceComparison::CompareAphabetically); + // Order ownership goes to btdevmodel - don't push it to stack + self->ConstructL(aGroup, aObserver, order); + } + else + { + order=aOrder; + self->ConstructL(aGroup, aObserver, order); + } + CleanupStack::Pop(self); + return self; + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::~CBTDevModel +// +// Destructor +// -------------------------------------------------------------------------------------------- + +CBTDevModel::~CBTDevModel() + { + TRACE_FUNC_ENTRY + delete iDevModel; + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::ConstructL +// +// Constructs CBTPairedModel or CBTBlockedModel, depending on aGroup +// -------------------------------------------------------------------------------------------- +void CBTDevModel::ConstructL(const TBTDeviceGroup aGroup, + MBTDeviceObserver* aObserver, + TBTDeviceSortOrder* aOrder ) + { + TRACE_FUNC_ENTRY + iGroup=aGroup; + switch (aGroup) + { + case EGroupPaired: + iDevModel = CBTPairedModel::NewL(aObserver, aOrder); + break; + + case EGroupBlocked: + iDevModel = CBTBlockedModel::NewL(aObserver, aOrder); + break; + default: + break; + } + TRACE_FUNC_EXIT + } + +EXPORT_C TBool CBTDevModel::IsAnyDeviceConnected() + { + return iDevModel->IsAnyDeviceConnected(); + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::GetDevice +// wrapper function +// -------------------------------------------------------------------------------------------- +EXPORT_C TInt CBTDevModel::GetDevice(TBTDevice& aDevice) + { + return iDevModel->GetDevice(aDevice); + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::CreateDevice +// wrapper function +// -------------------------------------------------------------------------------------------- +EXPORT_C TBTDevice* CBTDevModel::CreateDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry) + { + return iDevModel->CreateDeviceL(aRegDevice, aNameEntry); + } + +// -------------------------------------------------------------------------------------------- +// CBTDevModel::GetDeviceType +// wrapper function +// -------------------------------------------------------------------------------------------- +EXPORT_C void CBTDevModel::ChangeAllDevices(const TBTDeviceOp aOperation) + { + iDevModel->ChangeAllDevices(aOperation); + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::ChangeDevice +// wrapper function +// -------------------------------------------------------------------------------------------- +EXPORT_C void CBTDevModel::ChangeDevice(const TBTDevice& aDevice) + { + iDevModel->ChangeDevice(aDevice); + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::ChangeDevice +// -------------------------------------------------------------------------------------------- +EXPORT_C void CBTDevModel::ChangeDevice(const CBTDevice* aDevice, + TNameEntry* aNameEntry, TBTDeviceOp aOp) + { + TRACE_FUNC_ENTRY + TBTDevice *tmp=NULL; + TInt err = KErrNone; + if(aOp == EOpPair) + { + if(iGroup !=EGroupPaired ) + { + err = KErrNotSupported; + } + else + { + TInt err2 = KErrNone; + TRAP(err, err2 = static_cast(iDevModel)->PairDeviceL( aDevice, aNameEntry)); + err = (err2 != KErrNone) ? err2 : err; + } + } + else + { + TRAP(err, tmp=iDevModel->CreateDeviceL(aDevice, aNameEntry )); + if(err == KErrNone) + { + tmp->iOperation=aOp; + iDevModel->ChangeDevice(*tmp ); + } + } + if(err != KErrNone) + { + iDevModel->HandleLeave(err,tmp); + } + TRACE_FUNC_EXIT + } +// -------------------------------------------------------------------------------------------- +// CBTDevModel::CancelChange +// wrapper function +// -------------------------------------------------------------------------------------------- +EXPORT_C void CBTDevModel::CancelChange(const TBTDevice& aDevice) + { + iDevModel->CancelChange(aDevice); + } + +// -------------------------------------------------------------------------------------------- +// CBTDevModel::DeviceChangeInProgress +// wrapper function +// -------------------------------------------------------------------------------------------- +EXPORT_C TBool CBTDevModel::DeviceChangeInProgress() + { + return iDevModel->DeviceChangeInProgress(); + } +// -------------------------------------------------------------------------------------------- +// TBTDeviceComparison::CompareAphabetically +// -------------------------------------------------------------------------------------------- +EXPORT_C TInt TBTDeviceComparison::CompareAphabetically( + const TBTDevice& aFirstDevice, const TBTDevice& aSecondDevice) + { + // This funtion is used when sorting devicelists, so the tracing has been omnitted + // in order decreas the amount of trash in the logs. + TInt rvalue= aFirstDevice.iName.CompareC(aSecondDevice.iName); + if(rvalue !=0) + { + return rvalue; + } + if( aFirstDevice.iAddr <= aSecondDevice.iAddr ) + { + return -1; + } + else + { + return 1; + } + } + +// -------------------------------------------------------------------------------------------- +// TBTDeviceComparison::ReverseCompareAphabetically +// -------------------------------------------------------------------------------------------- +EXPORT_C TInt TBTDeviceComparison::ReverseCompareAphabetically( + const TBTDevice& aFirstDevice, const TBTDevice& aSecondDevice) + { + // This funtion is used when sorting devicelists, so the tracing has been omnitted + // in order decreas the amount of trash in the logs. + TInt rvalue= aSecondDevice.iName.CompareC(aFirstDevice.iName); + if(rvalue !=0) + { + return rvalue; + } + if(aFirstDevice.iAddr <= aSecondDevice.iAddr ) + { + return 1; + } + else + { + return -1; + } + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/src/btdevmodelbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/src/btdevmodelbase.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,807 @@ +/* +* Copyright (c) 2006-2007 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: Maintain a Bluetooth devices data model for UI components. +* +*/ + +#include "btdevice.h" +#include "btdevmodelbase.h" +#include +#include "debug.h" +#include "btui.h" +#include "btregistryobserver.h" + +// -------------------------------------------------------------------------------------------- +// 1st phaze constructor +// -------------------------------------------------------------------------------------------- +CBTDevModelBase::CBTDevModelBase(MBTDeviceObserver* aObserver, TBTDeviceSortOrder* aOrder) + : iObserver(aObserver) + { + TRACE_FUNC_ENTRY + iSortOrder=aOrder; + TRACE_FUNC_EXIT + + } + +// -------------------------------------------------------------------------------------------- +// Destructor +// -------------------------------------------------------------------------------------------- +CBTDevModelBase::~CBTDevModelBase() + { + TRACE_FUNC_ENTRY + delete iRegistryObserver; + + for(TInt i=0;iCancel(); + delete iDevMan; + + delete iSortOrder; + TRACE_FUNC_EXIT + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::IsAnyDeviceConnected +// Allways false, since base class does not support connection +// -------------------------------------------------------------------------------------------- + +TBool CBTDevModelBase::IsAnyDeviceConnected() + { + TRACE_FUNC_ENTRY + return EFalse; + + } + +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::GetDevice +// -------------------------------------------------------------------------------------------- +TInt CBTDevModelBase::GetDevice(TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + TBTDeviceOp op=aDevice.iOperation; + + TInt index = GetIndexByAddress(aDevice.iAddr,aDevice.iIndex); + + if (index < 0 ) + { + if(aDevice.iAddr == KNullAddress ) + { + return KErrArgument; + } + else + { + return KErrNotFound ; + } + } + if(index >= iDeviceArray.Count()) + return KErrOverflow; + + aDevice=*iDeviceArray[index]; + aDevice.iOperation=op; + TRACE_FUNC_EXIT + return KErrNone; + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::ChangeAllDevices +// -------------------------------------------------------------------------------------------- +void CBTDevModelBase::ChangeAllDevices(const TBTDeviceOp aOperation) + { + TRACE_FUNC_ENTRY + TInt count = iDeviceArray.Count(); + + for (TInt i = 0; i < count; i++) + { + //TBTDevice device; + //device=iDeviceArray[i]; + //device.iIndex = i; + //device.iOperation = aOperation; + //ChangeDevice(device); + iDeviceArray[i]->iIndex = i; + iDeviceArray[i]->iOperation = aOperation; + ChangeDevice(*iDeviceArray[i]); + } + TRACE_FUNC_EXIT + } + +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::GetIndexByAddress +// +// returns the index of the address, if one is not null address. +// if it is give aNullAdressIndex +// -------------------------------------------------------------------------------------------- +TInt CBTDevModelBase::GetIndexByAddress(TBTDevAddr aAddr,TInt aNullAdressIndex) + { + TRACE_FUNC_ENTRY + + if(aAddr == KNullAddress ) + { + TRACE_FUNC_EXIT + return aNullAdressIndex; + } + else + { + TInt count = iDeviceArray.Count(); + TInt i; + for (i = 0; i < count; i++) + { + if (iDeviceArray[i]->iAddr == aAddr) break; + } + if(i == count) + { + TRACE_FUNC_EXIT + return KErrNotFound ; + } + + else + { + TRACE_FUNC_EXIT + return i; + } + } + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::DoChangeDevice +// -------------------------------------------------------------------------------------------- +TInt CBTDevModelBase::DoChangeDeviceL(const TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + //check that the command in progress has been started + __ASSERT_DEBUG(iDevice==NULL,PANIC(EBTPanicDevManQueueIsCorrupt)); + + TInt index = GetIndexByAddress(aDevice.iAddr, aDevice.iIndex ); + + if (index == KErrNotFound) + { + TRACE_INFO(_L("index not found")); + TRACE_FUNC_EXIT + if (aDevice.iAddr == KNullAddress) + { + return KErrArgument; + } + else + { + return KErrNotFound ; + } + } + if(index >= iDeviceArray.Count()) + { + TRACE_INFO((_L("index is %d, max expected is %d"), index, iDeviceArray.Count())); + TRACE_FUNC_EXIT + return KErrOverflow; + } + + + TBTDevice* device = iDeviceArray[index]; + // store pointer to the indexed TBTDevice + + // untrust trusted device to be deleted, and delete it only after that + if( (device->iStatus & EStatusTrusted ) + && aDevice.iOperation== EOpUnpair ) + { + device=new (ELeave) TBTDevice(*iDeviceArray[index]); + device->iOperation=EOPInternalUntust; + iQueue.Insert(device,0); + TInt rvalue=DoChangeDeviceL(*device); + TRACE_FUNC_EXIT + return rvalue; + } + + + iDevice = new (ELeave) TBTDevice(*device); + iDevice->iOperation = aDevice.iOperation; + + CBTDevice* regDevice = CBTDevice::NewL(iDevice->iAddr); + + regDevice->SetPaired( aDevice.iLinkKeyType ); + + TBTDeviceSecurity security; + + if(aDevice.iOperation != EOpChangeName) + { + regDevice->SetDeviceNameL( BTDeviceNameConverter::ToUTF8L( iDevice->iName ) ); + + // BTEngDevMan will delete friendly name when modify device if friendly name is not set + // So if friendly name has been set before, it need to be set again before modify it for + // any other purpuse e.g change security + regDevice->SetFriendlyNameL(iDevice->iFriendlyName); + } + + switch (aDevice.iOperation) + { + case EOpUntrust: + case EOPInternalUntust: + security.SetNoAuthenticate(EFalse); + security.SetNoAuthorise(EFalse); + regDevice->SetGlobalSecurity(security); + UnsetStatusFlags(iDeviceArray[index]->iStatus,EStatusTrusted ); + break; + + case EOpTrust: + security.SetNoAuthenticate(EFalse); + security.SetNoAuthorise(ETrue); + security.SetBanned(EFalse); + regDevice->SetGlobalSecurity(security); + + SetStatusFlags(iDeviceArray[index]->iStatus,EStatusTrusted ); + break; + + case EOpUnblock: + // unblock may be done to a number of devices. + // So we want it to happen as quicky as possible + iRegistryObserver->Cancel(); + UnsetStatusFlags( iDevice->iStatus,EStatusBlocked ); + security.SetBanned(EFalse ); + regDevice->DeleteLinkKey(); + + regDevice->SetGlobalSecurity(security); + break; + + case EOpBlock: + security.SetBanned(ETrue ); + security.SetNoAuthenticate(EFalse ); + security.SetNoAuthorise(EFalse); + regDevice->SetGlobalSecurity(security); + regDevice->DeleteLinkKey(); + + UnsetStatusFlags( iDevice->iStatus,EStatusTrusted ); + SetStatusFlags( iDevice->iStatus,EStatusBlocked ); + break; + + case EOpUnpair: + // unpair may be done to a number of devices. + // So we want it to happen as quicky as possible + iRegistryObserver->Cancel(); + regDevice->DeleteLinkKey(); + + UnsetStatusFlags(iDevice->iStatus,EStatusPaired); + security.SetNoAuthenticate(EFalse ); + security.SetNoAuthorise(EFalse ); + regDevice->SetGlobalSecurity(security); + break; + + case EOpChangeName: + if (IsNameExisting(aDevice.iName)) + { + delete regDevice; + regDevice=NULL; + return KErrAlreadyExists; + } + + regDevice->SetFriendlyNameL(aDevice.iName); + iDevice->iName = aDevice.iName; + + // set iFriendlyName to remember that friendly name has been set + iDevice->iFriendlyName = aDevice.iName; + break; + + default: + delete regDevice; + delete iDevice; + iDevice=NULL; + TRACE_FUNC_EXIT + return KErrNotSupported; + } + iDevMan->ModifyDevice(*regDevice); + delete regDevice; + + TRACE_FUNC_EXIT + return KErrNone; + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::DoChangeDevice +// -------------------------------------------------------------------------------------------- +void CBTDevModelBase::DoCancelChangeL(const TBTDevice& /*aDevice*/) + { + TRACE_FUNC_ENTRY + iDevMan->Cancel(); + TRACE_FUNC_EXIT + } + +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::CreateDevice +// -------------------------------------------------------------------------------------------- +TBTDevice* CBTDevModelBase::CreateDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry) + { + TRACE_FUNC_ENTRY + TRACE_BDADDR(aRegDevice->BDAddr()); + TRACE_INFO((_L("CoD %b"), aRegDevice->DeviceClass().DeviceClass())); + TBTDevice* device = new (ELeave) TBTDevice(); + if ( aNameEntry ) + { + device->iNameEntry = *aNameEntry; + } + switch( aRegDevice->DeviceClass().MajorDeviceClass() ) + { + case EMajorDeviceComputer: + device->iType=EDeviceComputer; + break; + case EMajorDevicePhone: + device->iType=EDevicePhone; + break; + case EMajorDeviceAudioDevice: + if ( aRegDevice->DeviceClass().MinorDeviceClass() == EMinorDeviceAVCarAudio || + aRegDevice->DeviceClass().MinorDeviceClass() == EMinorDeviceAVHandsfree) + { + device->iType=EDeviceCarkit; + } + else + { + device->iType=EDeviceAudio; + } + break; + + case EMajorDevicePeripheral: + if ( aRegDevice->DeviceClass().MinorDeviceClass() == EMinorDevicePeripheralKeyboard ) + { + device->iType=EDeviceKeyboard; + } + else + { + + if ( aRegDevice->DeviceClass().MinorDeviceClass() == EMinorDevicePeripheralPointer ) + { + device->iType=EDeviceMice; + } + else + { + device->iType=EDeviceDefault; + } + } + break; + + case EMajorDeviceImaging: + if ( aRegDevice->DeviceClass().MinorDeviceClass() == EMinorDeviceImagingPrinter ) + { + device->iType=EDevicePrinter; + } + else + { + device->iType=EDeviceDefault; + } + break; + + default: + device->iType=EDeviceDefault; + break; + } + device->iAddr = aRegDevice->BDAddr(); + + TBTDeviceSecurity security = aRegDevice->GlobalSecurity(); + + if(security.Banned() ) + { + SetStatusFlags(device->iStatus,EStatusBlocked); + } + if( IsUserAwarePaired( aRegDevice->AsNamelessDevice() ) ) + { + SetStatusFlags(device->iStatus,EStatusPaired); + device->iLinkKeyType = aRegDevice->LinkKeyType(); + } + if( security.NoAuthorise()) + SetStatusFlags(device->iStatus,EStatusTrusted); + if(aRegDevice->FriendlyName().Length() >0) + { + device->iName = aRegDevice->FriendlyName(); + + // set iFriendlyName to remember that friendly name has been set before in registry + device->iFriendlyName = aRegDevice->FriendlyName(); + } + else + { + CleanupStack::PushL(device); + device->iName = BTDeviceNameConverter::ToUnicodeL(aRegDevice->DeviceName()); + CleanupStack::Pop(device); + } + + + device->iDeviceClass=aRegDevice->DeviceClass(); + TRACE_FUNC_EXIT + return device; + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::AddDeviceL +// -------------------------------------------------------------------------------------------- +void CBTDevModelBase::AddDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry, const TBTDeviceOp aOperation) + { + TRACE_FUNC_ENTRY + TBTDevice* device = CreateDeviceL(aRegDevice, aNameEntry); + device->iOperation = aOperation; + // insert it to the RDeviceArray by order + iDeviceArray.InsertInOrderL(device,*iSortOrder); + TRACE_FUNC_EXIT + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::CreateDevices +// -------------------------------------------------------------------------------------------- +void CBTDevModelBase::CreateDevicesL(const CBTDeviceArray* aDeviceArray) + { + TRACE_FUNC_ENTRY + // clear the old contents of the array + for(TInt i=0;iCount(); + for (TInt i = 0; i < count; i++) + { + // form a TBTDevice for a CBTDevice + CBTDevice* regDevice = aDeviceArray->At(i); + HandleNewDeviceL(regDevice, NULL); + RenumberDeviceArray(); + } + TRACE_FUNC_EXIT + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::IsNameExisting +// -------------------------------------------------------------------------------------------- +TBool CBTDevModelBase::IsNameExisting(const TDesC& aName) + { + TRACE_FUNC_ENTRY + for (TInt i = 0; i < iDeviceArray.Count(); i++) + { + if (iDeviceArray[i]->iName.Compare(aName) == 0) + { + return ETrue; + } + } + TRACE_FUNC_EXIT + return EFalse; + } +// -------------------------------------------------------------------------------------------- +// CBTDevModelBase::RegistryChangedL +// -------------------------------------------------------------------------------------------- +void CBTDevModelBase::RegistryChangedL(const CBTDeviceArray* aDeviceArray) + { + TRACE_FUNC_ENTRY + + // Store the device seleted before refresh + TInt bSelectedDeviceIndex = KErrNotFound; + if (iObserver) + { + bSelectedDeviceIndex=iObserver->CurrentItemIndex(); + } + + // the selected device before the update + TBTDevice currentDevice; + + if (bSelectedDeviceIndex != KErrNotFound && bSelectedDeviceIndex < iDeviceArray.Count() ) + { + currentDevice=*iDeviceArray[bSelectedDeviceIndex]; + } + + CreateDevicesL(aDeviceArray); + + TInt newIndex=GetIndexByAddress(currentDevice.iAddr,KErrNotFound); + if (newIndex==KErrNotFound) + { + newIndex= bSelectedDeviceIndex; + } + + newIndex=Min(newIndex,iDeviceArray.Count() -1 ); + + // notify the listener about the new list of devices + SendRefreshIfNoError(KErrNone,newIndex); + TRACE_FUNC_EXIT + } +// ---------------------------------------------------------- +// CBTDevModelBase::RenumberDeviceArray +// +// ReCalculates the indexes of internal array. +// ---------------------------------------------------------- +void CBTDevModelBase::RenumberDeviceArray() + { + TRACE_FUNC_ENTRY + for(TInt i=0;iiIndex=i; + } + TRACE_FUNC_EXIT + } +//--------------------------------------------------------------------------------------------- +// from MBTEngDevManObserver for call back on adding, modifying, deleting device completion +//--------------------------------------------------------------------------------------------- +void CBTDevModelBase::HandleDevManComplete(TInt aErr) + { + TRACE_FUNC_ENTRY + //command has been succesfully completed. If there is no command but something has + // completed, something is very wrong. + __ASSERT_DEBUG(iDevice != NULL || aErr != KErrNone, PANIC(EBTPanicDevManQueueIsCorrupt)); + __ASSERT_DEBUG(iQueue.Count()>0, PANIC(EBTPanicDevManQueueIsCorrupt)); + + RenumberDeviceArray(); + + // EOPInternalUntust is untrst before delete. It is not an operation of its own, so no-one is notified about it. + if(iDevice && iDevice->iOperation== EOPInternalUntust) + { + delete(iDevice); + iDevice=NULL; + delete iQueue[0]; + iQueue.Remove(0); + + HandleQueue(); + TRACE_FUNC_EXIT + return; + } + // in case of just paired device the refresh does + // not work adequately quickly, so we have not refresh the + // shown devices immediately. + // + // If we would not do it, there might be a small window, for + // answering yes to to question if user wants to trust the + // device. This would fail, since the device would not + // be in the list. + if( aErr == KErrNone && (iDevice->iOperation== EOpTrust || iDevice->iOperation== EOpUntrust )) + { + TInt index=GetIndexByAddress(iDevice->iAddr); + if(index != KErrNotFound) + { + if(iDevice->iOperation== EOpTrust ) + { + SetStatusFlags(iDeviceArray[index]->iStatus, EStatusTrusted); + } + else + { + UnsetStatusFlags(iDeviceArray[index]->iStatus, EStatusTrusted); + } + + SendRefreshIfNoError(aErr); + } + + } + // delete the unpaired and blocked devices from the list + if( aErr == KErrNone && iDevice && + (iDevice->iOperation== EOpBlock || iDevice->iOperation== EOpUnpair ) ) + { + TInt index=GetIndexByAddress(iDevice->iAddr); + if(index != KErrNotFound ) + { + delete( iDeviceArray[index] ); + iDeviceArray.Remove(index); + } + // do not send refresh if this and the next are unpair/unblock operations. + // This is meant to hasten the screen refresh, in case of DeleteAll command + // is issued. + if( iQueue.Count()>1 && iQueue[1]->iOperation==iDevice->iOperation ) + { + + } + else + { + SendRefreshIfNoError(); + iRegistryObserver->StartIfNotRunning(); + //NOTE:It is ok to attempt starting when allready running. + } + + } + if(iObserver && iDevice) + iObserver->NotifyChangeDeviceComplete(aErr, *iDevice); + + delete(iDevice); + iDevice=NULL; + + iRegistryObserver->Refresh(); + + delete iQueue[0]; + iQueue.Remove(0); + + HandleQueue(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTDevModelBase::HandleGetDevicesComplete +// From MBTEngDevManObserver +// +// Devices are received from CBTRegistryObserver, so this is not used. +// ---------------------------------------------------------------------- +void CBTDevModelBase::HandleGetDevicesComplete(TInt /*aErr*/, CBTDeviceArray* /*aDeviceArray*/) + { + TRACE_FUNC_ENTRY + + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------- +// CBTDevModelBase::SendRefreshIfNoError +// --------------------------------------------------------------------- +void CBTDevModelBase::SendRefreshIfNoError(TInt aErr,TInt selectedItem) + { + TRACE_FUNC_ENTRY + + //this shouldn't be reached if iObserver is NULL + __ASSERT_DEBUG(iObserver, PANIC(EBTPanicNullObserver)); + + if (selectedItem == KErrNotSupported ) + { + iObserver->RefreshDeviceList( &iDeviceArray , + Min(iObserver->CurrentItemIndex(),iDeviceArray.Count()-1 ) ); + } + else + { + if (aErr == KErrNone && iObserver) + { + iObserver->RefreshDeviceList( &iDeviceArray, + Min(selectedItem,iDeviceArray.Count()-1 ) ); + } + } + + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTDevModelBase::ChangeDeviceL +// +// puts the change device command into Queue +// --------------------------------------------------------------------- +void CBTDevModelBase::ChangeDeviceL(const TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + + TBTDevice* device=new(ELeave) TBTDevice(aDevice); + CleanupStack::PushL(device); + + TInt err = GetDevice(*device); + if(err!=KErrNone) + { + CleanupStack::PopAndDestroy(device); + User::Leave(err); + } + + if(aDevice.iOperation==EOpChangeName) + { + device->iName=aDevice.iName; + } + + iQueue.Append(device); + CleanupStack::Pop(device); + if(iQueue.Count() ==1 ) + { + User::LeaveIfError( DoChangeDeviceL(*iQueue[0]) ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTDevModelBase::ChangeDevice +// +// Calls the ChangeDeviceL and traps leaves and calls error callback, +// if they occur. +// --------------------------------------------------------------------- +void CBTDevModelBase::ChangeDevice(const TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + TRAPD(err, + ChangeDeviceL(aDevice); + ); + if(err!=KErrNone) + { + HandleLeave(err,&aDevice); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTDevModelBase::CancelChange +// +// cancels the change from queue, only calls DoCancelChange, +// if the command is actually in progress. +// --------------------------------------------------------------------- +void CBTDevModelBase::CancelChange(const TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + // retrieve the device based on index, in + // case the address is not filled in. + TBTDevice device=aDevice; + GetDevice(device); + device.iOperation=aDevice.iOperation; + + // delete any operations to device from queueu + if(iQueue.Count()>0 ) + { + // Before calling DoCancelChangeL check if first operation on the + // queue is the one to be cancelled - otherwise crash may occure + // as per TSW EMZA-7EUHYE + if(iQueue[0]->iAddr== device.iAddr && + iQueue[0]->iOperation== device.iOperation ) + TRAP_IGNORE(DoCancelChangeL(device)); + + for (TInt i = iQueue.Count() - 1; i >= 0; i--) + { + if(iQueue[i]->iAddr== device.iAddr && + iQueue[i]->iOperation== device.iOperation ) + { + delete iQueue[i]; + iQueue.Remove(i); + } + } + } + // failed cancel is not reported forward. + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTDevModelBase::DeviceChangeInProgress +// --------------------------------------------------------------------- +TBool CBTDevModelBase::DeviceChangeInProgress() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + return iQueue.Count() !=0; + } + +// --------------------------------------------------------------------- +// CBTDevModelBase::HandleQueue +// +// Starts executing the next devicechange(if any). +// Currently Executed command must be deleted from iQueue and iDevice +// (and corresponding places in subclasses), before calling this method. +// --------------------------------------------------------------------- + +void CBTDevModelBase::HandleQueue() + { + TRACE_FUNC_ENTRY + + RenumberDeviceArray(); + if(iQueue.Count() >0 ) + { + TRAPD(err2, DoChangeDeviceL(*iQueue[0]); ); + if (err2 !=KErrNone) + { + HandleLeave(err2,iQueue[0]); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTDevModelBase::HandleLeave +// --------------------------------------------------------------------- +void CBTDevModelBase::HandleLeave(TInt aErr,const TBTDevice* aDevice ) + { + TRACE_FUNC_ENTRY + iRegistryObserver->StartIfNotRunning(); + iRegistryObserver->Refresh(); + if(aDevice == NULL ) + { + iObserver->NotifyChangeDeviceComplete(aErr,TBTDevice() ); + } + else + { + iObserver->NotifyChangeDeviceComplete(aErr, *aDevice ); + } + delete iDevice; + iDevice=NULL; + iDevMan->Cancel(); + + if(aDevice != NULL && iQueue.Count() > 0 && + (iQueue[0]->iAddr == aDevice->iAddr ) && + (iQueue[0]->iOperation == aDevice->iOperation ) ) + { + delete iQueue[0]; + iQueue.Remove(0); + } + + HandleQueue(); + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/src/btpairedmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/src/btpairedmodel.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,976 @@ +/* +* Copyright (c) 2006-2007 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: Maintain a Bluetooth devices data model for paired devices view +* +*/ + + +#include "btpairedmodel.h" +#include +#include "debug.h" +#include "btui.h" + +const TInt KMaxCheckedConnections=20; + + +// --------------------------------------------------------------------- +// CBTPairedModel::CBTPairedModel +// --------------------------------------------------------------------- +// +CBTPairedModel::CBTPairedModel(MBTDeviceObserver* aObserver, TBTDeviceSortOrder* aOrder) + : CBTDevModelBase(aObserver, aOrder) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::NewL +// --------------------------------------------------------------------- +// +CBTPairedModel* CBTPairedModel::NewL(MBTDeviceObserver* aObserver, TBTDeviceSortOrder* aOrder ) + { + CBTPairedModel* self = new (ELeave) CBTPairedModel(aObserver, aOrder); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// -------------------------------------------------------------------------------------------- +// Destructor +// -------------------------------------------------------------------------------------------- +// +CBTPairedModel::~CBTPairedModel() + { + TRACE_FUNC_ENTRY + + delete iConnMan; + delete iPairingDevice; + delete iLinks; + delete iBtEngSettings; + iSocketServ.Close(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::ConstructL +// ---------------------------------------------------------------------- +// +void CBTPairedModel::ConstructL() + { + TRACE_FUNC_ENTRY + + // get all devices from btregistry to cache - local copy of CBTDeviceArray + iDevMan = CBTEngDevMan::NewL(this); + iConnMan = CBTEngConnMan::NewL(this); + iSearchPattern.FindAll(); + iRegistryObserver = CBTRegistryObserver::NewL(this, iSearchPattern); + iRegistryObserver->Refresh(); + User::LeaveIfError( iSocketServ.Connect() ); + iLinks=CBluetoothPhysicalLinks::NewL(*this,iSocketServ); + + iBtEngSettings = CBTEngSettings::NewL(this); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::IsAnyDeviceConnected +// ---------------------------------------------------------------------- +// +TBool CBTPairedModel::IsAnyDeviceConnected() + { + TRACE_FUNC_ENTRY + + FlagPhysicallyConnectedDevices(iDeviceArray); + + for(TInt i = 0; i < iDeviceArray.Count(); i++) + { + if(iDeviceArray[i]->iStatus & (EStatusPhysicallyConnected|EStatusBtuiConnected)) + { + TRACE_FUNC_EXIT + return ETrue; + } + } + + TRACE_FUNC_EXIT + + return EFalse; + } + +// --------------------------------------------------------------------- +// CBTPairedModel::DoChangeDevice +// --------------------------------------------------------------------- + +TInt CBTPairedModel::DoChangeDeviceL(const TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + TRACE_BDADDR(aDevice.iAddr) + // check that the device actually still exists + if(aDevice.iOperation != EOpPair ) + { + User::LeaveIfError( GetIndexByAddress(aDevice.iAddr, aDevice.iIndex ) ); + } + + // disconnect device to be unpaired, or blocked + if((aDevice.iOperation == EOpBlock || aDevice.iOperation == EOpUnpair )) + { + if( iState != EDisconnectBeforeOperationState) + { + // disconnect by CBTEngConnMan if connected that way. + if (aDevice.iStatus & static_cast(EStatusBtuiConnected ) ) + { + TInt code=KErrNone; + TRAPD(err, + iState=EDisconnectBeforeOperationState; + iDisconnectDevice=new(ELeave) TBTDevice(aDevice); + code=iConnMan->Disconnect(aDevice.iAddr,EBTDiscImmediate); + ); + // if the return code is KErrNone then there will be + // a callback. However if it fails, there will not be any. + // So the execution will go on inside this method, if there was an error. + if(err == KErrNone && code==KErrNone ) + { + return KErrNone; + } + + } + else // try disconnecting from the link layer + { + TInt code=KErrNone; + TRAPD(err, + iState=EDisconnectBeforeOperationState; + iDisconnectDevice=new(ELeave) TBTDevice(aDevice); + code=iLinks->Disconnect(aDevice.iAddr); + ); + // if the return code is KErrNone then there will be + // a callback. However if it fails, there will not be any. + // So the execution will go on inside this method, if there was an error. + if(err == KErrNone && code==KErrNone ) + { + return KErrNone; + } + } + } + else + iState=EIdleState; + + } + + if( aDevice.iOperation ==EOpPair) + { + DoPairDeviceL(); + TRACE_FUNC_EXIT + return KErrNone; + } + + TInt err = CBTDevModelBase::DoChangeDeviceL(aDevice); + if(iDisconnectDevice!= NULL) + { + delete iDisconnectDevice; + iDisconnectDevice=NULL; + } + + if (err != KErrNone) + { + TBTDevAddr addr; + if(aDevice.iAddr == KNullAddress ) + { + if(aDevice.iIndex < 0 || aDevice.iIndex >= iDeviceArray.Count()) + return KErrArgument; + else + addr=iDeviceArray[aDevice.iIndex]->iAddr; + } + else + addr=aDevice.iAddr; + + switch (aDevice.iOperation) + { + case EOpConnect: + { + err = iConnMan->Connect(addr, aDevice.iDeviceClass); + break; + } + case EOpDisconnect: + { + iDisconnectDevice=new(ELeave) TBTDevice(aDevice); + if (aDevice.iStatus & static_cast(EStatusBtuiConnected ) ) + { + err = iConnMan->Disconnect(addr, EBTDiscImmediate); + } + else + { + err=iLinks->Disconnect(aDevice.iAddr); + } + + break; + } + default: + User::Leave(err); + break; + } + } + + TRACE_FUNC_EXIT + + return err; + } + +// --------------------------------------------------------------------- +// CBTPairedModel::DoCancelChange +// --------------------------------------------------------------------- +// +void CBTPairedModel::DoCancelChangeL(const TBTDevice& aDevice) + { + TRACE_FUNC_ENTRY + + if(aDevice.iIndex >= iDeviceArray.Count()) + { + TRACE_INFO((_L("index is %d, max expected is %d"), aDevice.iIndex, iDeviceArray.Count())); + TRACE_FUNC_EXIT + return; + } + + // in case it was stopped + iRegistryObserver->StartIfNotRunning(); + switch (aDevice.iOperation) + { + case EOpPair: + if( iState==EDeleteDeviceState || iState==EAddDeviceState ) + { + iDevMan->Cancel(); + } + else + { + iConnMan->CancelPairDevice(); + } + delete iPairingDevice; + iPairingDevice=NULL; + iState=EIdleState; + iRegistryObserver->Refresh(); + break; + + case EOpConnect: + { + + TBTDevAddr addr; + if(aDevice.iIndex == KErrNotFound) + { + addr=aDevice.iAddr; + } + else + { + addr=iDeviceArray[aDevice.iIndex]->iAddr; + } + + iConnMan->CancelConnect(addr); + break; + } + default: + CBTDevModelBase::CancelChange(aDevice); + return; + } + iRegistryObserver->StartIfNotRunning(); + + if(iQueue.Count()>0) + { + delete iQueue[0]; + iQueue.Remove(0); + HandleQueue(); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::HandleNewDevice +// +// Adds the device if it is not banned +// --------------------------------------------------------------------- +// +void CBTPairedModel::HandleNewDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry) + { + TRACE_FUNC_ENTRY + + // It is needed to filter out blocked devices, + // since otherwise blocked and paired devices would + // be listed. + if( ! aRegDevice->GlobalSecurity().Banned() + && IsUserAwarePaired( aRegDevice->AsNamelessDevice() ) ) + { + AddDeviceL(aRegDevice, aNameEntry, EOpNone); + } + + TRACE_FUNC_EXIT + } + +// ----------------------------------------------------------------------- +// CBTPairedModel::CreateDevice +// +// This implementaion will add the connectable status from the superclass. +// ----------------------------------------------------------------------- +// +TBTDevice* CBTPairedModel::CreateDeviceL(const CBTDevice* aRegDevice, + TNameEntry* aNameEntry) + { + TRACE_FUNC_ENTRY + + TBTDevice* device = CBTDevModelBase::CreateDeviceL(aRegDevice, aNameEntry); + + // add EStatusBtuiConnected status if the device has a profile connection + TBTEngConnectionStatus connStatus; + iConnMan->IsConnected(device->iAddr, connStatus); + + if(connStatus == EBTEngConnecting || connStatus == EBTEngConnected) + { + SetStatusFlags(device->iStatus,EStatusBtuiConnected); + } + + // add connectable status + TBool connectable=EFalse; + iConnMan->IsConnectable(aRegDevice->BDAddr(), aRegDevice->DeviceClass(), connectable ); + + if( connectable) + { + SetStatusFlags(device->iStatus, EStatusConnectable ); + } + + TRACE_FUNC_EXIT + + return device; + } + +// --------------------------------------------------------------------- +// CBTPairedModel::ConnectComplete +// from MBTEngConnObserver +// ---------------------------------------------------------------------- +// +void CBTPairedModel::ConnectComplete(TBTDevAddr& aAddr, TInt aErr, RBTDevAddrArray* aConflicts) + { + TRACE_FUNC_ENTRY + + TRACE_INFO((_L("aErr=%d"), aErr)) + + TInt index = GetIndexByAddress(aAddr); + TBool requestIssuedFromPhone = EFalse; + TBTDevice connectedDevice; + + // was the device connected from request by the ui + if(iQueue.Count()>0 && iQueue[0]->iOperation==EOpConnect && + iQueue[0]->iAddr == aAddr) + { + requestIssuedFromPhone = ETrue; + if(index >=0) // is it from paired list + { + connectedDevice=*iDeviceArray[index]; + connectedDevice.iOperation=EOpConnect; + } + else + { + connectedDevice=*iQueue[0]; + } + + } + else + { + requestIssuedFromPhone = EFalse; + if(index >=0) // is it from paired list + { + connectedDevice=*iDeviceArray[index]; + connectedDevice.iOperation=EOpConnect; + } + else + { + // it was not. Try to fill what can be filled. + connectedDevice.iAddr=aAddr; + connectedDevice.iIndex=KErrNotFound; + connectedDevice.iOperation = EOpConnect; + } + } + + if (aErr == KErrAlreadyExists ) + { + // gather the names of the conflicting devices. + RBTDevNameArray nameArray; + for (TInt i = 0; aConflicts!= NULL && i < aConflicts->Count(); i++) + { + //remove duplicates + if(i>0&& (*aConflicts)[i]==(*aConflicts)[i-1]) + { + continue; + } + TInt di = GetIndexByAddress((*aConflicts)[i]); + + if(di >=0 ) + { + nameArray.Append(&iDeviceArray[di]->iName); + } + } + if(iObserver ) + { + iObserver->NotifyChangeDeviceComplete(aErr, connectedDevice, &nameArray); + } + nameArray.Reset(); + } + else + { + if (aErr == KErrNone) + { + // we will set the connect status of the device + // if it is found in paired devices. + if( index >= 0 ) + { + SetStatusFlags(iDeviceArray[index]->iStatus,EStatusBtuiConnected ); + } + } + else + { + // we will unset the connect status of the device if connection failed & + // it is found in paired devices. + if( index >= 0 ) + { + // add EStatusBtuiConnected status if the device has a profile connection + TBTEngConnectionStatus connStatus; + iConnMan->IsConnected(connectedDevice.iAddr, connStatus); + + if (connStatus != EBTEngConnecting && connStatus != EBTEngConnected) + { + TRACE_INFO(_L("Unset EStatusBtuiConnected")) + UnsetStatusFlags(iDeviceArray[index]->iStatus,EStatusBtuiConnected ); + } + } + } + if(iObserver) + { + //Show only phone issued request complete notes + //Do not show notes for device issued request when BTUI is active + if ( requestIssuedFromPhone ) + { + iObserver->NotifyChangeDeviceComplete(aErr, connectedDevice); + } + + SendRefreshIfNoError(aErr); + } + } + + // Process the next command if the connect was + //initiated by this UI. + if(iQueue.Count()>0 && iQueue[0]->iOperation==EOpConnect && + iQueue[0]->iAddr == aAddr) + { + delete iQueue[0]; + iQueue.Remove(0); + HandleQueue(); + } + else + { + if( iQueue.Count()==0 ) + { + TRACE_INFO((_L("op Q is empty"))); + } + else + { + TRACE_INFO((_L("unexpected op Q contents, count is %d, op is %d"), iDeviceArray.Count(), iQueue[0]->iOperation)); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::PowerStateChanged +// from MBTEngSettingObserver +// ---------------------------------------------------------------------- +// +void CBTPairedModel::PowerStateChanged( TBTPowerStateValue ) + { + TRACE_FUNC_ENTRY + + // This is implemented for case like when user choses offlne mode, Bluetooth is swithced off + // very fast. Bt audio components don't have enough time to close audio connection. + // BTUI needs to update UI display. + + TInt count = iDeviceArray.Count(); + + for (TInt i = 0; i < count; i++) + { + UnsetStatusFlags(iDeviceArray[i]->iStatus, EStatusBtuiConnected ); + } + + SendRefreshIfNoError(KErrNone); + + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------- +// CBTPairedModel::VisibilityModeChanged +// from MBTEngSettingObserver +// ---------------------------------------------------- +// +void CBTPairedModel::VisibilityModeChanged( TBTVisibilityMode ) + { + TRACE_FUNC_ENTRY + + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::DisconnectComplete +// from MBTEngConnObserver +// ---------------------------------------------------------------------- +// +void CBTPairedModel::DisconnectComplete(TBTDevAddr& aAddr, TInt aErr) + { + TRACE_FUNC_ENTRY + + // the disconnect was part of a unpairing or blocking operation + if(iState == EDisconnectBeforeOperationState && iDisconnectDevice && aAddr == iDisconnectDevice->iAddr ) + { + + TRAPD(err, + DoChangeDeviceL(*iDisconnectDevice); + ); + iState=EIdleState; + if(err != KErrNone) + { + HandleLeave(err,iDisconnectDevice); + } + TRACE_FUNC_EXIT + return; + } + + TInt index = GetIndexByAddress(aAddr); + + // the disconnected device was not the devicein the list, + // so we do not tell anyone about it. + if ( iDisconnectDevice == NULL || iDisconnectDevice->iAddr != aAddr ) + { + if (index >=0 ) + { + UnsetStatusFlags(iDeviceArray[index]->iStatus, EStatusBtuiConnected ); + } + + SendRefreshIfNoError(KErrNone); + + TBTDevice disconnectedDevice; + disconnectedDevice.iAddr = aAddr; + // Notify needed when there is active disconnect query dialog + iObserver->NotifyChangeDeviceComplete(KErrDisconnected, disconnectedDevice); + + TRACE_FUNC_EXIT + return; + } + + if(index >=0 ) + { + // set it to "not connected" no matter disconnection works or not + UnsetStatusFlags(iDeviceArray[index]->iStatus, EStatusBtuiConnected ); + iDeviceArray[index]->iOperation = EOpDisconnect; + iObserver->NotifyChangeDeviceComplete(aErr, *iDeviceArray[index]); + } + else + { + iDisconnectDevice->iIndex=index; + iObserver->NotifyChangeDeviceComplete(aErr, *iDisconnectDevice); + } + + delete iDisconnectDevice; + iDisconnectDevice=NULL; + + SendRefreshIfNoError(aErr); + // continue processing queue only if the disconnected device is + // the device with we requested disconnect to. + // this has to be checked so that we do not end on having multiple + // queue processors at the same time + if(iQueue.Count()>0 && iQueue[0]->iOperation==EOpDisconnect && + iQueue[0]->iAddr == aAddr) + { + delete iQueue[0]; + iQueue.Remove(0); + HandleQueue(); + } + else + { + if( iQueue.Count()==0 ) + { + TRACE_INFO((_L("op Q is empty"))); + } + else + { + TRACE_INFO((_L("unexpected op Q contents, count is %d, op is %d"), iDeviceArray.Count(), iQueue[0]->iOperation)); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::PairingComplete +// from MBTEngConnObserver +// ---------------------------------------------------------------------- +// +void CBTPairedModel::PairingComplete(TBTDevAddr& aAddr, TInt aErr) + { + TRACE_FUNC_ENTRY + + TRAPD(err, + PairingCompleteL(aAddr,aErr); + ); + + if(err!=KErrNone) + { + TBTDevice tmp; + tmp.iAddr=aAddr; + tmp.iIndex=GetIndexByAddress(aAddr); + tmp.iOperation=EOpPair; + HandleLeave(err,&tmp ); + + delete iPairingDevice; + iPairingDevice=NULL; + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::PairingCompleteL +// Leaving version of PairingComplete +// ---------------------------------------------------------------------- +// +void CBTPairedModel::PairingCompleteL(TBTDevAddr& aAddr, TInt aErr) + { + TRACE_FUNC_ENTRY + + // The device that was attempted to be paired is + // different from the the device that the pairing is finnished. + // This cannot happen, since CBTConnMan will report + // only pairing started by the listener and the UI + // does not allow making two pairings at the same time + __ASSERT_DEBUG(aAddr==iPairingDevice->BDAddr(), + PANIC(EBTPanicCommandComplettedToDiffrentDeviceThanStarted)); + (void) aAddr; + + // bail out if the operation queue is not what we expect + if( iQueue.Count() == 0 + || iQueue[0]->iOperation != EOpPair + || iQueue[0]->iAddr != aAddr ) + { + if( iQueue.Count()==0 ) + { + TRACE_INFO((_L("op Q is empty"))); + } + else + { + TRACE_INFO((_L("unexpected op Q contents, count is %d, op is %d"), iDeviceArray.Count(), iQueue[0]->iOperation)); + } + TRACE_FUNC_EXIT + return; + } + + iState=EIdleState; + TBTDevice* tmpDevice=NULL; + tmpDevice=CreateDeviceL(iPairingDevice, &( iQueue[0]->iNameEntry ) ); + tmpDevice->iOperation=EOpPair; + + // new paired device must be inserted to the array, since + // user may be doing trust/ connect operations before + // it is refreshed from registry + TBool deleleteTmpDevice=ETrue; + + if( aErr == KErrNone ) + { + SetStatusFlags(tmpDevice->iStatus,EStatusPaired); + TInt index; + index=GetIndexByAddress(iPairingDevice->BDAddr()); + + if(index == KErrNotFound) + { + iDeviceArray.InsertInOrderL(tmpDevice,*iSortOrder ); + + RenumberDeviceArray(); + + // iPairingDevice is now owned by iDeviceArray. + // So it must not be deleted by his function + deleleteTmpDevice=EFalse; + + SendRefreshIfNoError(aErr,GetIndexByAddress(iPairingDevice->BDAddr())); + } + } + + + iObserver->NotifyChangeDeviceComplete(aErr, *tmpDevice); + + /* + * We issue an background refresh in case + * registry is updated from btnotif + */ + iRegistryObserver->StartIfNotRunning(); + iRegistryObserver->Refresh(); + // delete if the ownership has not changed + if(deleleteTmpDevice ) + { + delete tmpDevice; + tmpDevice=NULL; + } + + delete iPairingDevice; + iPairingDevice=NULL; + delete iQueue[0]; + iQueue.Remove(0); + + HandleQueue(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// BTPairedModel::HandleDevManComplete +// from MBTEngDevModelBase +// ---------------------------------------------------------------------- +// +void CBTPairedModel::HandleDevManComplete(TInt aErr) + { + TRACE_FUNC_ENTRY + + // if this is handled we can remove this + if(iDisconnectDevice) + { + delete iDisconnectDevice; + iDisconnectDevice=NULL; + } + + if(iPairingDevice) + { + // add the device just deleted + if(iState==EDeleteDeviceState && (aErr==KErrNone || aErr == KErrNotFound)) + { + iPairingDevice->DeleteLinkKey(); + TBTDeviceSecurity sec=iPairingDevice->GlobalSecurity(); + sec.SetBanned(EFalse); + sec.SetNoAuthorise(EFalse); + iDevMan->AddDevice(*iPairingDevice); + iState=EAddDeviceState; + TRACE_FUNC_EXIT + return; + } + // if the device is added allready, or if deletion failed + // we will go on with pairing the device + if(iState==EAddDeviceState||(iState==EDeleteDeviceState&& aErr != KErrNone)) + { + aErr = iConnMan->PairDevice(iPairingDevice->BDAddr(), iPairingDevice->DeviceClass()); + iState=EPairDeviceState; + // NOTE: now PairingComplete will be called and not this method. + TRACE_FUNC_EXIT + return; + } + } + // these are not handled by superclass + if(iQueue.Count()>0 && + ( iQueue[0]->iOperation==EOpConnect || + iQueue[0]->iOperation==EOpDisconnect ) ) + { + iObserver->NotifyChangeDeviceComplete(aErr, *iQueue[0]); + } + + CBTDevModelBase::HandleDevManComplete(aErr); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::DoPairDevice +// --------------------------------------------------------------------- +// +void CBTPairedModel::DoPairDeviceL() + { + TRACE_FUNC_ENTRY + + // we are starting a new command. Checks that no earlier commands + // have been executed, but not finished properly. + __ASSERT_DEBUG(iState==EIdleState,PANIC(EBTPanicDevManQueueIsInIllegalState)); + // check that there is no other pairing going on. + __ASSERT_DEBUG(iPairingDevice!=NULL,PANIC(EBTPanicTwoPairingAttemptsAtTheSameTime)); + + iRegistryObserver->Cancel(); + + // devices to be paired are first deleted + // then added back. Only after that the paring itself is + // started + TBTRegistrySearch dele; + dele.FindAddress(iPairingDevice->BDAddr()); + TInt err = iDevMan->DeleteDevices(dele); + + iState=EDeleteDeviceState; + if (err) + { + HandleDevManComplete(err); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::PairDevice +// +// Puts the given aPairingDevice to iPairingDevice and +// adds and empty device with iOperation=EOpPair as placeholder to iQueue. +// the pairing itself will be handled by DoChangeDevice that +// cals then +// --------------------------------------------------------------------- +// +TInt CBTPairedModel::PairDeviceL(const CBTDevice* aPairingDevice, + TNameEntry* aNameEntry) + { + TRACE_FUNC_ENTRY + + // cannot put two pairings to queue. + // this is not possible since ui does not allow it. + if(iPairingDevice) + return KErrInUse; + + TBTDevice* device=new(ELeave) TBTDevice(); + device->iOperation=EOpPair; + device->iAddr=aPairingDevice->BDAddr(); + if ( aNameEntry ) + { + device->iNameEntry = *aNameEntry; + } + CleanupStack::PushL(device); + iPairingDevice=aPairingDevice->CopyL(); + // put the device to queue directly + iQueue.AppendL(device); + TInt err = KErrNone; + if(iQueue.Count() ==1 ) + { + err = DoChangeDeviceL(*iQueue[0]); + } + CleanupStack::Pop(device); + TRACE_FUNC_EXIT + return err; + + } + +// --------------------------------------------------------------------- +// CBTPairedModel::HandleDisconnectCompleteL +// Disconnection by CBluetoothPhysicalLinks, for those +// connections not opened by btui. +// --------------------------------------------------------------------- +// +void CBTPairedModel::HandleDisconnectCompleteL(TInt aErr) + { + TRACE_FUNC_ENTRY + + if(iDisconnectDevice) + { + DisconnectComplete(iDisconnectDevice->iAddr,aErr); + } + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTPairedModel::FlagPhysicallyConnectedDevices +// +// Marks the EStatusPhysicallyConnected attribute to the devices +// that have active connection. +// --------------------------------------------------------------------- +// +void CBTPairedModel::FlagPhysicallyConnectedDevices(RDeviceArray &aDeviceArray) + { + TRACE_FUNC_ENTRY + + RBTDevAddrArray a; + iLinks->Enumerate(a,KMaxCheckedConnections); + + TInt i=0; + + for(i=0;iEnumerate(a,KMaxCheckedConnections); + FlagPhysicallyConnectedDevices(aDevice, a); + a.Close(); + + TRACE_FUNC_EXIT + + return rvalue; + } + +// --------------------------------------------------------------------- +// CBTPairedModel::HandleLeave +// from CBTDevModelBase +// --------------------------------------------------------------------- +// +void CBTPairedModel::HandleLeave(TInt aErr,const TBTDevice* aDevice ) + { + TRACE_FUNC_ENTRY + + iConnMan->CancelPairDevice(); + + delete iPairingDevice; + iPairingDevice=NULL; + + delete iDisconnectDevice; + iDisconnectDevice=NULL; + + iRegistryObserver->StartIfNotRunning(); + iRegistryObserver->Refresh(); + + iState=EIdleState; + + CBTDevModelBase::HandleLeave(aErr,aDevice ); + + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/devmodel/src/btregistryobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/devmodel/src/btregistryobserver.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,256 @@ +/* +* Copyright (c) 2006-2007 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: Monitors BTRegistry device changes and sends the +* new status to listener +* +*/ + +#include "btregistryobserver.h" +#include "debug.h" + +#include +const TInt KDeviceArrayDefaultSize=10; +// --------------------------------------------------------------------- +// Constructor +// --------------------------------------------------------------------- +CBTRegistryObserver::CBTRegistryObserver(MBTRegistryObserver* aObserver, + const TBTRegistrySearch aPattern) + : CActive(CActive::EPriorityHigh), + iObserver(aObserver), iSearchPattern(aPattern) + { + TRACE_FUNC_ENTRY + CActiveScheduler::Add(this); + // The priority will be EPriorityHigh only initially. + // after the first successfull retrieval of the devicelist + // the priority will be changed to EPriorityLow. + + // This will make the 1st devicelist drawn as quickly as possible, + // but the subsequent refrehes will not decrease the responsiveness + // of the Btui. + iAnotherEventPending=EFalse; + + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTRegistryObserver::NewL +// --------------------------------------------------------------------- +CBTRegistryObserver* CBTRegistryObserver::NewL(MBTRegistryObserver* aObserver, + const TBTRegistrySearch aPattern) + { + CBTRegistryObserver* self = new (ELeave) CBTRegistryObserver(aObserver, aPattern); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } +// --------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------- +CBTRegistryObserver::~CBTRegistryObserver() + { + TRACE_FUNC_ENTRY + Cancel(); + iProperty.Close(); + delete iDevMan; + + DeleteAllocatedDevices(); + + delete iRegDeviceArray; + iRegDeviceArray=NULL; + + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTRegistryObserver::ConstructL() +// --------------------------------------------------------------------- +void CBTRegistryObserver::ConstructL() + { + TRACE_FUNC_ENTRY + iRegDeviceArray = new (ELeave) CBTDeviceArray(KDeviceArrayDefaultSize); + iDevMan = CBTEngDevMan::NewL(this); + iDevMan->SetPriority(CActive::EPriorityHigh); + + iProperty.Attach(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetRegistryTableChange); + StartIfNotRunning(); + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTRegistryObserver::Refresh +// This will simulate registry change event. +// --------------------------------------------------------------------- +void CBTRegistryObserver::Refresh() + { + TRACE_FUNC_ENTRY + + __ASSERT_DEBUG(iDevMan, User::Invariant()); + + if (iDevMan->IsActive()) + { + // An attempt to start a new search, during a prior + // one. + iAnotherEventPending=ETrue; + return; + } + Cancel(); + + DeleteAllocatedDevices(); + iDevMan->GetDevices(iSearchPattern, iRegDeviceArray); + + StartIfNotRunning(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTRegistryObserver::StartIfNotRunning +// this have to be called again each time there has been registry event +// --------------------------------------------------------------------- +void CBTRegistryObserver::StartIfNotRunning() + { + TRACE_FUNC_ENTRY + if (!IsActive()) + { + TRACE_INFO(_L("Start()")) + iIsStopped = EFalse; + iProperty.Subscribe(iStatus); + SetActive(); + } + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTRegistryObserver::RunL +// From CAtive +// This is called when registry has changed. This will not +// be called when BTRegistry date retrieval is complete, since +// HandleGetDevicesComplete is called when RBTregistry data retrieval +// is complete +// ---------------------------------------------------------------------- + +void CBTRegistryObserver::RunL() + { + TRACE_FUNC_ENTRY + if(iDevMan && iDevMan->IsActive()) + { + // An attempt to start a new search, during a prior + // one. We will not start a new search, but we + // will do it after the current search is complete + iAnotherEventPending=ETrue; + StartIfNotRunning(); + TRACE_FUNC_EXIT + return; + } + if(!IsActive()) + SetPriority(CActive::EPriorityLow); + + + + TInt registryTable; + iProperty.Get(registryTable); + iAnotherEventPending=EFalse; + + if(iDevMan && iStatus.Int() == KErrNone && registryTable == KRegistryChangeRemoteTable) + { + TRACE_INFO(_L("Remote table change")) + + DeleteAllocatedDevices(); + iDevMan->GetDevices(iSearchPattern, iRegDeviceArray); + } + StartIfNotRunning(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTRegistryObserver::HandleGetDevicesComplete +// From MBTEngDevManObserver +// +// This function will not filter out refreshes with no changes, +// since the connect status may have been changed in those cases, and +// this class does not know about that +// +// It is worth to mention that CBTDeviceContainer will not refresh parts +// of the screen that are not changed. +// --------------------------------------------------------------------- +void CBTRegistryObserver::HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray) + { + TRACE_FUNC_ENTRY + TRACE_INFO((_L("aErr = %d"), aErr)) + + // the initial view refresh is done. We will decrese + // the priority of this component to quarantee UI + // responsiveness + if(!iDevMan->IsActive()) + iDevMan->SetPriority(CActive::EPriorityLow); + + TRAP_IGNORE( + if( aErr != KErrNotFound) + iObserver->RegistryChangedL(aDeviceArray ); + else + { + // handle the empty response case. The DevMan may issue + // NULL in that case + iObserver->RegistryChangedL(iRegDeviceArray ); + } + ); + + DeleteAllocatedDevices(); + + if(iAnotherEventPending) + { + // Current results are not sent further, since + // there has been changes, witch may have rendered the current + // results allready obsolate. Therefore a refresh is made instead + + iAnotherEventPending=EFalse; + iDevMan->GetDevices(iSearchPattern, iRegDeviceArray); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------- +// CBTRegistryObserver::DeleteAllocatedDevices +// --------------------------------------------------------------------- +void CBTRegistryObserver::DeleteAllocatedDevices() + { + TRACE_FUNC_ENTRY + if(iRegDeviceArray) + { + iRegDeviceArray->ResetAndDestroy(); + } + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTRegistryObserver::Cancel +// From CActive +// --------------------------------------------------------------------- + +void CBTRegistryObserver::Cancel() + { + TRACE_FUNC_ENTRY + iIsStopped = ETrue; + iAnotherEventPending=EFalse; + CActive::Cancel(); + if (iDevMan) iDevMan->Cancel(); + DeleteAllocatedDevices(); + TRACE_FUNC_EXIT + } +// --------------------------------------------------------------------- +// CBTRegistryObserver::DoCancel +// From CActive +// --------------------------------------------------------------------- +void CBTRegistryObserver::DoCancel() + { + TRACE_FUNC_ENTRY + iProperty.Cancel(); + TRACE_FUNC_EXIT + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/group/BTUI.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/group/BTUI.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2002 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: This is project specification file for the BTUI. +* +*/ + +#include +#include +#include + +VENDORID VID_DEFAULT + +CAPABILITY CAP_APPLICATION NetworkServices NetworkControl + +TARGET BTUI.exe +TARGETTYPE exe +EPOCSTACKSIZE 0x5000 +UID 0x100039CE 0x10005951 + +SOURCEPATH ../src +SOURCE BTUIApp.cpp +SOURCE BTUIAppUi.cpp +SOURCE BTUIDocument.cpp + + +// Application Resource +// +START RESOURCE ../data/BTUI.rss +HEADER +TARGETPATH APP_RESOURCE_DIR +LANGUAGE_IDS +END + + +// Application Registeration Resource +// +START RESOURCE ../data/Btui_reg.rss +DEPENDS btui.rsg + +// Do not change the UID below. +TARGETPATH /private/10003a3f/apps +END + +USERINCLUDE ../inc +USERINCLUDE ../devmodel/inc +USERINCLUDE ../Ecom/inc +USERINCLUDE ../data + +SYSTEMINCLUDE ../../inc //for private API headers (BluetoothEngine subsystem) +SYSTEMINCLUDE ../../../inc //for internal API headers (localconnectivity) +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib apparc.lib cone.lib // Symbian OS framework libraries +LIBRARY eikcore.lib eikcoctl.lib eikctl.lib // UIKON libraries +LIBRARY avkon.lib // Series 60 UI library +LIBRARY bafl.lib // Basic Application Framework +LIBRARY AknSkins.lib // Skinned icons +LIBRARY aknicon.lib +LIBRARY BtdevModel.lib +LIBRARY ecom.lib + +LIBRARY GSEcomPlugin.lib +LIBRARY GSFramework.lib + +#ifdef __SERIES60_HELP +LIBRARY hlplch.lib // Help library +#endif + +DEBUGLIBRARY flogger.lib // File logging services + +// This is optional - used only by Codewarrior IDE for .RSS file editing. +// +//Document ../data/Btui_reg.rss +//Document ../data/BTUI.rss +//Document ../inc/btui.loc + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2002 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: This file provides project information required for BTUI. +* +*/ + + +#include +#include "../devmodel/group/bld.inf" + +PRJ_PLATFORMS +//DEFAULT + +PRJ_EXPORTS +../loc/btui.loc MW_LAYER_LOC_EXPORT_PATH(btui.loc) +../rom/btui.iby CORE_MW_LAYER_IBY_EXPORT_PATH(btui.iby) +../rom/BtuiResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(BtuiResources.iby) +../inc/BtuiPluginInterface.h |../../inc/BtuiPluginInterface.h +../inc/BtuiPluginInterface.inl |../../inc/BtuiPluginInterface.inl +// Help exports +#include "../help/group/bld.inf" + +PRJ_EXTENSIONS + +START EXTENSION s60/mifconv +OPTION TARGETFILE btui.mif +OPTION HEADERFILE btui.mbg +OPTION SOURCES \ + -c8,8 qgn_prop_bt_devices_tab3 -c8,8 qgn_prop_bt_set_tab3 -c8,8 qgn_prop_set_apps_bt \ + -c8,8 qgn_prop_bt_blocked_tab3 -c8,8 qgn_prop_set_apps_bt_off -c8,8 qgn_prop_set_apps_bt_on_shown \ + -c8,8 qgn_prop_set_apps_bt_on_hidden -c8,8 qgn_prop_set_apps_bt_conn_shown -c8,8 qgn_prop_set_apps_bt_conn_hidden \ + -c8,8 qgn_prop_bt_audio_connect -c8,8 qgn_prop_bt_computer_connect -c8,8 qgn_prop_bt_car_kit_connect \ + -c8,8 qgn_prop_bt_keyboard_connect -c8,8 qgn_prop_bt_mouse_connect +END + +START EXTENSION s60/mifconv +OPTION TARGETFILE btui_aif.mif +OPTION SOURCES -c8,8 qgn_menu_bt +END + +PRJ_MMPFILES + +../Ecom/group/BtuiPlugin.mmp +../group/BTUI.mmp + + +//---End of File--- diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/group/btui_Icons_aif_bitmaps_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/group/btui_Icons_aif_bitmaps_dc.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,69 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +# TODO: Configure these +# ---------------------------------------------------------------------------- + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\btui_aif.mbm + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# TODO: Configure these. +# +# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by +# MifConv if the mask detph is defined. +# +# NOTE 2: Usually, source paths should not be included in the bitmap +# definitions. MifConv searches for the icons in all icon directories in a +# predefined order, which is currently \s60\icons, \s60\bitmaps2. +# The directory \s60\icons is included in the search only if the feature flag +# __SCALABLE_ICONS is defined. +# ---------------------------------------------------------------------------- + +RESOURCE : + mifconv $(ICONTARGETFILENAME) \ + /c8,8 qgn_menu_bt_lst.bmp \ + /c8,8 qgn_menu_bt_cxt.bmp + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/group/btui_Icons_aif_scalable_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/group/btui_Icons_aif_scalable_dc.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,68 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +# TODO: Configure these +# ---------------------------------------------------------------------------- + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\btui_aif.mif + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# TODO: Configure these. +# +# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by +# MifConv if the mask detph is defined. +# +# NOTE 2: Usually, source paths should not be included in the bitmap +# definitions. MifConv searches for the icons in all icon directories in a +# predefined order, which is currently \s60\icons, \s60\bitmaps2. +# The directory \s60\icons is included in the search only if the feature flag +# __SCALABLE_ICONS is defined. +# ---------------------------------------------------------------------------- + +RESOURCE : + mifconv $(ICONTARGETFILENAME) \ + /c8,8 qgn_menu_bt.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/group/btui_icons_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/group/btui_icons_dc.mk Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,84 @@ +# +# Copyright (c) 2004 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +# TODO: Configure these +# ---------------------------------------------------------------------------- + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\btui.mif + +HEADERDIR=\epoc32\include +HEADERFILENAME=$(HEADERDIR)\btui.mbg + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# TODO: Configure these. +# +# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by +# MifConv if the mask detph is defined. +# +# NOTE 2: Usually, source paths should not be included in the bitmap +# definitions. MifConv searches for the icons in all icon directories in a +# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps. +# The directory \s60\icons is included in the search only if the feature flag +# __SCALABLE_ICONS is defined. +# ---------------------------------------------------------------------------- + +RESOURCE : + mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ + /c8,8 qgn_prop_bt_devices_tab3.svg \ + /c8,8 qgn_prop_bt_set_tab3.svg \ + /c8,8 qgn_prop_set_apps_bt.svg \ + /c8,8 qgn_prop_bt_blocked_tab3.svg \ + /c8,8 qgn_prop_set_apps_bt_off.svg \ + /c8,8 qgn_prop_set_apps_bt_on_shown.svg \ + /c8,8 qgn_prop_set_apps_bt_on_hidden.svg \ + /c8,8 qgn_prop_set_apps_bt_conn_shown.svg \ + /c8,8 qgn_prop_set_apps_bt_conn_hidden.svg \ + /c8,8 qgn_prop_bt_audio_connect.svg \ + /c8,8 qgn_prop_bt_computer_connect.svg \ + /c8,8 qgn_prop_bt_car_kit_connect.svg \ + /c8,8 qgn_prop_bt_keyboard_connect.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(HEADERFILENAME)&& \ + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/help/data/xhtml.zip Binary file bluetoothengine/btui/help/data/xhtml.zip has changed diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/help/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/help/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 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: +* Export help related files. +* +*/ + +#include +PRJ_EXPORTS +:zip ../data/xhtml.zip /epoc32/data/z/resource/ overwrite +:zip ../data/xhtml.zip /epoc32/winscw/c/resource/ overwrite + +../inc/bt.hlp.hrh MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/bt.hlp.hrh) +../rom/btuihelps_variant.iby CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(btuihelps_variant.iby) diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/help/inc/bt.hlp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/help/inc/bt.hlp.hrh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 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: +* +*/ + +// +// bt.hlp.hrh generated by CSXHelp Utilities. +// + +#ifndef __BT_HLP_HRH__ +#define __BT_HLP_HRH__ + +_LIT(KBT_HLP_MAIN, "BT_HLP_MAIN"); // +_LIT(KBT_HLP_PAIRED, "BT_HLP_PAIRED"); // +_LIT(KBT_HLP_BLOCKED, "BT_HLP_BLOCKED"); // +_LIT(KBTKEYBOARD_HLP_SETTINGS, "BTKEYBOARD_HLP_SETTINGS"); // + +#endif diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/help/rom/btuihelps_variant.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/help/rom/btuihelps_variant.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 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: +* +*/ + +#ifndef __BTUIHELPS_VARIANT_IBY__ +#define __BTUIHELPS_VARIANT_IBY__ + +#if defined(FF_S60_HELPS_IN_USE) && defined(__BT) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10005951\contents.zip, RESOURCE_FILES_DIR\xhtml\%02d\0x10005951\contents.zip) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10005951\index.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x10005951\index.xml) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10005951\keywords.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x10005951\keywords.xml) + data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x10005951\meta.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x10005951\meta.xml) +#endif + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/BTUIApp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/BTUIApp.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2002-2007 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: +* +*/ + + +#ifndef BTUIAPP_H +#define BTUIAPP_H + +#include + +/** +* CBTUIApp application class +* +* Provides factory to create concrete document object. +* +* @lib btui.exe +* @sice S60v3.0 +*/ +class CBTUIApp : public CAknApplication + { + + private: + + /** + * From CAknApplication Creates CBTUIDocument document object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + + /** + * From CAknApplication Returns application's UID (KUidBTUI). + * @return The value of KUidBTUI. + */ + TUid AppDllUid() const; + }; + +#endif + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/BTUIAppUi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/BTUIAppUi.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2002-2007 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: +* +*/ + + +#ifndef BTUIAPPUI_H +#define BTUIAPPUI_H + +// INCLUDES +#include // AVKON components +#include +#include +#include +#include +#include "BtuiPluginInterface.h" + +// CLASS DECLARATION + +/** +* This class is a base class mandatory for all Symbian OS UI applications. +*/ +class CBTUIAppUi : public CAknViewAppUi, + public MAknTabObserver, + public MBtuiPluginViewActivationObserver + { + public: // Constructors and destructor + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + /** + * Destructor + */ + virtual ~CBTUIAppUi(); + + + public: // Functions from base classes + + /** + * From CAknViewAppUi Handles user commands. + * @param aCommand A command id. + * @return None. + */ + void HandleCommandL(TInt aCommand); + + private: // Functions from base classes + + /** + * From CAknViewAppUi Initializes menu pane dynamically. + * @param aResourceId Resource ID identifying the menu pane to initialise. + * @param aMenuPane The in-memory representation of the menu pane. + * @return None. + */ + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + + /** + * From CAknViewAppUi Handles key events. + * @param aKeyEvent The key event that occurred. + * @param aType The event type. + * @return Response to the key event. + */ + virtual TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType ); + + /** + * From MBtuiPluginViewActivationObserver + * @param aViewId activated plugin id + * @return none + */ + void PluginViewActivated(TPluginViewId aViewId); + + /** + * From MAknTabObserver Takes care of tab handling. + * @param aIndex tab to be handled + */ + virtual void TabChangedL(TInt aIndex); + + private: // Data + + CAknNavigationControlContainer* iNaviPane; // pointer to the navi pane control + CAknTabGroup* iTabGroup; // Tab group + CAknNavigationDecorator* iDecoratedTabGroup; // Frame for tabgroup + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/BTUIDocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/BTUIDocument.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2002-2007 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: +* +*/ + + +#ifndef BTUIDOCUMENT_H +#define BTUIDOCUMENT_H + +// INCLUDES + +#include +#include + +// FORWARD DECLARATIONS + +class CEikAppUi; +//class CBTUIModel; + +// CLASS DECLARATION + +/** +* This class is a base class mandatory for all Symbian OS UI applications. +*/ +class CBTUIDocument : public CAknDocument + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTUIDocument* NewL(CAknApplication& aApp); + + /** + * Destructor. + */ + virtual ~CBTUIDocument(); + + private: // Functions from base classes + + /** + * From CAknDocument Creates AppUi class. + * @param None. + * @return A reference to created class. + */ + CEikAppUi* CreateAppUiL(); + + private: + + /** + * C++ default constructor. + */ + CBTUIDocument(CEikApplication& aApp) :CAknDocument(aApp) { } + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + }; + +#endif + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/BtuiPluginInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/BtuiPluginInterface.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2002-2007 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: +* +*/ + +#ifndef BTUIPLUGININTERFACE_H +#define BTUIPLUGININTERFACE_H + +#include +#include +#include + +const TUid KCBtuiPluginInterfaceUid = { 0x1020745F }; + + +enum TPluginViewId +{ + EMainViewId =1, + EPairedDevicesViewId=2, + EBlockedDevicesViewId=3 +}; + + + +/** +* Callback interface for plugins view activation observer +*/ +class MBtuiPluginViewActivationObserver +{ +public: + /** + * Called when view is activated + * + * @param aView Activated view id + */ + virtual void PluginViewActivated(TPluginViewId aViewId)=0; +}; + + +/** This class implements the CGSPluginInterface which is used +* to implement the main view as general settings plugin. +* +*@lib BTUIPlugin.dll +*@since S60 v3.1 +*/ +class CBtuiPluginInterface : public CGSBaseView + { + public: // Constructors & destructors + + /** + * Creates new BTUI View plugin having the given UID. + * Uses Leave code KErrNotFound if implementation is not found. + * + * @param aImplementationUid Implementation UID of the plugin to be + * created. + * @param aModel Pointer to the BTUI Model of BTUI Application. + */ + static CBtuiPluginInterface* NewL( + const TUid aImplementationUid, MBtuiPluginViewActivationObserver* aObserver = NULL); + + /** + * From CGSPluginInterface + */ + void GetCaptionL( TDes& aCaption ) const; + + /** + * Destructor + */ + inline ~CBtuiPluginInterface(); + + /** + * One ECom plugin of a type of HID device has its unique DeviceClass. + * The HID plugin has to implement this function to report the plug-in loader of its COD. + * Otherwise, it won't be added to enable setting view. + * @return TBTDeviceClass Class of Device defined in btdevice.h + */ + inline void SetCOD(TBTDeviceClass& aCOD); + inline TBTDeviceClass GetCOD() const; + + protected: + /** Non leaving constructor + */ + inline CBtuiPluginInterface(); + + inline void NewContainerL(); + + inline void HandleListBoxSelectionL(); + + + private: // Data + + /** + * ECOM plugin instance UID. + */ + TUid iDtor_ID_Key; + TBTDeviceClass iCOD; + }; + +#include "BtuiPluginInterface.inl" + +#endif //BTUIPLUGININTERFACE_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/BtuiPluginInterface.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/BtuiPluginInterface.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 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: Inline code of CBtuiPluginInterface class. +* +*/ + + +// ----------------------------------------------------------------------------- +// Empty implementations of 3 pure virtual functions +// defined in base class CGSBaseView +// ----------------------------------------------------------------------------- +inline void CBtuiPluginInterface::NewContainerL() + { + } +inline void CBtuiPluginInterface::HandleListBoxSelectionL() + { + } +inline CBtuiPluginInterface::CBtuiPluginInterface() + { + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +// +inline CBtuiPluginInterface::~CBtuiPluginInterface() + { + REComSession::DestroyedImplementation( iDtor_ID_Key ); + } + +// ----------------------------------------------------------------------------- +// CBtuiPluginInterface::NewL +// ----------------------------------------------------------------------------- +// +inline CBtuiPluginInterface* CBtuiPluginInterface::NewL( + TUid aImplementationUid, MBtuiPluginViewActivationObserver* aObserver) + { + TInt32 keyOffset = _FOFF( CBtuiPluginInterface, iDtor_ID_Key ); + TAny* ptr = REComSession::CreateImplementationL( aImplementationUid, keyOffset, aObserver); + + return reinterpret_cast< CBtuiPluginInterface* >( ptr ) ; + } + +// ----------------------------------------------------------------------------- +// CBtuiPluginInterface::NewL +// offer a default implementation to make it non-pure virtual. +// ----------------------------------------------------------------------------- +// +inline void CBtuiPluginInterface::GetCaptionL( TDes& aCaption ) const + { + _LIT( NO_CAPTION,"no caption to offer" ); + aCaption.Copy(NO_CAPTION); + return; + } + +// ----------------------------------------------------------------------------- +// CBtuiPluginInterface::SetCOD +// only used for derived add-on plugins out of BTUI +// ----------------------------------------------------------------------------- +// +inline void CBtuiPluginInterface::SetCOD(TBTDeviceClass& aCOD) + { + iCOD = aCOD; + } +inline TBTDeviceClass CBtuiPluginInterface::GetCOD() const + { + return iCOD; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/btui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/btui.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2002-2007 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: This header file contains global declarations and methods +* which are visible to all BTUI classes. +* +*/ + +#ifndef BTUI_H +#define BTUI_H + +#include // For RDebug and Panic +#include + +const TUid KBtuiUid3 = { 0x10005951 }; //Application UID for help context + +//Ecom implementation UID of GS interface plugin +const TUid KGsBtuiPluginUid = { 0x1020742B }; + +//Ecom implementation UID of BTUI interface plugin +const TUid KBtuiPluginUidMainView = { 0x1020745C }; // Ecom interface implementation UID +const TUid KBtuiPluginUidPairedDevicesView = { 0x1020745D }; // Ecom interface implementation UID +const TUid KBtuiPluginUidBlockedDevicesView = {0x20002780 }; // Ecom interface implementation UID + + +_LIT( KBTUIAppName, "BTUI" ); // The application name + +// Literals for bitmap files ( drive, directory, filename(s) ) +_LIT(KBitmapFileDrive,"z:"); +// KDC_APP_BITMAP_DIR == from data_caging_path_literals.hrh + + +_LIT( KGSBtuiPluginResourceFileName, "z:BtuiViewResources.rsc" ); + +_LIT(KBtuiBmpFileName,"btui.mbm"); + +_LIT(KFileDrive,"z:"); +_LIT(KResourceFileName, "BtuiViewResources.rsc"); + + +enum TBTPanics { + EBTMainListNotEmpty = 10000, + EBTAllFormatStingsArrayNotEmpty, + EBTFormatStingsArrayNotEmpty, + EBTPairedDevicesListNotEmpty, + EBTPanicClassMemberVariableNotNull, + EBTPanicClassMemberVariableIsNull, + EBTPanicIllegalValue, + EBTPanicDevManQueueIsCorrupt, + EBTPanicDevManQueueIsInIllegalState, + EBTPanicTwoPairingAttemptsAtTheSameTime, + EBTPanicCommandComplettedToDiffrentDeviceThanStarted, + EBTPanicNullObserver +}; + +// MACROS +//#define PANIC(aPanic) User::Panic(KBTUIAppName,aPanic) + +#endif // BTUI_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/btui.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/btui.hrh Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2006 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: This file contains declarations for resources of BTUI. +* +*/ + + + + +#ifndef BTUI_HRH +#define BTUI_HRH + +enum TBTUIMenuCommands + { + EBTUICmdUndefined = 0, + EBTUICmdChangePowerStateMenu, + EBTUICmdChangePowerStateSelect, + EBTUICmdChangeVisibilityMenu, + EBTUICmdChangeVisibilitySelect, + EBTUICmdChangeBTNameMenu, + EBTUICmdChangeBTNameSelect, + EBTUICmdNewPairedDevice, + EBTUICmdDelete, + EBTUICmdDeleteAll, + EBTUICmdSetTrusted, + EBTUICmdSetUnTrusted, + EBTUICmdGiveNickname, + EBTUICmdConnect, + EBTUICmdConnectAudio, + EBTUICmdDisconnect, + EBTUICmdChangeSapStateMenu, + EBTUICmdChangeSapStateSelect, + EBTUICmdMSK, + EBTUICmdUnblock, + EBTUICmdUnblockAll, + EBTUIDeleteTabGroup, + EBTUICreateTabGroup, + EBTUICmdSetBlocked, + EBTUICmdSettings + }; + +enum TBTUITabViewId + { + EBTUIMainViewTab = 1, + EBTUIPairedDevicesViewTab, + EBTUIBlockedDevicesViewTab + }; + +enum TBTUINotes + { + EBTUIGeneralError = 100, + EBTUIPhoneVisibleToOthers, + EBTUIHiddenFromOthersNote, + EBTUINameAlreadyExists, + EBTUIInvalidLocalNameNote, + EBTUIDeviceSetAsUntrusted, + EBTUIWaitingForPairing, + EBTUIConnectingTo, + EBTUIDisconnectWired, + EBTUINotIncall, + EBTUIBtBusy, + EBTUIBtSapEnableNote + }; + +// This enum reflects the "r_bt_label_strings" in .rss file and must follow the same order. +// +enum TBTUIMainViewSettingFormatStrings + { + EBTUISettModulePowerOn, + EBTUISettModulePowerOff, + EBTUISettVisibilityModeGeneral, + EBTUISettVisibilityModeHidden, + EBTUISettVisibilityModeTemp, + + EBTUISettBTNameHeader, + EBTUISettSapEnabled, + EBTUISettSapDisabled + }; + +// Main list item indexes (see KNumberOfMainViewItems also) + +enum TBTMainListItemIndexes + { + EBTMainListItemPowerMode = 0, + EBTMainListItemVisibilityMode, + EBTMainListItemNameSetting, + EBTMainListItemSapMode, + + EBTMainListItemVisibilityTimeSetting + }; + +#ifdef __BT_SAP + #define KNumberOfMainViewItems 4 +#else + #define KNumberOfMainViewItems 3 +#endif + +// Maximum lengths of bluetooth device names +#define KBTUIMaxNameLength 30 // Series 60 local BT name +#define KBTUIMaxAliasLength 30 // Series 60 friendlyname/alias BT name +#define KBTUIMaxFormattedNameLength 270 // Localized header (icon indexes with tabs) + name + +#define btui_bitmap_file "Z:\\system\\data\\btui.mbm" +#define btui_bitmap_file_data_caging "Z:\\resource\\apps\\btui.mbm" + +#endif // BTUI + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/debug.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2006 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: Logging definition +* +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); +#endif + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); +#endif + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + User::Leave(aReason); + } + +inline void DebugPrintBDAddr(const TBTDevAddr& aAddr) + { + TBuf<16> addrdes; + aAddr.GetReadable(addrdes); + Trace(_L("[BTENG]\t BD addr %S") , &addrdes); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, KErrGeneral);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#define TRACE_BDADDR( a ) { if( KTraceMask & KPRINTINFO ) DebugPrintBDAddr(a); } + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE_IF_NULL(PTR) {static_cast(User::LeaveIfNull(PTR));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_STATIC_FUNC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} + +#define TRACE_BDADDR( a ) + +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/debugconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008 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: logging configure file. +* +*/ + + +#ifndef BTUI_DEBUGCONFIG_H +#define BTUI_DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"btuilog.txt"); +_LIT(KLogDir,"BT"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[BTUI] "); +_LIT8(KTracePrefix8, "[BTUI] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "BTUI"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // BTUI_DEBUGCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/inc/prjconfig.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2008 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: Project configure file. +* +*/ + + +#ifndef BTUI_PRJCONFIG_H +#define BTUI_PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // BTUI_PRJCONFIG_H diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/loc/btui.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/loc/btui.loc Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,528 @@ +/* +* Copyright (c) 2002 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: This is a localisation file for Bluetooth UI application. +* +*/ + + +// LOCALISATION STRINGS + +// Please note! Default class of device names are defined in "btnotif.loc". + + +// *** CAPTION STRINGS *** + +// d: BTUI application name on the application shell's app. list +// l: list_single_large_graphic_pane_t1 +// +#define qtn_apps_bluetooth_list "Bluetooth" + +// d: BTUI application name on the application shell's app. grid +// l: cell_app_pane_t1 +// +#define qtn_apps_bluetooth_grid "Bluetooth" + + +// *** TITLES *** + +// d: Status pane title for main view +// l: title_pane_t2/opt9 +// +#define qtn_bt_title_bluetooth "Bluetooth" + +// d: Status pane title for paired devices view +// l: title_pane_t2/opt9 +// +#define qtn_bt_title_paired_dev "Paired devices" + + +// *** MAIN VIEW SETTING ITEMS *** + +// d: The setting item title for bluetooth functionality (1st item) +// l: list_setting_pane_t1 +// +#define qtn_bt_sett_module "Bluetooth" + +// d: The setting item value when bluetooth functionality is enabled +// l: list_set_graphic_pane_t1 +// +#define qtn_bt_sett_on "On" + +// d: The setting item value when bluetooth functionality is disabled +// l: list_set_graphic_pane_t1 +// +#define qtn_bt_sett_off "Off" + +// d: The setting item title for phone's bluetooth visibility mode (2nd item) +// l: list_setting_pane_t1 +// +#define qtn_bt_sett_phone_visibility "My phone's visibility" + +// d: The setting item value visibility mode +// l: list_set_graphic_pane_t1 +// +#define qtn_bt_det_sett_general "Shown to all" + +// d: The setting item value visibility mode +// l: list_set_graphic_pane_t1 +// +#define qtn_bt_hidden "Hidden" + +// d: The setting item title for phones bluetooth name (3rd item) +// d: Also for the title of settings item editing window for phones bluetooth name +// l: list_setting_pane_t1 +// +#define qtn_bt_sett_bt_name "My bluetooth name" + +// d: The setting item title for SIM Access Profile (4th item) +// l: list_setting_pane_t1 +// +#define qtn_bt_sap "SIM Access Profile" + +// d: The setting item value when SIM Access Profile is enabled +// l: list_set_graphic_pane_t1 +// +#define qtn_bt_sap_enabled "Enabled" + +// d: The setting item value when SIM Access profile is disabled +// l: list_set_graphic_pane_t1 +// +#define qtn_bt_sap_disabled "Disabled" + +// *** EMPTY LISTS *** + +// d: Empty list text when there are no paired devices +// l: main_list_empty_pane +// +#define qtn_bt_no_paired_devices "(no paired devices)" + + +// *** MENU POPUP OPTIONS *** + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_change_value "Change" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_new_paired_device "New paired device" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_give_nickname "Assign short name" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_set_as_trusted "Set as authorised" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_set_as_untrusted "Set as unauthorised" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_delete "Delete" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_delete_all "Delete all" + +// d: Command in options list, and this text should inform user that only an audio connection can be established with this command. +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_connect "Connect to audio" + +// d: Command in options list, and this text should inform user that connection can be established with this command. +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_gen_connect "Connect" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_disconnect "Disconnect" + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// +#define qtn_bt_settings "Settings" + + +// *** QUERIES *** + +// d: Confirmation query if the value Enabled is selected when Bluetooth is off +// l: popup_note_window +// +#define qtn_bt_sap_enable_info "Enabling SIM Access Profile connection Bluetooth must be on" + +// d: Data query when user has opened BTUI (for first time) and +// d: there is no local Bluetooth name defined yet (empty name). +// l: popup_query_data_window +// +#define qtn_enter_bt_name "My Bluetooth name:" + +// d: Confirmation query to disable bluetooth functionality while there is still connections active. +// l: popup_note_window +// +#define qtn_bt_switch_off_anyway "Active Bluetooth connection. Switch off anyway?" + +// d: Confirmation query when Bluetooth needs to be activated in off-line mode. +// l: popup_note_window +// +#define qtn_bt_activate_in_offline "Do you want to activate bluetooth in off-line mode?" + +// d: Confirmation query when bluetooth functionality is off and user action (connect) cannot be performed. +// l: popup_note_window +// +#define qtn_bt_is_off "Bluetooth is currently switched off.\nSwitch on?" + +// d: Confirmation query when user has requested to remove pairing for bluetooth device concerned. +// l: popup_note_window +// +#define qtn_bt_warn_erase "Delete pairing with: %U" + +// d: Confirmation query when user has requested to remove pairing with connected Bluetooth device. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_warn_erase_connected "Deleting this pairing will disconnect %U" + +// d: Confirmation query when user has requested to remove all pairings. +// l: popup_note_window +// +#define qtn_bt_warn_erase_all "Delete all pairings?" + +// d: Confirmation query when user has requested to remove all pairings and +// some ( or only one ) of the devices are connected. +// l: popup_note_window +// +#define qtn_bt_warn_erase_all_connected "Delete all pairings? Some devices may be disconnected." + +// d: Data query when user has requested to change local friendlyname/nickname for bluetooth device concerned. +// l: popup_query_data_window +// +#define qtn_bt_enter_nickname "Short name:" + +// d: Confirmation query when user has requested to change Bluetooth device security to trusted. +// l: popup_note_window +// +#define qtn_bt_conf_aut "Connections will take place automatically without confirmation. Continue?" + +// d: Confirmation query when disconnecting BT Accessory. +// l: popup_note_window +// +#define qtn_bt_disconn_from "Disconnect from: %U" + + +// *** NOTES *** + +// d: Information note after the phone's visibility has changed to general. +// l: popup_note_window +// +#define qtn_bt_phone_visib_to_oth "Phone is detectable by all other devices." + +// d: Information note after the phone's visibility has changed to hidden. +// l: popup_note_window +// +#define qtn_bt_hidden_from_others "Phone is not detectable in searches made by other devices" + +// d: Error note after user has changed the local friendlyname/nickname and it conflicts with existing one +// l: popup_note_window +// +#define qtn_bt_name_exists "Short name already in use" + +// d: Confirmation note when user has requested to change Bluetooth device security to untrusted. +// l: popup_note_window +// +#define qtn_bt_dev_set_as_untrust "Device set as unauthorised. Connection requests will require confirmation." + +// d: Error note for situations which are not defined in UI specs. and user interaction cannot be completed. +// l: popup_note_window +// +#define qtn_bt_general_error "Unable to perform Bluetooth operation" + +// d: Wait note after "New paired device" is executed from paired devices view. +// d: %U contains device name. +// l: popup_note_wait_window +// +#define qtn_bt_waiting "Waiting for response from %U" + + +// d: Information note for disconnecting wired accessory +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_disconnect_wired "Disconnect wired accessory" + +// d: Wait note during connection establishment. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_wait_connecting_to "Connecting to %U" + +// d: Information note telling there's already an active BTAA connection. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_disconnect_first "Disconnect %U first" + +// d: Information note telling there's already an active BTAA connection with call ongoing. +// l: popup_note_window +// +#define qtn_bt_not_incall "Not possible during a call" + +// d: Information note if there is maximum number of connections and new one can not be created. +// l: popup_note_window +// +#define qtn_bt_busy "Maximum amount of Bluetooth connections in use. Can't establish a new one." + +// d: An information note when Bluetooth needs to be activated and it's disallowed in off-line mode. +// l: popup_note_window +// +#define qtn_bt_offline_disabled "Bluetooth can't activated in off-line mode" + +// d: Information note telling there's already an active BTAA connection. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_disconnect_first_stereo "Disconnect %0U device and %1U device first" + +// *** GLOBAL NOTES *** + +// d: Global Information note telling audio is routed to BT handsfree. +// l: popup_note_window +// +#define qtn_bt_audio_accessory "Audio routed to BT handsfree" + +// d: Global Information note for successful connection establishment. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_conf_connected "Connected to %U" + +// d: Global Information note for successful connection close. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_conf_disconnected "Disconnected from %U" + +// d: Global Information note for unsuccessful connection establishment. +// d: Reason: The audio device does not support Hands-Free Profile. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_hfp_not_supported "Hands-Free Profile not supported by %U" + +// d: Global Information note for unsuccessful connection establishment. +// d: Reason: The audio device does not support Bluetooth Hands-Free nor Headset Profile. +// d: %U contains device name. +// l: popup_note_window +// +#define qtn_bt_device_not_supported "Unsupported device: %U" + + +// VISIBILITY MODE OPTION + +//d:The setting item value of visibility mode (option item in radio box) +//l:list_set_graphic_pane_t1 +//w: +//r:3.1 +// +#define qtn_bt_set_visibility_time "Set visibility time" + +//d:The setting item value of visibility mode (shows in listbox after visibility timeout set) +//l:list_set_graphic_pane_t1 +//w: +//r:3.1 +// +#define qtn_bt_temp_visible "Temporarily visible" + + +// VISIBLILITY TIME SETTING SLIDER + +//d:Text in slider control head label +//d:visibility time-out setting page +//l:list_setting_pane_t1 +//w: +//r:3.1 +// +#define qtn_bt_slider_visibility_time "Visibility time" + +//d:Text in slider control slider's current value label +//d:visibility time-out setting page +//d:Current value when it's 1 minute +//l:list_set_graphic_pane_t1 + +//w: +//r:3.1 +// +#define qtn_bt_slider_singular "%U minute" + +//d:Text in slider control slider's current value label +//d:visibility time-out setting page +//d:Current value when it's > 1 minute +//l:list_set_graphic_pane_t1 +//w: +//r:3.1 +// +#define qtn_bt_slider_plural "%U minutes" + +//d:Text in slider control +//d:visibility time-out setting page +//d:Minimum value +//l:setting_slider_pane_t2 + +//w: +//r:3.1 +// +#define qtn_bt_slider_min "1 min" + +//d:Text in slider control +//d:visibility time-out setting page +//d:Maximum value +//l:setting_slider_pane_t2 + +//w: +//r:3.1 +// +#define qtn_bt_slider_max "60 min" + +//Blocked device view + +// d: Command in options list +// l: list_single_pane_t1_cp2 +// w: +// r: 3.2 +#define qtn_bt_block "Block" + +// d: Status pane title for blocked devices view +// l: title_pane_t2/opt9 + +// w: +// r: 3.2 +#define qtn_bt_title_blocked_devices "Blocked devices" + +// d: query header of the message queries about blocked devices +// l: heading_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_block_device_header "Block device?" + +// d: text of dialog asking about blocking a paired devices. +// l: popup_info_list_pane_t1 +// w: +// r:3.2 +#define qtn_bt_block_paired_device "Do you want to block all future connection attempts from paired device ?U? \nThis will delete your pairing with the device." + + +// d: text of dialog asking about blocking a paired devices. +// l: popup_info_list_pane_t1 +// w: +// r:3.2 +#define qtn_bt_block_connected_paired_devices "Do you want to block all future connection attempts from paired device ?U?\n This will disconnect the device and delete your pairing with it." + +// d: the link key to help in blocking queries. +// l: popup_info_list_pane_t1 +// w: +// r: 3.2 +#define qtn_bt_block_device_link "More Info" + +// d: the query text about deleting one blocking. +// l: popup_note_window +// w: +// r: 3.2 +#define qtn_bt_warn_erase_blocked "Delete blocked device\n%U?" + +// d: the query text about deleting all blockings +// l: popup_note_window +// w: +// r: 3.2 +#define qtn_bt_warn_erase_all_blocked "Delete all blocked devices?" + +// d: Empty list text when there are no blocked devices +// l: main_list_empty_pane +// w: +// r: 3.2 +#define qtn_bt_no_blocked_devices "(no blocked devices)" + +// d: Empty list primary text when there are no blocked devices +// l: main_pane_empty_t1/opt2 +// w: +// r: 3.2 +#define qtn_bt_empty_blocked_view_primary_text "(no blocked devices)" + +// d: Empty list secondary text when there are no blocked devices +// l: main_list_empty_pane/opt2 +// w: +// r: 3.2 +#define qtn_bt_empty_blocked_view_sedondary_text "Block devices only if you wish to ever receive connections from them." + +// *** For General Setting Application *** + +// *** Caption for General Setting Application *** +// d: BTUI Setting caption +// l: list_double_large_graphic_pane_t1 +// w: +// r: 3.1 +#define qtn_set_folder_bluetooth "Bluetooth" + +// d: Secondary status information of BT power, discoverability and connection +// l: list_double_large_graphic_pane_t2 +// w: +// r:5.0 +#define qtn_cp_detail_bt_off "Switched off" + +// d: Secondary status information +// l: list_double_large_graphic_pane_t2 +// w: +// r:5.0 +#define qtn_cp_detail_bt_on_shown "Enabled, shown to all" + +// d: Secondary status information +// l: list_double_large_graphic_pane_t2 +// w: +// r:5.0 +#define qtn_cp_detail_bt_on_hidden "Enabled, hidden" + +// d: Secondary status information +// l: list_double_large_graphic_pane_t2 +// w: +// r:5.0 +#define qtn_cp_detail_bt_conn_shown "Connected, shown to all" + +// d: Secondary status information +// l: list_double_large_graphic_pane_t2 +// w: +// r:5.0 +#define qtn_cp_detail_bt_conn_hidden "Connected, hidden" + +// *** Error code handling for SSP PasskeyEntry mode *** +// d: Warning Note if the passcode entered on the remote device doesn't match the one given on the local device (Passkey Entry mode). +// l: popup_note_window +// r: 5.1 +#define qtn_bt_simple_incorrect_passcode "Incorrect passcode" + +// d: Query gives the user an option to enter a passcode again (Passkey Entry mode). +// l: popup_note_window +// r: 5.1 +#define qtn_bt_simple_passcode_retry "Try again?" + +// End of File diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/rom/BtuiResources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/rom/BtuiResources.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef __BTUIRESOURCES_IBY__ +#define __BTUIRESOURCES_IBY__ + +#ifdef __BT +//Resource file(s) for BTUI application (BtUi.iby) +data=DATAZ_\APP_RESOURCE_DIR\BTUI.RSC APP_RESOURCE_DIR\Btui.rsc + +//View resource in Ecom plutin +data=DATAZ_\RESOURCE_FILES_DIR\BtuiViewResources.rsc RESOURCE_FILES_DIR\BtuiViewResources.rsc + +#endif //__BT +#endif //__BTUIRESOURCES_IBY__ diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/rom/btui.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/rom/btui.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef __BTUI_IBY__ +#define __BTUI_IBY__ + +#ifdef __BT + +// BTUI Application(EXE) +S60_APP_EXE(BtUi) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,BtUi) +S60_APP_AIF_ICONS(BtUi) +S60_APP_AIF_RSC(BtUi) + +// BTUI Model(DLL) +file=ABI_DIR\BUILD_DIR\btdevmodel.dll SHARED_LIB_DIR\btdevmodel.dll + +//ECOM plugin(Ecom DLL) +ECOM_PLUGIN( BtuiPlugin.dll, BtuiPlugin.rsc ) + +#endif //__BT + +#endif //__BTUI_IBY__ diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/src/BTUIApp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/src/BTUIApp.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2002-2007 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: This is the implementation of application class. + * +*/ + + +// INCLUDE FILES + +#include "btui.h" // Global declarations +#include "BTUIApp.h" +#include "BTUIDocument.h" + +// --------------------------------------------------------- +// CBTUIApp::AppDllUid() +// Returns application UID +// --------------------------------------------------------- +// +TUid CBTUIApp::AppDllUid() const + { + return KBtuiUid3; + } + +// --------------------------------------------------------- +// CBTUIApp::CreateDocumentL() +// Creates CBTUIDocument object +// --------------------------------------------------------- +// +CApaDocument* CBTUIApp::CreateDocumentL() + { + return CBTUIDocument::NewL( *this ); + } + +#include + +// --------------------------------------------------------- +// NewApplication() +// --------------------------------------------------------- +LOCAL_C CApaApplication* NewApplication() + { + return new CBTUIApp; + } +// --------------------------------------------------------- +// E32Main() +// --------------------------------------------------------- +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + + + + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/src/BTUIAppUi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/src/BTUIAppUi.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,214 @@ +/* +* Copyright (c) 2002-2007 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: This class the care of opening and closing the views. + * +*/ + + +// INCLUDE FILES +#include "BTUIDocument.h" +#include +#include "BTUIAppUi.h" +#include +#include +#include "BtuiPluginInterface.h" +#include "btui.h" +#include "BTUIMainView.h" +#include "debug.h" + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTUIAppUi::ConstructL +// +// Symbian 2nd phase constructor can leave. +// Contains status pane, navi pane, tab group and view +// creations and setting the main view active. +// ---------------------------------------------------------- +// +void CBTUIAppUi::ConstructL() + { + TRACE_FUNC_ENTRY + + BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible); + + // Show tabs for main views from resources + CEikStatusPane* sp = StatusPane(); + + // Fetch pointer to the default navi pane control + iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); + + // Tabgroup has been read from resource and it were pushed to the navi pane. + // Get pointer to the navigation decorator and set this to be a MAknTabObserver + iDecoratedTabGroup = iNaviPane->ResourceDecorator(); + + if (iDecoratedTabGroup) + { + iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl(); + iTabGroup->SetObserver( this ); + } + + // ----------------------------------------------------------------------- + // Construct Views by calling ECOM interface CBtuiPluginInterface's + // factory function NewL(), which in turn will call instantiation funtion + // of the concrate class that implement this interface. + // ----------------------------------------------------------------------- + + // 1.Construct Mainview + // + CBtuiPluginInterface* mainView = CBtuiPluginInterface::NewL(KBtuiPluginUidMainView,(MBtuiPluginViewActivationObserver*) this ); + + CleanupStack::PushL( mainView ); + AddViewL( mainView ); // Transfer ownership to CAknViewAppUi + CleanupStack::Pop(mainView ); + + // 2.Construct OtherDeviceView + // + CBtuiPluginInterface* otherDeviceView = CBtuiPluginInterface::NewL( + KBtuiPluginUidPairedDevicesView, (MBtuiPluginViewActivationObserver*) this ); + + CleanupStack::PushL( otherDeviceView ); + AddViewL( otherDeviceView ); // Transfer ownership to CAknViewAppUi + CleanupStack::Pop(otherDeviceView ); + + // 3.Construct BlockDeviceView + // + CBtuiPluginInterface* blockDeviceView = CBtuiPluginInterface::NewL( + KBtuiPluginUidBlockedDevicesView , (MBtuiPluginViewActivationObserver*) this ); + + CleanupStack::PushL( blockDeviceView ); + AddViewL( blockDeviceView ); // Transfer ownership to CAknViewAppUi + CleanupStack::Pop(blockDeviceView ); + + //ActivateLocalViewL( mainView->Id() ); + TRACE_FUNC_EXIT + } + +// ---------------------------------------------------- +// CBTUIAppUi::~CBTUIAppUi +// ---------------------------------------------------- +// +CBTUIAppUi::~CBTUIAppUi() + { + TRACE_FUNC_ENTRY + if(iNaviPane != NULL && iDecoratedTabGroup != NULL) + { + + delete iDecoratedTabGroup; // Tabgroup was read from resource. + iDecoratedTabGroup=NULL; + } + + REComSession::FinalClose(); + + TRACE_FUNC_EXIT + } + + +// ------------------------------------------------------------------------------ +// CBTUIAppUi::DynInitMenuPaneL +// +// This function is called by the UIKON framework just before it displays +// a menu pane. Its default implementation is empty, and by overriding it, +// the application can set the state of menu items dynamically according +// to the state of application data. +// ------------------------------------------------------------------------------ +// +void CBTUIAppUi::DynInitMenuPaneL( TInt /* aResourceId */, CEikMenuPane* /* aMenuPane */ ) + { + } + +// ---------------------------------------------------- +// CBTUIAppUi::HandleKeyEventL +// ---------------------------------------------------- +// + +TKeyResponse CBTUIAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) + { + TRACE_FUNC + + iTabGroup = (CAknTabGroup*)iDecoratedTabGroup->DecoratedControl(); + + // Event will not be handled, if: + // 1.It is not a key event. + // 2.No tab group be created yet. + // 3.Device's BT name hasn't been initialized by user yet. + // + if (aType != EEventKey || !iTabGroup ) + { + return EKeyWasNotConsumed; + } + + return iTabGroup->OfferKeyEventL(aKeyEvent, aType); + } + +// ---------------------------------------------------- +// CBTUIAppUi::HandleCommandL +// +// Handle user commands. All commands are handled via +// this routine. +// ---------------------------------------------------- +// +void CBTUIAppUi::HandleCommandL(TInt aCommand) + { + TRACE_INFO((_L("command = %d"), aCommand )) + + switch ( aCommand ) + { + case EAknCmdExit: + case EEikCmdExit: + { + Exit(); + break; + } + default: + { + break; + } + } + } +// ---------------------------------------------------- +// CBTUIAppUi::PluginViewActivated +// ---------------------------------------------------- +// +void CBTUIAppUi::PluginViewActivated(TPluginViewId aViewId) + + { + TRACE_INFO((_L("view id = %d"), aViewId )) + if(iTabGroup->ActiveTabId()!=aViewId) + { + iTabGroup->SetActiveTabById(aViewId); + } + } + +// ---------------------------------------------------- +// CBTUIAppUi::TabChangedL +// ---------------------------------------------------- +// +void CBTUIAppUi::TabChangedL(TInt aIndex) + { + TRACE_FUNC + switch (aIndex) + { + case 0: + ActivateLocalViewL(KBtuiPluginUidMainView); + break; + case 1: + ActivateLocalViewL(KBtuiPluginUidPairedDevicesView); + break; + case 2: + ActivateLocalViewL(KBtuiPluginUidBlockedDevicesView); + break; + } + } + diff -r 000000000000 -r f63038272f30 bluetoothengine/btui/src/BTUIDocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/src/BTUIDocument.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2002-2007 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: This is the implementation of document class. + * +*/ + + +// INCLUDE FILES + +#include "BTUIDocument.h" +#include "debug.h" +#include "BTUIAppUi.h" + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------- +// Destructor +// ---------------------------------------------------- +// +CBTUIDocument::~CBTUIDocument() + { + TRACE_FUNC + // delete iModel; + } + +// ---------------------------------------------------- +// Symbian OS default constructor can leave. +// ---------------------------------------------------- +// +void CBTUIDocument::ConstructL() + { + TRACE_FUNC + } + +// ---------------------------------------------------- +// Two-phased constructor +// ---------------------------------------------------- +// +CBTUIDocument* CBTUIDocument::NewL( CAknApplication& aApp ) // CBTUIApp reference + { + CBTUIDocument* self = new (ELeave) CBTUIDocument( aApp ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self); + + return self; + } + +// ---------------------------------------------------- +// CBTUIDocument::CreateAppUiL() +// constructs CBTUIAppUi +// ---------------------------------------------------- +// +CEikAppUi* CBTUIDocument::CreateAppUiL() + { + return new (ELeave) CBTUIAppUi; + } diff -r 000000000000 -r f63038272f30 bluetoothengine/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006 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: Build information file for project ?myapp +* +*/ + + +PRJ_PLATFORMS +DEFAULT + + +#include "../bteng/group/bld.inf" +#include "../btnotif/group/bld.inf" +#include "../btaudioman/group/bld.inf" +#include "../btmac/group/bld.inf" +#include "../btsac/group/bld.inf" +#include "../btaudiostreamer/group/bld.inf" +#include "../btsap/group/bld.inf" +#include "../btui/group/bld.inf" +#include "../btpbap/group/bld.inf" +#include "../bthid/group/bld.inf" +#include "../btctrldcmoadapter/group/bld.inf" + + +PRJ_EXPORTS + + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS diff -r 000000000000 -r f63038272f30 btservices_info/btservices_metadata/btservices_metadata.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_info/btservices_metadata/btservices_metadata.mrp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,6 @@ +component btservices_metadata +source \sf\mw\btservices\btservices_info\btservices_metadata +source \sf\mw\btservices\package_definition.xml +source \sf\mw\btservices\distribution.policy.s60 +notes_source \component_defs\release.src +ipr T diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dosserver_audio_api/bluetooth_dosserver_audio_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dosserver_audio_api/bluetooth_dosserver_audio_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth DosServer Audio API + Used for Bluetooth audio routing via the DosServer. The API is deprecated wherever the Accessory Framework is in place. + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dosserver_audio_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dosserver_audio_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth DosServer Audio API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btaudio4dosdomainpskeys.h MW_LAYER_PLATFORM_EXPORT_PATH(btaudio4dosdomainpskeys.h) +../inc/btaudio4dos.inl MW_LAYER_PLATFORM_EXPORT_PATH(btaudio4dos.inl) +../inc/btaudio4dos.h MW_LAYER_PLATFORM_EXPORT_PATH(btaudio4dos.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dosserver_audio_api/inc/btaudio4dos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dosserver_audio_api/inc/btaudio4dos.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine ECom plug-in interface for DosServer audio routing. +* +*/ + + + +#ifndef BT_AUDIO_FOR_DOSSERVER_H +#define BT_AUDIO_FOR_DOSSERVER_H + +#include + +const TUid KBTAudio4DosInterfaceUid = { 0x1020896B }; + +/** + * Bluetooth Audio API when DosServer is in use. + * + * This is the base class from which a BT DosServer audio ECom plug-in inherit. + * The BT DosServer audio plug-in is only needed when old DosServer is in use. + * Since S60 3.1, the Accessory Framework is replacing the DosServer and + * taking care of BT audio routing. The API is deprecated whenever the Accessory + * Framwork is in place. + * + * @since S60 v3.2 + */ +class CBTAudio4Dos : public CBase + { + +public: + + /** + * Constructor; loads the plug-in through the ECom framework. + * + * @param aImplementationUid a UID specifying the required interface implementation + * @return an intance of CBTAudio4Dos + */ + static CBTAudio4Dos* NewL(TUid aImplementationUid); + + /** + * Destructor; destroys the plug-in through the ECom framework. + */ + virtual ~CBTAudio4Dos(); + + /** + * Routes Audio to phone. + * @return a completion error code + */ + virtual TInt AudioToPhone() = 0; + + /** + * Routes Audio to accessory. + * @param aStatus On completion, will contain an error code + */ + virtual void AudioToAccessory(TRequestStatus& aStatus) = 0; + + /** + * Cancel Audio routing to accessory request. + */ + virtual void CancelAudioToAccessory() = 0; + +private: + + /** + * UID set by ECOM when the instance is created. + * Used when the instance is destroyed. + */ + TUid iInstanceUid; + }; + +#include + +#endif + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dosserver_audio_api/inc/btaudio4dos.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dosserver_audio_api/inc/btaudio4dos.inl Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine ECom plug-in interface for DosServer audio routing. +* +*/ + + +#include + +inline CBTAudio4Dos* CBTAudio4Dos::NewL(TUid aImplementationUid) + { + CBTAudio4Dos* self = reinterpret_cast( + REComSession::CreateImplementationL( + aImplementationUid, _FOFF(CBTAudio4Dos, iInstanceUid)) + ); + return self; + } + +inline CBTAudio4Dos::~CBTAudio4Dos() + { + REComSession::DestroyedImplementation(iInstanceUid); + } + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dosserver_audio_api/inc/btaudio4dosdomainpskeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dosserver_audio_api/inc/btaudio4dosdomainpskeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2007 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: Bluetooth accessory connection state P&S key definition +* This is only for non- Accessory Framework build since A3.2 +* +*/ + + +#ifndef BTAUDIO4DOS_DOMAINPSKEYS_H +#define BTAUDIO4DOS_DOMAINPSKEYS_H + +/** +* Notice that the keys declared in this header are ONLY for Dos Server version build since A3.2 release. +* The keys are not available at runtime in Accessory Framework version. +* +* In Dos Server build, the keys are defined when Bluetooth power is ON and deleted when +* Bluetooth power is OFF. +*/ + +// PubSub Uid of BTAAC state +const TUid KPSUidBluetoothAudioAccessoryState = { 0x101FFE49 }; + +// Key1 : Bluetooth HW address of the connected BTAA (string value) +// No connected BT audio accessory if this key is not defined or the value is "", +// otherwise, it contains the readable BT address of audio accessory +// +const TUint KBtaaAddress = 0x00000001; + +// Key2 : Is a BTAA (BT Audio Accessory) connected and does it support remote volume control. +// No connected BT audio accessory if this key is not defined. +const TUint KBtaacConnected = 0x00000002; + +// Possible integer values for key KBtaacConnected +enum TBtaaConnectionStatus + { + EBTaacNoAudioAccConnected, + EBTaacRemoteVolCtrlCapableAccConnected, + EBTaacRemoteVolCtrlIncapableAccConnected, + EBTaacAccTemporarilyDisconnected, + EBTaacAccTemporarilyUnavailable + }; + +#endif + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dut_mode_api/bluetooth_dut_mode_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dut_mode_api/bluetooth_dut_mode_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth DUT Mode API + defines a P&S key for setting Device Under Test mode, and a P&S key for setting Secure Simple Pairing debug mode + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dut_mode_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dut_mode_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth DUT Mode API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengdomainpskeys.h MW_LAYER_PLATFORM_EXPORT_PATH(btengdomainpskeys.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_dut_mode_api/inc/btengdomainpskeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_dut_mode_api/inc/btengdomainpskeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2006-2008 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: Bluetooth Engine domain publish & subscribe key definitions. +* +*/ + + +#ifndef BTENG_DOMAIN_PS_KEYS_H +#define BTENG_DOMAIN_PS_KEYS_H + +const TUint32 KBTBluetoothTestingMode = 0x101FFE48; + +/** Bluetooth Testing mode publish and subscribe UID */ +const TUid KPSUidBluetoothTestingMode = {KBTBluetoothTestingMode}; + +/** Bluetooth DUT mode - deprecated and replaced by Bluetooth Testing mode */ +const TUid KPSUidBluetoothDutMode = {KBTBluetoothTestingMode}; + + +/** + * Publish and Subscribe key defining the Bluetooth + * Device Under Test mode. + * + * Possible integer values: + * 0 Device not in test mode + * 1 Device in test mode + * + * Default value: 0 + */ +const TUint KBTDutEnabled = 0x01; + + +/** Enumeration for Bluetooth Device Under Test mode */ +enum TBTDutModeValue + { + EBTDutOff, + EBTDutOn + }; + + +/** + * Publish and Subscribe key defining the Bluetooth + * Secure Simple Pairing debug mode. + * + * Possible integer values: + * 0 Device not in debug mode + * 1 Device in debug mode + * + * Default value: 0 + */ +const TUint KBTSspDebugmode = 0x02; + + +/** Enumeration for Bluetooth Device Under Test mode */ +enum TBTSspDebugModeValue + { + EBTSspDebugModeOff, + EBTSspDebugModeOn + }; + + +#endif // BTENG_DOMAIN_PS_KEYS_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_api/bluetooth_engine_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_api/bluetooth_engine_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,21 @@ + + + Bluetooth Engine API + High level Bluetooth API on top of Symbian BT APIs + c++ + bluetoothengine + + + + + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengconstants.h MW_LAYER_PLATFORM_EXPORT_PATH(btengconstants.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_api/inc/btengconstants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_api/inc/btengconstants.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2006 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: Definitions of Bluetooth Engine constant. +* +*/ + + +#ifndef BTENCONSTANTS_H +#define BTENCONSTANTS_H + + +/** Connect status of the service-level connection. */ +enum TBTEngConnectionStatus + { + EBTEngNotConnected, + EBTEngConnecting, + EBTEngConnected, + EBTEngDisconnecting + }; + + +/** Type of disconnect operation for the service-level connection. */ +enum TBTDisconnectType + { + EBTDiscImmediate, + EBTDiscGraceful + }; + + +/** Enumeration for Bluetooth visibility mode */ +enum TBTVisibilityMode + { + EBTVisibilityModeNoScans = 0x00, //will be used when turning off BT/power off phone + EBTVisibilityModeInquiryScanOnly = 0x01, + EBTVisibilityModeHidden = 0x02, + EBTVisibilityModeGeneral = 0x03, + EBTVisibilityModeTemporary = 0x100 + }; + + +/** Enumeration for Bluetooth profiles */ +enum TBTProfile + { + EBTProfileUndefined = 0x0, + EBTProfileDUN = 0x1103, + EBTProfileOPP = 0x1105, + EBTProfileFTP = 0x1106, + EBTProfileHSP = 0x1108, + EBTProfileA2DP = 0x110D, + EBTProfileAVRCP = 0x110E, + EBTProfileFAX = 0x1111, + EBTProfilePANU = 0x1115, + EBTProfileNAP = 0x1116, + EBTProfileGN = 0x1117, + EBTProfileBIP = 0x111A, + EBTProfileHFP = 0x111E, + EBTProfileBPP = 0x1122, + EBTProfileHID = 0x1124, + EBTProfileSAP = 0x112D, + EBTProfilePBAP = 0x1130, + EBTProfileDI = 0x1200 + }; + +/** + * Bits of UI cookie identifiers of a TBTNamelessDevice in BT registry + */ +enum TBTDeviceUiCookie + { + // invalid UI cookie + EBTUiCookieUndefined = 0x0, + + // this device is paired with Just Works model under user's awareness. + // + // The purpose of this bit is for the paired device view of + // Bluetooth application to show devices that have been paired with + // Just Works model under user's awareness. + // + // Pairing device from Bluetooth application is a user aware bonding. + // Another example is connecting to HFP of a not-paired v2.1 headset via + // BluetoothEngine API during which pairing is performed due to the + // security setting of HFP AG. + // Just-Works pairing due to service connection request from a v2.1 device without + // IO capability is not considered as a user aware pairing. + // + EBTUiCookieJustWorksPaired = 0x01 + }; + +#endif // BTENCONSTANTS_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_connection_management_api/bluetooth_engine_connection_management_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_connection_management_api/bluetooth_engine_connection_management_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,18 @@ + + + Bluetooth Engine Connection Management API + for managing connections with remote BT devices + c++ + bluetoothengine + + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_connection_management_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_connection_management_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine Connection Management API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengconnman.h MW_LAYER_PLATFORM_EXPORT_PATH(btengconnman.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_connection_management_api/inc/btengconnman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_connection_management_api/inc/btengconnman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,467 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine API for connection management functionality. +* +*/ + + +#ifndef BTENGCONNMAN_H +#define BTENGCONNMAN_H + +#include +#include + +class CBTEngConnHandler; + +/** + * Class MBTEngConnObserver + * + * Callback class for receiving CBTEngConnMan + * connect/disconnect complete events. + * + * @lib btengdevman.dll + * @since S60 V3.0 + */ +class MBTEngConnObserver + { + +public: + + /** + * Indicates to the caller that a service-level connection has completed. + * This function is called for both incoming and outgoing connections. + * This function is also called when an outgoing connection request fails, + * e.g. with error code KErrCouldNotConnect. + * When this function is called, new commands can be issued to the + * CBTEngConnMan API immediately. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device. + * @param aErr Status information of the connection. KErrNone if the + * connection succeeded, otherwise the error code with + * which the outgoing connection failed. KErrAlreadyExists + * is returned if there already is an existing connection + * for the selected profile(s), or otherwise e.g. + * KErrCouldNotConnect or KErrDisconnected for indicating + * connection problems. + * @param aConflicts If there already is a connection for the selected + * profile(s) of an outgoing connection request (the + * selection is performed by BTEng), then this array + * contains the bluetooth device addresses of the + * remote devices for those connections. + */ + virtual void ConnectComplete( TBTDevAddr& aAddr, TInt aErr, + RBTDevAddrArray* aConflicts = NULL ) = 0; + + /** + * Indicates to the caller that a service-level connection has disconnected. + * When this function is called, new commands can be issued to the + * CBTEngConnMan API immediately. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device. + * @param aErr The error code with which the disconnection occured. + * KErrNone for a normal disconnection, + * or e.g. KErrDisconnected if the connection was lost. + */ + virtual void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr ) = 0; + + /** + * Indicates to the caller that a pairing procedure has been completed. + * When this function is called, new commands can be issued to the + * CBTEngConnMan API immediately. + * A default implementation (that does nothing) of this method exists. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device. + * @param aErr The error code indicating the result of the pairing + * procedure; KErrNone for a normal disconnection, or + * e.g. KErrCancel if the user cancelled the pairing dialog. + */ + virtual void PairingComplete( TBTDevAddr& aAddr, TInt aErr ); + + }; + + +/** + * Class CBTEngConnMan + * + * This class provides functionality for Bluetooth connection management + * on profile-level. The class mainly forwards the commands to BTEng server + * side, which passes the commands to its plug-ins which handle the + * profile-level (service-level) connection management. + * + * Connection management commands are asynchronous, and the result is passed + * back to the caller through the MBTEngConnObserver callback interface. + * Multiple commands can be outstanding simultaneously. + * + * @lib btengconnman.lib + * @since S60 v3.2 + */ +class CBTEngConnMan : public CBase + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives + * connection events (see also SetObserver below). + * @return Pointer to the constructed CBTEngConnMan object. + */ + IMPORT_C static CBTEngConnMan* NewL( MBTEngConnObserver* aObserver = NULL ); + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives + * connection events (see also SetObserver below). + * @return Pointer to the constructed CBTEngConnMan object. + */ + IMPORT_C static CBTEngConnMan* NewLC( MBTEngConnObserver* aObserver = NULL ); + + /** + * Destructor + */ + virtual ~CBTEngConnMan(); + + /** + * Create a service-level connection to the specified Bluetooth address. + * The decision which profile to use for the service-level connection is + * taken by BTEng, based on the parameters that are part of the address + * structure passed as argument. + * + * This is an asynchronous operation; on completion, the caller is + * informed through MBTEngConnObserver::ConnectComplete with the + * appropriate error code. + * + * + * @since S60 v3.2 + * @param aAddr The Bluetooth address of the remote device. + * @param aDeviceClass The device class of the remote device. This will + * be used to select the correct plug-in for creating + * the service-level connection. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt Connect( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass ); + + /** + * Cancels the creation of a service-level connection to the specified + * Bluetooth address. + * + * This is part of an asynchronous operation; on completion, the caller + * is informed through MBTEngConnObserver::ConnectComplete with error + * code with KErrCancel if successfully canceled, or KErrNotFound if no + * service-level connection with the specified Bluetooth address existed. + * + * @since S60 v3.2 + * @param aAddr The Bluetooth address of the remote device. + */ + IMPORT_C void CancelConnect( const TBTDevAddr& aAddr ); + + /** + * Disconnects the creation of a service-level connection with the + * specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the caller is + * informed through MBTEngConnObserver::DisconnectComplete with the + * appropriate error code. + * + * @since S60 v3.2 + * @param aAddr The Bluetooth address of the remote device. + * @param aDiscType The type of disconnection; + * EGraceful for graceful (normal) disconnection, + * EImmediate for immediate (forced) disconnection. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType aDiscType ); + + /** + * Checks whether there is a service-level connection to the specified + * Bluetooth device. + * + * @since S60 v3.2 + * @param aAddr The Bluetooth address of the remote device. + * @param aConnected On return, holds the connection status for the + * specified address; ENotConnected if no connection + * exists, EConnecting if a (service-level) connection + * is being established, EConnected if a service-level + * connection exists, and EDisconnecting if a + * service-level connection is being disconnected. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt IsConnected( const TBTDevAddr& aAddr, + TBTEngConnectionStatus& aConnected ); + + /** + * Checks whether a service-level connection can be created to a device + * that advertises the specified Class of Device. + * Note that this only indicate that a suitable profile plug-in is + * currently loaded by BTEng, it does does not indicate that a connection + * would succeed (e.g. the device may refuse the connection or could be + * out of range). + * + * @since S60 v3.2 + * @param aConnectable On return, contains the value for indicating + * whether the device is connectable: + * ETrue if the device is connectable, EFalse if not. + * @param aDeviceClass The device class of the remote device. This will + * be used to determine whether the device is + * connectable or not. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt IsConnectable( const TBTDeviceClass& aDeviceClass, + TBool& aConnectable ); + + /** + * Subscribes to service-level connection events. This will replace any + * previoously registered callback interface object. The observer is + * informed of connection events through the MBTEngConnObserver + * callback interface. + * Note: the observer is only notified of events related to service-level + * connections. Generic notifications about Bluetooth baseband events can + * be obtained through bluetooth.lib. + * + * An observer must be set before issueing any connection-related commands. + * + * @since S60 v3.2 + * @param aObserver The callback interface through which connection + * events are passed back. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt SetObserver( MBTEngConnObserver* aObserver ); + + /** + * Removes the subscription to service-level connection events. + * Note: this functionality is implicit when destroying CBTConnMan. + * + * @since S60 v3.2 + */ + IMPORT_C void RemoveObserver(); + + /** + * Gets the remote addresses for all the open Bluetooth connections. + * These include all baseband connections, so also connections for + * which no service-level connection is handled by BTEng profile plug-ins. + * + * @since S60 v3.2 + * @param aAddrArray On return, holds the Bluetooth device addresses of + * all the connected Bluetooth devices. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt GetConnectedAddresses( RBTDevAddrArray& aAddrArray ); + + /** + * Gets the remote addresses for all the open Bluetooth connections + * for the specified profile. + * + * @since S60 v3.2 + * @param aAddrArray On return, holds the Bluetooth device addresses + * of the connected Bluetooth devices for the + * requested profile. + * @param aConnectedProfile The profile for which the existing + * connections are requested. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt GetConnectedAddresses( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ); + + /** + * Start a pairing (a.k.a. bonding) operation with a remote + * Bluetooth device. This will launch an authentication dialog + * as part of the pairing procedure (Except Just Works pairing). + * Since S60 5.1, a confirmation note will be shown + * indicating whether pairing succeeded when pairing completes; + * and user will be queried if he/she wants to set the device as + * trusted if the device has been paired. This operation + * finally completes when user answers the query or pairing failed + * confirmation has been shown. + * + * This is an asynchronous operation; on completion, the caller is + * informed through MBTEngConnObserver::PairingComplete with the + * appropriate error code. + * + * Note: this method is intended for operations that only include + * pairing, and no connection establishment. When requiring + * authentication/encryption on a Bluetooth link, the preferred method + * is to pass the security requirements through the TBTSockAddr structure. + * + * @since S60 v3.2 + * @param aDevice The address of the remote device to perform pairing with. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt PairDevice( const TBTDevAddr& aAddr ); + /** + * Start a pairing (a.k.a. bonding) operation with a remote + * Bluetooth device. This will launch an authentication dialog + * as part of the pairing procedure (Except Just Works pairing). + * Or in case of audio headset whose version is earlier than BT v2.1,and if + * the auto-pairing feature is supported, the PIN query is not shown but + * the default PIN (0000) is given automatically. If that fails the PIN query + * is shown normally. + * Since S60 5.1, a confirmation note will be shown + * indicating whether pairing succeeded when pairing completes; + * and user will be queried if he/she wants to set the device as + * trusted if the device has been paired. This operation + * finally completes when user answers the query or pairing failed + * confirmation has been shown. + * + * This is an asynchronous operation; on completion, the caller is + * informed through MBTEngConnObserver::PairingComplete with the + * appropriate error code. + * + * Note: this method is intended for operations that only include + * pairing, and no connection establishment. When requiring + * authentication/encryption on a Bluetooth link, the preferred method + * is to pass the security requirements through the TBTSockAddr structure. + * + * @since S60 v3.2 + * @param aDevice The address of the remote device to perform pairing with. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt PairDevice( const TBTDevAddr& aAddr, TBTDeviceClass aDeviceClass ); + + /** + * Cancels an ongoing pairing with a Bluetooth device. If + * this function is issued after the device has been + * actually paired, the device will not be un-paired. + * + * @since S60 v3.2 + */ + IMPORT_C void CancelPairDevice(); + + /** + * Listen to the result of a pairing operation, and launch + * the authorization notifier if successful. + * Note: this method is for usage of BTNotif only. The authorization + * notifier is called independently i.e. there is no callback resulting + * from calling this function. + * This function requires LocalServices and WriteDeviceData capabilities. + * + * @since S60 v5.1 + * @param aDevice The remote device with which pairing is performed. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C static TInt StartPairingObserver( const TBTDevAddr& aAddr ); + + /** + * Prepares any existing Bluetooth connection topology for performing + * device discovery. As a result of this call, the server will request + * the master role on each existing connection. + * Note: this method is for usage of BTNotif only. It attempts to + * optimize the existing topology so therefore there is no result to + * be informed. The functionality is only executed after this function + * has returned. + * + * @since S60 v3.2 + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C void PrepareDiscovery(); + + /** + * Stop handling the result of a pairing operation. + * Note: this method is for usage of BTNotif only. The authorization + * notifier is called independently i.e. there is no callback resulting + * from calling this function. + * This function requires LocalServices and WriteDeviceData capabilities. + * + * @since S60 v5.1 + * @param aDevice The remote device with which pairing is performed. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C static TInt StopPairingObserver( const TBTDevAddr& aAddr ); + + /** + * Checks whether a service-level connection can be created to a device + * that advertises the specified Class of Device. + * Note that this only indicate that a suitable profile plug-in is + * currently loaded by BTEng, it does does not indicate that a connection + * would succeed (e.g. the device may refuse the connection or could be + * out of range). + * + * @since S60 v5.1 + * @param aAddr The address of the remote device. This will be used to + * get service UUIDs in EIR data to determine whether the + * device is connectable or not. + * @param aConnectable On return, contains the value for indicating + * whether the device is connectable: + * ETrue if the device is connectable, EFalse if not. + * @param aDeviceClass The device class of the remote device. This will + * be used to determine whether the device is + * connectable or not. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt IsConnectable( const TBTDevAddr& aAddr, + const TBTDeviceClass& aDeviceClass, TBool& aConnectable ); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives + * connection events. + */ + CBTEngConnMan( MBTEngConnObserver* aObserver ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + +private: // data + + /** + * Handle to BTEng server side and listener to connection events. + * Own. + */ + CBTEngConnHandler* iConnHandler; + + /** + * This field is NOT used. Reserved for future extension. + * Own. + */ + TAny* iReserved; + + /** + * Reference to receiver of connection events. + * Not own. + */ + MBTEngConnObserver* iObserver; + + + }; + + +#endif // BTENGCONNMAN_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_device_management_api/bluetooth_engine_device_management_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_device_management_api/bluetooth_engine_device_management_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,18 @@ + + + Bluetooth Engine Device Management API + for adding, removing, updating used devices information in the Bluetooth Registry database. + c++ + bluetoothengine + + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_device_management_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_device_management_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine Device Management API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengdevman.h MW_LAYER_PLATFORM_EXPORT_PATH(btengdevman.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_device_management_api/inc/btengdevman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_device_management_api/inc/btengdevman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2006 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: The Bluetooth Engine Device Management API +* +*/ + + +#ifndef BTENGDEVMAN_H +#define BTENGDEVMAN_H + +#include + + +/** + * Class MBTEngDevManObserver + * + * Mix-in class for calling back to CBTEngDevMan observer when + * device handling has completed. + * + * @lib btengdevman.dll + * @since S60 V3.0 + */ +class MBTEngDevManObserver + { + +public: + + /** + * Indicates to the caller that adding, deleting or modifying a device + * has completed. + * When this function is called, new commands can be issued to the + * CBTEngDevMan API immediately. + * + * @since S60 v3.2 + * @param aErr Status information, if there is an error. + */ + IMPORT_C virtual void HandleDevManComplete( TInt aErr ); + + /** + * Indicates to the caller that getting an array of devices has completed. + * When this function is called, new commands can be issued to the + * CBTEngDevMan API immediately. + * + * @since S60 v3.0 + * @param aErr Status information, if there is an error. + * @param aDeviceArray Array of devices that match the given criteria + * (the array provided by the calller). + */ + IMPORT_C virtual void HandleGetDevicesComplete( TInt aErr, + CBTDeviceArray* aDeviceArray ); + + }; + + +/** + * Class CBTEngDevMan + * + * This is a helper class that simplifies the usage + * of Symbian's BT Device Registry interface. + * + * @lib btengdevman.dll + * @since S60 v3.0 + */ +class CBTEngDevMan : public CActive + { + +public: + + /** States enumeration */ + enum TState + { + EStateIdle, + EStateAddDevice, + EStateGetDevices, + EStateModifyDevice, + EStateDeleteDevices + }; + + /** Substates enumeration for modifying device parameters */ + enum TModifyState + { + ECheckNone, + ECheckPairing, + ECheckDevName, + ECheckFriendlyName, + ECheckNameless, + ECheckFinal + }; + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface for informing + * the result of the operation. If NULL, the GetDevices + * operation will operate syncrhonously; the other + * operations are then not available. + * @return Pointer to the constructed CBTEngDevMan object. + */ + IMPORT_C static CBTEngDevMan* NewL( MBTEngDevManObserver* aObserver ); + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface for informing + * the result of the operation. If NULL, the GetDevices + * operation will operate syncrhonously; the other + * operations are then not available. + * @return Pointer to the constructed CBTEngDevMan object. + */ + IMPORT_C static CBTEngDevMan* NewLC( MBTEngDevManObserver* aObserver ); + + /** + * Destructor + */ + virtual ~CBTEngDevMan(); + + /** + * Add a device into the Bluetooth device registry. + * + * @since S60 v3.0 + * @param aDevice Device to be added. + * @return KErrNone if the request was succesful, + * KErrBusy if there is already an ongoing request or + * another error code in case of failure. + */ + IMPORT_C TInt AddDevice( const CBTDevice& aDevice ); + + /** + * Get an array of devices that match the search pattern + * from the registry. + * If no callback interface has been passed during construction, + * this function will complete synchronously. + * + * @since S60 v3.0 + * @param aCriteria Search criteria for the devices to be returned. + * @param aDevice Array owned by the client in which the result + * will be returned. Ownership is not transferred, + * so his pointer must remain valid until the callback + * is made (for the asyncronous version). If no callback + * interface has been supplied, the array will contain the + * results, if any. + * @return KErrNone if the request was succesful, + * KErrBusy if there is already an ongoing request or + * another error code in case of failure. + */ + IMPORT_C TInt GetDevices( const TBTRegistrySearch& aCriteria, + CBTDeviceArray* aResultArray ); + + /** + * Delete one or more devices that match the search pattern from the + * registry. + * + * @since S60 v3.0 + * @param aCriteria Search criteria for the devices to be deleted. + * @return KErrNone if the request was succesful, + * KErrBusy if there is already an ongoing request or + * another error code in case of failure. + */ + IMPORT_C TInt DeleteDevices( const TBTRegistrySearch& aCriteria ); + + /** + * Modify a device in the Bluetooth device registry. + * + * @since S60 v3.2 + * @param aDevice Device to be modifed. + * @return KErrNone if the request was succesful, + * KErrBusy if there is already an ongoing request or + * another error code in case of failure. + */ + IMPORT_C TInt ModifyDevice( const CBTDevice& aDevice ); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.0 + * @param aObserver Pointer to callback interface for informing + * the result of the operation. + */ + CBTEngDevMan( MBTEngDevManObserver* aObserver ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.0 + */ + void ConstructL(); + +// from base class CActive + + /** + * When the Active Object completes succesfully, the callback is called + * with the return value. + * + * @since S60 v3.0 + */ + void RunL(); + + /** + * If an error occurs, the callback is called with the error code. + * + * @since S60 v3.0 + */ + TInt RunError( TInt aError ); + + /** + * Cancel current outstanding operation, if any. + * + * @since S60 v3.0 + */ + void DoCancel(); + + /** + * Processes the result of a registry search. + * + * @since S60 v3.0 + */ + void DoModifyDeviceL(); + +private: // data + + /** + * Keeps track of the current state. + */ + TState iState; + + /** + * Keeps track of sequence of modifications. + */ + TModifyState iModifyState; + + /** + * Used to mark when a view is being created. + */ + TBool iCreatingView; + + /** + * Registry access session. + */ + RBTRegServ iRegServ; + + /** + * Subsession on the BT Registry Server. + */ + RBTRegistry iRegistry; + + /** + * Holds the response from the registry query. + * Own. + */ + CBTRegistryResponse* iResponse; + + /** + * Reference to modified device to be stored in registry. + * own. + */ + CBTDevice* iModifiedDevice; + + /** + * Nested active scheduler loop for synchronous GetDevice operation. + * own. + */ + CActiveSchedulerWait* iAsyncWaiter; + + /** + * Reference to the device array in which the results will be stored. + * Not own. + */ + CBTDeviceArray* iResultArray; + + /** + * Observer class which implements the method that is called when the + * request is completed. + * Not own. + */ + MBTEngDevManObserver* iObserver; + + }; + +#endif // BTENGDEVMAN_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_discovery_api/bluetooth_engine_discovery_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_discovery_api/bluetooth_engine_discovery_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,18 @@ + + + Bluetooth Engine Discovery API + for searching remote devices and discovering their services. + c++ + bluetoothengine + + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_discovery_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_discovery_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine Discovery API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengdiscovery.h MW_LAYER_PLATFORM_EXPORT_PATH(btengdiscovery.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_discovery_api/inc/btengdiscovery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_discovery_api/inc/btengdiscovery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,599 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine API for remote device and service discovery +* and local SDP database functionality. +* +*/ + + +#ifndef BTENGDISCOVERY_H +#define BTENGDISCOVERY_H + +#include +#include + +class CBTEngSdpDbHandler; +class CBTEngSdpQuery; +class CBTEngDeviceSearch; +class TBTEngSdpAttrValue; + +/** Array definition for storing SDP record handles */ +typedef RArray RSdpRecHandleArray; + +/** Array definition for storing SDP attribute values */ +typedef RArray RSdpResultArray; + + +/** + * class TBTEngSdpResult + * + * Data structure for passing SDP results to the client. + * + * @lib btengdiscovery.lib + * @since S60 v3.2 + */ +class TBTEngSdpAttrValue + { + +public: + + /** + * Data structure containing the SDP attribute value. + * Note: the member varaible containing the data is dependent + * on the data type attribute of the parent class. + */ + class TSdpAttrValue + { + + public: + + /** + * Numeric value (0 if the attribute is non-numeric). + */ + TInt iValNumeric; + + /** + * String value (empty if the attribute is numeric). + */ + TPtrC8 iValString; + + }; + +public: // data + + /** + * Attribute identifier of this attribute. + */ + TSdpAttributeID iAttrId; + + /** + * Attribute type of this attribute. + */ + TSdpElementType iAttrType; + + /** + * Attribute value of this attribute. + */ + TSdpAttrValue iAttrValue; + + }; + + +/** + * Class CBTEngDiscovery + * + * Callback interface for receiving results from queries + * of remote SDP databases. + * Clients that make SDP queries through CBTEngDiscovery + * must implement this interface to handle the results. + * + * @lib btengdiscovery.lib + * @since S60 v3.2 + */ +class MBTEngSdpResultReceiver + { + +public: + + /** + * Provides notification of the result of a service search that matches + * the requested UUID (through CBTEngDiscovery::RemoteSdpQuery). + * This method indicates that the search has completed, and returns + * all the results to the caller at once. + * + * @since S60 v3.2 + * @param aResult Array of record handles that match the requested UUID. + * Note: the array will not be available anymore after + * this method returns. + * @param aTotalRecordsCount The total number of records returned. + * @param aErr Error code of the service search operation; KErrNone if + * sucessful, KErrEof if no record matched the requested UUID, + * KErrCouldNotConnect and KErrCouldDisconnected in case of + * Bluetooth connection errors; otherwise one of the + * system-wide error codes. + */ + virtual void ServiceSearchComplete( const RSdpRecHandleArray& aResult, + TUint aTotalRecordsCount, TInt aErr ) = 0; + + /** + * Provides notification of the result of an attribute search that matches + * the requested attribute (through CBTEngDiscovery::RemoteSdpQuery). + * This method indicates that the search has completed, and returns + * all the results to the caller at once. + * + * @since S60 v3.2 + * @param aHandle Record handle of the service record containing the result. + * @param aAttr Array containing the attribute that matches the + * requested attribute. + * Note: the array will not be available anymore after + * this method returns. + * @param aErr Error code of the service search operation; KErrNone if + * sucessful, KErrEof if the requested attribute was not + * contained in the specified service record, + * KErrCouldNotConnect and KErrCouldDisconnected in case of + * Bluetooth connection errors; otherwise one of the + * system-wide error codes. + */ + virtual void AttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ) = 0; + + /** + * Provides notification of the result of an combination of a service + * and attribute search (through CBTEngDiscovery::RemoteSdpQuery). + * This method is called for each service and attribute combination for + * which a match was found. The last result (which could be empty if no + * match was found) contain error code KErrEof to indicate that the + * search has completed. The corresponding CBTEngDiscovery instance + * can only be deleted inside the callback method if the serach + * has completed (KErrEof is received). + * + * @since S60 v3.2 + * @param aHandle Record handle of the service record containing the result. + * @param aAttr Array containing the attribute that matches the + * requested attribute. + * Note: the array will not be available anymore after + * this method returns. + * @param aErr Error code of the service search operation; KErrNone if + * sucessful and more results follow, KErrEof indicates that + * this is the last result (which could be empty if no match + * was found), KErrCouldNotConnect and KErrCouldDisconnected + * in case of Bluetooth connection errors; otherwise one of + * the system-wide error codes. + */ + virtual void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ) = 0; + + /** + * Provides notification of the result of the discovery of nearby + * Bluetooth devices. + * + * @since S60 v3.2 + * @param aDevice The data structure encapsulates information + * about the selected device. Ownership of the data + * structure has not been transfered and is still with + * the API client. + * @param aErr Error code of the device search operation; KErrNone if + * sucessful, KErrCancel if the user cancelled the + * dialog, KErrAbort if CBTEngDiscovery::CancelSearchRemoteDevice + * was called; otherwise one of the system-wide error codes. + */ + virtual void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ) = 0; + + /** + * Provides notification of the result of the discovery of nearby + * Bluetooth devices and EIR data. + * + * @since S60 v5.1 + * @param aDevice The data structure encapsulates information + * about the selected device. + * Ownership of the data structure has not been transfered and + * is still with the API client. + * @param aNameEntry Contains the EIR data of the remote device. + * Ownership of the data structure has not been transfered and + * is still with the API client. + * @param aErr Error code of the device search operation; KErrNone if + * sucessful, KErrCancel if the user cancelled the + * dialog, KErrAbort if CBTEngDiscovery::CancelSearchRemoteDevice + * was called; otherwise one of the system-wide error codes. + */ + IMPORT_C virtual void DeviceSearchComplete( CBTDevice* aDevice, + TNameEntry* aNameEntry, TInt aErr ); + + /** + * Provides notification of the result of service UUIDs retrieval. + * + * @since S60 v5.1 + * @param aNameEntry Contains the EIR data of the remote device. + * Ownership of the data structure has not been transfered and + * is still with the API client. + * @param aErr KErrNone if sucessful; + * otherwise one of the system-wide error codes. + */ + IMPORT_C virtual void GetEirServiceUUIDsComplete( + TNameEntry* aNameEntry, TInt aErr ); + + }; + +/** + * Class CBTEngDiscovery + * + * This is a helper class that simplifies the usage of Symbian's + * BluetoothT SDP interface, for registration of SDP records in + * the local database and for queries of remote SDP databases. + * Additionally, functionality for searching for and pairing with + * remote Bluetooth devices. + * + * @lib btengdiscovery.lib + * @since S60 v3.2 + */ +class CBTEngDiscovery : public CBase + { + +public: + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aNotifier Pointer to callback interface that receives + * the SDP query results. + * @return Pointer to the constructed CBTEngDiscovery object. + */ + IMPORT_C static CBTEngDiscovery* NewL( MBTEngSdpResultReceiver* aNotifier = NULL ); + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aNotifier Pointer to callback interface that receives + * the SDP query results. + * @return Pointer to the constructed CBTEngDiscovery object. + */ + IMPORT_C static CBTEngDiscovery* NewLC( MBTEngSdpResultReceiver* aNotifier = NULL ); + + /** + * Destructor + */ + virtual ~CBTEngDiscovery(); + + /** + * Launches to notifier for discovering nearby Bluetooth devices and + * user selection of one device. + * When completed, the selected device is passed back to the client + * through the callback interface + * method MBTEngSdpResultReceiver::DeviceSearchComplete(). + * + * @since S60 v3.2 + * @param aDevice The data structure in which the result will be stored + * (passed back thorugh DeviceSearchComplete()). + * Ownership of the data structure remains with the caller + * of this method. + * @param aServiceClass Filter for device search; this will filter the + * results according to the specified major service + * class field of the CoD. The default value + * is zero and will not apply any filter. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt SearchRemoteDevice( CBTDevice* aDevice, TUint aServiceClass = 0 ); + + /** + * Launches to notifier for discovering nearby Bluetooth devices and + * user selection of one device. Additionally, this method returns service + * UUIDs in the EIR data of the selected device. + * When completed, the selected device and its serivice UUID list are passed + * back to the client through the callback interface + * method MBTEngSdpResultReceiver::DeviceSearchComplete(). + * + * @since S60 v5.1 + * @param aDevice The data structure in which the result will be stored + * (passed back thorugh DeviceSearchComplete()). + * Ownership of the data structure remains with the caller + * of this method. + * @param aNameEntry The data structure in which the EIR data of the + * selected device will be stored + * (passed back thorugh DeviceSearchComplete()). + * TBluetoothNameRecordWrapper can be constructed from a + * TNameRecord instance for the purpose of parsing and + * getting Extended Inquiry Response tags. + * Ownership of the data structure remains with the caller + * of this method. + * @param aServiceClass Filter for device search; this will filter the + * results according to the specified major service + * class field of the CoD. The default value + * is zero and will not apply any filter. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt SearchRemoteDevice( CBTDevice* aDevice, + TNameEntry* aNameEntry, TUint aServiceClass = 0 ); + + /** + * Cancels an ongoing search for nearby Bluetooth devices. + * This results in a call to the callback interface + * method MBTEngSdpResultReceiver::ServiceSearchComplete() with error + * code KErrAbort. + * + * @since S60 v3.2 + */ + IMPORT_C void CancelSearchRemoteDevice(); + + /** + * Retieves the information about the service UUIDs in the EIR data + * of a device specified by a BD address. + * + * The EIR data got through this API is cached data and depends + * on a previous inquiry that has taken place. Moreover, a lagecy + * device (pre BT v2.1) doesn't have EIR data at all. Thus to ensure + * wether a device supports a service or not at present, SDP query + * would still be the most reliable approach. + * + * When completed, the information are passed + * back to the client through the callback interface + * method MBTEngSdpResultReceiver::GetEirServiceUUIDsComplete(). + * + * @since S60 v5.1 + * @param aAddr The BD address of the device. + * @param aNameEntry The data structure in which the EIR data of the + * selected device will be stored + * (passed back thorugh DeviceSearchComplete()). + * TBluetoothNameRecordWrapper can be constructed from a + * TNameRecord instance for the purpose of parsing and + * getting Extended Inquiry Response tags. + * Ownership of the data structure remains with the caller + * of this method. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt GetEirServiceUUIDs( const TBTDevAddr& aAddr, TNameEntry* aNameEntry); + + /** + * Cancels an ongoing device service UUIDs retrieval. + * + * @since S60 5.1 + */ + IMPORT_C void CancelGetEirServiceUUIDs(); + + /** + * Registers an service record in the local SDP database, based on + * a known service as defined in Bluetooth Engine resource file. + * The instance of CBTEngDiscovery must be kept alive as long as + * the service record is needed to be stored (deletion of CBTEngDiscovery + * will remove all the records stored during the same session). + * + * @since S60 v3.2 + * @param aService UUID of the service to be registered. + * @param aChannel The value of the channel of the ProtocolDescriptorList + attribute (e.g. the RFCOMM channel), if applicable. + * @param aHandle On return, contains the service record handle + * identifying the created service record. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt RegisterSdpRecord( const TUUID& aService, const TUint aChannel, + TSdpServRecordHandle& aHandle ); + + /** + * Deletes a service record from the local SDP database that was + * previously registered by through this instance of CBTEngDiscovery. + * + * @since S60 v3.2 + * @param aHandle Handle to the SDP record to be deleted. Note that + * this has to be a valid (existing) SDP record. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt DeleteSdpRecord( const TSdpServRecordHandle aHandle ); + + /** + * Sets the callback class for receiving SDP query results. This will + * replace the current callback interface used to pass back the + * SDP query results. + * + * @since S60 v3.2 + * @param aNotifier Callback class to receive the SDP results. + */ + IMPORT_C void SetNotifier( MBTEngSdpResultReceiver* aNotifier ); + + /** + * Starts an SDP query. The remote SDP database is searched + * for service records containing the specified UUID, the + * equivalent of an SDP ServiceSearch transaction. + * When completed, record handles for all matching service records + * are passed back to the client through the callback interface + * method MBTEngSdpResultReceiver::ServiceSearchComplete(). + * + * @since S60 v3.2 + * @param aAddr Target Bluetooth device address for the SDP query. + * @param aService The UUID to search for. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt RemoteSdpQuery( const TBTDevAddr& aAddr, const TUUID& aService ); + + /** + * Starts an SDP query. A specific service record on the remote SDP + * database is queried for the value of a specified attribute, the + * equivalent of an SDP ServiceAttribute transaction. + * When completed, the result is passed back to the client + * through the callback interface method + * MBTEngSdpResultReceiver::AttributeSearchComplete(). + * + * @since S60 v3.2 + * @param aAddr Target Bluetooth device address for the SDP query. + * @param aHandle The service record handle identifying the + * service record to search the attribute from. + * @param aAttrId The service attribute to search for. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt RemoteSdpQuery( const TBTDevAddr& aAddr, + const TSdpServRecordHandle aHandle, + const TSdpAttributeID aAttrId ); + + /** + * Starts an SDP query. The remote SDP database is searched for + * the value of a specified attribute in a service record + * containing the specified UUID, the equivalent of an + * SDP ServiceAttributeSearch transaction. + * When completed, the results are passed back to the client + * through the callback interface method + * MBTEngSdpResultReceiver::ServiceAttributeSearchComplete(). + * + * @since S60 v3.2 + * @param aAddr Target Bluetooth device address for the SDP query. + * @param aService The UUID to search for. + * @param aAttrId The service attribute to search for. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt RemoteSdpQuery( const TBTDevAddr& aAddr, const TUUID& aService, + const TSdpAttributeID aAttrId ); + + /** + * Starts an SDP query. The remote SDP database is searched for the + * value of the ProtocolDescriptorList attribute in a service record + * containing the specified UUID, the equivalent of an SDP + * ServiceAttributeSearch transaction with ProtocolDescriptorList as + * attribute. This can e.g. be used to search the remote RFCOMM channel. + * When completed, the results are passed back to the client + * through the callback interface method + * MBTEngSdpResultReceiver::AttributeSearchComplete(). + * + * @since S60 v3.2 + * @param aAddr Target Bluetooth device address for the SDP query. + * @param aService The UUID to search for. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + IMPORT_C TInt RemoteProtocolChannelQuery( const TBTDevAddr& aAddr, + const TUUID& aService ); + + /** + * Cancels an ongoing SDP query. + * + * @since S60 v3.2 + */ + IMPORT_C void CancelRemoteSdpQuery(); + + /** + * Closes a remote SDP connection. The method should be called after + * RemoteSdpQuery and RemoteProtocolChannelQuery methods are completed + * and the CBTEngDiscovery obejct + * is still kept alive. + * + * @since S60 v3.2 + */ + IMPORT_C void CBTEngDiscovery::CloseRemoteSdpConnection(); + + /** + * Static helper function to return the SDP element type + * of an indexed element in a list (DES or DEA). + * + * @param aResultArray The array containing the SDP attribute. + * @param aIndex The position of the element to be parsed, relative + * to zero (i.e. zero is the first element). + * @param aType On return, contains the element type + * of the element at position aIndex. + * @return KErrNone if sucessful, + * KErrEof if the index is greater than the number of items in the array. + * @since S60 v3.2 + */ + IMPORT_C static TInt ParseNextSdpAttrValueType( RSdpResultArray& aResultArray, + TInt aIndex, TSdpElementType& aType ); + + /** + * Static helper function to return the protocol channel number from the + * result array of a ServiceAttributeSearch. This value can be used to + * obtain e.g. the remote RFCOMM channel after a RemoteProtocolChannelQuery + * has completed. + * + * @param aResultArray The array containing the SDP attribute. + * @param aType On return, contains the channel number. + * @return KErrNone if sucessful, KErrArgument if the SDP attribute is not + * of type ProtocolDescriptorList. + * @since S60 v3.2 + */ + IMPORT_C static TInt ParseRfcommChannel( RSdpResultArray& aResultArray, + TInt& aChannel ); + +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + * @param aNotifier Pointer to callback interface that receives + * the SDP query results. + */ + CBTEngDiscovery( MBTEngSdpResultReceiver* aNotifier ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + + /** + * Helper function to check that a valid session with + * the local SDP database exists. + * + * @since S60 v3.2 + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + TInt CheckSdpDbHandler(); + + /** + * Helper function to check that a valid handler of + * remote SDP queries exists. + * + * @since S60 v3.2 + * @return KErrNone if sucessful, + * KErrNotReady if no SDP result notifier has been set, + * otherwise the error code indicating the error situation. + */ + TInt CheckSdpQueryHandler(); + +private: // data + + /** + * Reference to SDP DB handler. + * Own. + */ + CBTEngSdpDbHandler* iSdpDbHandler; + + /** + * Reference to handler of remote SDP queries. + * Own. + */ + CBTEngSdpQuery* iSdpQueryHandler; + + /** + * Reference to handler of remote device searches. + * Own. + */ + CBTEngDeviceSearch* iDevSearchHandler; + + /** + * Reference to receiver of results. + * Not own. + */ + MBTEngSdpResultReceiver* iResultNotifier; + + }; + +#endif // BTENGDISCOVERY_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_features_api/bluetooth_engine_features_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_features_api/bluetooth_engine_features_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,18 @@ + + + Bluetooth Engine Features API + Utility library for determining supported/enabled BT features. + C++ + bluetoothengine + + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_features_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_features_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine Features API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btfeaturescfg.h MW_LAYER_PLATFORM_EXPORT_PATH(btfeaturescfg.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_features_api/inc/btfeaturescfg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_features_api/inc/btfeaturescfg.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 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: +* +*/ + + +#ifndef BTFEATURES_H +#define BTFEATURES_H + +#include + + + +/** Namespace supporting Bluetooth features. */ +namespace BluetoothFeatures + { + /** Enumeration for the different Enterprise IT Bluetooth enablement types. */ + enum TEnterpriseEnablementMode + { + /** Bluetooth is disabled entirely. */ + EDisabled, + /** Only certain profiles are allowed: HSP, HFP, AVRCP, A2DP, HID. */ + EDataProfilesDisabled, + /* Bluetooth is enabled as normal, i.e. it is subject to usual user + control via the UI. */ + EEnabled + }; + + /** Obtains the current Enterprise IT enablement setting. Used by mw + software to control the creation of listening services and to police + outgoing services. + @return The current setting. + */ + IMPORT_C TEnterpriseEnablementMode EnterpriseEnablementL(); + + /** Sets the current Enterprise IT enablement setting. + This function is provided only for use by the Bluetooth DCMO plugin. + No other software should use this to control Bluetooth availability. + Changes only take effect on reboot. + @param aEnablement The desired setting. + */ + IMPORT_C void SetEnterpriseEnablementL(TEnterpriseEnablementMode aEnablement); + } + +#endif // BTFEATURES_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_plugin_api/bluetooth_engine_plugin_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_plugin_api/bluetooth_engine_plugin_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth Engine Plugin API + ECOM interface for managing connections to BT accessory + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_plugin_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_plugin_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine Plugin API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengplugin.h MW_LAYER_PLATFORM_EXPORT_PATH(btengplugin.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_plugin_api/inc/btengplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_plugin_api/inc/btengplugin.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,265 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine ECom plug-in base class declaration. +* +*/ + + + +#ifndef BTENGINEPLUGIN_H +#define BTENGINEPLUGIN_H + + +#include +#include +#include + + +/** + * Class MBTEngConnObserver + * + * Callback class for receiving CBTEngPlugin events + * for connect/disconnect complete events. + * + * @lib btengdevman.dll + * @since S60 V3.0 + */ +class MBTEngPluginObserver + { + +public: + + /** + * Indicates to the caller that a service-level connection has completed. + * This function is called for both incoming and outgoing connections. + * This function is also called when an outgoing connection request fails, + * e.g. with error code KErrCouldNotConnect. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * The caller of this function must be ready to receive new commands on the + * CBTEngPlugin interface during execution of this function i.e. it should + * have released all resources relating to execution of such commands. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device. + * @param aProfile Identifier for the service-level connection. + * @param aErr Status information, if there is an error. + * @param aConflicts If there already is a connection for the selected + * profile(s) of an outgoing connection request, then + * this array contains the bluetooth device addresses + * of the remote devices for those connections. + */ + virtual void ConnectComplete( const TBTDevAddr& aAddr, + TBTProfile aProfile, TInt aErr, + RBTDevAddrArray* aConflicts = NULL ) = 0; + + /** + * Indicates to the caller that a service-level connection has disconnected. + * + * The caller of this function must be ready to receive new commands on the + * CBTEngPlugin interface during execution of this function i.e. it should + * have released all resources relating to execution of such commands. + * + * @since S60 v3.2 + * @param aAddr The address of the remote device. + * @param aProfile Identifier for the service-level connection. + * @param aErr Status information, if there is an error. + */ + virtual void DisconnectComplete( const TBTDevAddr& aAddr, + TBTProfile aProfile, TInt aErr ) = 0; + + }; + + +/** + * BTEng plug-in base class. + * + * This is the base class from which a BT Engine ECom plug-in inherit. + * BT Engine plug-ins implement Bluetooth profiles. This interface is + * used to issue commands relating to service-level connection management + * (i.e. relating to profile connections). Each plugin implementation + * identifies itself through the SDP Service Class UUIDs defined by + * the Bluetooth SIG for profiles it supports. + * + * @lib bteng.lib + * @since S60 v3.2 + */ +class CBTEngPlugin : public CBase + { + +public: + + /** Array of BT profiles. */ + typedef RArray RProfileArray; + + /** + * Constructor; loads the plug-in through the ECom framework. + * + * @since S60 v3.2 + * @param aImplementationUid The UID of the interface implementation + * to be loaded. + * @return Pointer to the constructed CBTEngPlugin object. + */ + inline static CBTEngPlugin* NewL( const TUid aImplementationUid ); + + /** + * Destructor; destroys the plug-in through the ECom framework. + */ + inline virtual ~CBTEngPlugin(); + + /** + * Sets the observer for receiving connection events through the + * MBTEngPluginObserver interface. This method MUST be called + * before any command is given to the plug-in + * + * @since S60 v3.2 + * @param aObserver The observer of connection events. + */ + virtual void SetObserver( MBTEngPluginObserver* aObserver ) = 0; + + /** + * Gets the list of profiles implemented by this plug-in. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v3.2 + * @param aProfiles Array of integers identifying the BT profiles + * implemented by this plug-in. + */ + virtual void GetSupportedProfiles( RProfileArray& aProfiles ) = 0; + + /** + * Indicates if this plug-in implements the specified profiles. + * Profiles are identified by the SDP Service Class UUID (short form), + * as assigned by the Bluetooth SIG. + * + * @since S60 v3.2 + * @param aProfile Integer identifying the BT profile. + * @return ETrue if the plug-in implements the requested profile, + * otherwise EFalse. + */ + virtual TBool IsProfileSupported( const TBTProfile aProfile ) const = 0; + + /** + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::ConnectComplete with + * the appropriate error code. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * @return KErrNone on success, otherwise an appropriate error code. + */ + virtual TInt Connect( const TBTDevAddr& aAddr ) = 0; + + /** + * Instructs the plug-in to cancel the creation a service-level + * connection with the specified Bluetooth address. + * + * In addition, as this is part of an asynchronous operation, the plug-in + * completes the outstanding asyncronous request status with KErrCancel. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + */ + virtual void CancelConnect( const TBTDevAddr& aAddr ) = 0; + + /** + * Instructs the plug-in to create a service-level connection + * with the specified Bluetooth address. + * + * This is an asynchronous operation; on completion, the plug-in informs + * the observer by calling MBTEngPluginObserver::DisconnectComplete with + * the appropriate error code. + * + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * In case the address is the NULL address, the plug-in is + * expected to disconnect all its connections. + * @param aDiscType The type of disconnection; + * EGraceful for graceful (normal) disconnection, + * EImmediate for immediate (forced) disconnection. + * @return KErrNone on success, otherwise an appropriate error code. + */ + virtual TInt Disconnect( const TBTDevAddr& aAddr, + TBTDisconnectType aDiscType ) = 0; + + /** + * Gets the addresses of the connected devices for the specified profile. + * + * @since S60 v3.2 + * @param aAddrArray On return, holds the Bluetooth device addresses + * of the connected Bluetooth devices for the + * requested profile. + * @param aConnectedProfile The profile for which the existing + * connections are requested. + * @return KErrNone if sucessful, otherwise the error code + * indicating the error situation. + */ + virtual void GetConnections( RBTDevAddrArray& aAddrArray, + TBTProfile aConnectedProfile ) = 0; + + /** + * Indicates if this plug-in has a service-level connection + * with the specified Bluetooth address. + * + * @since S60 v3.2 + * @param aAddr The BT device address identifying a remote device. + * @return The status of the connection according to the TConnectionStatus + * enumeration. EConnecting is interpreted that at least one + * incoming connection request has been completed, but that not + * all service-level connections have been fully established. + */ + virtual TBTEngConnectionStatus IsConnected( const TBTDevAddr& aAddr ) = 0; + + +private: // data + + /** + * UID set by ECOM when the instance is created. + * Used when the instance is destroyed. + */ + TUid iInstanceUid; + + }; + + +// ----------------------------------------------------------------------------- +// Create the requested implementation. +// ----------------------------------------------------------------------------- +// +inline CBTEngPlugin* CBTEngPlugin::NewL( const TUid aImplementationUid ) + { + TInt32 keyOffset = _FOFF( CBTEngPlugin, iInstanceUid ); + TAny* plugin = REComSession::CreateImplementationL( aImplementationUid, + keyOffset ); + return reinterpret_cast( plugin ); + } + + +// ----------------------------------------------------------------------------- +// The implementation has been deleted. +// ----------------------------------------------------------------------------- +// +inline CBTEngPlugin::~CBTEngPlugin() + { + REComSession::DestroyedImplementation( iInstanceUid ); + } + + +#endif // BTENGINEPLUGIN_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/bluetooth_engine_settings_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/bluetooth_engine_settings_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,18 @@ + + + Bluetooth Engine Settings API + for local settings, e.g. power state, name, visibility mode + c++ + bluetoothengine + + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Engine Settings API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengsettings.h MW_LAYER_PLATFORM_EXPORT_PATH(btengsettings.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/inc/btengsettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/inc/btengsettings.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,269 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine API for managing device settings. +* +*/ + + +#ifndef BTENGSETTINGS_H +#define BTENGSETTINGS_H + +#include +#include +#include + +class CBase; +class CBTEngSettingsNotify; + + +/** + * Class MBTEngSettingsObserver + * + * Callback interface for receiving events related to changes + * in Bluetooth power and discoverability mode settings. + * + * @lib btengsettings.lib + * @since S60 v3.2 + */ +class MBTEngSettingsObserver + { + +public: + + /** + * Provides notification of changes in the power state + * of the Bluetooth hardware. + * + * @since S60 v3.2 + * @param aState EBTPowerOff if the BT hardware has been turned off, + * EBTPowerOn if it has been turned off. + */ + virtual void PowerStateChanged( TBTPowerStateValue aState ) = 0; + + /** + * Provides notification of changes in the discoverability + * mode of the Bluetooth hardware. + * + * @since S60 v3.2 + * @param aState EBTDiscModeHidden if the BT hardware is in hidden mode, + * EBTDiscModeGeneral if it is in visible mode. + */ + virtual void VisibilityModeChanged( TBTVisibilityMode aState ) = 0; + + }; + + +/** + * Class CBTEngSettings + * + * This class provides functionality for + * getting and setting Bluetooth settings. + * + * @lib btengsettings.lib + * @since S60 v3.2 + */ +class CBTEngSettings : public CBase + { + +public: + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives + * settings change events. + * @return Pointer to the constructed CBTEngSettings object. + */ + IMPORT_C static CBTEngSettings* NewL( MBTEngSettingsObserver* aObserver = NULL ); + + /** + * Two-phase constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives + * settings change events. + * @return Pointer to the constructed CBTEngSettings object. + */ + IMPORT_C static CBTEngSettings* NewLC( MBTEngSettingsObserver* aObserver = NULL ); + + /** + * Destructor + */ + virtual ~CBTEngSettings(); + + /** + * Gets the Bluetooth power state (on or off). + * + * @since S60 v3.2 + * @param aState On return, contains the current power mode. + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt GetPowerState( TBTPowerStateValue& aState ); + + /** + * Sets the Bluetooth power state (on or off). If a callback interface has + * been provided, the result is communicated through PowerStateChanged() + * when to power state change has been fully completed. + * + * @since S60 v3.2 + * @param aState Power mode to be set. + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt SetPowerState( TBTPowerStateValue aState ); + + /** + * Gets Bluetooth visibility mode (hidden, + * limited or general discoverable mode). + * + * @since S60 v3.2 + * @param aMode On return, contains the current visibility mode. + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt GetVisibilityMode( TBTVisibilityMode& aMode ); + + /** + * Sets Bluetooth visibility mode (hidden, + * limited or general discoverable mode). + * + * @since S60 v3.2 + * @param aMode Discoverability mode to be set to Central Repository. + * @param aTime Time during which the phone remains in general + * discoverable state (in minutes), only used with + * EBTDiscModeTemporary (otherwise ignored). + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt SetVisibilityMode( TBTVisibilityMode aMode, TInt aTime = 0 ); + + /** + * Gets Bluetooth local name. If the name has not been set, a + * zero-lenght name is returned. + * + * @since S60 v3.2 + * @param aMode On return, contains the current local name. + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt GetLocalName( TDes& aName ); + + /** + * Sets Bluetooth local name. + * + * @since S60 v3.2 + * @param aMode Local mode to be set to Central Repository. + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt SetLocalName( const TDes& aName ); + + /** + * Sets the Bluetooth power state (on or off). If a callback interface has + * been provided, the result is communicated through PowerStateChanged() + * when to power state change has been fully completed. + * If bluetooth is on, power will be switched off gracefully after + * all temporary connections have been disconnected. If a non-temporary + * connection has been established in the mean time (e.g. with a headset), + * power will be switched on permanently. + * Note: power will only be switched off gracefully if it has also been + * switched on through this method, otherwise KErrAccessDenied will be + * returned. + * + * @since S60 v5.0 + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt ChangePowerStateTemporarily(); + + /** + * Gets Bluetooth offline mode settings. + * + * @since S60 v5.0 + * @param aOffline On return, indicates whether Offline Mode is active. + * @param aOfflineAllowed On return, indicates wether Bluetooth is allowed + * to be turned on in offline mode. + * @return KErrNone on success, otherwise a system wide error code. + */ + IMPORT_C TInt GetOfflineModeSettings( TCoreAppUIsNetworkConnectionAllowed& aOffline, + TBTEnabledInOfflineMode& aOfflineAllowed ); +private: + + /** + * C++ default constructor + * + * @since S60 v3.2 + * @param aObserver Pointer to callback interface that receives + * settings change events. + */ + CBTEngSettings( MBTEngSettingsObserver* aObserver ); + + /** + * Symbian 2nd-phase constructor + * + * @since S60 v3.2 + */ + void ConstructL(); + + /** + * Helper function to get the status from Central Repository of + * whether the local name has been modified. + * + * @since S60 v3.2 + * @param aStatus On return, contains the current status of the local name. + * @return KErrNone on success, otherwise a system wide error code. + */ + TInt GetLocalNameModified( TBool& aStatus ); + + /** + * Helper function for reading a Central Repository key, and + * verifying that the value is within the appropriate range. + * + * @since S60 v3.2 + * @param aUid UID of the key to be read. + * @param aKey The key to be read. + * @param aValue Default value of the key; on return contains + * the value as read from CenRep. + * @param aMinRange1 Lower limit of the first valid range of key values. + * @param aMaxRange1 Upper limit of the first valid range of key values. + * @param aMinRange2 Lower limit of the second valid range of key values. + * @param aMaxRange2 Upper limit of the second valid range of key values. + */ + void GetCenRepKeyL( const TUid aUid, const TInt aKey, TInt& aValue, + const TInt aMinRange1, const TInt aMaxRange1, + const TInt aMinRange2 = 0, const TInt aMaxRange2 = 0 ); + + /** + * Helper function for getting/setting BT local name in BT Registry. + * + * @since S60 v3.2 + * @param aName The BT local device name to be read or written. If it + * contains an empty string, it will hold the name on return, + * otherwise the contained string will be set to BT Registry. + * @return KErrNone on success, otherwise a system wide error code. + */ + TInt HandleBTRegistryNameSetting( TDes& aName ); + +private: // data + + /** + * Timer for temporary discoverable mode. + * Own. + */ + CBTEngSettingsNotify* iSettingsWatcher; + + /** + * Observer for changes in BT settings. + * Not own. + */ + MBTEngSettingsObserver* iObserver; + + }; + +#endif // BTENGSETTINGS_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/LC_ATS3DropGen.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/LC_ATS3DropGen.py Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,659 @@ +# +# Copyright (c) 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: +# + +import os +import sys +import string +from xml.dom.minidom import Document +import re + +TRUE = 1 +FALSE = 0 + +#Parameter Parsing +NONEOPTION = 0 +PATHOPTION = 1 +IMAGEPATHOPTION = 2 +TARGETOPTION = 3 +PLUGINRSCOPTION = 4 +HARNESSOPTION = 5 +STIFTYPEOPTION = 6 + +pluginrscs = [] +testspath = "" +imagepath = "" +target = "" +targethost = "" +harness = "" +stiftype = "" + +index = 1 +argnumber = len(sys.argv) +if((argnumber < 2) or (sys.argv[1] == "HELP") or (sys.argv[1] == "help") or (sys.argv[1] == "Help")or (sys.argv[1] == "-HELP") or (sys.argv[1] == "-help") or (sys.argv[1] == "-Help")): + print "\n" + print "********** DropGenerator Tool Usage Manual ********** " + print "" + print " -------- THIS TOOL IS USED FOR: --------" + print " - Building the test module " + print " - Create the ATS3Drop folder under tsrc folder" + print " - Generate test.xml file under tsrc folder" + print " - Generate testdrop.zip file including ATS3Drop and test.xml" + print "" + print " -------- PARAMETERS TO BE PASSED TO THE TOOL: -------- \n" + print " dropgenerator.py -PATH " + print " -IMAGEPATH " + print " -TARGET " + print " [-PLUGINRSCS ]" + print " -HARNESS " + print " -STIFTYPE " + print " Supported STIF Types: Testscripter, Hardcoded" + sys.exit() + +# read paramters +option = NONEOPTION +for index in range(len(sys.argv)): + param = sys.argv[index] + if((param == "-PATH") or (param == "-path") or (param == "-Path")): + option = PATHOPTION + param = sys.argv[index] + continue + if((param == "-IMAGEPATH") or (param == "-imagepath") or (param == "-Imagepath")): + option = IMAGEPATHOPTION + param = sys.argv[index] + continue + elif((param == "-TARGET") or (param == "-target") or (param == "-Target")): + option = TARGETOPTION + param = sys.argv[index] + continue + elif((param == "-PLUGINRSCS") or (param == "-pluginrscs") or (param == "-Pluginrscs")): + option = PLUGINRSCOPTION + param = sys.argv[index] + continue + elif((param == "-DATAFILES") or (param == "-datafiles") or (param == "-Datafiles")): + option = DATAFILESOPTION + param = sys.argv[index] + continue + + elif((param == "-HARNESS") or (param == "-harness") or (param == "-Harness")): + option = HARNESSOPTION + param = sys.argv[index] + continue + + elif((param == "-STIFTYPE") or (param == "-Stiftype") or (param == "-stiftype")): + option = STIFTYPEOPTION + param = sys.argv[index] + continue + + if(option == PATHOPTION): + testspath = param + + if(option == IMAGEPATHOPTION): + imagepath = param + + if(option == TARGETOPTION): + target = param + + if(option == PLUGINRSCOPTION): + pluginrscs.append(param) + + if(option == HARNESSOPTION): + harness = param + + if(option == STIFTYPEOPTION): + stiftype = param + +#validating parameters passed +if(cmp(testspath, "") == 0): + print "\n ERROR: tests PATH parameter not provided" + sys.exit() + +if(cmp(imagepath, "") == 0): + print "\n ERROR: image PATH parameter not provided" + sys.exit() + +if(cmp(target, "") == 0): + print "\n ERROR: TARGET parameter not provided" + sys.exit() + +if(cmp(harness, "") == 0): + print "\n ERROR: HARNESS parameter not provided" + sys.exit() +elif((cmp(harness, "STIF") == 0) or (cmp(harness, "stif") == 0) or (cmp(harness, "Stif") == 0)): + if(cmp(stiftype, "") == 0): + print "\n ERROR: STIFTYPE parameter not provided" + sys.exit() + +EXECUTABLE = 0 +CFGFILE = 1 +INIFILE = 2 +FLASHFILE = 3 +DATAFILE = 4 +INCLUDEFILE = 5 +MMPFILE = 6 +INFFILE = 7 +PLUGINRSCFILE = 8 + +EXTDLL = ".dll" +EXTEXE = ".exe" +EXTCFG = ".cfg" +EXTMMP = ".mmp" + +COMMONPATH = "\\tsrc" + +#get the list of files&dirs in tests folder and clean ATS3Drop folder, test.xml and testdrop package +Directory = testspath +os.system("dir "+Directory+" /B /A > files1.txt") +pre = open("files1.txt", 'r') +file = pre.readline() +while file: + if(file[-1] == "\n"): + file = file[:-1] + + if(cmp(file, "ATS3Drop") == 0): + os.system("rmdir /S /Q " + Directory + "\\" + file) + elif(cmp(file, "test.xml") == 0): + os.system("del /Q " + Directory + "\\" + file) + elif(cmp(file, "testdrop.zip") == 0): + os.system("del /Q " + Directory + "\\" + file) + file = pre.readline() +pre.close() +print "\nDirectory Path Parsed: "+Directory+"\n" + +#list all files under tests folder +os.system("dir "+Directory+" /S/B /A-D > files.txt") +cpp = open("files.txt", 'r') + +CfgFiles = [] +ExecutableFiles = [] + +count = 0 +file = cpp.readline() + +#go through each file in files.txt and pick up .cfg, and extract binary names with extension .dll and .exe from mmp files. +while file: + if(file[-1] == "\n"): + file = file[:-1] + + if((re.search("\.cfg$", file) != None )): + CfgFiles.append(file) + + if((re.search("\.mmp$", file) != None )): + #parsing mmp file for getting the executable name + mmp = open(file, "r") + mmpline = mmp.readline() + while mmpline: + if(string.find(mmpline, "TARGET ") != -1): + mmplinetarget = string.split(mmpline) + ExecutableFiles.append(mmplinetarget[-1]) + break + mmpline = mmp.readline() + mmp.close(); + + count = count + 1 + file = cpp.readline() +cpp.close(); + +#validate if any .cfg exists as we are using STIP scripter. +if((cmp(harness, "STIF") == 0) or (cmp(harness, "stif") == 0) or (cmp(harness, "Stif") == 0)): + if((cmp(stiftype, "TESTSCRIPTER") == 0) or (cmp(stiftype, "Testscripter") == 0) or (cmp(stiftype, "testscripter") == 0)): + if(len(CfgFiles) == 0): + print "\n CFG file not available for TestScripter type STIF module" + sys.exit() + +path = string.split(Directory, "\\") +EXECUTABLEPATH = path[0] + "\\epoc32\\RELEASE\\armv5\\UREL\\" +PLUGINRESOURCEPATH = path[0] + "\\epoc32\\data\Z\\resource\\plugins\\" + +#Create test drop structure and copy files to test drop +print "\n Creating ATSDrop Directory" +ret = os.mkdir(Directory + "\\ATS3Drop") +ATS3DropDir = Directory + "\\ATS3Drop\\" +ret = os.mkdir(Directory + "\\ATS3Drop\\armv5_urel") +ATS3EXEDir = Directory + "\\ATS3Drop\\armv5_urel" +ret = os.mkdir(Directory + "\\ATS3Drop\\images") +ATS3ImageDir = Directory + "\\ATS3Drop\\images" + +DropFloderCreated = TRUE + +print "\n Copying files to the Drop" + +#copy test binaries +for file in ExecutableFiles: + print("\n copy " + EXECUTABLEPATH + file +" to "+ ATS3EXEDir) + ret = os.system("copy /Y "+ EXECUTABLEPATH + file +" "+ ATS3EXEDir) + if(ret != 0): + print "Error : unable to copy " + EXECUTABLEPATH + file + sys.exit() + +#copy STIF .cfg files +for file in CfgFiles: + print("\n copy " + file +" to "+ ATS3DropDir) + ret = os.system("copy /Y "+ file +" "+ ATS3DropDir) + if(ret != 0): + print "Error : unable to copy " + file + sys.exit() +#copy ecom plugin resource files +for file in pluginrscs: + print("\n copy " + PLUGINRESOURCEPATH + file +" to "+ ATS3DropDir) + ret = os.system("copy /Y "+ PLUGINRESOURCEPATH + file +" "+ ATS3DropDir) + if(ret != 0): + print "Error : unable to copy " + PLUGINRESOURCEPATH + file + sys.exit() + +#copy images files + +#list all files under the given image path +os.system("dir "+ imagepath +" /S/B /A-D > imgs.txt") +imgs = open("imgs.txt", 'r') + +ImageFiles = [] +line = imgs.readline() +#get the complete path and name of the core image +while line: + if(line[-1] == "\n"): + line = line[:-1] + + if((re.search("\.C00$", line) != None )): + ImageFiles.append(line) + break; + line = imgs.readline(); +imgs.close(); + +#get the complete path and name of the variant image +imgs = open("imgs.txt", 'r') +line = imgs.readline() +while line: + if(line[-1] == "\n"): + line = line[:-1] + if((re.search("\.V01$", line) != None )): + ImageFiles.append(line) + break + line = imgs.readline(); +imgs.close(); + +#get the complete path and name of userdisk erase image +imgs = open("imgs.txt", 'r') +line = imgs.readline() +while line: + if(line[-1] == "\n"): + line = line[:-1] + if((re.search("\erase_userdisk.fpsx$", line) != None )): + ImageFiles.append(line) + break + line = imgs.readline(); +imgs.close(); + +#copy image files +for file in ImageFiles: + print("\n copy " + file +" to "+ ATS3ImageDir) + ret = os.system("copy /Y "+ file +" "+ ATS3ImageDir) + if(ret != 0): + print "Error : unable to copy " + file + sys.exit() + +DLLTARGETPATH = "c:\\sys\\bin\\" +PLUGINRSCTARGETPATH = "c:\\resource\\plugins\\" +CFGTARGETPATH = "e:\\testing\\" +LOGTARGETPATH = "e:\\temp\\lc_apitest\\" + +imagestoflash = [] +cfgFileNoPath = [] +filestoinstall = [] +BINARYFILE = 0 +NONBINARYFILE = 1 + +for line in ImageFiles: + imagestoflash.append(line.split("\\")[-1]) +for line in CfgFiles: + cfgFileNoPath.append(line.split("\\")[-1]) + filestoinstall.append([line.split("\\")[-1], NONBINARYFILE, CFGTARGETPATH]) +for file in ExecutableFiles: + filestoinstall.append([file, BINARYFILE, DLLTARGETPATH]) +for file in pluginrscs: + filestoinstall.append([file, NONBINARYFILE, PLUGINRSCTARGETPATH]) + + +#Create XML if the test drop folder is created +if(DropFloderCreated == TRUE): + # Create the minidom document + #test tage + xmldoc = Document() + xmltest = xmldoc.createElement("test") + xmldoc.appendChild(xmltest) + + #id tag + xmlid = xmldoc.createElement("id") + xmltest.appendChild(xmlid) + xmlidtext = xmldoc.createTextNode("1") + xmlid.appendChild(xmlidtext) + + xmlname = xmldoc.createElement("name") + xmltest.appendChild(xmlname) + xmlnametext = xmldoc.createTextNode("LC API test") + xmlname.appendChild(xmlnametext) + + #target tag + xmltarget = xmldoc.createElement("target") + xmltest.appendChild(xmltarget) + + xmltergetdevice1 = xmldoc.createElement("device") + xmltergetdevice1.setAttribute("alias", "DEFAULT") + xmltergetdevice1.setAttribute("rank", "none") + xmltarget.appendChild(xmltergetdevice1) + + xmltargetproperty1 = xmldoc.createElement("property") + xmltargetproperty1.setAttribute("value",harness) + xmltargetproperty1.setAttribute("name","HARNESS") + xmltergetdevice1.appendChild(xmltargetproperty1) + + xmltargetproperty2 = xmldoc.createElement("property") + xmltargetproperty2.setAttribute("value",target) + xmltargetproperty2.setAttribute("name","TYPE") + xmltergetdevice1.appendChild(xmltargetproperty2) + + #plan tag + xmlplan1 = xmldoc.createElement("plan") + xmlplan1.setAttribute("passrate","100") + xmlplan1.setAttribute("enabled","true") + xmlplan1.setAttribute("harness",harness) + xmlplan1.setAttribute("name",string.rstrip("Test Plan")) + xmlplan1.setAttribute("id","1.1") + xmltest.appendChild(xmlplan1) + + #session tag + xmlp1session1 = xmldoc.createElement("session") + xmlp1session1.setAttribute("passrate","100") + xmlp1session1.setAttribute("enabled","true") + xmlp1session1.setAttribute("harness",harness) + xmlp1session1.setAttribute("name","session") + xmlp1session1.setAttribute("id","1.1.1") + xmlplan1.appendChild(xmlp1session1) + + #set tag + xmlp1s1set1 = xmldoc.createElement("set") + xmlp1s1set1.setAttribute("passrate","100") + xmlp1s1set1.setAttribute("enabled","true") + xmlp1s1set1.setAttribute("harness",harness) + xmlp1s1set1.setAttribute("name","set") + xmlp1s1set1.setAttribute("id","1.1.1.1") + xmlp1session1.appendChild(xmlp1s1set1) + + xmlp1s1s1target = xmldoc.createElement("target") + xmlp1s1set1.appendChild(xmlp1s1s1target) + + xmlp1s1s1targetdevice = xmldoc.createElement("device") + xmlp1s1s1targetdevice.setAttribute("alias","DEFAULT") + xmlp1s1s1targetdevice.setAttribute("rank","master") + xmlp1s1s1target.appendChild(xmlp1s1s1targetdevice) + + #case tag + xmlp1s1s1case1 = xmldoc.createElement("case") + xmlp1s1s1case1.setAttribute("passrate","100") + xmlp1s1s1case1.setAttribute("enabled","true") + xmlp1s1s1case1.setAttribute("harness",harness) + xmlp1s1s1case1.setAttribute("name","Test Case 1") + xmlp1s1s1case1.setAttribute("id","1.1.1.1.1") + xmlp1s1set1.appendChild(xmlp1s1s1case1) + + #flash tags if there are images + for xmlimage in imagestoflash: + xmlp1s1s1c1flash = xmldoc.createElement("flash") + xmlp1s1s1case1.appendChild(xmlp1s1s1c1flash) + xmlp1s1s1c1flash.setAttribute("target-alias","DEFAULT") + xmlp1s1s1c1flash.setAttribute("images","ATS3Drop\\images\\" + xmlimage) + + #install steps + xmlstepcount = 0 + for file in filestoinstall: + xmlstepcount = xmlstepcount + 1 + #step1 + xmlp1s1s1c1step = xmldoc.createElement("step") + xmlp1s1s1c1step.setAttribute("significant","false") + xmlp1s1s1c1step.setAttribute("passrate","100") + xmlp1s1s1c1step.setAttribute("enabled","true") + xmlp1s1s1c1step.setAttribute("harness",harness) + xmlp1s1s1c1step.setAttribute("name","Step "+str(xmlstepcount)) + xmlp1s1s1c1step.setAttribute("id","1.1.1.1.1."+str(xmlstepcount)) + xmlp1s1s1case1.appendChild(xmlp1s1s1c1step) + + xmlp1s1s1c1s1command1 = xmldoc.createElement("command") + xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1command1) + xmlp1s1s1c1s1command1text = xmldoc.createTextNode("install") + xmlp1s1s1c1s1command1.appendChild(xmlp1s1s1c1s1command1text) + + xmlp1s1s1c1s1params1 = xmldoc.createElement("params") + xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1params1) + if(file[1] == BINARYFILE): + #parameter1 + xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param1.setAttribute("type","binary") + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1) + #end of parameter1 + #parameter2 + xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param1.setAttribute("src",file[0]) + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1) + #end of parameter2 + #parameter3 + xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param1.setAttribute("dst",file[2] + file[0]) + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1) + #end of parameter3 + #parameter4 + xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param1.setAttribute("component-path","ATS3Drop") + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1) + #end of parameter4 + #end of Step1 + + xmlstepcount = xmlstepcount + 1 + xmlp1s1s1c1step6 = xmldoc.createElement("step") + xmlp1s1s1c1step6.setAttribute("significant","false") + xmlp1s1s1c1step6.setAttribute("passrate","100") + xmlp1s1s1c1step6.setAttribute("enabled","true") + xmlp1s1s1c1step6.setAttribute("harness",harness) + xmlp1s1s1c1step6.setAttribute("name","Step "+str(xmlstepcount)) + xmlp1s1s1c1step6.setAttribute("id","1.1.1.1.1."+str(xmlstepcount)) + xmlp1s1s1case1.appendChild(xmlp1s1s1c1step6) + + xmlp1s1s1c1s6command1 = xmldoc.createElement("command") + xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6command1) + xmlp1s1s1c1s1command1text = xmldoc.createTextNode("makedir") + xmlp1s1s1c1s6command1.appendChild(xmlp1s1s1c1s1command1text) + + xmlp1s1s1c1s6params1 = xmldoc.createElement("params") + xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6params1) + + xmlp1s1s1c1s6p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param1.setAttribute("dir","e:\\temp\\lc_apitest") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param1) + + #execute test case step + if((cmp(harness, "STIF") == 0) or (cmp(harness, "stif") == 0) or (cmp(harness, "Stif") == 0)): + if((cmp(stiftype, "TESTSCRIPTER") == 0) or (cmp(stiftype, "Testscripter") == 0) or (cmp(stiftype, "testscripter") == 0)): + for cfgfiles_ in cfgFileNoPath: + xmlstepcount = xmlstepcount + 1 + xmlp1s1s1c1step = xmldoc.createElement("step") + xmlp1s1s1c1step.setAttribute("significant","false") + xmlp1s1s1c1step.setAttribute("passrate","100") + xmlp1s1s1c1step.setAttribute("enabled","true") + xmlp1s1s1c1step.setAttribute("harness",harness) + xmlp1s1s1c1step.setAttribute("name","Step "+str(xmlstepcount)) + xmlp1s1s1c1step.setAttribute("id","1.1.1.1.1."+str(xmlstepcount)) + xmlp1s1s1case1.appendChild(xmlp1s1s1c1step) + + xmlp1s1s1c1s1command1 = xmldoc.createElement("command") + xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1command1) + xmlp1s1s1c1s1command1text = xmldoc.createTextNode("run-cases") + xmlp1s1s1c1s1command1.appendChild(xmlp1s1s1c1s1command1text) + + xmlp1s1s1c1s1params1 = xmldoc.createElement("params") + xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1params1) + + xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param1.setAttribute("module","testscripter") + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1) + + xmlp1s1s1c1s1p1param2 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param2.setAttribute("filter","*") + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param2) + + xmlp1s1s1c1s1p1param3 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param3.setAttribute("timeout","3000") + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param3) + + xmlp1s1s1c1s1p1param4 = xmldoc.createElement("param") + xmlp1s1s1c1s1p1param4.setAttribute("testcase-file", CFGTARGETPATH + cfgfiles_) + xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param4) + + #fetch STIF test report + xmlstepcount = xmlstepcount + 1 + xmlp1s1s1c1step6 = xmldoc.createElement("step") + xmlp1s1s1c1step6.setAttribute("significant","false") + xmlp1s1s1c1step6.setAttribute("passrate","100") + xmlp1s1s1c1step6.setAttribute("enabled","true") + xmlp1s1s1c1step6.setAttribute("harness",harness) + xmlp1s1s1c1step6.setAttribute("name","Step "+str(xmlstepcount)) + xmlp1s1s1c1step6.setAttribute("id","1.1.1.1.1."+str(xmlstepcount)) + xmlp1s1s1case1.appendChild(xmlp1s1s1c1step6) + + xmlp1s1s1c1s6command1 = xmldoc.createElement("command") + xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6command1) + xmlp1s1s1c1s1command1text = xmldoc.createTextNode("fetch-log") + xmlp1s1s1c1s6command1.appendChild(xmlp1s1s1c1s1command1text) + + xmlp1s1s1c1s6params1 = xmldoc.createElement("params") + xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6params1) + + xmlp1s1s1c1s6p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param1.setAttribute("type","text") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param1) + + xmlp1s1s1c1s6p1param2 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param2.setAttribute("delete","true") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param2) + + xmlp1s1s1c1s6p1param3 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param3.setAttribute("path","C:\\Logs\\TestFramework\\*") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param3) + + #fetch test module own logs + xmlstepcount = xmlstepcount + 1 + xmlp1s1s1c1step6 = xmldoc.createElement("step") + xmlp1s1s1c1step6.setAttribute("significant","false") + xmlp1s1s1c1step6.setAttribute("passrate","100") + xmlp1s1s1c1step6.setAttribute("enabled","true") + xmlp1s1s1c1step6.setAttribute("harness",harness) + xmlp1s1s1c1step6.setAttribute("name","Step "+str(xmlstepcount)) + xmlp1s1s1c1step6.setAttribute("id","1.1.1.1.1."+str(xmlstepcount)) + xmlp1s1s1case1.appendChild(xmlp1s1s1c1step6) + + xmlp1s1s1c1s6command1 = xmldoc.createElement("command") + xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6command1) + xmlp1s1s1c1s1command1text = xmldoc.createTextNode("fetch-log") + xmlp1s1s1c1s6command1.appendChild(xmlp1s1s1c1s1command1text) + + xmlp1s1s1c1s6params1 = xmldoc.createElement("params") + xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6params1) + + xmlp1s1s1c1s6p1param1 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param1.setAttribute("type","text") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param1) + + xmlp1s1s1c1s6p1param2 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param2.setAttribute("delete","true") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param2) + + xmlp1s1s1c1s6p1param3 = xmldoc.createElement("param") + xmlp1s1s1c1s6p1param3.setAttribute("path","e:\\temp\\lc_apitest\\*") + xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param3) + + #files section + xmlfiles = xmldoc.createElement("files") + xmltest.appendChild(xmlfiles) + for file in filestoinstall: + xmlfilesfile1 = xmldoc.createElement("file") + if(file[1] == BINARYFILE): + xmlfile1text = xmldoc.createTextNode("ATS3Drop\\armv5_urel\\"+file[0]) + xmlfilesfile1.appendChild(xmlfile1text) + xmlfiles.appendChild(xmlfilesfile1) + else: + xmlfile1text = xmldoc.createTextNode("ATS3Drop\\"+file[0]) + xmlfilesfile1.appendChild(xmlfile1text) + xmlfiles.appendChild(xmlfilesfile1) + #image files in files section + for xmlimage in imagestoflash: + xmlflashfile = xmldoc.createElement("file") + xmlflashfiletext = xmldoc.createTextNode("ATS3Drop\\images\\" + xmlimage) + xmlflashfile.appendChild(xmlflashfiletext) + xmlfiles.appendChild(xmlflashfile) + + #post action: send logs by email + xmlpostaction = xmldoc.createElement("postAction") + xmltest.appendChild(xmlpostaction) + xmlactiontype = xmldoc.createElement("type") + xmlpostaction.appendChild(xmlactiontype) + xmlactiontext = xmldoc.createTextNode("SendEmailAction") + xmlactiontype.appendChild(xmlactiontext) + + xmlsendemailparams = xmldoc.createElement("params") + xmlpostaction.appendChild(xmlsendemailparams) + + xmlsendemailparam = xmldoc.createElement("param") + xmlsendemailparam.setAttribute("name", "type") + xmlsendemailparam.setAttribute("value", "ATS3_REPORT") + xmlsendemailparams.appendChild(xmlsendemailparam) + + xmlsendemailparam = xmldoc.createElement("param") + xmlsendemailparam.setAttribute("name", "to") + xmlsendemailparam.setAttribute("value","ext-aminul.2.islam@nokia.com;yongjiang.yu@nokia.com") + xmlsendemailparams.appendChild(xmlsendemailparam) + + xmlsendemailparam = xmldoc.createElement("param") + xmlsendemailparam.setAttribute("name", "subject") + xmlsendemailparam.setAttribute("value","LC API test report") + xmlsendemailparams.appendChild(xmlsendemailparam) + + xmlsendemailparam = xmldoc.createElement("param") + xmlsendemailparam.setAttribute("name", "unzip") + xmlsendemailparam.setAttribute("value","true") + xmlsendemailparams.appendChild(xmlsendemailparam) + + xmlsendemailparam = xmldoc.createElement("param") + xmlsendemailparam.setAttribute("name", "send-files") + xmlsendemailparam.setAttribute("value","true") + xmlsendemailparams.appendChild(xmlsendemailparam) + + xmlsendemailparam = xmldoc.createElement("param") + xmlsendemailparam.setAttribute("name", "report-dir") + xmlsendemailparam.setAttribute("value","\\\\jamppa\\ATS\\filestore\\api_auto_test_logs") + xmlsendemailparams.appendChild(xmlsendemailparam) + + # Print our newly created XML and create test.xml + print xmldoc.toprettyxml(indent=" ") + xmlfile = open(Directory + "\\test.xml", "w") + xmldoc.writexml(xmlfile, indent=" ", addindent=" ", newl="\n") + xmlfile.close() + + #create the testdrop.zip file + os.chdir(Directory) + + ret = os.system("zip -R testdrop.zip test.xml \".\\ATS3drop\\*\" \".\\ATS3drop\\armv5_urel\\*\" \".\\ATS3drop\\images\\*\"") + if(ret != 0): + print "Error : unable to create test.xml" + sys.exit() + +print "\n Test Drop Sucessfully created in "+Directory diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/bwins/btengsettingapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/bwins/btengsettingapitestu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/conf/btengsettingapitest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/conf/btengsettingapitest.cfg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,53 @@ +[StifSettings] +//CheckHeapBalance = on +[EndStifSettings] + +[Define] +BT_LOCAL_NAME BtApiTest +[Enddefine] + +# no 1 +[Test] +title Settings API: PowerState +create btengsettingapitest Tester +Tester PowerState +waittestclass Tester +delete Tester +[Endtest] + +#no 2 +[Test] +title Settings API: Visibility +create btengsettingapitest Tester +Tester Visibility +waittestclass Tester +delete Tester +[Endtest] + + +#no 3 +[Test] +title Settings API: LocalName +create btengsettingapitest Tester +Tester LocalName BT_LOCAL_NAME +waittestclass Tester +delete Tester +[Endtest] + +#no 4 +[Test] +title Settings API: GetOfflineModeSettingsApi +create btengsettingapitest Tester +Tester GetOfflineModeSettingsApi +waittestclass Tester +delete Tester +[Endtest] + +#no 5 +[Test] +title Settings API: ChangePowerStateTemporarily +create btengsettingapitest Tester +Tester ChangePowerStateTemporarily +waittestclass Tester +delete Tester +[Endtest] \ No newline at end of file diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/eabi/btengsettingapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/eabi/btengsettingapitestu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/gentestdrop.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/gentestdrop.bat Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +LC_ATS3DropGen.py -path \sf\mw\btservices\btservices_plat\bluetooth_engine_settings_api\tsrc -imagepath \sf\mw\btservices\tests\images -target devlon -harness STIF -stiftype Testscripter \ No newline at end of file diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +// NOTE: If using ARS requirements .mmp file operation should be done under this. +// 'abld test build' +btengsettingapitest.mmp + +PRJ_MMPFILES +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +/agnmodel/group/agnmodel.mmp +#if defined(MARM) +/agnmodel/group/agsvexe.mmp +#endif +*/ + + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/group/btengsettingapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/group/btengsettingapitest.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/*TYPE TESTCLASS*//* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + +#if defined(__S60_) + // To get the OS_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET btengsettingapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE btengsettingapitest.def + +SOURCEPATH ../src +SOURCE btapitest.cpp +SOURCE btapitestblocks.cpp +SOURCE bttestlogger.cpp +SOURCE btapisettings.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY sysutil.lib +LIBRARY stiftestinterface.lib +LIBRARY bluetooth.lib +LIBRARY btdevice.lib +//LIBRARY btmanclient.lib +LIBRARY btengsettings.lib +//LIBRARY btengdevman.lib +//LIBRARY btengdiscovery.lib +//LIBRARY btengconnman.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/group/btengsettingapitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/group/btengsettingapitest.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +; +; Copyright (c) 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: +; +;Languages +&EN + +;Header +#{"BtEngDiscoveryAPiTest"},(0x00000000),1,0,0 + +;Localised Vendor name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + +;Product ID for S60 5.1 +[0x10283160], 0, 0, 0, {"S60ProductID"} + +;Files to install +"\epoc32\release\armv5\udeb\btengsettingapitest.dll"-"c:\sys\bin\btengsettingapitest.dll" + +"..\conf\\btengsettingapitest.cfg"-"e:\testing\conf\btengsettingapitest.cfg" +"..\init\btengsettingapitest.ini"-"e:\testing\init\btengsettingapitest.ini" \ No newline at end of file diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/inc/btapisettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/inc/btapisettings.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef BTAPISETTINGS_H +#define BTAPISETTINGS_H + +#include +#include +#include + +#include "testobserver.h" + +/** +* Class for testing BT engine API +*/ +NONSHARABLE_CLASS ( CBTApiSettings ): public CBase, public MBTEngSettingsObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTApiSettings* NewL(MBTTestObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBTApiSettings(); + + // Testing functions + TInt TurnBtOn(); + TInt TurnBtOff(); + TInt SwitchPowerState(); + TInt SetPowerState( TBTPowerStateValue aState ); + TInt GetPowerState( TBTPowerStateValue & aState ); + TInt SetVisibilityMode( TBTVisibilityMode visibilityState, TInt aTimer = 0 ); + TInt GetVisibilityMode(); + TInt SetLocalName( TDesC& aName ); + TInt GetLocalName(); + TInt SetVisibilityNormalState(); + TInt GetExpectedState( TBTPowerStateValue & aState ); + TInt GetOfflineModeSettings(TCoreAppUIsNetworkConnectionAllowed &aOffline, + TBTEnabledInOfflineMode & aOfflineAllowed); + TInt ChangePowerStateTemporarily(); + + TInt KeepCurrentBtPowerStatus(); + TInt RecoverBtPowerStatus(); + + private: + + /** from MBTEngSettingsObserver */ + void PowerStateChanged( TBTPowerStateValue aState ); + void VisibilityModeChanged( TBTVisibilityMode aState ); + + /** + * C++ default constructor. + */ + CBTApiSettings( MBTTestObserver& aObserver ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: + + MBTTestObserver& iObserver; + CBTEngSettings* iBTEngSettings; + TBTPowerStateValue iExpectedPowerState; + TBTVisibilityMode iExpectedVisibility; + TBuf<100> iExpectedLocalName; + TInt iError; + CActiveSchedulerWait iWaiter; + + //For PowerState recovery purposes + TBTPowerStateValue iRecoveryPowerState; + }; + +#endif // BTAPISETTINGS_H + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/inc/btapitest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/inc/btapitest.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +#ifndef BTAPITEST_H +#define BTAPITEST_H + +// INCLUDES +#include +#include +#include +#include "testobserver.h" + + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +// Logging path +_LIT( KBtApiTestLogPath, "\\logs\\LC\\BTEng\\" ); +// Log file +_LIT( KBtApiTestLogFile, "BTEngSettingsApiTest.txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +class CBtTestLogger; +class CBTApiSettings; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CCBtApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CBtApiTest) : public CScriptBase, public MBTTestObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBtApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CBtApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + private: // From MBTTestObserver + + void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ); + + CBtTestLogger& Logger(); + + private: + + /** + * C++ default constructor. + */ + CBtApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Test methods. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CBTEngSettings_GetAndSetPowerState ( CStifItemParser& aItem ); + virtual TInt CBTEngSettings_SetAndGetVisibility ( CStifItemParser& aItem ); + virtual TInt CBTEngSettings_SetAndGetLocalName ( CStifItemParser& aItem ); + virtual TInt CBTEngSettings_GetOfflineModeSettingsApi ( CStifItemParser& aItem ); + virtual TInt CBTEngSettings_ChangePowerStateTemporarily ( CStifItemParser& aItem ); + + + private: // Data + + CBTApiSettings* iSettings; + CBtTestLogger* iTestLogger; + + }; + +#endif // BTAPITEST_H + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/inc/bttestlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/inc/bttestlogger.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +#ifndef BTTESTLOGGER_H +#define BTTESTLOGGER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CStifLogger; +class CTestModuleIf; + +// CLASS DECLARATION + +NONSHARABLE_CLASS( CBtTestLogger ) : public CBase +{ + public: + + static CBtTestLogger* NewL(const CTestModuleIf* aTestModuleIf); + virtual ~CBtTestLogger(); + + public: // Data used by functions + + enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug}; + + public: // New functions + + TBool GetEnabled() const; + CStifLogger* GetLogger() const; + const CTestModuleIf* GetTestModuleIf() const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const; + TInt LogNewLine() const; + void SetEnabled(TBool aEnabled); + void SetLogger(CStifLogger* aLog); + void SetTestModuleIf(const CTestModuleIf* aTestModuleIf); + + public: // Functions from base classes + + private: // New functions + + TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const; + TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const; + static TPtrC GetPrefix(TLogLevel aLevel); + TInt CheckLogFile(); + void LogHeadSectionL(); + void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const; + + private: // Constructors + + CBtTestLogger(const CTestModuleIf* aTestModuleIf); + void ConstructL(); + + public: // Data + static const TInt KPrefixLength; + + private: // Data + + TBool iEnabled; + CStifLogger* iLog; + const CTestModuleIf* iTestModuleIf; + }; + +#endif // BTTESTLOGGER_H + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/inc/testobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/inc/testobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef TESTOBSERVER_H +#define TESTOBSERVER_H + +#include + +#define TLFUNCLOG (TUint8*) __FUNCTION__ + +class CBtTestLogger; + +/** +* Testing supervisor +*/ +class MBTTestObserver + { + public: + + virtual void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) = 0; + + virtual CBtTestLogger& Logger() = 0; + + }; + +#endif // TESTOBSERVER_H + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/init/btengsettingapitest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/init/btengsettingapitest.ini Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,197 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= e:\testing\logs\ +TestReportFileName= btEngSettingApiTest_TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds + +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= TestScripter +TestCaseFile= e:\testing\conf\btengsettingapitest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file \ No newline at end of file diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/src/btapisettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/src/btapisettings.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,422 @@ +/* +* Copyright (c) 2002 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: Used for testing BT API +* Revision : $Revision: $ +* Date : $Date: $ +* +*/ + +#include +#include +#include +#include + +#include "btapisettings.h" +#include "bttestlogger.h" + +// Constructor +CBTApiSettings::CBTApiSettings( MBTTestObserver& aObserver ) + : iObserver( aObserver ) + { + } + +// Destructor +CBTApiSettings::~CBTApiSettings( ) + { + delete iBTEngSettings; + } + + +// NewL +CBTApiSettings* CBTApiSettings::NewL (MBTTestObserver& aObserver) + { + CBTApiSettings* self = new (ELeave) CBTApiSettings(aObserver); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// Symbian 2nd phase constructor. +void CBTApiSettings::ConstructL() + { + iBTEngSettings = CBTEngSettings::NewL( this ); + iExpectedPowerState = EBTPowerOff; + iExpectedVisibility = EBTVisibilityModeGeneral; + iError = KErrNone; + iExpectedLocalName.Zero(); + iRecoveryPowerState = EBTPowerOff; + } + +void CBTApiSettings::PowerStateChanged( TBTPowerStateValue aState ) + { + iError = KErrNone; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "PowerStateChanged: %d " ), aState); + + if ( iExpectedPowerState != aState ) + { + iError = KErrArgument; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "PowerStateChanged: state %d != expected %d" ), aState, iExpectedPowerState ); + } + if ( iWaiter.IsStarted() ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "PowerStateChanged: AsyncStop" ) ); + iWaiter.AsyncStop(); + } + } + +void CBTApiSettings::VisibilityModeChanged( TBTVisibilityMode aState ) + { + iError = KErrNone; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "VisibilityModeChanged: %d " ), aState ); + + if ( iExpectedVisibility != aState ) + { + iError = KErrArgument; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "VisibilityModeChanged: state %d != expected %d" ), aState, iExpectedVisibility ); + } + if ( iWaiter.IsStarted() ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "VisibilityModeChanged: AsyncStop" ) ); + iWaiter.AsyncStop(); + } + //User::After(2000000); + } + +TInt CBTApiSettings::TurnBtOn() + { + TBTPowerStateValue state; + TInt err = KErrNone; + + err = iBTEngSettings->GetPowerState( state ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::TurnBtOn: err %d, current state %d expected state %d" ), err, state, iExpectedPowerState ); + if ( err ) + { + return err; + } + + if( state == EBTPowerOff ) + { + state = EBTPowerOn; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::TurnBtOn: turning BT ON: %d (EBTPowerOn) " ), state); + } + else if ( state == EBTPowerOn ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::TurnBtOn: BT is ON. Nothing to do. " ), state); + return KErrNone; + } + else + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::TurnBtOn: State not allowed: %d ??? " ), state); + return KErrArgument; + } + + err = iBTEngSettings->SetPowerState( state ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::TurnBtOn: SetPowerState: err %d, state %d" ), err, state); + if ( err ) + { + return err; + } + + iExpectedPowerState = state; + iWaiter.Start(); + + return iError; + } + + +TInt CBTApiSettings::TurnBtOff( ) + { + TBTPowerStateValue state; + TInt err(KErrNone); + + err = iBTEngSettings->GetPowerState( state ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Current PowerState %d" ), state ); + if ( err ) + { + return err; + } + + if ( state == EBTPowerOn ) + { + state = EBTPowerOff; + } + else + return KErrNone; + + + err = iBTEngSettings->SetPowerState( state ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "SetPowerState: %d" ), state); + User::After(5000000); + if ( err ) + { + return err; + } + + iExpectedPowerState = state; + iWaiter.Start(); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "BT turned OFF" ) ); + + return iError; + } + +TInt CBTApiSettings::SwitchPowerState() + { + TBTPowerStateValue state; + TInt err = KErrNone; + + err = iBTEngSettings->GetPowerState( state ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::SwitchPowerState: err %d, current state %d" ), err, state); + if ( err ) + { + return err; + } + + if( state == EBTPowerOff ) + { + state = EBTPowerOn; + } + else if ( state == EBTPowerOn) + { + state = EBTPowerOff; + } + else + { + return KErrArgument; + } + + err = iBTEngSettings->SetPowerState( state ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::SwitchPowerState: err %d, new state %d" ), err, state); + if ( err ) + { + return err; + } + iExpectedPowerState = state; + iWaiter.Start(); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Switching BT power: %d" ), state); + return iError; + } + +TInt CBTApiSettings::SetPowerState( TBTPowerStateValue aState ) + { + TInt err = KErrNone; + + err = iBTEngSettings->SetPowerState( aState ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::SetPowerState: err %d, set state %d" ), err, aState); + if ( err ) + { + return err; + } + iExpectedPowerState = aState; + iWaiter.Start(); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::SetPowerState: Done" ) ); + + return iError; + } + +TInt CBTApiSettings::GetExpectedState( TBTPowerStateValue & aState ) + { + aState = iExpectedPowerState; + return KErrNone; + } + +TInt CBTApiSettings::GetPowerState(TBTPowerStateValue & aState) + { + TInt err = KErrNone; + + err = iBTEngSettings->GetPowerState( aState ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::GetPowerState: err %d, state %d" ), err, aState); + if ( err ) + { + return err; + } + + if ( iExpectedPowerState != aState ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::GetPowerState: state %d != expected %d" ), aState); + return KErrArgument; + } + return err; + } + +TInt CBTApiSettings::SetVisibilityNormalState() + { + TInt err = KErrNone; + TBTVisibilityMode mode; + + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "SetVisibilityNormalState:" )); + + err = iBTEngSettings->GetVisibilityMode( mode ); + if ( err ) + { + return err; + } + + if ( mode != EBTVisibilityModeGeneral ) + { + err = iBTEngSettings->SetVisibilityMode( EBTVisibilityModeGeneral ); + if ( err ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "SetVisibilityNormalState: err %d" ), err); + return err; + } + } + return KErrNone; + } + +TInt CBTApiSettings::SetVisibilityMode( TBTVisibilityMode visibilityState, TInt aTimer ) + { + TInt err = KErrNone; + + err = iBTEngSettings->SetVisibilityMode( visibilityState, aTimer ); + + if ( err ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Switching BT visibility: err %d" ), err); + return err; + } + + iExpectedVisibility = visibilityState; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Switching BT visibility: %d" ), visibilityState); + iWaiter.Start(); + return iError; + } + +TInt CBTApiSettings::GetVisibilityMode() + { + TInt err = KErrNone; + TBTVisibilityMode mode; + + err = iBTEngSettings->GetVisibilityMode( mode ); + + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "GetVisibilityMode: err %d" ), err); + if ( err ) + { + return err; + } + + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "GetVisibilityMode: mode %d != %d" ), mode, iExpectedVisibility); + if ( iExpectedVisibility!= mode ) + { + return KErrArgument; + } + + return iError; + } + +TInt CBTApiSettings::SetLocalName( TDesC& aName ) + { + TInt err = KErrNone; + iExpectedLocalName = aName; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Setting BT localname to: %S" ), &aName); + err = iBTEngSettings->SetLocalName( iExpectedLocalName ); + if ( err ) + { + iExpectedLocalName.Zero(); + } + return err; + } + +TInt CBTApiSettings::GetLocalName() + { + TInt err = KErrNone; + TBuf<100> name; + err = iBTEngSettings->GetLocalName( name ); + + if ( iExpectedLocalName.Length() ) + { + if ( name.Compare( iExpectedLocalName ) ) + { + err = KErrArgument; + } + } + return err; + } + +TInt CBTApiSettings::KeepCurrentBtPowerStatus() + { + TInt err(KErrNone); + err = iBTEngSettings->GetPowerState( iRecoveryPowerState ); + iObserver.Logger().Log(CBtTestLogger::ETLDebug, _L( "KeepCurrentBtPowerStatus %d" ), iRecoveryPowerState ); + User::After(5000000); + if ( err ) + { + iObserver.Logger().Log(CBtTestLogger::ETLDebug, _L( "KeepCurrentBtPowerStatus: Error %d" ), err ); + return err; + } + return err; + } + +TInt CBTApiSettings::RecoverBtPowerStatus() + { + TInt err(KErrNone); + iObserver.Logger().Log(CBtTestLogger::ETLDebug, _L( "RecoverBtPowerStatus %d" ), iRecoveryPowerState ); + err = iBTEngSettings->SetPowerState( iRecoveryPowerState ); + User::After(5000000); + if ( err ) + { + iObserver.Logger().Log(CBtTestLogger::ETLDebug, _L( "RecoverBtPowerStatus: Error %d" ), err ); + return err; + } + iExpectedPowerState = iRecoveryPowerState; + iWaiter.Start(); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "RecoverBtPowerStatus: Done" ) ); + return iError; + } + +TInt CBTApiSettings::GetOfflineModeSettings(TCoreAppUIsNetworkConnectionAllowed & aOffline, TBTEnabledInOfflineMode & aOfflineAllowed) + { + TInt err(KErrNone); + + err = iBTEngSettings->GetOfflineModeSettings( aOffline, aOfflineAllowed ); + iObserver.Logger().Log(CBtTestLogger::ETLDebug, _L( "Offline: %d OfflineAllowed %d" ), aOffline, aOfflineAllowed ); + return err; + } + +TInt CBTApiSettings::ChangePowerStateTemporarily() + { + TInt err(KErrNone); + /* + err = KeepCurrentBtPowerStatus(); + if ( err ) + { + return err; + } + + err = TurnBtOff(); + if ( err ) + { + return err; + } + */ + err = iBTEngSettings->ChangePowerStateTemporarily(); + if( err) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "ChangePowerStateTemporarily: Error" ) ); + return err; + } + iWaiter.Start(); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "ChangePowerStateTemporarily: Done" ) ); + /* + err = RecoverBtPowerStatus(); + if ( err ) + { + return err; + } + */ + return err; + } + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/src/btapitest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/src/btapitest.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include "btapitest.h" +#include "bttestlogger.h" +#include "btapisettings.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtApiTest::CCBtApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBtApiTest::CBtApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CBtApiTest::ConstructL() + { + iTestLogger = CBtTestLogger::NewL( &TestModuleIf() ); + iLog = iTestLogger->GetLogger(); + iSettings = CBTApiSettings::NewL( *this ); + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBtApiTest* CBtApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CBtApiTest* self = new (ELeave) CBtApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// Destructor +CBtApiTest::~CBtApiTest() + { + // Delete resources allocated from test methods + Delete(); + + delete iSettings; + delete iTestLogger; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CBtApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/src/btapitestblocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/src/btapitestblocks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,372 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "btapitest.h" +#include "bttestlogger.h" +#include "btapisettings.h" + + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CBtApiTest::Delete() + { + + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + ENTRY( "PowerState", CBTEngSettings_GetAndSetPowerState ), + ENTRY( "Visibility", CBTEngSettings_SetAndGetVisibility ), + ENTRY( "LocalName", CBTEngSettings_SetAndGetLocalName ), + ENTRY( "GetOfflineModeSettingsApi", CBTEngSettings_GetOfflineModeSettingsApi ), + ENTRY( "ChangePowerStateTemporarily", CBTEngSettings_ChangePowerStateTemporarily ), + ENTRY( "CP", CBTEngSettings_ChangePowerStateTemporarily ), + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::TestCompleted +// ----------------------------------------------------------------------------- +// +void CBtApiTest::TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) + { + iTestLogger->LogResult( (TPtrC8( aFunc )), aArg, aErr ); + Signal( aErr ); + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::Logger +// ----------------------------------------------------------------------------- +// +CBtTestLogger& CBtApiTest::Logger() + { + return *iTestLogger; + } + + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngSettings_SetAndGetPowerState +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngSettings_GetAndSetPowerState( CStifItemParser& /*aItem*/ ) + { + /* + TInt err = KErrNone; + TBTPowerStateValue state, expState; + TInt i = 0; + + for ( i=0 ; i<2 ; i++ ) + { + state = EBTPowerOn; + err = iSettings->SetPowerState( state ); + iSettings->GetExpectedState( expState ); + iTestLogger->Log(CBtTestLogger::ETLDebug, _L( "CBTApiSettings::SetAndGetPowerState: %d) Error %d -:- state %d -:- expected state %d" ), i, err, state, expState ); + iTestLogger->LogNewLine(); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L("SetAndGetPowerState: Problem with state seting)")); + return err; + } + } + TestCompleted( err, TLFUNCLOG, _L("SetAndGetPowerState: Done)")); + return err; +*/ +/* + for ( i=0 ; i<2 ; i++ ) + { + iSettings->GetExpectedState( expState ); + err = iSettings->GetPowerState( state ); + iTestLogger->Log(CBtTestLogger::ETLDebug, _L( "CBTApiSettings::SetAndGetPowerState: %d) Error %d -:- state %d -:- expected state %d" ), i, err, state, expState ); + iTestLogger->LogNewLine(); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L("SetAndGetPowerState: Problem with state reading)")); + return err; + } + } + TestCompleted( err, TLFUNCLOG, _L("SetAndGetPowerState: Done)")); + return err; + */ + +/************************* + * Working implementation + * ********************** + + TInt err = KErrNone; + + err = iSettings->TurnBtOn(); + if( err ) + { + TestCompleted( err, TLFUNCLOG, _L("TurnBTOn")); + return err; + } + */ + TInt err = KErrNone; + + err = iSettings->SwitchPowerState(); + if( err ) + { + TestCompleted( err, TLFUNCLOG, _L("SwitchPowerState (1)")); + return err; + } + + TestCompleted( err, TLFUNCLOG, _L("SetAndGetPowerState: Done)")); + return err; + +/* + TInt ret = KErrNone; + + ret = iSettings->SwitchPowerState(); + _LIT(KSetAndGetPowerStateSwitchPowerState, "\nSetAndGetPowerState:> SwitchPowerState = %d"); + iLog->Log(KSetAndGetPowerStateSwitchPowerState, ret); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("SwitchPowerState 1")); + return KErrNone; + } + + ret = iSettings->GetPowerState(); + _LIT(KSetAndGetPowerStateGetPowerState, "\nSetAndGetPowerState:> GetPowerState err = %d"); + iLog->Log(KSetAndGetPowerStateGetPowerState, ret); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("GetPowerState")); + return KErrNone; + } + + ret = iSettings->TurnBtOn(); + _LIT(KSetAndGetPowerStateTurnBtOn, "\nSetAndGetPowerState:> TurnBtOn = %d"); + iLog->Log(KSetAndGetPowerStateTurnBtOn, ret); + + TestCompleted( ret, TLFUNCLOG, _L("TurnBtOn)")); + + return KErrNone; + */ + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngSettings_SetAndGetVisibility +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngSettings_SetAndGetVisibility( CStifItemParser& /*aItem*/ ) + { + TInt ret = KErrNone; + + ret = iSettings->SetVisibilityNormalState(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("SetVisibilityNormalState() method error")); + return KErrNone; + } + + + ret = iSettings->SetVisibilityMode( EBTVisibilityModeHidden ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Set EBTVisibilityModeHidden")); + return KErrNone; + } + ret = iSettings->GetVisibilityMode(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Get EBTVisibilityModeHidden")); + return KErrNone; + } + + ret = iSettings->SetVisibilityMode( EBTVisibilityModeTemporary, 1 ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Set EBTVisibilityModeTemporary")); + return KErrNone; + } + + ret = iSettings->GetVisibilityMode(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Get EBTVisibilityModeTemporary")); + return KErrNone; + } + + ret = iSettings->SetVisibilityMode( EBTVisibilityModeGeneral ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Set EBTVisibilityModeGeneral")); + return KErrNone; + } + ret = iSettings->GetVisibilityMode(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Get EBTVisibilityModeGeneral")); + return KErrNone; + } + + TestCompleted( ret, TLFUNCLOG, _L("")); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngSettings_SetAndGetLocalName +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngSettings_SetAndGetLocalName( CStifItemParser& aItem ) + { + TPtrC name(KNullDesC); + TInt ret = aItem.GetNextString( name ); + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "Set new local name: %S" ), &name); + if ( ret ) + { + TestCompleted( KErrArgument, TLFUNCLOG, name ); + return KErrNone; + } + + ret = iSettings->SetLocalName( name ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, name ); + return KErrNone; + } + + ret = iSettings->GetLocalName(); + + TestCompleted( ret, TLFUNCLOG, name ); + return KErrNone; + } + + +TInt CBtApiTest::CBTEngSettings_GetOfflineModeSettingsApi( CStifItemParser& /*aItem*/ ) + { + TPtrC name(KNullDesC); + TInt err(KErrNone); + + TCoreAppUIsNetworkConnectionAllowed offline; + TBTEnabledInOfflineMode offlineAllowed; + + err = iSettings->GetOfflineModeSettings(offline, offlineAllowed); + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "Start GetOfflineModeSettingsApiTest> %d %d" ), offline, offlineAllowed); + if( err ) + { + TestCompleted( err, TLFUNCLOG, _L("") ); + return err; + } + + switch( offline ) + { + case ECoreAppUIsNetworkConnectionNotAllowed: + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "Network connection not allowed (%d)" ), ECoreAppUIsNetworkConnectionNotAllowed); + break; + case ECoreAppUIsNetworkConnectionAllowed: + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "Network connection allowed (%d)" ), ECoreAppUIsNetworkConnectionAllowed); + break; + } + + switch( offlineAllowed ) + { + case EBTDisabledInOfflineMode: + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "BT activation disabled in offline mode (%d)" ), EBTDisabledInOfflineMode); + break; + case EBTEnabledInOfflineMode: + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "BT activation enabled in offline mode (%d)" ), EBTEnabledInOfflineMode); + break; + } + + TestCompleted( err, TLFUNCLOG, _L("") ); + return err; + } + +TInt CBtApiTest::CBTEngSettings_ChangePowerStateTemporarily( CStifItemParser& /*aItem*/ ) +{ + TPtrC name(KNullDesC); + TInt err(KErrNone); + + err = iSettings->ChangePowerStateTemporarily(); + if( err ) + { + TestCompleted(err, TLFUNCLOG, _L("")); + return err; + } + + TestCompleted(err, TLFUNCLOG, _L("")); + return err; +} + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_engine_settings_api/tsrc/src/bttestlogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_engine_settings_api/tsrc/src/bttestlogger.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,531 @@ +/* +* Copyright (c) 2007 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: +* +*/ + +// INCLUDES + +#include "bttestlogger.h" + +#include +#include + +#include +#include +#include + +// RDebug +#include + +const TInt CBtTestLogger::KPrefixLength = 8; +// Timestamp string length +const TInt KTimeStampStrLen = 21; +// Extended Timestamp string length +const TInt KExtTimeStampStrLen = 80; +// Extended time stamp +typedef TBuf TExtTimeStamp; +// Logging path +_LIT( KBtAudioTestSystemLogPath, "e:\\temp\\LC\\BTEng\\" ); +//_LIT( KBtAudioTestSystemLogPath, "c:\\temp\\lc_apitest\\" ); +// Log file +_LIT( KBtAudioTestSystemLogFile, "BTEngSettingsApiTestLog.html" ); +// Log file +_LIT( KBtAudioTestSystemLogFullName, "\\temp\\LC\\BTEng\\BtEngSettingsApiTestLog.html" ); +// Time stamp format string +_LIT( KFormatTimeStamp, "
[%H:%T:%S.%*C4] " ); +// Date format string +_LIT( KFormatDate, "%F%D %N %Y" ); +// HTML header section +_LIT( KHtmlHeadSection, "\n\nBT Audio Test System results\n\n\n\n\n\n" ); +// HTML code which will display the statistics +_LIT( KHtmlStatSection, "

Logfile created on %S at %S
\nS60 version %S

\n\n
\n
\n\n" ); +// HTML identifier for test case start +_LIT( KHtmlTestCaseStart, "
" ); +// Test case result logging +_LIT( KTestCaseResult, "Test completed; function %S, parameter %S, result
%d
" ); +// JavaScript function for calculating test result +#define KJSSECTION _L( "" ) + +// Construction and destruction. + +// ----------------------------------------------------------------------------- +// CBtTestLogger::NewL +// Static constructor to constructor builder objects. +// ----------------------------------------------------------------------------- +// +CBtTestLogger* CBtTestLogger::NewL(const CTestModuleIf* aTestModuleIf) + { + CBtTestLogger* self = new (ELeave) CBtTestLogger(aTestModuleIf); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::CBtTestLogger +// Constructor. +// ----------------------------------------------------------------------------- +// +CBtTestLogger::CBtTestLogger(const CTestModuleIf* aTestModuleIf) + : CBase(), + iEnabled(ETrue), + iTestModuleIf(aTestModuleIf) + { + } + +// ----------------------------------------------------------------------------- +// CTestLogger::ConstructL +// 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::ConstructL() + { + TInt err = CheckLogFile(); + iLog = CStifLogger::NewL( KBtAudioTestSystemLogPath, KBtAudioTestSystemLogFile, + CStifLogger::ETxt, CStifLogger::EFile, EFalse, EFalse ); + if( err == KErrNotFound ) + { // Add info & HTML markup to the beginning of the log file. + LogHeadSectionL(); + } + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::~CBtTestLogger +// Destructor. +// ----------------------------------------------------------------------------- +// +CBtTestLogger::~CBtTestLogger() + { + delete iLog; + } + +// Member functions. + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetLogger +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +CStifLogger* CBtTestLogger::GetLogger() const + { + return iLog; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetTestModuleIf +// Returns a pointer to current STIF test module interface. +// ----------------------------------------------------------------------------- +// +const CTestModuleIf* CBtTestLogger::GetTestModuleIf() const + { + return iTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList( aLogText, args ); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Append log prefix to the output buffer. + buffer.Insert( 0, GetPrefix( aLevel ) ); + + // Log a timestamp + TStifLoggerTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Log a timestamp + TStifLoggerTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const + { + TExtTimeStamp func; + func.Copy( aFunc ); // Copy 8-bit string to 16-bit buffer + + Log( CBtTestLogger::ETLResult, KTestCaseResult, &func, &aArg, aRes ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::LogNewLine() const + { + if (!iEnabled) + { + return KErrNone; + } + TExtTimeStamp time; + TRAPD( err, LogTimeStampL( time ) ); + if( !err ) + { + time.Insert( 0, KHtmlTestCaseStart ); + err = iLog->Log( time ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetEnabled +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetEnabled(TBool aEnabled) + { + iEnabled = aEnabled; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetLogger +// Sets a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetLogger(CStifLogger* aLog) + { + iLog = aLog; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetTestModuleIf +// Sets a pointer to current STIF test module. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetTestModuleIf(const CTestModuleIf* aTestModuleIf) + { + iTestModuleIf = aTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::WriteLog(TLogLevel aLevel, TDes16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(aLevel, _L(""), log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(0, aCategory, log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetPrefix +// Returns the prefix for a given logging level. +// ----------------------------------------------------------------------------- +// +TPtrC CBtTestLogger::GetPrefix(TLogLevel aLevel) + { + // Select a prefix for a log level and return a pointer to it. + switch(aLevel) + { + case ETLError: + { + TPtrC logPrefix = _L("ERROR : "); + return logPrefix; + } + case ETLInfo: + case ETLResult: + { + TPtrC logPrefix = _L("INFO : "); + return logPrefix; + } + case ETLDebug: + { + TPtrC logPrefix = _L("DEBUG : "); + return logPrefix; + } + default: + { + // Return a null pointer. + return TPtrC(); + } + + } + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::CheckLogFile +// Check if a log file is already existing, otherwise HTML formatting +// should be added. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::CheckLogFile() + { + RThread thread; + TInt id = thread.Id(); + TBuf file; + file.Format( KBtAudioTestSystemLogFullName, id ); + RFs fs; + TInt err = fs.Connect(); + TBool open = EFalse; + if( !err ) + { + err = fs.IsFileOpen( file, open ); + } + fs.Close(); + return err; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogTimeStamp +// Log HTML head section and general information in a newly created logfile. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::LogHeadSectionL() + { + iLog->Log( KHtmlHeadSection ); + iLog->Log( KJSSECTION ); + TBuf version( _L( "Version unknown!" ) ); + (void) SysUtil::GetSWVersion( version ); + TStifLoggerTimeStamp8 date; + LogTimeStampL( date, EFalse ); + TStifLoggerTimeStamp8 time; + LogTimeStampL( time ); + TPtrC timePtr( time.Mid( 6, 13 ) ); + iLog->Log( KHtmlStatSection, &date, &timePtr, &version ); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogTimeStamp +// Format a timestamp for logging. +// If aTime is set to false, the (formatted) date is returned. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::LogTimeStampL(TDes& aBuf, TBool aTime) const + { + TTime time; + time.HomeTime(); // Get time and format it + if( aTime ) + { + time.FormatL( aBuf, KFormatTimeStamp ); + } + else + { + time.FormatL( aBuf, KFormatDate ); + } + } diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_local_variation_api/bluetooth_local_variation_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_local_variation_api/bluetooth_local_variation_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth Local Variation API + defines local variable features in Bluetooth Engine subsystem + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_local_variation_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_local_variation_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Local Variation API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btengdomaincrkeys.h MW_LAYER_PLATFORM_EXPORT_PATH(btengdomaincrkeys.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_local_variation_api/inc/btengdomaincrkeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_local_variation_api/inc/btengdomaincrkeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine domain central repository key definitions. +* +*/ + + +#ifndef BTENG_DOMAIN_CR_KEYS_H +#define BTENG_DOMAIN_CR_KEYS_H + + +#include + + +/** Bluetooth Engine CenRep Uid */ +const TUid KCRUidBluetoothEngine = { 0x10204DAB }; + + +/** + * CenRep key for storing Bluetooth feature settings. + * Indicates if Bluetooth Headset Profile is supported or not. + * + * Possible integer values: + * 0 Headset Profile not supported + * 1 Headset Profile supported + * + * Default value: 1 + */ +const TUint32 KBTHspSupported = 0x00000001; + + +/** Enumeration for Headset profile support */ +enum TBTHspSupported + { + EBTHspNotSupported = 0, + EBTHspSupported + }; + + +/** + * CenRep key for storing Bluetooth feature settings. + * Product specific settings for activating BT in offline mode. + * + * Possible integer values: + * 0 BT activation disabled in offline mode + * 1 BT activation enabled in offline mode + * + * Default value: 1 + */ +const TUint32 KBTEnabledInOffline = 0x00000002; + + +/** Enumeration for Bluetooth activation in offline mode */ +enum TBTEnabledInOfflineMode + { + EBTDisabledInOfflineMode = 0, + EBTEnabledInOfflineMode + }; + + +/** + * CenRep key for storing Bluetooth feature settings. + * Indicates if eSCO is supported. + * + * Possible integer values: + * 0 eSCO not supported + * 1 eSCO not supported + * + * Default value: 0 + */ +const TUint32 KBTEScoSupportedLV = 0x00000003; + + +/** Enumeration for eSCO support */ +enum TBTEScoSupported + { + EBTEScoNotSupported = 0, + EBTEScoSupported + }; + + +/** + * CenRep key for storing Bluetooth feature settings. + * Indicates if device selection/passkey setting by means + * other than user input is enabled. + * + * Possible integer values: + * 0 Out-of-band setting is disabled + * 1 Out-of-band setting is enabled + * + * Default value: 0 + */ +const TUint32 KBTOutbandDeviceSelectionLV = 0x00000004; + + +/** Enumeration for out-of-band selection mode */ +enum TBTOutbandSelection + { + EBTOutbandDisabled = 0, + EBTOutbandEnabled + }; + + +/** + * CenRep key for storing Bluetooth feature settings. + * Stores the Bluetooth Vendor ID. + * + * The integer value is specified by the Bluetooth SIG, and used for the + * Device Identification Profile. It needs to be pre-set by each product. + */ +const TUint32 KBTVendorID = 0x00000005; + + +/** + * CenRep key for storing Bluetooth feature settings. + * Stores the Bluetooth Product ID. + * + * The integer value is used for the Device Identification Profile. It is + * product-specific, and the values are managed by the company + * (as identified by the Vendor ID) It needs to be pre-set by each product. + */ +const TUint32 KBTProductID = 0x00000006; + +/** + * CenRep key for storing Bluetooth feature settings. + * Indicates if supports remote volume control over AVRCP Controller. + * + * Possible integer values: + * 0 supported + * 1 supported + * + * Default value: 1 + */ +const TUint32 KBTAvrcpVolCTLV = 0x00000007; + +/** Enumeration for remote volume control AVRCP Controller support */ +enum TBTAvrcpVolCTSupported + { + EBTAvrcpVolCTNotSupported = 0, + EBTAvrcpVolCTSupported + }; + + +/** + * CenRep key for default folder for file receiving. + * Indicates where receving files will be saved. + + * Possible integer values: + * 0 supported + * 1 supported + * + * Default value: Received files\\ + */ +const TUint32 KLCReceiveFolder = 0x0000000A; + +/** + * CenRep key for storing Bluetooth feature settings. + * Indicates support of automatic disconnection when audio link opening fails + * + * Possible integer values: + * 0 disabled; + * 1 enabled. + * + * Default value: 1 in S60 3.2, and 0 since S60 5.0 + */ +const TUint32 KBTDisconnectIfAudioOpenFailsLV = 0x00000010; + +/** Enumeration for automatic disconnection activation/deactivation */ +enum TBTAutoDisconnectIfAudioOpenFails + { + EBTNotDisconnectIfAudioOpenFails = 0, + EBTDisconnectIfAudioOpenFails = 1 + }; + +/** Bluetooth Local Device Address CenRep UID */ +const TUid KCRUidBluetoothLocalDeviceAddress = { 0x10204DAA }; + +/** + * CenRep key for storing the Bluetooth local device address. + * + * Default value (in string format): "" + */ +const TUint32 KBTLocalDeviceAddress = 0x00000001; + + +#endif // BTENG_DOMAIN_CR_KEYS_H diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_notifier_internal_api/bluetooth_notifier_internal_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_notifier_internal_api/bluetooth_notifier_internal_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth Notifier internal API + Contains domain notifier UIDs + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_notifier_internal_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_notifier_internal_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Notifier internal API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btnotif.h MW_LAYER_PLATFORM_EXPORT_PATH(btnotif.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_notifier_internal_api/inc/btnotif.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_notifier_internal_api/inc/btnotif.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth notifiers API (partly). +* +*/ + + + +#ifndef BTNOTIF_H +#define BTNOTIF_H + +#include +#include //Definition of "KPowerModeSettingNotifierUid" +#include +#include //BT protocol wide types +#include +#include + +const TUid KBTObexPasskeyQueryNotifierUid = {0x100059A0}; +const TUid KBTGenericInfoNotifierUid = {0x20002778}; +const TUid KBTGenericQueryNotifierUid = {0x20002779}; +const TUid KBTPairedDeviceSettingNotifierUid = {0x100059E3}; +const TUid KBTEnterpriseItSecurityInfoNotifierUid = {0x20028779}; + +//Type definition for ObexPin notifier +const TInt KBTObexPasskeyMaxLength = 16; + +//Copied from BTUI.h, btui and btnotif under same aContext.iMajor. +const TUid KUidBTUI = { 0x10005951 }; + +typedef TBuf8 TBTObexPasskey; +typedef TPckgBuf TObexPasskeyBuf; + +enum TBTGenericQueryNoteType + { + EBTReceiveMessageQuery=300, + EBTReceiveMessagePairedQuery, + EBTIsOffQuery, + EBTActivateOffLineQuery, + EBTNoDevicesFoundQuery, + EBTAcceptRequestQuery, + EBTBlockConnectionQuery, + EBTBlockPairedConnectionQuery, + + EBTIsNotShownQuery, + EBTIsOffJavaQuery, + EBTNameQuery, + EBTSwitchOffAnyway + }; + +enum TBTGenericInfoNoteType + { + EBTConnected=0 /*R_BT_CONF_CONNECTED_PROMPT*/, + EBTDisconnected /*R_BT_CONF_DISCONNECTED_PROMPT*/, + EBTAudioAccessory /*R_BT_AUDIO_ACCESSORY_PROMPT*/, + EBTAudioHandset /*R_BT_AUDIO_HANDSET_PROMPT*/, + EBTClosed /*R_BT_CONN_CLOSED_PROMPT*/, + EBTDeviceNotAvailable /*R_BT_DEVICE_NOT_AVAIL*/, + EBTOfflineDisabled /*R_BT_OFFLINE_DISABLED*/, + + EBTVisibilityTimeout /*R_BT_HIDDEN_FROM_OTHERS_NOTE*/, + + EBTEnterSap /*R_BT_ENTER_SAP_NOTE*/, + EBTSapOk /*R_BT_ENTER_SAP_SUCCEED_NOTE*/, + EBTSapFailed /*R_BT_ENTER_SAP_FAILED_NOTE*/, + EBTSapNoSim /*R_BT_SAP_NO_SIM_NOTE*/, + + EBTDeviceBusy /*R_BT_BUSY_NOTE */, + + EIRNotSupported /*R_IR_NOT_SUPPORTED */, + + ECmdShowBtBatteryLow /*R_BT_ACCESSORY_LOW */, + ECmdShowBtBatteryCritical /*R_BT_ACCESSORY_CRITICAL */, + EBTStayPowerOn /*R_BT_PERMANENT_ON*/, + EBTSwitchedOn /*R_BT_SWITCHED_ON*/, + EBTSwitchedOff /*R_BT_SWITCHED_OFF*/ + }; + +struct TBTGenericInfoNotifierParams + { + TBuf8 iRemoteAddr; + TBTGenericInfoNoteType iMessageType; + }; + +struct TBTGenericQueryNotifierParams + { + TBTGenericQueryNoteType iMessageType; + TBool iNameExists; // False if the name is not filled. + TBTDeviceName iName; + }; + +struct TBTPairedDeviceSettingParams + { + TBTDevAddr iRemoteAddr; + TInt iPairingStatus; + }; + +typedef TPckgBuf TBTGenericInfoNotiferParamsPckg; +typedef TPckgBuf TBTGenericQueryNotiferParamsPckg; +typedef TPckgBuf TBTPairedDeviceSettingParamsPckg; + +#endif // BTNOTIF_H + +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_sap_connection_state_api/bluetooth_sap_connection_state_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_sap_connection_state_api/bluetooth_sap_connection_state_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth SAP Connection State API + defines a P&S key for getting SAP connection status + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_sap_connection_state_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_sap_connection_state_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth SAP Connection State API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/BTSapInternalPSKeys.h MW_LAYER_PLATFORM_EXPORT_PATH(BTSapInternalPSKeys.h) +../inc/BTSapDomainPSKeys.h MW_LAYER_PLATFORM_EXPORT_PATH(BTSapDomainPSKeys.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_sap_connection_state_api/inc/BTSapDomainPSKeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_sap_connection_state_api/inc/BTSapDomainPSKeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef __BTSAP_DOMAIN_PS_KEYS_H__ +#define __BTSAP_DOMAIN_PS_KEYS_H__ + +const TUid KPSUidBluetoothSapConnectionState = {0x10204DB1}; + +/** +* Information about the state of the BTSap connection +* +* Possible integer values: +* 0 (EBTSapNotConnected) Not connected +* 1 (EBTSapConnecting) Connection under negotiation +* 2 (EBTSapConnected) Connected +* +* Default value: 0 (EBTSapNotConnected) +* +* (Shared data key: KSapState) +*/ +const TUint KBTSapConnectionState = 0x00000001; + +// Enumeration that defines the different SAP connection states +enum TBTSapState + { + EBTSapNotConnected = 0, + EBTSapConnecting = 1, + EBTSapConnected = 2, + EBTSapAccepted = 3, + EBTSapRejected = 4 + }; + +#endif // __BTSAP_DOMAIN_PS_KEYS_H__ diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_sap_connection_state_api/inc/BTSapInternalPSKeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_sap_connection_state_api/inc/BTSapInternalPSKeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,22 @@ +/* +* Copyright (c) 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: +* +*/ +#ifndef __BTSAP_INTERNAL_PS_KEYS_H__ +#define __BTSAP_INTERNAL_PS_KEYS_H__ + +#include "BTSapDomainPSKeys.h" + +#endif // __BTSAP_INTERNAL_PS_KEYS_H__ diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_secondary_display_notification_api/bluetooth_secondary_display_notification_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_secondary_display_notification_api/bluetooth_secondary_display_notification_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth Secondary Display Notification API + defines message IDs for showing in the secondary display + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_secondary_display_notification_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_secondary_display_notification_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Secondary Display Notification API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/secondarydisplay/BTnotifSecondaryDisplayAPI.h MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/BTnotifSecondaryDisplayAPI.h) +../inc/secondarydisplay/BtuiSecondaryDisplayAPI.h MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/BtuiSecondaryDisplayAPI.h) diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_secondary_display_notification_api/inc/secondarydisplay/BTnotifSecondaryDisplayAPI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_secondary_display_notification_api/inc/secondarydisplay/BTnotifSecondaryDisplayAPI.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2002-2005 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: The set of messages provided to Secondary Display software by +* : BT notifier. +* +*/ + +#ifndef BTNOTIF_SECONDARY_DISPLAY_API_H +#define BTNOTIF_SECONDARY_DISPLAY_API_H + +// INCLUDES +#include + +/* +* ============================================================================== +* Input parameter TBTDeviceName is defined in btdevice.h +* "typedef TBuf TBTDeviceName" +* ============================================================================== +*/ +#include + + +// The category UID for the messages in this header file. +// +const TUid KUidCoverUiCategoryBTnotif = { 0x10005953 }; // UID of the BTnotif Dll + + +/* +* ============================================================================== +* Dialogs shown by BT notifier. These messages are handled using the +* Secondary Display support in Avkon. +* ============================================================================== +*/ +enum TSecondaryDisplayBTnotifDialogs + { + /** + * Command for a specified dialog is unavailable + */ + ECmdBTnotifUnavailable = 0, + + /** + * A command for showing "e.g. Open cover and enter pin code" + */ + // do we need this one at all ??? + ECmdShowBtOpenCoverNote = 1, + + /** + * A command for showing the "Receive message via Bluetooth from paired device %U?" + */ + ECmdShowReceiveMessageFromPairedDeviceDlg, +//#define qtn_bt_receive_message_paired "Receive message via Bluetooth from paired device %U?" + + /** + * A command for showing the "Receive Bluetooth message from: %U" + */ + ECmdShowReceiveMessageFromDeviceDlg, +//#define qtn_bt_receive_message "Receive Bluetooth message from: %U" + + /** + * A command for showing the "Accept connection request from:\n%U" + */ + ECmdShowAcceptConnRequestDlg, +//#define qtn_bt_accept_conn_request "Accept connection request from:\n%U" + + /** + * A command for showing "Maximum amount of Bluetooth connections in use. Can't establish a new one." + */ + ECmdShowBtBusyNote, +//#define qtn_bt_busy "Maximum amount of Bluetooth connections in use. Can't establish a new one." + + /** + * A command for showing "Bluetooth can't activated in off-line mode". + */ + ECmdShowBtOfflineDisableNote, +//#define qtn_bt_offline_disabled "Bluetooth can't activated in off-line mode" + + /** + * A command for showing "Bluetooth is currently switched off. Switch on?". + */ + ECmdShowBtIsOffDlg, +//#define qtn_bt_is_off "Bluetooth is currently switched off. Switch on?" + + /** + * A command for showing "Do you want to activate bluetooth in off-line mode?" + */ + ECmdShowBtActivateInOfflineDlg, +//#define qtn_bt_activate_in_offline "Do you want to activate bluetooth in off-line mode?" + + /** + * A command for showing "Connected to %U" + */ + ECmdShowBtConnectedNote, +//#define qtn_bt_conf_connected "Connected to %U" + + /** + * A command for showing "Disconnected from %U" + */ + ECmdShowBtDisconnectedNote, +//#define qtn_bt_conf_disconnected "Disconnected from %U" + + /** + * A command for showing "Bluetooth connection to %U closed" + */ + ECmdShowBtConnectionClosedNote, +//#define qtn_bt_conn_closed "Bluetooth connection to %U closed" + + /** + * A command for showing "Audio routed to BT handsfree" + */ + ECmdShowBtAudioAccessoryNote, +//#define qtn_bt_audio_accessory "Audio routed to BT handsfree" + + /** + * A command for showing "Audio routed to handset" + */ + ECmdShowBtAudioHandsetNote, +//#define qtn_bt_audio_handset "Audio routed to handset" + + /** + * A command for showing "Cannot establish Bluetooth connection" + */ + ECmdShowBtDeviceNotAvailableNote, +//#define qtn_bt_device_not_avail "Cannot establish Bluetooth connection" + + /** + * A command for showing "Phone entering SIM access profile mode" + */ + ECmdShowBtSapEnteringNote, +//#define qtn_bt_wait_sap_entering "Phone entering SIM access profile mode" + + /** + * A command for showing "Phone in SIM access profile mode" + */ + ECmdShowBtSapEnteringSucceededNote, +//#define qtn_bt_sap_entering_succeeded "Phone in SIM access profile mode" + + /** + * A command for showing "Unable to enter SIM access profile mode" + */ + ECmdShowBtSapEnteringFailedNote, +//#define qtn_bt_sap_entering_failed "Unable to enter SIM access profile mode" + + /** + * A command for showing "No sim card in phone" + */ + ECmdShowBtSapNoSimNote, +//#define qtn_bt_sap_no sim ""No sim card in phone" + + + /** + * A command for showing "Phone is not detectable in searches made by other devices" + */ + ECmdShowBtHiddenFromOthersNote, +//#define qtn_bt_hidden_from_others "Phone is not detectable in searches made by other devices" + + /** + * From .loc file: #define qtn_bt_is_off_java "The application you are using will not be fully functional while Bluetooth is off. \n\nDo you want to turn Bluetooth on?" + */ + ECmdShowBtBtIsOffJavaDlg, + + /** + * From .loc file: #define qtn_bt_is_hidden_java "Do you want to change your Bluetooth visibility setting value to 'Shown to all'? \n\nThe application you are using will not be fully functional while your Bluetooth visibility is set as 'Hidden'." + */ + ECmdShowBtIsNotVisibleDlg, + + /** + * From .loc file: #define qtn_ir_not_supported "Infrared not supported" + */ + ECmdShowIrNotSupportedNote, + + /** + * From .loc file: #define qtn_bt_accessory_low "%U battery level low" + */ + ECmdShowBtBatteryLowNote, + + /** + * From .loc file: #define qtn_bt_accessory_critical "%U battery level critical" + */ + ECmdShowBtBatteryCriticalNote + }; + + + +#endif // BTNOTIF_SECONDARY_DISPLAY_API_H +// End of File diff -r 000000000000 -r f63038272f30 btservices_plat/bluetooth_secondary_display_notification_api/inc/secondarydisplay/BtuiSecondaryDisplayAPI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/bluetooth_secondary_display_notification_api/inc/secondarydisplay/BtuiSecondaryDisplayAPI.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,220 @@ +/* +* Copyright (c) 2002-2005 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: The set of messages provided to Secondary Display software by +* : BTUI application. +* +*/ + +#ifndef BTUISECONDARYDISPLAYAPI_H +#define BTUISECONDARYDISPLAYAPI_H + +#include +#include + +const TUid KUidCoverUiCategoryBtui = { 0x10005951 }; // UID of the bluetooth application + +/* +* ============================================================================== +* Dialogs shown by BTUI. These messages are handled using the +* Secondary Display support in Avkon. +* ============================================================================== +*/ +enum TSecondaryDisplayBtuiDialogs + { + + /** + * A command for showing "Active Bluetooth connection. Switch off anyway?" + */ + ECmdShowBtSwitchOffAnywayQuery = 1, +//#define qtn_bt_switch_off_anyway "Active Bluetooth connection. Switch off anyway?" + + /** + * A command for showing "Do you want to activate bluetooth in off-line mode?" + */ + ECmdShowBtActivateInOfflineQuery, +//#define qtn_bt_activate_in_offline "Do you want to activate bluetooth in off-line mode?" + + /** + * A command for showing "Bluetooth can't activated in off-line mode" + */ + ECmdShowBtOfflineDisabledNote, +//#define qtn_bt_offline_disabled "Bluetooth can't activated in off-line mode" + + /** + * A command for showing "Phone is detectable by all other devices." + */ + ECmdShowBtPhoneVisibToAllNote, +//#define qtn_bt_phone_visib_to_oth "Phone is detectable by all other devices." + + /** + * A command for showing "Unable to perform Bluetooth operation" + */ + ECmdShowBtGeneralErrorNote, +//#define qtn_bt_general_error "Unable to perform Bluetooth operation" + + /** + * A command for showing "Pairing with %U complete" + */ + ECmdShowBtSuccesfullyPairedNote, +//#define qtn_bt_succesfully_paired "Pairing with %U complete" + + /** + * A command for showing "Authorise this device to make connections automatically?" + */ + ECmdShowBtAuthorizationQuery, +//#define qtn_bt_authorisation_query "Authorise this device to make connections automatically?" + + /** + * A command for showing "Connect to %U?" + */ + ECmdShowBtConnectQuery, +//#define qtn_bt_query_connect "Connect to %U?" + + /** + * A command for showing "Failed to pair with %U" + */ + ECmdShowBtPairingFailedNote, +//#define qtn_bt_pairing_failed "Failed to pair with %U" + + /** + * A command for showing "Delete pairing with: %U" + */ + ECmdShowBtWarnEraseNote, +//#define qtn_bt_warn_erase "Delete pairing with: %U" + + /** + * A command for showing "Delete all pairings? Some devices may be disconnected." + */ + ECmdShowBtWarnEraseAllConnectedQuery, +//#define qtn_bt_warn_erase_all_connected "Delete all pairings? Some devices may be disconnected." + + /** + * A command for showing "Delete all pairings?" + */ + ECmdShowBtWarnEraseAllQuery, +//#define qtn_bt_warn_erase_all "Delete all pairings?" + + /** + * A command for showing "Connections will take place automatically without confirmation. Continue?" + */ + ECmdShowBtAuthConfirmQuery, +//#define qtn_bt_conf_aut "Connections will take place automatically without confirmation. Continue?" + + /** + * A command for showing "Device set as unauthorised. Connection requests will require confirmation." + */ + ECmdShowBtDevSetAsUntrustNote, +//#define qtn_bt_dev_set_as_untrust "Device set as unauthorised. Connection requests will require confirmation." + + /** + * A command for showing "Disconnect wired accessory" + */ + ECmdShowBtDisconnectWiredtNote, +//#define qtn_bt_disconnect_wired "Disconnect wired accessory" + + /** + * A command for showing "Not possible during a call" + */ + ECmdShowBtImpossibleIncallNote, +//#define qtn_bt_not_incall "Not possible during a call" + + /** + * A command for showing "Disconnect %U first" + */ + ECmdShowBtDisconnectFirstNote, +//#define qtn_bt_disconnect_first "Disconnect %U first" + + + /** + * A command for showing "Disconnect from: %U" + */ + ECmdShowDisconnectQuery, +//#define qtn_bt_disconn_from "Disconnect from: %U" + + /** + * A command for showing "Enabling SIM Access Profile connection Bluetooth must be on" + */ + ECmdShowBtSapEnableNote, +//#define qtn_bt_sap_enable_info "Enabling SIM Access Profile connection Bluetooth must be on" + + + /** + * A command for showing "Waiting for response from %U" + */ + ECmdShowBtWaitingNote, +//#define qtn_bt_waiting "Waiting for response from %U" + + /** + * A command for showing "Connecting to %U" + */ + ECmdShowBtWaitConnectingToNote, +//#define qtn_bt_wait_connecting_to "Connecting to %U" + + /** + * A command for showing "Phone is not detectable in searches made by other devices" + */ + ECmdBtuiShowBtHiddenFromOthersNote, +//#define qtn_bt_hidden_from_others "Phone is not detectable in searches made by other devices" + + /** + * A command for showing "Maximum amount of Bluetooth connections in use. Can't establish a new one." + */ + ECmdBtuiShowBtBusyNote, +//#define qtn_bt_busy "Maximum amount of Bluetooth connections in use. Can't establish a new one." + + /** + * A command for showing "Bluetooth can't activated in off-line mode". + */ + ECmdBtuiShowBtOfflineDisableNote, +//#define qtn_bt_offline_disabled "Bluetooth can't activated in off-line mode" + + /** + * A command for showing "Bluetooth is currently switched off. Switch on?". + */ + ECmdBtuiShowBtIsOffDlg, +//#define qtn_bt_is_off "Bluetooth is currently switched off. Switch on?" + + /** + * A command for showing "Do you want to activate bluetooth in off-line mode?" + */ + ECmdBtuiShowBtActivateInOfflineDlg, +//#define qtn_bt_activate_in_offline "Do you want to activate bluetooth in off-line mode?" + + /** + * A command for showing "Cannot establish Bluetooth connection" + */ + ECmdBtuiShowBtDeviceNotAvail, +//#define qtn_bt_device_not_avail "Cannot establish Bluetooth connection" + + /* + * A command for showing "Unsupported device: %U" + */ + ECmdBtuiShowBtDeviceNotSupported, +//#define qtn_bt_device_not_supported "Unsupported device: %U" + + /** + * A command for showing "Audio routed to BT handsfree" + */ + ECmdBtuiShowBtAudioAccessory, +//#define qtn_bt_audio_accessory "Audio routed to BT handsfree" + + /** + * A command for showing "Connected to %U" + */ + ECmdBtuiShowBtConfConnected +//#define qtn_bt_conf_connected "Connected to %U" + }; + + +#endif // BTUI_SECONDARY_DISPLAY_API_H diff -r 000000000000 -r f63038272f30 btservices_plat/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_plat/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006 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: Includes all the Domain API specific bld.inf files, which +* export files. +* +*/ + + + +#include "../bluetooth_dosserver_audio_api/group/bld.inf" +#include "../bluetooth_dut_mode_api/group/bld.inf" +#include "../bluetooth_engine_api/group/bld.inf" +#include "../bluetooth_engine_connection_management_api/group/bld.inf" +#include "../bluetooth_engine_device_management_api/group/bld.inf" +#include "../bluetooth_engine_discovery_api/group/bld.inf" +#include "../bluetooth_engine_features_api/group/bld.inf" +#include "../bluetooth_engine_settings_api/group/bld.inf" +#include "../bluetooth_engine_plugin_api/group/bld.inf" +#include "../bluetooth_local_variation_api/group/bld.inf" +#include "../bluetooth_notifier_internal_api/group/bld.inf" +#include "../bluetooth_sap_connection_state_api/group/bld.inf" +#include "../bluetooth_secondary_display_notification_api/group/bld.inf" diff -r 000000000000 -r f63038272f30 btservices_pub/bluetooth_notifier_api/bluetooth_notifier_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/bluetooth_notifier_api/bluetooth_notifier_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth Notifier API + Contains public notifier UIDs, e.g. UID of notifier for switching BT on/off + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_pub/bluetooth_notifier_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/bluetooth_notifier_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Notifier API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btnotifierapi.h MW_LAYER_PUBLIC_EXPORT_PATH(btnotifierapi.h) diff -r 000000000000 -r f63038272f30 btservices_pub/bluetooth_notifier_api/inc/btnotifierapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/bluetooth_notifier_api/inc/btnotifierapi.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2002 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: Declares Bluetooth notifiers SDK API. +* +*/ + + + +#ifndef BTNOTIFIERAPI_H +#define BTNOTIFIERAPI_H + +// CONSTANTS + +/** +* @file btnotifierapi.h +* The UID of the Bluetooth Power Mode Notifier. This notifier checks the Bluetooth +* power status, If Bluetooth is off, a dialog is poped up asking user's +* acceptance of switching on Bluetooth. The notifier is launched via +* the notifier framework through RNotifier API. +* +* Sample code of using RNotifier: +* +* RNotifier notifier; +* TRequestStatus status; +* TPckgBuf param, result; +* notifier.StartNotifierAndGetResponse (status, KPowerModeSettingNotifierUid, param, result); +*/ + +const TUid KPowerModeSettingNotifierUid = {0x100059E2}; + +#endif // BTNOTIFIERAPI_H + +// End of File diff -r 000000000000 -r f63038272f30 btservices_pub/bluetooth_power_state_api/bluetooth_power_state_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/bluetooth_power_state_api/bluetooth_power_state_api.metaxml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ + + + Bluetooth Power State API + defines a CenRep key for getting Bluetooth power state + c++ + bluetoothengine + + + + + + + + no + no + + diff -r 000000000000 -r f63038272f30 btservices_pub/bluetooth_power_state_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/bluetooth_power_state_api/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 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: File that exports the files belonging to +: Bluetooth Power State API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/btserversdkcrkeys.h MW_LAYER_PUBLIC_EXPORT_PATH(btserversdkcrkeys.h) diff -r 000000000000 -r f63038272f30 btservices_pub/bluetooth_power_state_api/inc/btserversdkcrkeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/bluetooth_power_state_api/inc/btserversdkcrkeys.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2006 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: Bluetooth Engine SDK central repository key definitions. +* The file name is kept as before for compatibility reasons. +* +*/ + + +#ifndef BTSERVER_SDK_CR_KEYS_H +#define BTSERVER_SDK_CR_KEYS_H + + +/** +* @file btserversdkcrkeys.h +* +* The API provides the BT power state central repository key that is updated by +* the S60 BT Server. The key provides up-to-date information on the BT +* HW power state. Any application may monitor to the cenrep key that is +* updated to receive notifications of any change in state. +* +* The key UID is #KCRUidBluetoothPowerState and following key is provided: +* - #KBTPowerState +*/ + +/** Bluetooth Power Mode UID */ +const TUid KCRUidBluetoothPowerState = { 0x10204DA9 }; + +/** + * The cenrep key for storing the Bluetooth power mode. + * + * Valid values are defined by the enum #TBTPowerStateValue + * + * Possible values are: + * 0 Bluetooth chip is not powered/in sleep mode + * 1 Bluetooth chip is powered up and fully functional + * + * Default value: 0 + * + * @see TBTPowerStateValue + */ +const TUint32 KBTPowerState = 0x00000001; + + +/** Enumeration for Bluetooth power mode values */ +enum TBTPowerStateValue + { + EBTPowerOff, + EBTPowerOn + }; +#endif // BTSERVER_SDK_CR_KEYS_H diff -r 000000000000 -r f63038272f30 btservices_pub/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btservices_pub/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2006 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: Includes all the SDK API specific bld.inf files, which +* export files. +* +*/ + + + +#include "../bluetooth_power_state_api/group/bld.inf" +#include "../bluetooth_notifier_api/group/bld.inf" diff -r 000000000000 -r f63038272f30 group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 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: Build information file for package btservices +* +*/ + + +PRJ_PLATFORMS +DEFAULT +#include "../btservices_plat/group/bld.inf" +#include "../btservices_pub/group/bld.inf" +#include "../bluetoothengine/group/bld.inf" + +PRJ_EXPORTS + + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS diff -r 000000000000 -r f63038272f30 layers.sysdef.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layers.sysdef.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,19 @@ + + +]> + + + + + + + + + + + + + + + diff -r 000000000000 -r f63038272f30 package_definition.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_definition.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r f63038272f30 sysdef_1_4_0.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdef_1_4_0.dtd Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/bwins/atextpluginapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/bwins/atextpluginapitestu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/eabi/atextpluginapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/eabi/atextpluginapitestu.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/group/atextpluginapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/group/atextpluginapitest.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +/*TYPE TESTCLASS*/ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + +#if defined(__S60_) + // To get the OS_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET atextpluginapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE atextpluginapitest.def + +SOURCEPATH ../src +SOURCE atextpluginapitest.cpp +SOURCE atextpluginapitestblocks.cpp +SOURCE bttestlogger.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY sysutil.lib +LIBRARY ECom.lib +LIBRARY stiftestinterface.lib +LIBRARY atextpluginbase.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +// NOTE: If using ARS requirements .mmp file operation should be done under this. +// 'abld test build' + +PRJ_MMPFILES +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +/agnmodel/group/agnmodel.mmp +#if defined(MARM) +/agnmodel/group/agsvexe.mmp +#endif +*/ +atextpluginapitest.mmp +pluginstub.mmp + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/group/pluginstub.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/group/pluginstub.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2007 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 + +CAPABILITY CAP_ECOM_PLUGIN + +VENDORID VID_DEFAULT + +TARGET atextpluginstub.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0xE000B183 + +SOURCEPATH ../src +SOURCE pluginproxy.cpp +SOURCE pluginstub.cpp +SOURCE genericactive.cpp + +USERINCLUDE ../inc + +SYSTEMINCLUDE /epoc32/include/ecom + +MW_LAYER_SYSTEMINCLUDE + +START RESOURCE ../src/E000B183.RSS +TARGET atextpluginstub.rsc +END + +LIBRARY ECom.lib +LIBRARY euser.lib +LIBRARY atextpluginbase.lib + + + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/inc/atextpluginapitest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/inc/atextpluginapitest.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +#ifndef BTAPITEST_H +#define BTAPITEST_H + +// INCLUDES +#include +#include +#include +#include +#include "atextpluginobserver.h" +#include "bttestlogger.h" + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +// Logging path +// Log file + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CCAtExtPluginApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CAtExtPluginApiTest) : public CScriptBase, public MATExtPluginObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CAtExtPluginApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CAtExtPluginApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + private: // From MATExtPluginObserver + + TInt SendUnsolicitedResult(CATExtPluginBase& aPlugin, const TDesC8& aAT); + + void HandleCommandCompleted(CATExtPluginBase& aPlugin, TInt aErr); + + void ATExtPluginClosed(CATExtPluginBase& aPlugin); + + private: + + /** + * C++ default constructor. + */ + CAtExtPluginApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Test methods. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + TInt TestPluginStub ( CStifItemParser& aItem ); + + void LoadPluginStubL(); + + private: // Data + + CATExtPluginBase* iPlugin; + RBuf8 iCmdBuf; + CBtTestLogger* iLogger; + }; + +#endif // BTAPITEST_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/inc/atextpluginobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/inc/atextpluginobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +#ifndef ATEXTENSIONPLUGINOBSERVER_H +#define ATEXTENSIONPLUGINOBSERVER_H + +#include + +class CATExtPluginBase; + +/** +* The interface for AT Extension Plugin to interact with AG. +*/ +class MATExtPluginObserver + { +public: + + /** + * Call by extension plugins when there is an unsolicited result code + * should be sent to target headset. + * + * Each AT Extension Plugin is responsible to format + * result codes properly, e.g. in BT HFP case, the + * format should be + * + * @param aAT the unsolicited result code to be sent. + */ + virtual TInt SendUnsolicitedResult(CATExtPluginBase& aPlugin, const TDesC8& aAT) = 0; + + /** + * Called by Extension Plugins to inform AG that a command + * handling has been completed or rejected. + * + * @return KErrNotSupported if the AT Extension Plugin doesn’t + * support the command passed in CATExtPluginBase::HandleCommand(); + * KErrNone otherwise. No other error code is allowed. + */ + virtual void HandleCommandCompleted(CATExtPluginBase& aPlugin, TInt aErr) = 0; + + /** + * Called by the destructor of CATExtPluginBase. + * A concrete service provider implementation should not touch this. + * + * @param aATExt the reference of the service provider. + */ + virtual void ATExtPluginClosed(CATExtPluginBase& aPlugin) = 0; + + }; + +#endif \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/inc/bttestlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/inc/bttestlogger.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +#ifndef BTTESTLOGGER_H +#define BTTESTLOGGER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CStifLogger; +class CTestModuleIf; + +// CLASS DECLARATION + +NONSHARABLE_CLASS( CBtTestLogger ) : public CBase +{ + public: + + static CBtTestLogger* NewL(const CTestModuleIf* aTestModuleIf); + virtual ~CBtTestLogger(); + + public: // Data used by functions + + enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug}; + + public: // New functions + + TBool GetEnabled() const; + CStifLogger* GetLogger() const; + const CTestModuleIf* GetTestModuleIf() const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const; + TInt LogNewLine() const; + void SetEnabled(TBool aEnabled); + void SetLogger(CStifLogger* aLog); + void SetTestModuleIf(const CTestModuleIf* aTestModuleIf); + + public: // Functions from base classes + + private: // New functions + + TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const; + TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const; + static TPtrC GetPrefix(TLogLevel aLevel); + TInt CheckLogFile(); + void LogHeadSectionL(); + void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const; + + private: // Constructors + + CBtTestLogger(const CTestModuleIf* aTestModuleIf); + void ConstructL(); + + public: // Data + static const TInt KPrefixLength; + + private: // Data + + TBool iEnabled; + CStifLogger* iLog; + const CTestModuleIf* iTestModuleIf; + }; + +#endif // BTTESTLOGGER_H + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/inc/genericactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/inc/genericactive.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2007 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: An Active Object offering its request status for any +* asynchronous request handling. +* +*/ + + +#ifndef C_GENERICACTIVE_H +#define C_GENERICACTIVE_H + +// INCLUDES +#include + +class CGenericActive; + +/** + * The observer of CGenericActive's request events + * + * This class defines the interface to handle request events from CGenericActive. + * + * @since S60 v3.1 + */ +class MGenericActiveObserver + { + +public: + + /** + * Called by CGenericActive::RunL() to handle the request completion event. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void RequestCompletedL(CGenericActive& aActive) = 0; + + /** + * alled by CGenericActive::RunL() to handle the cancellation of an outstanding request. + * + * @since S60 v3.1 + * @param aActive the Active Object to which the request is assigned to. + */ + virtual void CancelRequest(CGenericActive& aActive) = 0; + + /** + * alled by CGenericActive::RunError() to handle an exception. + * + * @since S60 v3.1 + * @param aErr the leave code of RunL() + */ + virtual TInt HandleRunError(TInt aErr) = 0; + }; + +/** + * + * CGenericActive provides TRequestStatus for an async operation but it doesn't know the + * detail of the request. CGenericActive could be used to implement timers, P&S subscribes + * that are "simple" enough operations. + * + * @since S60 v3.1 + */ +class CGenericActive : public CActive + { + +public: + + static CGenericActive* New(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + + static CGenericActive* NewL(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + + virtual ~CGenericActive(); + +public: + + /** + * Calls SetActive(). + * + * @since S60 v3.1 + */ + virtual void GoActive(); + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @return the request identifier + */ + TInt RequestId() const; + + /** + * Gets the identifier of the request that this active object is serving. + * + * @since S60 v3.1 + * @param the request identifier + */ + void SetRequestId(TInt aRequestId); + + TRequestStatus& RequestStatus(); + +protected: + + /** + * From CActive. + * cancels the outstanding request. + * + * @since S60 v3.1 + */ + virtual void DoCancel(); + + /** + * From CActive. + * Handles the request completion event. + * + * @since S60 v3.1 + */ + virtual void RunL(); + + /** + * From CActive. + * Handles the leave from RunL(). + * + * @since S60 v3.1 + * @param aError the leave code in RunL() + * @return the error code to Active Scheduler + */ + virtual TInt RunError(TInt aError); + +protected: + + CGenericActive(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId); + +private: + + /** + * The observer which is interested in the request handling events. + * Not own. + */ + MGenericActiveObserver& iObserver; + + /** + * The request identifier assigned to this active object. + */ + TInt iRequestId; + + }; + +#endif // C_GENERICACTIVE_H diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/inc/pluginstub.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/inc/pluginstub.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2005 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: BT Mono Audio Controller class declaration. +* +*/ + + +#ifndef REFERENCE_ATEXT_IMPL_H +#define REFERENCE_ATEXT_IMPL_H + +#include +#include "genericactive.h" + +NONSHARABLE_CLASS(CAtExtPluginStub) : public CATExtPluginBase, public MGenericActiveObserver + { + public: + + /** + * Two-phased constructor. + */ + static CAtExtPluginStub* NewL(); + + /** + * Destructor. + */ + ~CAtExtPluginStub(); + +private: + + void HandleCommand( const TDesC8& aCmd, RBuf8& aReply ); + +private: + + void RequestCompletedL(CGenericActive& aActive); + + void CancelRequest(CGenericActive& aActive); + + TInt HandleRunError(TInt aErr); + + +private: + + CAtExtPluginStub(); + + void ConstructL(); + + void StartTimer(TInt aTimeout, TInt aId); + +private: // Data + CGenericActive* iActive; + RTimer iTimer; + }; + +#endif // REFERENCE_ATEXT_IMPL_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/E000B183.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/E000B183.rss Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2002 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: BT Stero Audio Controller +* +*/ + + +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0xE000B183; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2000B17B; + implementations = + { + // Info for BTSAC + IMPLEMENTATION_INFO + { + implementation_uid = 0x2000B185; + version_no = 1; + display_name = "AT EXT Plugin Stub"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/atextpluginapitest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/atextpluginapitest.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include "atextpluginapitest.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CAtExtPluginApiTest::CCAtExtPluginApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CAtExtPluginApiTest::CAtExtPluginApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CAtExtPluginApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CAtExtPluginApiTest::ConstructL() + { + iCmdBuf.CreateL(128); + iLogger = CBtTestLogger::NewL( &TestModuleIf() ); + } + +// ----------------------------------------------------------------------------- +// CAtExtPluginApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CAtExtPluginApiTest* CAtExtPluginApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CAtExtPluginApiTest* self = new (ELeave) CAtExtPluginApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// Destructor +CAtExtPluginApiTest::~CAtExtPluginApiTest() + { + // Delete resources allocated from test methods + Delete(); + + delete iPlugin; + REComSession::FinalClose(); + iCmdBuf.Close(); + delete iLogger; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CAtExtPluginApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/atextpluginapitestblocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/atextpluginapitestblocks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,183 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include "atextpluginapitest.h" + + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def +#define TLFUNCLOG (TUint8*) __FUNCTION__ + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CAtExtPluginApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CAtExtPluginApiTest::Delete() + { + } + +// ----------------------------------------------------------------------------- +// CAtExtPluginApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CAtExtPluginApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + ENTRY( "TestPluginStub", TestPluginStub ), + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + } + +TInt CAtExtPluginApiTest::SendUnsolicitedResult(CATExtPluginBase& aPlugin, const TDesC8& aAT) + { + iLogger->Log( CBtTestLogger::ETLInfo, _L8( "SendUnsolicitedResult %S" ), &aAT); + return KErrNone; + } + +void CAtExtPluginApiTest::HandleCommandCompleted(CATExtPluginBase& aPlugin, TInt aErr) + { + iLogger->Log( CBtTestLogger::ETLInfo, _L8( "HandleCommandCompleted %d" ), aErr); + } + +void CAtExtPluginApiTest::ATExtPluginClosed(CATExtPluginBase& aPlugin) + { + iPlugin = NULL; + iLogger->LogResult( (TPtrC8( TLFUNCLOG )), KNullDesC, KErrNone ); + Signal(KErrNone); + } + +TInt CAtExtPluginApiTest::TestPluginStub( CStifItemParser& /*aItem*/ ) + { + iLogger->Log( CBtTestLogger::ETLInfo, _L8( "TestPluginStub" )); + TInt ret(KErrNone); + TRAP(ret, LoadPluginStubL()); + if (ret) + { + iLogger->LogResult( (TPtrC8( TLFUNCLOG )), KNullDesC, ret ); + Signal(ret); + } + else + { + iPlugin->SetObserver(*this); + _LIT8(KTestCmd, "ApiTest"); + iPlugin->HandleCommand(KTestCmd, iCmdBuf); + iPlugin->HandleCommandCancel(); + } + return KErrNone; + } + +template +class CleanupResetDestroyClose + { +public: + inline static void PushL(T& aRef) + { + CleanupStack::PushL(TCleanupItem(&ResetDestroyClose,&aRef)); + } +private: + static void ResetDestroyClose(TAny *aPtr) + { + static_cast(aPtr)->ResetAndDestroy(); + static_cast(aPtr)->Close(); + } + }; + +/** + * Pushes an object into CleanupStack and specifies the cleanup + * function as ResetAndDestroy() and Close(). +*/ +template +inline void CleanupResetDestroyClosePushL(T& aRef) + {CleanupResetDestroyClose::PushL(aRef);} + +void CAtExtPluginApiTest::LoadPluginStubL() + { + delete iPlugin; + iPlugin = NULL; + const TUid KUidPluginInterface = TUid::Uid(0x2000B17B); + RImplInfoPtrArray implementations; + REComSession::ListImplementationsL(KUidPluginInterface, + implementations); + CleanupResetDestroyClosePushL(implementations); + const TUint count = implementations.Count(); + + TInt ret; + for ( TUint ii = 0 ; ii < count ; ++ii ) + { + if (TUid::Uid(0x2000B185) == implementations[ii]->ImplementationUid()) + { + iPlugin = CATExtPluginBase::NewL(implementations[ii]->ImplementationUid(), *this); + break; + } + } + CleanupStack::PopAndDestroy(&implementations); + if (!iPlugin) + { + User::Leave(KErrNotFound); + } + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/bttestlogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/bttestlogger.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,530 @@ +/* +* Copyright (c) 2007 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: +* +*/ + +// INCLUDES + +#include "bttestlogger.h" + +#include +#include + +#include +#include +#include + +// RDebug +#include + +const TInt CBtTestLogger::KPrefixLength = 8; +// Timestamp string length +const TInt KTimeStampStrLen = 21; +// Extended Timestamp string length +const TInt KExtTimeStampStrLen = 80; +// Extended time stamp +typedef TBuf TExtTimeStamp; +// Logging path +_LIT( KBtAudioTestSystemLogPath, "e:\\logs\\atextpluginapitest\\" ); +// Log file +_LIT( KBtAudioTestSystemLogFile, "ATExtPluginApiTestLog.html" ); +// Log file +_LIT( KBtAudioTestSystemLogFullName, "\\logs\\atextpluginapitest\\ATExtPluginApiTestLog_%x.html" ); +// Time stamp format string +_LIT( KFormatTimeStamp, "
[%H:%T:%S.%*C4] " ); +// Date format string +_LIT( KFormatDate, "%F%D %N %Y" ); +// HTML header section +_LIT( KHtmlHeadSection, "\n\nBT Audio Test System results\n\n\n\n\n\n" ); +// HTML code which will display the statistics +_LIT( KHtmlStatSection, "

Logfile created on %S at %S
\nS60 version %S

\n\n
\n
\n\n" ); +// HTML identifier for test case start +_LIT( KHtmlTestCaseStart, "
" ); +// Test case result logging +_LIT( KTestCaseResult, "Test completed; function %S, parameter %S, result
%d
" ); +// JavaScript function for calculating test result +#define KJSSECTION _L( "" ) + +// Construction and destruction. + +// ----------------------------------------------------------------------------- +// CBtTestLogger::NewL +// Static constructor to constructor builder objects. +// ----------------------------------------------------------------------------- +// +CBtTestLogger* CBtTestLogger::NewL(const CTestModuleIf* aTestModuleIf) + { + CBtTestLogger* self = new (ELeave) CBtTestLogger(aTestModuleIf); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::CBtTestLogger +// Constructor. +// ----------------------------------------------------------------------------- +// +CBtTestLogger::CBtTestLogger(const CTestModuleIf* aTestModuleIf) + : CBase(), + iEnabled(ETrue), + iTestModuleIf(aTestModuleIf) + { + } + +// ----------------------------------------------------------------------------- +// CTestLogger::ConstructL +// 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::ConstructL() + { + TInt err = CheckLogFile(); + iLog = CStifLogger::NewL( KBtAudioTestSystemLogPath, KBtAudioTestSystemLogFile, + CStifLogger::ETxt, CStifLogger::EFile, EFalse, EFalse ); + if( err == KErrNotFound ) + { // Add info & HTML markup to the beginning of the log file. + LogHeadSectionL(); + } + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::~CBtTestLogger +// Destructor. +// ----------------------------------------------------------------------------- +// +CBtTestLogger::~CBtTestLogger() + { + delete iLog; + } + +// Member functions. + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetLogger +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +CStifLogger* CBtTestLogger::GetLogger() const + { + return iLog; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetTestModuleIf +// Returns a pointer to current STIF test module interface. +// ----------------------------------------------------------------------------- +// +const CTestModuleIf* CBtTestLogger::GetTestModuleIf() const + { + return iTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList( aLogText, args ); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Append log prefix to the output buffer. + buffer.Insert( 0, GetPrefix( aLevel ) ); + + // Log a timestamp + TTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Log a timestamp + TTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const + { + TExtTimeStamp func; + func.Copy( aFunc ); // Copy 8-bit string to 16-bit buffer + + Log( CBtTestLogger::ETLResult, KTestCaseResult, &func, &aArg, aRes ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::LogNewLine() const + { + if (!iEnabled) + { + return KErrNone; + } + TExtTimeStamp time; + TRAPD( err, LogTimeStampL( time ) ); + if( !err ) + { + time.Insert( 0, KHtmlTestCaseStart ); + err = iLog->Log( time ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetEnabled +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetEnabled(TBool aEnabled) + { + iEnabled = aEnabled; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetLogger +// Sets a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetLogger(CStifLogger* aLog) + { + iLog = aLog; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetTestModuleIf +// Sets a pointer to current STIF test module. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetTestModuleIf(const CTestModuleIf* aTestModuleIf) + { + iTestModuleIf = aTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::WriteLog(TLogLevel aLevel, TDes16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(aLevel, _L(""), log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(0, aCategory, log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetPrefix +// Returns the prefix for a given logging level. +// ----------------------------------------------------------------------------- +// +TPtrC CBtTestLogger::GetPrefix(TLogLevel aLevel) + { + // Select a prefix for a log level and return a pointer to it. + switch(aLevel) + { + case ETLError: + { + TPtrC logPrefix = _L("ERROR : "); + return logPrefix; + } + case ETLInfo: + case ETLResult: + { + TPtrC logPrefix = _L("INFO : "); + return logPrefix; + } + case ETLDebug: + { + TPtrC logPrefix = _L("DEBUG : "); + return logPrefix; + } + default: + { + // Return a null pointer. + return TPtrC(); + } + + } + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::CheckLogFile +// Check if a log file is already existing, otherwise HTML formatting +// should be added. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::CheckLogFile() + { + RThread thread; + TInt id = thread.Id(); + TBuf file; + file.Format( KBtAudioTestSystemLogFullName, id ); + RFs fs; + TInt err = fs.Connect(); + TBool open = EFalse; + if( !err ) + { + err = fs.IsFileOpen( file, open ); + } + fs.Close(); + return err; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogTimeStamp +// Log HTML head section and general information in a newly created logfile. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::LogHeadSectionL() + { + iLog->Log( KHtmlHeadSection ); + iLog->Log( KJSSECTION ); + TBuf version( _L( "Version unknown!" ) ); + (void) SysUtil::GetSWVersion( version ); + TTimeStamp8 date; + LogTimeStampL( date, EFalse ); + TTimeStamp8 time; + LogTimeStampL( time ); + TPtrC timePtr( time.Mid( 6, 13 ) ); + iLog->Log( KHtmlStatSection, &date, &timePtr, &version ); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogTimeStamp +// Format a timestamp for logging. +// If aTime is set to false, the (formatted) date is returned. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::LogTimeStampL(TDes& aBuf, TBool aTime) const + { + TTime time; + time.HomeTime(); // Get time and format it + if( aTime ) + { + time.FormatL( aBuf, KFormatTimeStamp ); + } + else + { + time.FormatL( aBuf, KFormatDate ); + } + } diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/genericactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/genericactive.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2007 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 "genericactive.h" + +CGenericActive* CGenericActive::New(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + return new CGenericActive(aObserver, aPriority, aRequestId); + } + +CGenericActive* CGenericActive::NewL(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + { + CGenericActive* self = new (ELeave) CGenericActive(aObserver, aPriority, aRequestId); + return self; + } + +CGenericActive::~CGenericActive() + { + Cancel(); + } + +void CGenericActive::GoActive() + { + SetActive(); + } + +TInt CGenericActive::RequestId() const + { + return iRequestId; + } + +void CGenericActive::SetRequestId(TInt aRequestId) + { + iRequestId = aRequestId; + } + +TRequestStatus& CGenericActive::RequestStatus() + { + return iStatus; + } + +void CGenericActive::DoCancel() + { + iObserver.CancelRequest(*this); + } + +void CGenericActive::RunL() + { + iObserver.RequestCompletedL(*this); + } + +TInt CGenericActive::RunError(TInt aError) + { + return iObserver.HandleRunError(aError); + } + +CGenericActive::CGenericActive(MGenericActiveObserver& aObserver, + CActive::TPriority aPriority, TInt aRequestId) + : CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) + { + CActiveScheduler::Add(this); + } diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/pluginproxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/pluginproxy.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +#ifndef REFERENCE_ATEXT_H +#define REFERENCE_ATEXT_H + +#include +#include +#include "pluginstub.h" + +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x2000B185, CAtExtPluginStub::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/atextpluginapitest/src/pluginstub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/atextpluginapitest/src/pluginstub.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2007 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 "pluginstub.h" + +enum TTestCase + { + EEventAT, + EEventExtClose, + }; + +const TInt KFirstTimeout = 15000000; +const TInt KRestTimeout = 2000000; + +CAtExtPluginStub* CAtExtPluginStub::NewL() + { + CAtExtPluginStub* self = new (ELeave) CAtExtPluginStub(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CAtExtPluginStub::~CAtExtPluginStub() + { + delete iActive; + iTimer.Close(); + } + +void CAtExtPluginStub::HandleCommand( const TDesC8& aCmd, RBuf8& aReply ) + { + HandleCommandCompleted(KErrNone); + } + +void CAtExtPluginStub::RequestCompletedL(CGenericActive& aActive) + { + TInt err = aActive.RequestStatus().Int(); + switch (aActive.RequestId()) + { + case EEventAT: + { + _LIT8(KAT, "\r\n+AT : 0\r\n"); + SendUnsolicitedResult(KAT); + StartTimer(KRestTimeout, EEventExtClose); + break; + } + case EEventExtClose: + { + delete this; + } + } + } + +void CAtExtPluginStub::CancelRequest(CGenericActive& /*aActive*/) + { + iTimer.Cancel(); + } + +TInt CAtExtPluginStub::HandleRunError(TInt /*aErr*/) + { + return KErrNone; + } + +CAtExtPluginStub::CAtExtPluginStub() : CATExtPluginBase() + { + } + +void CAtExtPluginStub::ConstructL() + { + iActive = CGenericActive::NewL(*this, CActive::EPriorityStandard, EEventAT); + iTimer.CreateLocal(); + StartTimer(KFirstTimeout, EEventAT); + } + + +void CAtExtPluginStub::StartTimer(TInt aTimeout, TInt aId) + { + iActive->SetRequestId(aId); + iTimer.After(iActive->RequestStatus(), aTimeout); + iActive->GoActive(); + } + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/Bmarm/btengapitestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/Bmarm/btengapitestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/Bwins/btengapitestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/Bwins/btengapitestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/EABI/BtEngApiTestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/EABI/BtEngApiTestU.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS +../../conf/btengapi_scripter.cfg /epoc32/WINSCW/C/TestFramework/btengapi_scripter.cfg + +PRJ_TESTMMPFILES +// NOTE: If using ARS requirements .mmp file operation should be done under this. +// 'abld test build' + +PRJ_MMPFILES +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +/agnmodel/group/agnmodel.mmp +#if defined(MARM) +/agnmodel/group/agsvexe.mmp +#endif +*/ +btengapitest.mmp + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/btapitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/btapitest.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +; +; Copyright (c) 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: +; +;Languages +&EN + +;Header +#{"BtEngAPiTest"},(0x0782023A),1,0,0 + +;Localised Vendor name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + +;Product ID for S60 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +;Files to install +"\epoc32\release\armv5\urel\btengapitest.dll"-"!:\sys\bin\btengapitest.dll" +"\epoc32\winscw\c\testframework\btengapi_scripter.cfg"-"!:\testframework\btengapi_scripter.cfg" +"\epoc32\winscw\c\testframework\testframework.ini"-"!:\testframework\testframework.ini" diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/btengapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/btengapitest.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,90 @@ +/*TYPE TESTCLASS*/ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + +#if defined(__S60_) + // To get the OS_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET btengapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE btengapitest.def + +SOURCEPATH ../src +SOURCE btapitest.cpp +SOURCE btapitestblocks.cpp +SOURCE bttestlogger.cpp +SOURCE btapisettings.cpp +SOURCE btapidiscovery.cpp +SOURCE btapiconnman.cpp +SOURCE btapidevman.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY sysutil.lib +LIBRARY stiftestinterface.lib +LIBRARY bluetooth.lib +LIBRARY btdevice.lib +LIBRARY btmanclient.lib +LIBRARY btengsettings.lib +LIBRARY btengdevman.lib +LIBRARY btengdiscovery.lib +LIBRARY btengconnman.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/btengapitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/btengapitest.pkg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,34 @@ +; +; Copyright (c) 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: +; +;Languages +&EN + +;Header +#{"BtEngAPiTest"},(0x0782023A),1,0,0 + +;Localised Vendor name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + +;Product ID for S60 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +;Files to install +"\epoc32\release\armv5\urel\btengapitest.dll"-"!:\sys\bin\btengapitest.dll" +"\epoc32\winscw\c\testframework\btengapi_scripter.cfg"-"!:\testframework\btengapi_scripter.cfg" +"\epoc32\winscw\c\testframework\testframework.ini"-"!:\testframework\testframework.ini" diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/make_and_sign_sis.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/make_and_sign_sis.bat Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +makesis -v btengapitest.pkg +signsis.exe btengapitest.sis btengapitest_signed.sisx rd.cer rd-key.pem +del btengapitest.sis \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/rd-key.pem --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/rd-key.pem Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQDLRF+r1FGGkCwTrb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW4 +6Y+LWaA8HMlDdoHRB0FgASisYcFagwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh +7W7Dt9F5FZij8F7/9Pi6+FhhxZFIf1DD+yry9D7+Sp+BgdNALe4XOpf25QIBAwKB +gQCHgupyjYuvCsgNHn7PNtnvVxInrB5MQNoPli+O+uNJWUK/Q+57Rl+yO8AoEzDX +pFaLWiuVVhsdloDnAgabT/FXzYncs6uOHyEUV+dSXb78vtLPJqAX+Fg2i3hOXreB +yskcZ13/OsKVOu5wgrJkx2baZufkqMwOSytf5y9nwjEIKwJBAP+inobagVNrN62j +KQva3cC+UN/6XnKdTc0CA6bHyLOaJoH1xiMwG/VS2PGjHI0tiSMNtLn/QPpHJ003 +iabGhdUCQQDLjp/9UjFT6K6CF66Chqf30pZXhx+GTSQZmv/gvZiMly7X9fX9BGX3 +2MbJohBC4yI21XKTbisWywkF73Hwh+TRAkEAqmxprzxWN5zPyRdwspHpKymLP/w+ +9xOJM1atGdqFzRFvAU6EF3Vn+OHl9my9s3OwwgkjJqorUYTE3iUGby8D4wJBAIe0 +aqjhdjfwdFa6dFcEb/qMZDpaFQQzbWZnVUB+ZbMPdI/5TqitmU/l2dvBYCyXbCSO +TGJJcg8yBgP09qBamIsCQFL7j1tM0XPVQJQ89WpKCld7O9ORxRGVj1eG0tWijrH8 +mGbYh8SGCVoWV3vrKSS8GBrFVgQnqUaHuEdtM7tpCAQ= +-----END RSA PRIVATE KEY----- diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/group/rd.cer --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/group/rd.cer Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICzDCCAjWgAwIBAgIBADANBgkqhkiG9w0BAQUFADArMRAwDgYDVQQKEwdSRCBD +ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZTAeFw0wNDExMTUxMjQyMDZaFw0z +NzA5MjMxMjQyMDZaMCsxEDAOBgNVBAoTB1JEIENlcnQxFzAVBgNVBAMTDlJEIENl +cnRpZmljYXRlMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDLRF+r1FGGkCwT +rb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW46Y+LWaA8HMlDdoHRB0FgASisYcFa +gwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh7W7Dt9F5FZij8F7/9Pi6+FhhxZFI +f1DD+yry9D7+Sp+BgdNALe4XOpf25QIBA6OCAQAwgf0wDAYDVR0TBAUwAwEB/zAL +BgNVHQ8EBAMCAoQwHQYDVR0OBBYEFFi/kuGzxhVpjGxe9ZwlxC3fH9jFMFMGA1Ud +IwRMMEqAFFi/kuGzxhVpjGxe9ZwlxC3fH9jFoS+kLTArMRAwDgYDVQQKEwdSRCBD +ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZYIBADBsBgNVHSAEZTBjMGEGBFUd +IAAwWTATBggrBgEFBQcCARYHaHR0cDovLzBCBggrBgEFBQcCAjA2GjRGb3IgUiZE +IHVzYWdlIG9ubHkuIFRoaXMgY2VydGlmaWNhdGUgaXMgbm90IHRydXN0ZWQuMA0G +CSqGSIb3DQEBBQUAA4GBAHGB4RQMAgBdeT2hxfOr6f2nA/dZm+M5yX5daUtZnET9 +Ed0A9sazLawfN2G1KFQT9kxEParAyoAkpbMAsRrnRz/9cM3OHgFm/NiKRnf50DpT +7oCx0I/65mVD2kt+xXE62/Ii5KPnTufIkPi2uLvURCia1tTS8JmJ8dtxDGyQt8BR +-----END CERTIFICATE----- diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/btapiconnman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/btapiconnman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef BTAPICONNMAN_H +#define BTAPICONNMAN_H + +#include +#include + +#include "testobserver.h" + +/** +* Class for testing BT engine API +*/ +NONSHARABLE_CLASS ( CBTApiConnman ): public CBase, public MBTEngConnObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTApiConnman* NewL(MBTTestObserver& aObserver); + + TInt ConnectIfNotConnected( TBTDevAddr& aAddr, TBTDeviceClass& aCod ); + TInt DisconnectIfConnected( TBTDevAddr& aAddr ); + TInt ConnectAndCancel( TBTDevAddr& aAddr, TBTDeviceClass& aCod ); + TInt GetAddresses( TBTDevAddr& aAddr ); + TInt IsConnectable(); + TInt PairDevice( TBTDevAddr& aAddr ); + TInt PrepareDiscovery( TBTDevAddr& aAddr ); + + /** + * Destructor. + */ + virtual ~CBTApiConnman(); + + private: + + /** from MBTEngConnObserver */ + void ConnectComplete( TBTDevAddr& aAddr, TInt aErr, RBTDevAddrArray* aConflicts = NULL ); + + void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr ); + + void PairingComplete( TBTDevAddr& aAddr, TInt aErr ); + + /** + * C++ default constructor. + */ + CBTApiConnman( MBTTestObserver& aObserver ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: + + MBTTestObserver& iObserver; + CBTEngConnMan* iBTEngConnMan; + TInt iError; + CActiveSchedulerWait iWaiter; + }; + +#endif // BTAPICONNMAN_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/btapidevman.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/btapidevman.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef BTAPIDEVMAN_H +#define BTAPIDEVMAN_H + +#include +#include + +#include "testobserver.h" + +/** +* Class for settign BT Power +*/ +NONSHARABLE_CLASS ( CBTApiDevman ): public CBase, public MBTEngDevManObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTApiDevman* NewL(MBTTestObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBTApiDevman(); + + TInt AddDevicesL(); + TInt GetDevicesL(); + TInt ModifyDevicesL(); + + private: + + /** from MBTEngDevManObserver */ + void HandleDevManComplete( TInt aErr ); + + void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray ); + + // Utility method + CBTDevice* CreateDeviceL( const TBTDevAddr& aBDAddr, + const TDesC8& aDeviceName, + const TDesC& aFriendlyName ); + + /** + * C++ default constructor. + */ + CBTApiDevman( MBTTestObserver& aObserver ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: + + MBTTestObserver& iObserver; + CBTEngDevMan* iBTEngDevman; + CActiveSchedulerWait iWaiter; + TInt iError; + }; + +#endif // BTAPIDEVMAN_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/btapidiscovery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/btapidiscovery.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef BTAPIDISCOVERY_H +#define BTAPIDISCOVERY_H + +#include +#include + +#include "testobserver.h" + +/** +* Class for testing BT engine API +*/ +NONSHARABLE_CLASS ( CBTApiDiscovery ): public CBase, public MBTEngSdpResultReceiver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTApiDiscovery* NewL(MBTTestObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBTApiDiscovery(); + + TInt SearchRemoteDeviceL(); + TInt RegisterSdpRecord(); + TInt DeleteSdpRecord(); + TInt RemoteSdpQueryL( TBTDevAddr& aAddr ); + TInt ParseSdpAttrValues(); + + private: + + /** from MBTEngSdpResultReceiver */ + void ServiceSearchComplete( const RSdpRecHandleArray& aResult, + TUint aTotalRecordsCount, TInt aErr ); + void AttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ); + void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ); + void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ); + + /** + * C++ default constructor. + */ + CBTApiDiscovery( MBTTestObserver& aObserver ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: + + MBTTestObserver& iObserver; + CBTEngDiscovery* iBTEngDiscovery; + CActiveSchedulerWait iWaiter; + TInt iError; + CBTDevice* iRemoteDevice; + TSdpServRecordHandle iHandle1; + TSdpServRecordHandle iHandle2; + RSdpResultArray iSdpResults; + }; + +#endif // BTAPIDISCOVERY_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/btapisettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/btapisettings.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef BTAPISETTINGS_H +#define BTAPISETTINGS_H + +#include +#include +#include + +#include "testobserver.h" + +/** +* Class for testing BT engine API +*/ +NONSHARABLE_CLASS ( CBTApiSettings ): public CBase, public MBTEngSettingsObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTApiSettings* NewL(MBTTestObserver& aObserver); + + /** + * Destructor. + */ + virtual ~CBTApiSettings(); + + // Testing functions + TInt TurnBtOn(); + TInt SwitchPowerState(); + TInt GetPowerState(); + TInt SetVisibilityMode( TBTVisibilityMode visibilityState, TInt aTimer = 0 ); + TInt GetVisibilityMode(); + TInt SetLocalName( TDesC& aName ); + TInt GetLocalName(); + + + private: + + /** from MBTEngSettingsObserver */ + void PowerStateChanged( TBTPowerStateValue aState ); + void VisibilityModeChanged( TBTVisibilityMode aState ); + + /** + * C++ default constructor. + */ + CBTApiSettings( MBTTestObserver& aObserver ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: + + MBTTestObserver& iObserver; + CBTEngSettings* iBTEngSettings; + TBTPowerStateValue iExpectedPowerState; + TBTVisibilityMode iExpectedVisibility; + TBuf<100> iExpectedLocalName; + TInt iError; + CActiveSchedulerWait iWaiter; + }; + +#endif // BTAPISETTINGS_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/btapitest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/btapitest.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +#ifndef BTAPITEST_H +#define BTAPITEST_H + +// INCLUDES +#include +#include +#include +#include "testobserver.h" + + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +// Logging path +_LIT( KBtApiTestLogPath, "\\logs\\btengapitest\\" ); +// Log file +_LIT( KBtApiTestLogFile, "btengapitest.txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +class CBtTestLogger; +class CBTApiSettings; +class CBTApiDevman; +class CBTApiConnman; +class CBTApiDiscovery; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CCBtApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CBtApiTest) : public CScriptBase, public MBTTestObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBtApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CBtApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + private: // From MBTTestObserver + + void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ); + + CBtTestLogger& Logger(); + + private: + + /** + * C++ default constructor. + */ + CBtApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Test methods. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CBTEngSettings_SetAndGetPowerState ( CStifItemParser& aItem ); + virtual TInt CBTEngSettings_SetAndGetVisibility ( CStifItemParser& aItem ); + virtual TInt CBTEngSettings_SetAndGetLocalName ( CStifItemParser& aItem ); + virtual TInt CBTEngDevMan_AddDevices ( CStifItemParser& aItem ); + virtual TInt CBTEngDevMan_GetDevices ( CStifItemParser& aItem ); + virtual TInt CBTEngDevMan_ModifyDevice ( CStifItemParser& aItem ); + virtual TInt CBTEngDiscovery_SearchRemoteDevice ( CStifItemParser& aItem ); + virtual TInt CBTEngDiscovery_RegisterAndDeleteSdpRecord ( CStifItemParser& aItem ); + virtual TInt CBTEngDiscovery_RemoteSdpQuery ( CStifItemParser& aItem ); + virtual TInt CBTEngDiscovery_ParseSdpAttrValues ( CStifItemParser& aItem ); + virtual TInt CBTEngConnMan_ConnectDisconnectAndCancelConnect ( CStifItemParser& aItem ); + virtual TInt CBTEngConnMan_GetAddresses ( CStifItemParser& aItem ); + virtual TInt CBTEngConnMan_IsConnectable ( CStifItemParser& aItem ); + virtual TInt CBTEngConnMan_PairDevice ( CStifItemParser& aItem ); + virtual TInt CBTEngConnMan_PrepareDiscovery ( CStifItemParser& aItem ); + + + private: // Data + + CBTApiSettings* iSettings; + CBTApiDevman* iDevMan; + CBTApiConnman* iConnman; + CBTApiDiscovery* iDiscovery; + CBtTestLogger* iTestLogger; + + }; + +#endif // BTAPITEST_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/bttestlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/bttestlogger.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +#ifndef BTTESTLOGGER_H +#define BTTESTLOGGER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CStifLogger; +class CTestModuleIf; + +// CLASS DECLARATION + +NONSHARABLE_CLASS( CBtTestLogger ) : public CBase +{ + public: + + static CBtTestLogger* NewL(const CTestModuleIf* aTestModuleIf); + virtual ~CBtTestLogger(); + + public: // Data used by functions + + enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug}; + + public: // New functions + + TBool GetEnabled() const; + CStifLogger* GetLogger() const; + const CTestModuleIf* GetTestModuleIf() const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const; + TInt LogNewLine() const; + void SetEnabled(TBool aEnabled); + void SetLogger(CStifLogger* aLog); + void SetTestModuleIf(const CTestModuleIf* aTestModuleIf); + + public: // Functions from base classes + + private: // New functions + + TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const; + TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const; + static TPtrC GetPrefix(TLogLevel aLevel); + TInt CheckLogFile(); + void LogHeadSectionL(); + void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const; + + private: // Constructors + + CBtTestLogger(const CTestModuleIf* aTestModuleIf); + void ConstructL(); + + public: // Data + static const TInt KPrefixLength; + + private: // Data + + TBool iEnabled; + CStifLogger* iLog; + const CTestModuleIf* iTestModuleIf; + }; + +#endif // BTTESTLOGGER_H + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/inc/testobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/inc/testobserver.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#ifndef TESTOBSERVER_H +#define TESTOBSERVER_H + +#include + +#define TLFUNCLOG (TUint8*) __FUNCTION__ + +class CBtTestLogger; + +/** +* Testing supervisor +*/ +class MBTTestObserver + { + public: + + virtual void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) = 0; + + virtual CBtTestLogger& Logger() = 0; + + }; + +#endif // TESTOBSERVER_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/rom/btengapitest.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/rom/btengapitest.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2003-2006 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: Image description file for project bteng +* +*/ + +#ifndef BTENGAPITEST_IBY +#define BTENGAPITEST_IBY + +#include + +file=ABI_DIR\BUILD_DIR\btengapitest.dll SHARED_LIB_DIR\btengapitest.dll + +#endif // BTENGAPITEST_IBY diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/btapiconnman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/btapiconnman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,323 @@ +/* +* Copyright (c) 2002 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: Used for testing BT API +* Revision : $Revision: $ +* Date : $Date: $ +* +*/ + + +#include +#include + +#include "btapiconnman.h" +#include "bttestlogger.h" + +// Length of readable BT address +const TInt KBTAddrBufSize = 2 * KBTDevAddrSize; +// Typedef-ed buffer for logging readable BT address +typedef TBuf TBTAddrBuf; + +// Constructor +CBTApiConnman::CBTApiConnman( MBTTestObserver& aObserver ) + : iObserver( aObserver ) + { + } + +// Destructor +CBTApiConnman::~CBTApiConnman( ) + { + delete iBTEngConnMan; + } + + +// NewL +CBTApiConnman* CBTApiConnman::NewL (MBTTestObserver& aObserver) + { + CBTApiConnman* self = new (ELeave) CBTApiConnman(aObserver); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + + +// Symbian 2nd phase constructor. +void CBTApiConnman::ConstructL() + { + iBTEngConnMan = CBTEngConnMan::NewL( this ); + iError = KErrNone; + iBTEngConnMan->RemoveObserver(); + iBTEngConnMan->SetObserver( this ); + } + +void CBTApiConnman::ConnectComplete( TBTDevAddr& aAddr, TInt aErr, RBTDevAddrArray* /*aConflicts*/ ) + { + TBTAddrBuf buf; + aAddr.GetReadable( buf ); + iError = aErr; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiConnman.ConnectComplete %S, %d" ), &buf, aErr ); + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiConnman::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr ) + { + TBTAddrBuf buf; + aAddr.GetReadable( buf ); + iError = aErr; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiConnman.DisconnectComplete %S, %d" ), &buf, aErr ); + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiConnman::PairingComplete( TBTDevAddr& aAddr, TInt aErr ) + { + TBTAddrBuf buf; + aAddr.GetReadable( buf ); + iError = aErr; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiConnman.PairingComplete %S, %d" ), &buf, aErr ); + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +// Sets BT power according to aPowerState +TInt CBTApiConnman::ConnectIfNotConnected( TBTDevAddr& aAddr, TBTDeviceClass& aCod ) + { + TInt err = KErrNone; + TBTEngConnectionStatus connected; + TBTAddrBuf buf; + aAddr.GetReadable( buf ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "ConnectIfNotConnected ongoing %S" ), &buf); + + err = iBTEngConnMan->IsConnected( aAddr, connected ); + + if ( err ) + { + return err; + } + if ( connected != EBTEngNotConnected ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Wrong parameter: connected != EBTEngNotConnected" ) ); + // return KErrNone;; + } + + err = iBTEngConnMan->Connect( aAddr, aCod ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + return /*iError*/ KErrNone; + } + +TInt CBTApiConnman::DisconnectIfConnected( TBTDevAddr& aAddr ) + { + TInt err = KErrNone; + TBTAddrBuf buf; + TBTEngConnectionStatus connected; + aAddr.GetReadable( buf ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "DisconnectIfConnected ongoing_op %S" ), &buf ); + + err = iBTEngConnMan->IsConnected( aAddr, connected ); + + if ( err ) + { + return err; + } + if ( connected != EBTEngConnected ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Wrong parameter: connected != EBTEngConnected" ) ); + // return KErrNone; + } + + err = iBTEngConnMan->Disconnect( aAddr, EBTDiscGraceful ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + return /*iError*/ KErrNone; + } + +TInt CBTApiConnman::ConnectAndCancel( TBTDevAddr& aAddr, TBTDeviceClass& aCod ) + { + TInt err = KErrNone; + TBTEngConnectionStatus connected; + TBTAddrBuf buf; + aAddr.GetReadable( buf ); + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "ConnectAndCancel ongoing_op %S" ), &buf); + + err = iBTEngConnMan->IsConnected( aAddr, connected ); + if ( err ) + { + return err; + } + + if ( connected == EBTEngNotConnected ) + { + // Conncet first + err = iBTEngConnMan->Connect( aAddr, aCod ); + if ( err ) + { + return err; + } + } + + iBTEngConnMan->CancelConnect( aAddr ); + return KErrNone; + } + +TInt CBTApiConnman::GetAddresses( TBTDevAddr& aAddr ) + { + TInt err = KErrNone; + TBTDeviceClass cod(EMajorServiceAudio, 0, 0); + RBTDevAddrArray addrArray; + + err = iBTEngConnMan->GetConnectedAddresses( addrArray, EBTProfileHFP ); + if ( err ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "GetConnectedAddresses: error %d" ), err ); + } + err = iBTEngConnMan->GetConnectedAddresses( addrArray ); + if ( err ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "GetConnectedAddresses: error %d" ), err ); + } + +/* + err = iBTEngConnMan->Connect( aAddr, cod ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + + err = iBTEngConnMan->GetConnectedAddresses( addrArray ); + + if ( err ) + { + return err; + } + + if ( addrArray.Count() < 1 ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "GetConnectedAddresses: wrong value: %d" ), addrArray.Count() ); + // return KErrNotFound; + } + + iBTEngConnMan->Disconnect( aAddr, EBTDiscImmediate ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + + err = iBTEngConnMan->GetConnectedAddresses( addrArray ); + + if ( err ) + { + return err; + } + + if ( addrArray.Count() > 0 ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "GetConnectedAddresses: wrong value: %d" ), addrArray.Count() ); + // return KErrNotFound; + } +*/ + return err; + } + +TInt CBTApiConnman::IsConnectable() + { + TInt err = KErrNone; + TBTDeviceClass audioCoD( EMajorServiceAudio, 0, 0 ); + TBTDeviceClass invalidCoD( EMajorServiceTelephony, 0, 0 ); + TBool connectable = EFalse; + + err = iBTEngConnMan->IsConnectable( audioCoD, connectable ); + if ( err || !connectable ) + { + return KErrArgument; + } + + err = iBTEngConnMan->IsConnectable( invalidCoD, connectable ); + if ( err || connectable ) + { + return KErrArgument; + } + return err; + } + +TInt CBTApiConnman::PairDevice( TBTDevAddr& aAddr ) + { + TInt err = KErrNone; + TInt err2 = KErrNone; + + err = iBTEngConnMan->PairDevice( aAddr, EBTProfileHFP ); + iBTEngConnMan->CancelPairDevice(); + + err = iBTEngConnMan->PairDevice( aAddr ); + err2 = iBTEngConnMan->StartPairingObserver( aAddr ); + + if ( !err && !err2 ) + { + iWaiter.Start(); + } + else + { + if ( err ) + { + return err; + } + else + { + return err2; + } + } + if ( iError ) + { + return iError; + } + + return iError; + } + +TInt CBTApiConnman::PrepareDiscovery( TBTDevAddr& aAddr ) + { + TInt err = KErrNone; + iBTEngConnMan->PrepareDiscovery(); + return err; + } \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/btapidevman.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/btapidevman.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,304 @@ +/* +* Copyright (c) 2002 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: Used for testing BT API +* Revision : $Revision: $ +* Date : $Date: $ +* +*/ + + +#include + +#include "btapidevman.h" +#include "bttestlogger.h" + +_LIT8(KTestDeviceName, "TestDeviceName"); +_LIT8(KTestDeviceName2, "TestDeviceName2"); +_LIT8(KUpdatedTestDeviceName, "UpdatedTestDeviceName"); +_LIT(KTestDeviceFriendlyName, "TestDeviceFriendlyName"); +_LIT(KTestDeviceFriendlyName2, "TestDeviceFriendlyName2"); + +#define HighTestAddr 0x00e0 +#define LowTestAddr 0x0370cb9c +#define HighTestAddr2 0x00e2 +#define LowTestAddr2 0x0370ac8c + + +// Constructor +CBTApiDevman::CBTApiDevman( MBTTestObserver& aObserver ) + : iObserver( aObserver ) + { + } + +// Destructor +CBTApiDevman::~CBTApiDevman( ) + { + delete iBTEngDevman; + } + + +// NewL +CBTApiDevman* CBTApiDevman::NewL ( MBTTestObserver& aObserver ) + { + CBTApiDevman* self = new ( ELeave ) CBTApiDevman( aObserver ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + return self; + } + + +// Symbian 2nd phase constructor. +void CBTApiDevman::ConstructL() + { + iBTEngDevman = CBTEngDevMan::NewL( this ); + iError = KErrNone; + } + +void CBTApiDevman::HandleDevManComplete( TInt aErr ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiDevman::HandleDevManComplete: %d" ), aErr ); + MBTEngDevManObserver::HandleDevManComplete( aErr ); + iError = aErr; + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiDevman::HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiDevman::HandleGetDevicesComplete: %d" ), aErr ); + MBTEngDevManObserver::HandleGetDevicesComplete( aErr, aDeviceArray ); + iError = aErr; + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + }; + } + +TInt CBTApiDevman::AddDevicesL() + { + TInt err = KErrNone; + CBTDevice* device = NULL; + CBTDevice* device2 = NULL; + TBuf8<50> deviceName(KTestDeviceName()); + TBuf8<50> deviceName2(KTestDeviceName2()); + TBuf<50> friendlyName(KTestDeviceFriendlyName()); + TBuf<50> friendlyName2(KTestDeviceFriendlyName2()); + TBTDevAddr testAddress(MAKE_TINT64(HighTestAddr, LowTestAddr)); + TBTDevAddr testAddress2(MAKE_TINT64(HighTestAddr2, LowTestAddr2)); + TBTRegistrySearch criteria; + iError = KErrNone; + + device = CreateDeviceL( testAddress, deviceName, friendlyName); + CleanupStack::PushL( device ); + + device2 = CreateDeviceL( testAddress2, deviceName2, friendlyName2); + CleanupStack::PushL( device2 ); + + criteria.FindAddress( testAddress ); + + err = iBTEngDevman->DeleteDevices( criteria ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + CleanupStack::PopAndDestroy( 2, device ); + return err; + } + + criteria.FindAddress( testAddress2 ); + + err = iBTEngDevman->DeleteDevices( criteria ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + CleanupStack::PopAndDestroy( 2, device ); + return err; + } + + err = iBTEngDevman->AddDevice( *device ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + CleanupStack::PopAndDestroy( 2, device ); + return err; + } + + // Check the callback error code + if ( iError ) + { + CleanupStack::PopAndDestroy( 2, device ); + return iError; + } + + err = iBTEngDevman->AddDevice( *device2 ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + CleanupStack::PopAndDestroy( 2, device ); + return err; + } + CleanupStack::PopAndDestroy( 2, device ); + + // Check the callback error code + if ( iError ) + { + return iError; + } + return err; + } + +TInt CBTApiDevman::GetDevicesL() + { + TInt err = KErrNone; + TBTDevAddr testAddress(MAKE_TINT64( HighTestAddr, LowTestAddr ) ); + TBTDevAddr testAddress2(MAKE_TINT64( HighTestAddr2, LowTestAddr2 ) ); + TBTRegistrySearch criteria; + CBTDeviceArray* deviceArray = NULL; + iError = KErrNone; + + deviceArray = new (ELeave) CBTDeviceArray( 1 ); + criteria.FindAddress( testAddress ); + err = iBTEngDevman->GetDevices( criteria, deviceArray ); // asynchronous + if ( !err ) + { + iWaiter.Start(); + } + else + { + deviceArray->ResetAndDestroy(); + delete deviceArray; + return err; + } + + deviceArray->ResetAndDestroy(); + + // Check the callback error code + if ( iError ) + { + delete deviceArray; + return iError; + } + + criteria.FindAddress( testAddress2 ); + err = iBTEngDevman->GetDevices( criteria, deviceArray ); // asynchronous + if ( !err ) + { + iWaiter.Start(); + } + else + { + deviceArray->ResetAndDestroy(); + delete deviceArray; + return err; + } + + deviceArray->ResetAndDestroy(); + + // Check the callback error code + if ( iError ) + { + delete deviceArray; + return iError; + } + + criteria.FindAll(); + err = iBTEngDevman->GetDevices( criteria, deviceArray ); // asynchronous + if ( !err ) + { + iWaiter.Start(); + } + else + { + deviceArray->ResetAndDestroy(); + delete deviceArray; + return err; + } + + deviceArray->ResetAndDestroy(); + + // Check the callback error code + if ( iError ) + { + delete deviceArray; + return iError; + } + + // Test the synchronous version of GetDevices + CBTEngDevMan* devman = CBTEngDevMan::NewL( NULL ); + + criteria.FindAddress( testAddress ); + err = devman->GetDevices( criteria, deviceArray ); // synchronous + if ( err ) + { + + } + + deviceArray->ResetAndDestroy(); + delete deviceArray; + delete devman; + + return err; + } + +TInt CBTApiDevman::ModifyDevicesL() + { + TInt err = KErrNone; + CBTDevice* device = NULL; + TBuf8<50> updatedDeviceName(KUpdatedTestDeviceName()); + TBuf<50> friendlyName(KTestDeviceFriendlyName()); + TBTDevAddr testAddress(MAKE_TINT64(HighTestAddr, LowTestAddr)); + iError = KErrNone; + + device = CreateDeviceL( testAddress, updatedDeviceName, friendlyName ); + CleanupStack::PushL( device ); + + err = iBTEngDevman->ModifyDevice( *device ); + if ( !err ) + { + iWaiter.Start(); + } + + CleanupStack::PopAndDestroy( device ); + + if ( iError ) + { + return iError; + } + return err; + } + +CBTDevice* CBTApiDevman::CreateDeviceL(const TBTDevAddr& aBDAddr, const TDesC8& aDeviceName, const TDesC& aFriendlyName) + { + CBTDevice* newDevice = CBTDevice::NewLC( aBDAddr ); + newDevice->SetDeviceNameL( aDeviceName ); + newDevice->SetFriendlyNameL( aFriendlyName ); + CleanupStack::Pop(); + return newDevice; + }; \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/btapidiscovery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/btapidiscovery.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,364 @@ +/* +* Copyright (c) 2002 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: Used for testing BT API +* Revision : $Revision: $ +* Date : $Date: $ +* +*/ + + +#include +#include + +#include "btapidiscovery.h" +#include "bttestlogger.h" + +_LIT8(KServiceIdNokiaPcSuite, "0x000050050000100080000002EE000001"); + +// Constructor +CBTApiDiscovery::CBTApiDiscovery( MBTTestObserver& aObserver ) + : iObserver( aObserver ) + { + } + +// Destructor +CBTApiDiscovery::~CBTApiDiscovery( ) + { + delete iBTEngDiscovery; + delete iRemoteDevice; + } + + +// NewL +CBTApiDiscovery* CBTApiDiscovery::NewL (MBTTestObserver& aObserver) + { + CBTApiDiscovery* self = new (ELeave) CBTApiDiscovery(aObserver); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + + +// Symbian 2nd phase constructor. +void CBTApiDiscovery::ConstructL() + { + iBTEngDiscovery = CBTEngDiscovery::NewL( this ); + iBTEngDiscovery->SetNotifier( this ); + iError = KErrNone; + } + +void CBTApiDiscovery::ServiceSearchComplete( const RSdpRecHandleArray& aResult, + TUint aTotalRecordsCount, TInt aErr ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiDevman::HandleGetDevicesComplete: %d" ), aErr ); + iError = aErr; + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiDiscovery::AttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiDevman::HandleGetDevicesComplete: %d" ), aErr ); + iError = aErr; + if(iSdpResults.Count() == 0) + { + // Store one set of SDP results for furher testing + for(TInt i = 0; i < aAttr.Count(); i++) + { + iSdpResults.Append(aAttr[i]); + } + } + if(iWaiter.IsStarted()) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiDiscovery::ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, + const RSdpResultArray& aAttr, + TInt aErr ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiDevman::HandleGetDevicesComplete: %d" ), aErr ); + iError = aErr; + if(iSdpResults.Count() == 0) + { + // Store one set of SDP results for furher testing + for(TInt i = 0; i < aAttr.Count(); i++) + { + iSdpResults.Append(aAttr[i]); + } + } + if(iWaiter.IsStarted()) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiDiscovery::DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ) + { + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiDevman::HandleGetDevicesComplete: %d" ), aErr ); + iError = aErr; + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +TInt CBTApiDiscovery::SearchRemoteDeviceL() + { + TInt err = KErrNone; + CBTDevice* device = NULL; + + device = CBTDevice::NewLC(); + + /* + err = iBTEngDiscovery->SearchRemoteDevice( device ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + CleanupStack::PopAndDestroy( device ); + return err; + } + if ( iError ) + { + CleanupStack::PopAndDestroy( device ); + return iError; + } + */ + err = iBTEngDiscovery->SearchRemoteDevice( device ); + if ( !err ) + { + iBTEngDiscovery->CancelSearchRemoteDevice(); + } + + CleanupStack::PopAndDestroy( device ); + return err; + } + +TInt CBTApiDiscovery::RegisterSdpRecord() + { + TInt err = KErrNone; + TUUID service = EBTProfileSAP; + + err = iBTEngDiscovery->RegisterSdpRecord( service, 0, iHandle1 ); + if( err ) + { + return err; + } + if ( iHandle1 == 0 ) + { + return KErrNotFound; + } + + // Test 128 bit UUID + TLex8 lex; + TUint32 HH; TUint32 HL; TUint32 LH; TUint32 LL; + lex = KServiceIdNokiaPcSuite().Mid(2, 8); + lex.Val(HH, EHex); + lex = KServiceIdNokiaPcSuite().Mid(10, 8); + lex.Val(HL, EHex); + lex = KServiceIdNokiaPcSuite().Mid(18, 8); + lex.Val(LH, EHex); + lex = KServiceIdNokiaPcSuite().Mid(26, 8); + lex.Val(LL, EHex); + service = TUUID(HH, HL, LH, LL); + + err = iBTEngDiscovery->RegisterSdpRecord( service, 0, iHandle2 ); + if( err ) + { + return err; + } + if ( iHandle2 == 0 ) + { + return KErrNotFound; + } + return err; + } + +TInt CBTApiDiscovery::DeleteSdpRecord() + { + TInt err = KErrNone; + + if ( iHandle1 == 0 || iHandle2 == 0 ) + { + return KErrArgument; + } + + err = iBTEngDiscovery->DeleteSdpRecord( iHandle1 ); + if ( err ) + { + return err; + } + + err = iBTEngDiscovery->DeleteSdpRecord( iHandle2 ); + + return err; + } + +TInt CBTApiDiscovery::RemoteSdpQueryL( TBTDevAddr& aAddr ) + { + TInt err = KErrNone; + TUUID service = EBTProfileHSP; + TBTDevAddr btAddr; + delete iRemoteDevice; + iRemoteDevice = NULL; + + /* + iRemoteDevice = CBTDevice::NewL(); + + err = iBTEngDiscovery->SearchRemoteDevice( iRemoteDevice ); + + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + if ( iError ) + { + return iError; + } + */ + + btAddr = aAddr; // iRemoteDevice->BDAddr(); + + err = iBTEngDiscovery->RemoteSdpQuery( btAddr, service ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + if ( iError ) + { + iObserver.Logger().Log( CBtTestLogger::ETLError, _L( "RemoteSdpQuery failed!: %d" ), iError ); + // return iError; + } + + err = iBTEngDiscovery->RemoteSdpQuery( btAddr, iHandle1, KSdpAttrIdProtocolDescriptorList ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + if ( iError ) + { + iObserver.Logger().Log( CBtTestLogger::ETLError, _L( "RemoteSdpQuery failed!: %d" ), iError ); + // return iError; + } + + err = iBTEngDiscovery->RemoteSdpQuery( btAddr, service, KSdpAttrIdProtocolDescriptorList ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + if ( iError ) + { + iObserver.Logger().Log( CBtTestLogger::ETLError, _L( "RemoteSdpQuery failed!: %d" ), iError ); + // return iError; + } + + err = iBTEngDiscovery->RemoteProtocolChannelQuery( btAddr, service ); + if ( !err ) + { + iWaiter.Start(); + } + else + { + return err; + } + + if ( iError ) + { + iObserver.Logger().Log( CBtTestLogger::ETLError, _L( "RemoteProtocolChannelQuery failed!: %d" ), iError ); + // return iError; + } + + err = iBTEngDiscovery->RemoteProtocolChannelQuery( btAddr, service ); + iBTEngDiscovery->CancelRemoteSdpQuery(); + + delete iRemoteDevice; + iRemoteDevice = NULL; + + return err; + } + +TInt CBTApiDiscovery::ParseSdpAttrValues() + { + if (iSdpResults.Count() == 0) + { + TBTEngSdpAttrValue attrValue; + attrValue.iAttrValue.iValNumeric = 0; + iSdpResults.Append( attrValue ); + } + + TSdpElementType type; + TInt channel = KErrNotFound; + TBool check = ETrue; + + for(TInt i = 0; i < iSdpResults.Count(); i++) + { + CBTEngDiscovery::ParseNextSdpAttrValueType( iSdpResults, i, type ); + if(type == ETypeNil || + type == ETypeUint || + type == ETypeUUID || + type == ETypeString || + type == ETypeBoolean || + type == ETypeDES || + type == ETypeDEA || + type == ETypeURL || + type == ETypeEncoded) + { + + } + else + { + + } + + } + + CBTEngDiscovery::ParseRfcommChannel( iSdpResults, channel ); + if (channel > 0) + { + // Ok + return KErrNone; + } + else + { + // Failed + return KErrGeneral; + } + } diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/btapisettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/btapisettings.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2002 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: Used for testing BT API +* Revision : $Revision: $ +* Date : $Date: $ +* +*/ + +#include +#include +#include +#include + +#include "btapisettings.h" +#include "bttestlogger.h" + +// Log string for Power on +_LIT( KSetBTPowerOn, "on " ); +// Log string for Power off +_LIT( KSetBTPowerOff, "off" ); + +// Constructor +CBTApiSettings::CBTApiSettings( MBTTestObserver& aObserver ) + : iObserver( aObserver ) + { + } + +// Destructor +CBTApiSettings::~CBTApiSettings( ) + { + delete iBTEngSettings; + } + + +// NewL +CBTApiSettings* CBTApiSettings::NewL (MBTTestObserver& aObserver) + { + CBTApiSettings* self = new (ELeave) CBTApiSettings(aObserver); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + + +// Symbian 2nd phase constructor. +void CBTApiSettings::ConstructL() + { + iBTEngSettings = CBTEngSettings::NewL( this ); + iExpectedPowerState = EBTPowerOff; + iExpectedVisibility = EBTVisibilityModeGeneral; + iError = KErrNone; + iExpectedLocalName.Zero(); + } + +void CBTApiSettings::PowerStateChanged( TBTPowerStateValue aState ) + { + iError = KErrNone; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::PowerStateChanged: %d" ), aState); + + if ( iExpectedPowerState != aState ) + { + iError = KErrArgument; + } + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +void CBTApiSettings::VisibilityModeChanged( TBTVisibilityMode aState ) + { + iError = KErrNone; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "CBTApiSettings::VisibilityModeChanged: %d" ), aState); + + if ( iExpectedVisibility != aState ) + { + iError = KErrArgument; + } + if ( iWaiter.IsStarted() ) + { + iWaiter.AsyncStop(); + } + } + +TInt CBTApiSettings::TurnBtOn() + { + TBTPowerStateValue state; + TInt err = KErrNone; + + err = iBTEngSettings->GetPowerState( state ); + if ( err ) + { + return err; + } + + if( state == EBTPowerOff ) + { + state = EBTPowerOn; + } + else + { + return KErrNone; + } + + err = iBTEngSettings->SetPowerState( state ); + if ( err ) + { + return err; + } + + iExpectedPowerState = state; + iWaiter.Start(); + return iError; + } + +TInt CBTApiSettings::SwitchPowerState() + { + TBTPowerStateValue state; + TInt err = KErrNone; + + err = iBTEngSettings->GetPowerState( state ); + if ( err ) + { + return err; + } + + if( state == EBTPowerOff ) + { + state = EBTPowerOn; + } + else + { + state = EBTPowerOff; + } + + err = iBTEngSettings->SetPowerState( state ); + + if ( err ) + { + return err; + } + iExpectedPowerState = state; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Switching BT power: %d" ), state); + iWaiter.Start(); + return iError; + } + +TInt CBTApiSettings::GetPowerState() + { + TInt err = KErrNone; + TBTPowerStateValue state; + + err = iBTEngSettings->GetPowerState( state ); + + if ( err ) + { + return err; + } + + if ( iExpectedPowerState != state ) + { + return KErrArgument; + } + return err; + } + +TInt CBTApiSettings::SetVisibilityMode( TBTVisibilityMode visibilityState, TInt aTimer ) + { + TInt err = KErrNone; + err = iBTEngSettings->SetVisibilityMode( visibilityState ); + + if ( err ) + { + return err; + } + iExpectedVisibility = visibilityState; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Switching BT visibility: %d" ), visibilityState); + iWaiter.Start(); + return iError; + } + +TInt CBTApiSettings::GetVisibilityMode() + { + TInt err = KErrNone; + TBTVisibilityMode mode; + + err = iBTEngSettings->GetVisibilityMode( mode ); + + if ( err ) + { + return err; + } + + if ( iExpectedVisibility!= mode ) + { + return KErrArgument; + } + + return iError; + } + +TInt CBTApiSettings::SetLocalName( TDesC& aName ) + { + TInt err = KErrNone; + iExpectedLocalName = aName; + iObserver.Logger().Log( CBtTestLogger::ETLDebug, _L( "Setting BT localname to: %S" ), &aName); + err = iBTEngSettings->SetLocalName( iExpectedLocalName ); + if ( err ) + { + iExpectedLocalName.Zero(); + } + return err; + } + +TInt CBTApiSettings::GetLocalName() + { + TInt err = KErrNone; + TBuf<100> name; + err = iBTEngSettings->GetLocalName( name ); + + if ( iExpectedLocalName.Length() ) + { + if ( name.Compare( iExpectedLocalName ) ) + { + err = KErrArgument; + } + } + return err; + } + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/btapitest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/btapitest.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,154 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include "btapitest.h" +#include "bttestlogger.h" +#include "btapisettings.h" +#include "btapiconnman.h" +#include "btapidevman.h" +#include "btapidiscovery.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtApiTest::CCBtApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBtApiTest::CBtApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CBtApiTest::ConstructL() + { + iTestLogger = CBtTestLogger::NewL( &TestModuleIf() ); + iLog = iTestLogger->GetLogger(); + iSettings = CBTApiSettings::NewL( *this ); + iDevMan = CBTApiDevman::NewL( *this ); + iConnman = CBTApiConnman::NewL( *this ); + iDiscovery = CBTApiDiscovery::NewL( *this ); + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBtApiTest* CBtApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CBtApiTest* self = new (ELeave) CBtApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// Destructor +CBtApiTest::~CBtApiTest() + { + // Delete resources allocated from test methods + Delete(); + + delete iSettings; + delete iDevMan; + delete iConnman; + delete iDiscovery; + delete iTestLogger; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CBtApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/btapitestblocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/btapitestblocks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,501 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "btapitest.h" +#include "bttestlogger.h" +#include "btapisettings.h" +#include "btapiconnman.h" +#include "btapidevman.h" +#include "btapidiscovery.h" + + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBtApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CBtApiTest::Delete() + { + + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + ENTRY( "PowerState", CBTEngSettings_SetAndGetPowerState ), + ENTRY( "Visibility", CBTEngSettings_SetAndGetVisibility ), + ENTRY( "LocalName", CBTEngSettings_SetAndGetLocalName ), + ENTRY( "AddDevices", CBTEngDevMan_AddDevices ), + ENTRY( "GetDevices", CBTEngDevMan_GetDevices ), + ENTRY( "ModifyDevice", CBTEngDevMan_ModifyDevice ), + ENTRY( "SearchRemoteDevice", CBTEngDiscovery_SearchRemoteDevice ), + ENTRY( "RegisterAndDeleteSdpRecord", CBTEngDiscovery_RegisterAndDeleteSdpRecord ), + ENTRY( "RemoteSdpQuery", CBTEngDiscovery_RemoteSdpQuery ), + ENTRY( "ParseSdpAttrValues", CBTEngDiscovery_ParseSdpAttrValues ), + ENTRY( "ConnectDisconnectAndCancelConnect", CBTEngConnMan_ConnectDisconnectAndCancelConnect ), + ENTRY( "GetAddresses", CBTEngConnMan_GetAddresses ), + ENTRY( "IsConnectable", CBTEngConnMan_IsConnectable ), + ENTRY( "PairDevice", CBTEngConnMan_PairDevice ), + ENTRY( "PrepareDiscovery", CBTEngConnMan_PrepareDiscovery ) + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::TestCompleted +// ----------------------------------------------------------------------------- +// +void CBtApiTest::TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) + { + iTestLogger->LogResult( (TPtrC8( aFunc )), aArg, aErr ); + Signal( aErr ); + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::Logger +// ----------------------------------------------------------------------------- +// +CBtTestLogger& CBtApiTest::Logger() + { + return *iTestLogger; + } + + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngSettings_SetAndGetPowerState +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngSettings_SetAndGetPowerState( CStifItemParser& /*aItem*/ ) + { + TInt ret = KErrNone; + + ret = iSettings->SwitchPowerState(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("SwitchPowerState 1")); + return KErrNone; + } + ret = iSettings->GetPowerState(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("GetPowerState")); + return KErrNone; + } + ret = iSettings->TurnBtOn(); + + TestCompleted( ret, TLFUNCLOG, _L("TurnBtOn)")); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngSettings_SetAndGetVisibility +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngSettings_SetAndGetVisibility( CStifItemParser& /*aItem*/ ) + { + TInt ret = KErrNone; + + ret = iSettings->SetVisibilityMode( EBTVisibilityModeHidden ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Set EBTVisibilityModeHidden")); + return KErrNone; + } + ret = iSettings->GetVisibilityMode(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Get EBTVisibilityModeHidden")); + return KErrNone; + } + ret = iSettings->SetVisibilityMode( EBTVisibilityModeTemporary, 10 ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Set EBTVisibilityModeTemporary")); + return KErrNone; + } + ret = iSettings->GetVisibilityMode(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Get EBTVisibilityModeTemporary")); + return KErrNone; + } + ret = iSettings->SetVisibilityMode( EBTVisibilityModeGeneral ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Set EBTVisibilityModeGeneral")); + return KErrNone; + } + ret = iSettings->GetVisibilityMode(); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, _L("Get EBTVisibilityModeGeneral")); + return KErrNone; + } + + TestCompleted( ret, TLFUNCLOG, _L("")); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngSettings_SetAndGetLocalName +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngSettings_SetAndGetLocalName( CStifItemParser& aItem ) + { + TPtrC name(KNullDesC); + TInt ret = aItem.GetNextString( name ); + iTestLogger->Log( CBtTestLogger::ETLInfo, _L( "Set new local name: %S" ), &name); + if ( ret ) + { + TestCompleted( KErrArgument, TLFUNCLOG, name ); + return KErrNone; + } + + ret = iSettings->SetLocalName( name ); + if( ret ) + { + TestCompleted( ret, TLFUNCLOG, name ); + return KErrNone; + } + + ret = iSettings->GetLocalName(); + + TestCompleted( ret, TLFUNCLOG, name ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDevMan_AddDevice +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDevMan_AddDevices( CStifItemParser& /*aItem*/ ) + { + TInt leave = KErrNone; + TInt err = KErrNone; + TRAP( leave, err = iDevMan->AddDevicesL() ); + if ( leave ) + { + TestCompleted( leave, TLFUNCLOG, _L ("Leave occured!") ); + return KErrNone; + } + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDevMan_GetDevices +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDevMan_GetDevices( CStifItemParser& /*aItem*/ ) + { + TInt leave = KErrNone; + TInt err = KErrNone; + TRAP( leave, err = iDevMan->GetDevicesL() ); + if ( leave ) + { + TestCompleted( leave, TLFUNCLOG, _L ("Leave occured!") ); + return KErrNone; + } + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDevMan_ModifyDevice +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDevMan_ModifyDevice( CStifItemParser& /*aItem*/ ) + { + TInt leave = KErrNone; + TInt err = KErrNone; + TRAP( leave, err = iDevMan->ModifyDevicesL() ); + if ( leave ) + { + TestCompleted( leave, TLFUNCLOG, _L ("Leave occured!") ); + return KErrNone; + } + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDiscovery_SearchRemoteDevice +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDiscovery_SearchRemoteDevice( CStifItemParser& /*aItem*/ ) + { + TInt leave = KErrNone; + TInt err = KErrNone; + TRAP( leave, err = iDiscovery->SearchRemoteDeviceL() ); + if ( leave ) + { + TestCompleted( leave, TLFUNCLOG, _L ("Leave occured!") ); + return KErrNone; + } + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDiscovery_RegisterAndDeleteSdpRecord +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDiscovery_RegisterAndDeleteSdpRecord( CStifItemParser& /*aItem*/ ) + { + TInt err = KErrNone; + err = iDiscovery->RegisterSdpRecord(); + if( err ) + { + TestCompleted( err, TLFUNCLOG, _L( "Register SDP record failed!" ) ); + return KErrNone; + } + err = iDiscovery->DeleteSdpRecord(); + if( err ) + { + TestCompleted( err, TLFUNCLOG, _L( "Delete SDP record failed!" ) ); + } + + TestCompleted( err, TLFUNCLOG, _L("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDiscovery_RemoteSdpQuery +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDiscovery_RemoteSdpQuery( CStifItemParser& aItem ) + { + TInt leave = KErrNone; + TInt err = KErrNone; + + TPtrC item( KNullDesC ); + err = aItem.GetNextString( item ); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L ("StifItemParser::GetNextString failed!") ); + return KErrNone; + } + TBTDevAddr addr; + addr.SetReadable( item ); + + TRAP( leave, err = iDiscovery->RemoteSdpQueryL( addr ) ); + if ( leave ) + { + TestCompleted( leave, TLFUNCLOG, _L ("RemoteSdpQueryL failed! Leave occured!") ); + return KErrNone; + } + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngDiscovery_ParseSdpAttrValues +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngDiscovery_ParseSdpAttrValues( CStifItemParser& /*aItem*/ ) + { + TInt err = KErrNone; + err = iDiscovery->ParseSdpAttrValues(); + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngConnMan_ConnectDisconnectAndCancelConnect +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngConnMan_ConnectDisconnectAndCancelConnect( CStifItemParser& aItem ) + { + TInt leave = KErrNone; + TInt err = KErrNone; + + TPtrC item( KNullDesC ); + err = aItem.GetNextString( item ); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L ("StifItemParser::GetNextString failed!") ); + return KErrNone; + } + + TBTDevAddr addr; + addr.SetReadable( item ); + + TBTDeviceClass cod(EMajorServiceAudio, 0, 0); + + err = iConnman->ConnectIfNotConnected( addr, cod ); + if ( err ) + { + // TestCompleted( err, TLFUNCLOG, _L ("ConnectIfNotConnected failed!") ); + // return KErrNone; + } + + err = iConnman->DisconnectIfConnected( addr ); + if ( err ) + { + // TestCompleted( err, TLFUNCLOG, _L ("ConnectIfNotConnected failed!") ); + // return KErrNone; + } + + err = iConnman->ConnectAndCancel( addr, cod ); + if ( err ) + { + // TestCompleted( err, TLFUNCLOG, _L ("ConnectAndCancel failed!") ); + // return KErrNone; + } + + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngConnMan_GetAddresses +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngConnMan_GetAddresses( CStifItemParser& aItem ) + { + TPtrC item( KNullDesC ); + TInt err = aItem.GetNextString( item ); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L ("StifItemParser::GetNextString failed!") ); + return KErrNone; + } + + TBTDevAddr addr; + addr.SetReadable( item ); + + err = iConnman->GetAddresses( addr ); + TestCompleted( err, TLFUNCLOG, item ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngConnMan_IsConnectable +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngConnMan_IsConnectable( CStifItemParser& /*aItem*/ ) + { + TInt err = KErrNone; + err = iConnman->IsConnectable(); + TestCompleted( err, TLFUNCLOG, _L ("") ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngConnMan_PairDevice +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngConnMan_PairDevice( CStifItemParser& aItem ) + { + TPtrC item( KNullDesC ); + TInt err = aItem.GetNextString( item ); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L ("StifItemParser::GetNextString failed!") ); + return KErrNone; + } + TBTDevAddr addr; + addr.SetReadable( item ); + + err = iConnman->PairDevice( addr ); + TestCompleted( err, TLFUNCLOG, item ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtApiTest::CBTEngConnMan_PrepareDiscovery +// ----------------------------------------------------------------------------- +// +TInt CBtApiTest::CBTEngConnMan_PrepareDiscovery( CStifItemParser& aItem ) + { + TPtrC item( KNullDesC ); + TInt err = aItem.GetNextString( item ); + if ( err ) + { + TestCompleted( err, TLFUNCLOG, _L ("StifItemParser::GetNextString failed!") ); + return KErrNone; + } + TBTDevAddr addr; + addr.SetReadable( item ); + + err = iConnman->PrepareDiscovery( addr ); + TestCompleted( err, TLFUNCLOG, item ); + return KErrNone; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/btengapitest/src/bttestlogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/btengapitest/src/bttestlogger.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,530 @@ +/* +* Copyright (c) 2007 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: +* +*/ + +// INCLUDES + +#include "bttestlogger.h" + +#include +#include + +#include +#include +#include + +// RDebug +#include + +const TInt CBtTestLogger::KPrefixLength = 8; +// Timestamp string length +const TInt KTimeStampStrLen = 21; +// Extended Timestamp string length +const TInt KExtTimeStampStrLen = 80; +// Extended time stamp +typedef TBuf TExtTimeStamp; +// Logging path +_LIT( KBtAudioTestSystemLogPath, "e:\\logs\\btengapitest\\" ); +// Log file +_LIT( KBtAudioTestSystemLogFile, "BtEngApiTestLog.html" ); +// Log file +_LIT( KBtAudioTestSystemLogFullName, "\\logs\\btengapitest\\BtEngApiTestLog_%x.html" ); +// Time stamp format string +_LIT( KFormatTimeStamp, "
[%H:%T:%S.%*C4] " ); +// Date format string +_LIT( KFormatDate, "%F%D %N %Y" ); +// HTML header section +_LIT( KHtmlHeadSection, "\n\nBT Audio Test System results\n\n\n\n\n\n" ); +// HTML code which will display the statistics +_LIT( KHtmlStatSection, "

Logfile created on %S at %S
\nS60 version %S

\n\n
\n
\n\n" ); +// HTML identifier for test case start +_LIT( KHtmlTestCaseStart, "
" ); +// Test case result logging +_LIT( KTestCaseResult, "Test completed; function %S, parameter %S, result
%d
" ); +// JavaScript function for calculating test result +#define KJSSECTION _L( "" ) + +// Construction and destruction. + +// ----------------------------------------------------------------------------- +// CBtTestLogger::NewL +// Static constructor to constructor builder objects. +// ----------------------------------------------------------------------------- +// +CBtTestLogger* CBtTestLogger::NewL(const CTestModuleIf* aTestModuleIf) + { + CBtTestLogger* self = new (ELeave) CBtTestLogger(aTestModuleIf); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::CBtTestLogger +// Constructor. +// ----------------------------------------------------------------------------- +// +CBtTestLogger::CBtTestLogger(const CTestModuleIf* aTestModuleIf) + : CBase(), + iEnabled(ETrue), + iTestModuleIf(aTestModuleIf) + { + } + +// ----------------------------------------------------------------------------- +// CTestLogger::ConstructL +// 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::ConstructL() + { + TInt err = CheckLogFile(); + iLog = CStifLogger::NewL( KBtAudioTestSystemLogPath, KBtAudioTestSystemLogFile, + CStifLogger::ETxt, CStifLogger::EFile, EFalse, EFalse ); + if( err == KErrNotFound ) + { // Add info & HTML markup to the beginning of the log file. + LogHeadSectionL(); + } + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::~CBtTestLogger +// Destructor. +// ----------------------------------------------------------------------------- +// +CBtTestLogger::~CBtTestLogger() + { + delete iLog; + } + +// Member functions. + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetLogger +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +CStifLogger* CBtTestLogger::GetLogger() const + { + return iLog; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetTestModuleIf +// Returns a pointer to current STIF test module interface. +// ----------------------------------------------------------------------------- +// +const CTestModuleIf* CBtTestLogger::GetTestModuleIf() const + { + return iTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList( aLogText, args ); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Append log prefix to the output buffer. + buffer.Insert( 0, GetPrefix( aLevel ) ); + + // Log a timestamp + TTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Log a timestamp + TTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const + { + TExtTimeStamp func; + func.Copy( aFunc ); // Copy 8-bit string to 16-bit buffer + + Log( CBtTestLogger::ETLResult, KTestCaseResult, &func, &aArg, aRes ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::LogNewLine() const + { + if (!iEnabled) + { + return KErrNone; + } + TExtTimeStamp time; + TRAPD( err, LogTimeStampL( time ) ); + if( !err ) + { + time.Insert( 0, KHtmlTestCaseStart ); + err = iLog->Log( time ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetEnabled +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetEnabled(TBool aEnabled) + { + iEnabled = aEnabled; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetLogger +// Sets a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetLogger(CStifLogger* aLog) + { + iLog = aLog; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::SetTestModuleIf +// Sets a pointer to current STIF test module. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::SetTestModuleIf(const CTestModuleIf* aTestModuleIf) + { + iTestModuleIf = aTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::WriteLog(TLogLevel aLevel, TDes16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(aLevel, _L(""), log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(0, aCategory, log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::GetPrefix +// Returns the prefix for a given logging level. +// ----------------------------------------------------------------------------- +// +TPtrC CBtTestLogger::GetPrefix(TLogLevel aLevel) + { + // Select a prefix for a log level and return a pointer to it. + switch(aLevel) + { + case ETLError: + { + TPtrC logPrefix = _L("ERROR : "); + return logPrefix; + } + case ETLInfo: + case ETLResult: + { + TPtrC logPrefix = _L("INFO : "); + return logPrefix; + } + case ETLDebug: + { + TPtrC logPrefix = _L("DEBUG : "); + return logPrefix; + } + default: + { + // Return a null pointer. + return TPtrC(); + } + + } + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::CheckLogFile +// Check if a log file is already existing, otherwise HTML formatting +// should be added. +// ----------------------------------------------------------------------------- +// +TInt CBtTestLogger::CheckLogFile() + { + RThread thread; + TInt id = thread.Id(); + TBuf file; + file.Format( KBtAudioTestSystemLogFullName, id ); + RFs fs; + TInt err = fs.Connect(); + TBool open = EFalse; + if( !err ) + { + err = fs.IsFileOpen( file, open ); + } + fs.Close(); + return err; + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogTimeStamp +// Log HTML head section and general information in a newly created logfile. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::LogHeadSectionL() + { + iLog->Log( KHtmlHeadSection ); + iLog->Log( KJSSECTION ); + TBuf version( _L( "Version unknown!" ) ); + (void) SysUtil::GetSWVersion( version ); + TTimeStamp8 date; + LogTimeStampL( date, EFalse ); + TTimeStamp8 time; + LogTimeStampL( time ); + TPtrC timePtr( time.Mid( 6, 13 ) ); + iLog->Log( KHtmlStatSection, &date, &timePtr, &version ); + } + +// ----------------------------------------------------------------------------- +// CBtTestLogger::LogTimeStamp +// Format a timestamp for logging. +// If aTime is set to false, the (formatted) date is returned. +// ----------------------------------------------------------------------------- +// +void CBtTestLogger::LogTimeStampL(TDes& aBuf, TBool aTime) const + { + TTime time; + time.HomeTime(); // Get time and format it + if( aTime ) + { + time.FormatL( aBuf, KFormatTimeStamp ); + } + else + { + time.FormatL( aBuf, KFormatDate ); + } + } diff -r 000000000000 -r f63038272f30 tsrc/public/basic/conf/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/conf/TestFramework.ini Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,197 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds + +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= TestScripter +TestCaseFile= c:\testframework\btengapi_scripter.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/conf/atextpluginapi_scripter.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/conf/atextpluginapi_scripter.cfg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,7 @@ +[Test] +title AT Ext Plugin API test +create atextpluginapitest Tester +Tester TestPluginStub +waittestclass Tester +delete Tester +[Endtest] diff -r 000000000000 -r f63038272f30 tsrc/public/basic/conf/btengapi_scripter.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/conf/btengapi_scripter.cfg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,139 @@ +[Define] +BT_ADDRESS_1 0008c635159f +BT_LOCAL_NAME BtApiTest +[Enddefine] + +# no 1 +[Test] +title Settings API: PowerState +create BtEngApiTest Tester +Tester PowerState +waittestclass Tester +delete Tester +[Endtest] + +#no 2 +[Test] +title Settings API: Visibility +create BtEngApiTest Tester +Tester Visibility +waittestclass Tester +delete Tester +[Endtest] + +#no 3 +[Test] +title Settings API: LocalName +create BtEngApiTest Tester +Tester LocalName BT_LOCAL_NAME +waittestclass Tester +delete Tester +[Endtest] + +#no 4 +[Test] +title DevMan API: AddDevice +create BtEngApiTest Tester +Tester AddDevices +waittestclass Tester +delete Tester +[Endtest] + +#no 5 +[Test] +title DevMan API: GetDevices +create BtEngApiTest Tester +Tester GetDevices +waittestclass Tester +delete Tester +[Endtest] + +#no 6 +[Test] +title DevMan API: ModifyDevice +create BtEngApiTest Tester +Tester ModifyDevice +waittestclass Tester +delete Tester +[Endtest] + +#no 7 +[Test] +title Discovery API: SearchRemoteDevice +create BtEngApiTest Tester +Tester SearchRemoteDevice +waittestclass Tester +delete Tester +[Endtest] + +#no 8 +[Test] +title Discovery API: RegisterAndDeleteSdpRecord +create BtEngApiTest Tester +Tester RegisterAndDeleteSdpRecord +waittestclass Tester +delete Tester +[Endtest] + +#no 9 +[Test] +title Discovery API: RemoteSdpQuery +create BtEngApiTest Tester +Tester RemoteSdpQuery BT_ADDRESS_1 +waittestclass Tester +delete Tester +[Endtest] + +#no 10 +[Test] +title Discovery API: ParseSdpAttrValues +create BtEngApiTest Tester +Tester ParseSdpAttrValues +waittestclass Tester +delete Tester +[Endtest] + +#no 11 +[Test] +title Connman API: ConnectDisconnectAndCancelConnect +create BtEngApiTest Tester +Tester ConnectDisconnectAndCancelConnect BT_ADDRESS_1 +waittestclass Tester +delete Tester +[Endtest] + +#no 12 +[Test] +title Connman API: GetAddresses +create BtEngApiTest Tester +Tester GetAddresses BT_ADDRESS_1 +waittestclass Tester +delete Tester +[Endtest] + +#no 13 +[Test] +title Connman API: IsConnectable +create BtEngApiTest Tester +Tester IsConnectable +waittestclass Tester +delete Tester +[Endtest] + +#no 13 +[Test] +title Connman API: PairDevice +create BtEngApiTest Tester +Tester PairDevice BT_ADDRESS_1 +waittestclass Tester +delete Tester +[Endtest] + +#no 14 +[Test] +title Connman API: PrepareDiscovery +create BtEngApiTest Tester +Tester PrepareDiscovery BT_ADDRESS_1 +waittestclass Tester +delete Tester +[Endtest] diff -r 000000000000 -r f63038272f30 tsrc/public/basic/conf/obexservapitest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/conf/obexservapitest.cfg Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,70 @@ +[Test] +title Get file system status +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetFileSystemStatus +delete Message_Handler_Tester +[Endtest] +[Test] +title Get MMC file system status +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetMmcFileSystemStatus +delete Message_Handler_Tester +[Endtest] +[Test] +title Get message center drive +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetMessageCentreDriveL +delete Message_Handler_Tester +[Endtest] +[Test] +title Create default mtm service +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateDefaultMtmServiceL +delete Message_Handler_Tester +[Endtest] +[Test] +title Get cenrep key int value +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetCenRepKeyIntValueL +delete Message_Handler_Tester +[Endtest] +[Test] +title Get PubSub key int value +create obexservapitest Message_Handler_Tester +Message_Handler_Tester GetPubSubKeyIntValue +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and remove outpox entry +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateOutBoxEntry +Message_Handler_Tester RemoveOutBoxEntry +delete Message_Handler_Tester +[Endtest] +[Test] +title Crate and remove outpox entry +create obexservapitest Message_Handler_Tester +Message_Handler_Tester SaveObjToInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Save object to inbox +create obexservapitest Message_Handler_Tester +Message_Handler_Tester SaveObjToInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and save attacment +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateEntryToInbox +Message_Handler_Tester SaveRFileObjectToInbox +delete Message_Handler_Tester +[Endtest] +[Test] +title Create and Remove attacment +create obexservapitest Message_Handler_Tester +Message_Handler_Tester CreateEntryToInbox +Message_Handler_Tester RemoveObjectFromInbox +delete Message_Handler_Tester +[Endtest] + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/conf/test.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/conf/test.xml Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,220 @@ + + + 1 + Local Connectivity API test + + + + + + + + + + + + + + + + + install + + + + + + + + + install + + + + + + + + install + + + + + + + + + install + + + + + + + + install + + + + + + + + + + install + + + + + + + + + install + + + + + + + + + install + + + + + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + run-cases + + + + + + + + run-cases + + + + + + + + run-cases + + + + + + + + execute + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + fetch-log + + + + + + + fetch-log + + + + + + + fetch-log + + + + + + + + + + + LCDo_APITestDrop/images/LCDo_test_API_rnd.fpsx + LCDo_APITestDrop/images/LCDo_test_API_rnd_erase.fpsx + LCDo_APITestDrop/components/armv5_urel/btengapitest.dll + LCDo_APITestDrop/components/armv5_urel/obexservapitest.dll + LCDo_APITestDrop/components/armv5_urel/atextpluginapitest.dll + LCDo_APITestDrop/components/armv5_urel/atextpluginstub.dll + LCDo_APITestDrop/general/atextpluginstub.rsc + LCDo_APITestDrop/general/btengapi_scripter.cfg + LCDo_APITestDrop/general/obexservapitest.cfg + LCDo_APITestDrop/general/atextpluginapi_scripter.cfg + + + + FileStoreAction + + + + + + + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006 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: Build information file for project +* +*/ + + +PRJ_PLATFORMS +DEFAULT +#include "../btengapitest/group/bld.inf" +#include "../obexservapitest/group/bld.inf" +#include "../atextpluginapitest/group/bld.inf" + +//build files for shortlinkconn + + +PRJ_EXPORTS + + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/Bmarm/ObexServAPItestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/Bmarm/ObexServAPItestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/Bwins/ObexServAPItestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/Bwins/ObexServAPItestU.DEF Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/EABI/ObexServAPItestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/EABI/ObexServAPItestU.def Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/group/bld.inf Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +// NOTE: If using ARS requirements all export operations should be done under this. +// 'abld test export' + +PRJ_EXPORTS +// Specify the source file followed by its destination here +// copy will be used to copy the source file to its destination +// If there's no destination then the source file will be copied +// to the same name in /epoc32/include +// Example: +/* +/agnmodel/inc/AGMCOMON.H +*/ + +PRJ_TESTMMPFILES +// NOTE: If using ARS requirements .mmp file operation should be done under this. +// 'abld test build' + +PRJ_MMPFILES +// Specify the .mmp files required for building the important component +// releasables. +// +// Specify "tidy" if the component you need to build doesn't need to be +// released. Specify "ignore" if the MMP file exists but should be +// ignored. +// Example: +/* +/agnmodel/group/agnmodel.mmp +#if defined(MARM) +/agnmodel/group/agsvexe.mmp +#endif +*/ +obexservapitest.mmp + +// End of File \ No newline at end of file diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/group/obexservapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/group/obexservapitest.mmp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,58 @@ +/*TYPE TESTCLASS*/ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + +#if defined(__S60_) + // To get the OS_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET obexservapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE ObexServAPItest.def + +SOURCEPATH ../src +SOURCE ObexServAPItest.cpp +SOURCE ObexServAPItestBlocks.cpp +SOURCE testlogger.cpp + + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY sysutil.lib +LIBRARY obexutils.lib +LIBRARY irobex.lib +LIBRARY efsrv.lib + +LANG SC + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/inc/ObexServAPItest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/inc/ObexServAPItest.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,211 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +#ifndef OBEXSERVAPITEST_H +#define OBEXSERVAPITEST_H + +// INCLUDES +#include +#include +#include +#include +#include "testlogger.h" + + +// FORWARD DECLARATIONS +class CObexServAPItest; + + +// CLASS DECLARATION + +/** +* CObexServAPItest test class for STIF Test Framework TestScripter. +*/ +NONSHARABLE_CLASS(CObexServAPItest) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CObexServAPItest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CObexServAPItest(); + + public: // New functions + + + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + + + private: + + /** + * C++ default constructor. + */ + CObexServAPItest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ); + + /** + * Test methods are listed below. + */ + + /** + * Test code for getting file system status. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetFileSystemStatusL( CStifItemParser& aItem ); + + /** + * Test code for getting mmc file system status. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetMmcFileSystemStatusL( CStifItemParser& aItem ); + + /** + * Test code for getting message center drive. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetMessageCentreDriveL( CStifItemParser& aItem ); + + /** + * Test code for creating Default MTM services. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CreateDefaultMtmServiceL( CStifItemParser& aItem ); + + /** + * Test code for Getting CenRep key. . + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetCenRepKeyIntValueL( CStifItemParser& aItem ); + + /** + * Test code for Getting PubSub key. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt GetPubSubKeyIntValueL( CStifItemParser& aItem ); + + /** + * Test code for Creating outbox entry. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CreateOutBoxEntryL( CStifItemParser& aItem ); + + /** + * Test code for removing outbox entry. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt RemoveOutBoxEntryL( CStifItemParser& aItem ); + + /** + * Test code for save received file to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt SaveObjToInboxL( CStifItemParser& aItem ); + + /** + * Test code for creating entry to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt CreateEntryToInboxL( CStifItemParser& aItem ); + + /** + * Test code for creating entry to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt SaveRFileObjectToInboxL( CStifItemParser& aItem ); + + /** + * Test code for removing entry to inbox. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt RemoveObjectL( CStifItemParser& aItem ); + + + + private: // Data + + + + TMsvId iMessageServerIndex; + CObexBufObject* iObexObject; + RFile iFile; + CBufFlat* iBuf; + CObexTestLogger* iTestLogger; + + }; + +#endif // OBEXSERVAPITEST_H + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/inc/testlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/inc/testlogger.h Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +#ifndef BTTESTLOGGER_H +#define BTTESTLOGGER_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CStifLogger; +class CTestModuleIf; + +#define TLFUNCLOG (TUint8*) __FUNCTION__ + +// CLASS DECLARATION + +NONSHARABLE_CLASS( CObexTestLogger ) : public CBase +{ + public: + + static CObexTestLogger* NewL(const CTestModuleIf* aTestModuleIf); + virtual ~CObexTestLogger(); + + public: // Data used by functions + + enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug}; + + public: // New functions + + TBool GetEnabled() const; + CStifLogger* GetLogger() const; + const CTestModuleIf* GetTestModuleIf() const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; + TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; + TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const; + TInt LogNewLine() const; + void SetEnabled(TBool aEnabled); + void SetLogger(CStifLogger* aLog); + void SetTestModuleIf(const CTestModuleIf* aTestModuleIf); + + public: // Functions from base classes + + private: // New functions + + TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const; + TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const; + static TPtrC GetPrefix(TLogLevel aLevel); + TInt CheckLogFile(); + void LogHeadSectionL(); + void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const; + + private: // Constructors + + CObexTestLogger(const CTestModuleIf* aTestModuleIf); + void ConstructL(); + + public: // Data + static const TInt KPrefixLength; + + private: // Data + + TBool iEnabled; + CStifLogger* iLog; + const CTestModuleIf* iTestModuleIf; + }; + +#endif // BTTESTLOGGER_H + diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/rom/obexservapitest.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/rom/obexservapitest.iby Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2007-2007 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: Image description file for project bteng +* +*/ + +#ifndef BTENGAPITEST_IBY +#define BTENGAPITEST_IBY + +#include + +file=ABI_DIR\BUILD_DIR\ObexServAPItest.dll SHARED_LIB_DIR\ObexServAPItest.dll + +#endif // BTENGAPITEST_IBY diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/src/ObexServAPItest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/src/ObexServAPItest.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include "ObexServAPItest.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CObexServAPItest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CObexServAPItest::CObexServAPItest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CObexServAPItest::ConstructL() + { + + iTestLogger = CObexTestLogger::NewL( &TestModuleIf() ); + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CObexServAPItest* CObexServAPItest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CObexServAPItest* self = new (ELeave) CObexServAPItest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CObexServAPItest::~CObexServAPItest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iTestLogger; + iTestLogger = NULL; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CObexServAPItest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/src/ObexServAPItestBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/src/ObexServAPItestBlocks.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,412 @@ +/* +* Copyright (c) 2002 - 2007 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: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#include "testlogger.h" +#include "ObexServAPItest.h" + + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CObexServAPItest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CObexServAPItest::Delete() + { + delete iObexObject; + iObexObject = NULL; + delete iBuf; + iBuf = NULL; + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + ENTRY( "GetFileSystemStatus", CObexServAPItest::GetFileSystemStatusL ), + ENTRY( "GetMmcFileSystemStatus", CObexServAPItest::GetMmcFileSystemStatusL ), + ENTRY( "GetMessageCentreDriveL", CObexServAPItest::GetMessageCentreDriveL ), + ENTRY( "CreateDefaultMtmServiceL", CObexServAPItest::CreateDefaultMtmServiceL ), + ENTRY( "GetCenRepKeyIntValueL", CObexServAPItest::GetCenRepKeyIntValueL ), + ENTRY( "GetPubSubKeyIntValue", CObexServAPItest::GetPubSubKeyIntValueL ), + ENTRY( "CreateOutBoxEntry", CObexServAPItest::CreateOutBoxEntryL ), + ENTRY( "RemoveOutBoxEntry", CObexServAPItest::RemoveOutBoxEntryL ), + ENTRY( "SaveObjToInbox", CObexServAPItest::SaveObjToInboxL ), + ENTRY( "CreateEntryToInbox", CObexServAPItest::CreateEntryToInboxL ), + ENTRY( "SaveRFileObjectToInbox", CObexServAPItest::SaveRFileObjectToInboxL ), + ENTRY( "RemoveObjectFromInbox", CObexServAPItest::RemoveObjectL ), + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + + // ----------------------------------------------------------------------------- +// CBtApiTest::TestCompleted +// ----------------------------------------------------------------------------- +// +void CObexServAPItest::TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) + { + iTestLogger->LogResult( (TPtrC8( aFunc )), aArg, aErr ); + Signal( aErr ); + } + + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetFileSystemStatusL +// Test code for getting file system status. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetFileSystemStatusL( CStifItemParser& /*aItem*/ ) + { + // Print to log file + TInt retVal=TObexUtilsMessageHandler::GetFileSystemStatus(); + if (retVal == 0 || retVal == KErrDiskFull) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); + } + else + { + TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); + } + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetMmcFileSystemStatusL +// Test code for getting mmc file system status. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetMmcFileSystemStatusL( CStifItemParser& /*aItem*/ ) + { + TInt retVal=TObexUtilsMessageHandler::GetMmcFileSystemStatus(); + if (retVal == 0 || retVal == KErrDiskFull) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); + } + else + { + TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetMessageCentreDriveL +// Test code for getting message center drive. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetMessageCentreDriveL( CStifItemParser& /*aItem*/ ) + { + + TInt retVal = TObexUtilsMessageHandler::GetMessageCentreDriveL(); + if (retVal >= 0 ) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetMessageCentreDrive")); + } + else + { + TestCompleted( retVal, TLFUNCLOG, _L("GetMessageCentreDrive failed")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CreateDefaultMtmServiceL +// Test code for creating Default MTM services. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::CreateDefaultMtmServiceL( CStifItemParser& /*aItem*/ ) + { + + TRAPD(error, TObexUtilsMessageHandler::CreateDefaultMtmServiceL(KUidMsgTypeBt) ); + if (error == KErrNone) + { + TestCompleted( KErrNone, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); + } + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetCenRepKeyIntValueL +// Test code for Getting CenRep key. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetCenRepKeyIntValueL( CStifItemParser& /*aItem*/ ) + { + TInt limit=0; + TInt error=0; + TRAPD(leaveVal, error = TObexUtilsMessageHandler::GetCenRepKeyIntValueL(KCRUidUiklaf, + KUikOODDiskCriticalThreshold, + limit)); + if( leaveVal != KErrNone ) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValueL leaves")); + } + else if (error == KErrNone) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValue return error")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetCenRepKeyIntValueL")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::GetPubSubKeyIntValueL +// Test code for Getting PubSub key. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::GetPubSubKeyIntValueL( CStifItemParser& /*aItem*/ ) + { + TInt status = KErrNone; + TInt retVal = KErrNone; + + TRAPD(leaveVal, retVal = TObexUtilsMessageHandler::GetPubSubKeyIntValue(KPSUidUikon, KUikFFSFreeLevel, status)); + + if( leaveVal != KErrNone ) + { + TestCompleted( leaveVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL leaves")); + } + else if (retVal == KErrNone) + { + TestCompleted( retVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL return error")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("GetPubSubKeyIntValue")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::OutBoxEntryL +// Test code for Creating outbox entry. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::CreateOutBoxEntryL( CStifItemParser& /*aItem*/ ) + { + TRAPD(error, iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( KUidMsgTypeBt, R_BT_SEND_OUTBOX_SENDING )); + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("CreateOutBoxEntryL leaves")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("CreateOutBoxEntryL")); + } + + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::OutBoxEntryL +// Test code for removing outbox entry. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::RemoveOutBoxEntryL( CStifItemParser& /*aItem*/ ) + { + + TRAPD(error, TObexUtilsMessageHandler::DeleteOutboxEntryL( iMessageServerIndex )); + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("RemoveOutBoxEntryL leaves")); + } + else + { + TestCompleted( KErrNone, TLFUNCLOG, _L("RemoveOutBoxEntryL")); + } + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::SaveObjToInboxL +// Test code for save received file to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::SaveObjToInboxL( CStifItemParser& /*aItem*/ ) + { + + CObexBufObject* obexobject = CObexBufObject::NewL( NULL ); + CleanupStack::PushL(obexobject); + + TRAP_IGNORE(TObexUtilsMessageHandler::SaveObjToInboxL(obexobject , + KNullDesC, + KUidMsgTypeBt )); + TestCompleted( KErrNone, TLFUNCLOG, _L("SaveObjToInboxL leaves")); + + CleanupStack::PopAndDestroy(obexobject); + return KErrNone; + + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CreateAndSaveObjectL +// Test code for creating entry to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::CreateEntryToInboxL( CStifItemParser& /*aItem*/ ) + { + iFile = RFile(); + + if ( iObexObject) + { + delete iObexObject; + iObexObject = NULL; + } + + iObexObject = CObexBufObject::NewL( NULL ); + + TRAPD( error, TObexUtilsMessageHandler::CreateInboxAttachmentL( iObexObject, + KUidMsgTypeBt, + iMessageServerIndex, + iFile)); + + + iBuf = CBufFlat::NewL(1024); + iBuf->ResizeL(1024); + + TObexRFileBackedBuffer bufferdetails(*iBuf,iFile,CObexBufObject::EDoubleBuffering); + + TRAP_IGNORE( iObexObject->SetDataBufL( bufferdetails) ); + + + + iFile.Write(_L8("test")); + iObexObject->SetNameL(_L("test.txt")); + + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL")); + } + return KErrNone; + } + + +// ----------------------------------------------------------------------------- +// CObexServAPItest::CreateAndSaveObjectL +// Test code for creating entry to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::SaveRFileObjectToInboxL( CStifItemParser& /*aItem*/ ) + { + TRAPD( error, TObexUtilsMessageHandler::SaveObjToInboxL( + iObexObject, + iFile, + iMessageServerIndex)); + + delete iBuf; + iBuf = NULL; + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexServAPItest::RemoveObjectL +// Test code for removing entry to inbox. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TInt CObexServAPItest::RemoveObjectL( CStifItemParser& /*aItem*/ ) + { + TRAPD(error,TObexUtilsMessageHandler::RemoveInboxEntriesL(iObexObject, iMessageServerIndex)); + delete iBuf; + iBuf = NULL; + if( error != KErrNone) + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); + } + else + { + TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); + } + return KErrNone; + } + + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// End of File diff -r 000000000000 -r f63038272f30 tsrc/public/basic/obexservapitest/src/testlogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/public/basic/obexservapitest/src/testlogger.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,530 @@ +/* +* Copyright (c) 2007 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: +* +*/ + +// INCLUDES + +#include "testlogger.h" + +#include +#include + +#include +#include +#include + +// RDebug +#include + +const TInt CObexTestLogger::KPrefixLength = 8; +// Timestamp string length +const TInt KTimeStampStrLen = 21; +// Extended Timestamp string length +const TInt KExtTimeStampStrLen = 40; +// Extended time stamp +typedef TBuf TExtTimeStamp; +// Logging path +_LIT( KObexServAPITestSystemLogPath, "e:\\logs\\ObexServAPItest\\" ); +// Log file +_LIT( KObexServAPITestSystemLogFile, "ObexServAPItest.html" ); +// Log file +_LIT( KObexServAPITestSystemLogFullName, "\\logs\\ObexServAPItest\\ObexServAPItest%x.html" ); +// Time stamp format string +_LIT( KFormatTimeStamp, "
[%H:%T:%S.%*C4] " ); +// Date format string +_LIT( KFormatDate, "%F%D %N %Y" ); +// HTML header section +_LIT( KHtmlHeadSection, "\n\nObex Message Handler Test System results\n\n\n\n\n\n" ); +// HTML code which will display the statistics +_LIT( KHtmlStatSection, "

Logfile created on %S at %S
\nS60 version %S

\n\n
\n
\n\n" ); +// HTML identifier for test case start +_LIT( KHtmlTestCaseStart, "
" ); +// Test case result logging +_LIT( KTestCaseResult, "Test completed; function %S, parameter %S, result
%d
" ); +// JavaScript function for calculating test result +#define KJSSECTION _L( "" ) + +// Construction and destruction. + +// ----------------------------------------------------------------------------- +// CObexTestLogger::NewL +// Static constructor to constructor builder objects. +// ----------------------------------------------------------------------------- +// +CObexTestLogger* CObexTestLogger::NewL(const CTestModuleIf* aTestModuleIf) + { + CObexTestLogger* self = new (ELeave) CObexTestLogger(aTestModuleIf); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::CObexTestLogger +// Constructor. +// ----------------------------------------------------------------------------- +// +CObexTestLogger::CObexTestLogger(const CTestModuleIf* aTestModuleIf) + : CBase(), + iEnabled(ETrue), + iTestModuleIf(aTestModuleIf) + { + } + +// ----------------------------------------------------------------------------- +// CTestLogger::ConstructL +// 2nd phase constructor. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::ConstructL() + { + TInt err = CheckLogFile(); + iLog = CStifLogger::NewL( KObexServAPITestSystemLogPath, KObexServAPITestSystemLogFile, + CStifLogger::ETxt, CStifLogger::EFile, EFalse, EFalse ); + if( err == KErrNotFound ) + { // Add info & HTML markup to the beginning of the log file. + LogHeadSectionL(); + } + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::~CObexTestLogger +// Destructor. +// ----------------------------------------------------------------------------- +// +CObexTestLogger::~CObexTestLogger() + { + delete iLog; + } + +// Member functions. + +// ----------------------------------------------------------------------------- +// CObexTestLogger::GetLogger +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +CStifLogger* CObexTestLogger::GetLogger() const + { + return iLog; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::GetTestModuleIf +// Returns a pointer to current STIF test module interface. +// ----------------------------------------------------------------------------- +// +const CTestModuleIf* CObexTestLogger::GetTestModuleIf() const + { + return iTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList( aLogText, args ); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Append log prefix to the output buffer. + buffer.Insert( 0, GetPrefix( aLevel ) ); + + // Log a timestamp + TTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 8 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC8& actualData = aLogText; + + // Check that user does not try to output too much data. + if (actualData.Length() > KMaxLogData - KPrefixLength) + { + return KErrTooBig; + } + + // Buffer to convert 8 bit data to to 16 bit. + TLogInfo8 converter; + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + converter.FormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + TLogInfo buffer; + buffer.Copy( converter ); + + // Log a timestamp + TTimeStamp8 time; + TRAP_IGNORE( LogTimeStampL( time ) ); + buffer.Insert( 0, time ); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aLevel, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::Log +// Logs 16 bit data to screen and file. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const + { + if (!iEnabled) + { + return KErrNone; + } + + const TDesC16& actualData = aLogText; + // Check that user does not try to output too much data. + if (actualData.Length() + KPrefixLength > KMaxLogData) + { + return KErrTooBig; + } + + TLogInfo buffer; + + // Log a timestamp + TRAP_IGNORE( LogTimeStampL( buffer ) ); + + // Create variable argument list. + VA_LIST args; + VA_START(args, aLogText); + + // Format the argument list to the output buffer. + buffer.AppendFormatList(aLogText, args); + + // Free the variable argument list + VA_END(args); + + // Write log. + return WriteLog(aCategory, buffer); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const + { + TExtTimeStamp func; + func.Copy( aFunc ); // Copy 8-bit string to 16-bit buffer + + Log( CObexTestLogger::ETLResult, KTestCaseResult, &func, &aArg, aRes ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogNewLine +// Logs an HTML newline and timestamp. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::LogNewLine() const + { + if (!iEnabled) + { + return KErrNone; + } + TExtTimeStamp time; + TRAPD( err, LogTimeStampL( time ) ); + if( !err ) + { + time.Insert( 0, KHtmlTestCaseStart ); + err = iLog->Log( time ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::SetEnabled +// Returns a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::SetEnabled(TBool aEnabled) + { + iEnabled = aEnabled; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::SetLogger +// Sets a pointer to current STIF logger. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::SetLogger(CStifLogger* aLog) + { + iLog = aLog; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::SetTestModuleIf +// Sets a pointer to current STIF test module. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::SetTestModuleIf(const CTestModuleIf* aTestModuleIf) + { + iTestModuleIf = aTestModuleIf; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::WriteLog(TLogLevel aLevel, TDes16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(aLevel, _L(""), log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::WriteLog +// Writes log. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const + { + // Write log to file if file logger is available. + if (iLog != 0) + { + iLog->Log(aLog); + } + // Remove the timestamp from the logging data. + TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); + + // Write log with RDebug. + RDebug::Print(log); + + // Write log to screen if test module interface is available. + if (iTestModuleIf != 0) + { + CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); + nonStaticLogger->Printf(0, aCategory, log); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::GetPrefix +// Returns the prefix for a given logging level. +// ----------------------------------------------------------------------------- +// +TPtrC CObexTestLogger::GetPrefix(TLogLevel aLevel) + { + // Select a prefix for a log level and return a pointer to it. + switch(aLevel) + { + case ETLError: + { + TPtrC logPrefix = _L("ERROR : "); + return logPrefix; + } + case ETLInfo: + case ETLResult: + { + TPtrC logPrefix = _L("INFO : "); + return logPrefix; + } + case ETLDebug: + { + TPtrC logPrefix = _L("DEBUG : "); + return logPrefix; + } + default: + { + // Return a null pointer. + return TPtrC(); + } + + } + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::CheckLogFile +// Check if a log file is already existing, otherwise HTML formatting +// should be added. +// ----------------------------------------------------------------------------- +// +TInt CObexTestLogger::CheckLogFile() + { + RThread thread; + TInt id = thread.Id(); + TBuf file; + file.Format( KObexServAPITestSystemLogFullName, id ); + RFs fs; + TInt err = fs.Connect(); + TBool open = EFalse; + if( !err ) + { + err = fs.IsFileOpen( file, open ); + } + fs.Close(); + return err; + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogTimeStamp +// Log HTML head section and general information in a newly created logfile. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::LogHeadSectionL() + { + iLog->Log( KHtmlHeadSection ); + iLog->Log( KJSSECTION ); + TBuf version( _L( "Version unknown!" ) ); + (void) SysUtil::GetSWVersion( version ); + TTimeStamp8 date; + LogTimeStampL( date, EFalse ); + TTimeStamp8 time; + LogTimeStampL( time ); + TPtrC timePtr( time.Mid( 6, 13 ) ); + iLog->Log( KHtmlStatSection, &date, &timePtr, &version ); + } + +// ----------------------------------------------------------------------------- +// CObexTestLogger::LogTimeStamp +// Format a timestamp for logging. +// If aTime is set to false, the (formatted) date is returned. +// ----------------------------------------------------------------------------- +// +void CObexTestLogger::LogTimeStampL(TDes& aBuf, TBool aTime) const + { + TTime time; + time.HomeTime(); // Get time and format it + if( aTime ) + { + time.FormatL( aBuf, KFormatTimeStamp ); + } + else + { + time.FormatL( aBuf, KFormatDate ); + } + }